N-pair Loss

目录

16-NIPS-improved deep metric learning with multi-class n-pair loss objective

Multiple Negative Examples

(N+1)-tuplet loss

multi-class N-pair loss (N-pair-mc)

one-vs-one N-pair loss (N-pair-ovo)

Hard negative class mining

L2 norm regularization of embedding vectors

Experimental Results


16-NIPS-improved deep metric learning with multi-class n-pair loss objective

Multiple Negative Examples


 

(N+1)-tuplet loss

同时推开多个类的负样本

 N=2 类似triplet loss

(4)(5)

  • triplet loss的问题是can be unstable并且convergence会很慢

为了解决这个问题,在前人的工作中,使用smooth upper bound of the triplet loss来进行优化(利用 softplus 函数代替  hinge function

SoftPlus 激活函数

近似relu函数

不包含0,解决了 Dead ReLU 问题,但不包含负区间,不能加速学习

 N=L 类似softmax loss

【后面这里就很像交叉熵了:交叉熵损失采用的是learnable class-wise weights作为class instances的一个代理,而不是直接使用instances的embeddings;在交叉熵中,所有的negative classes都参与了损失的计算,然而在这里,仅仅是将anchor instance远离了那些mini-batch采样中的负样本。所以后来就有proxy不用采样了。。。】
 

multi-class N-pair loss (N-pair-mc)

one-vs-one N-pair loss (N-pair-ovo)

Hard negative class mining

L2 norm regularization of embedding vectors

排除范数的影响——>归一化

——>严格限制|fTf+|<1,优化困难——>正则化嵌入向量的L2范数让它小

 for anchor, positive, negative_set in zip(anchors, positives, negatives):
        a_embs, p_embs, n_embs = batch[anchor:anchor+1], batch[positive:positive+1], batch[negative_set]
        inner_sum = a_embs[:,None,:].bmm((n_embs - p_embs[:,None,:]).permute(0,2,1))
        inner_sum = inner_sum.view(inner_sum.shape[0], inner_sum.shape[-1])
        loss  = loss + torch.mean(torch.log(torch.sum(torch.exp(inner_sum), dim=1) + 1))/len(anchors)
        loss  = loss + self.l2_weight*torch.mean(torch.norm(batch, p=2, dim=1))/len(anchors)

Experimental Results

adapt the smooth upper bound of triplet loss in Equation (4) instead of large-margin formulation  in all our experiments to be consistent with N-pair-mc losses.

multi-class N-pair loss表现更好:one-vs-one N-pair loss解耦,每个负样本损失都是独立的

 在固定batch size下,每个类采集一对样本,样本来自的类变多。训练涉及的负类越多越好。

  • 2
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值