【Person Re-ID】In Defense of the Triplet Loss for Person Re-Identification
2017-12-14 19:34
696 查看
paper下载地址:https://arxiv.org/abs/1703.07737
code下载地址:https://github.com/VisualComputingInstitute/triplet-reid
耗时且无法明确定义什么是“good”hard triplets
选择太难的example会导致训练不稳定
当训练数据很大时,无法覆盖足够多的triplets
![](http://img.blog.csdn.net/20171211192651948)
![](http://img.blog.csdn.net/20171211192717115)
其中,Lpull为拉近属于同一类的样本,Lpush为拉远不同类的样本。由于是采用最近邻,因此同一类中可能存在多个clusters
![](http://img.blog.csdn.net/20171211193417490)
其中Da,p,Da,n分别表示anchor与positive和negative之间的距离。triplet loss能够保证给定一个anchor,属于同一类的样本之间的距离要小于不同类样本之间的距离。带来的弊端是,当训练样本数量非常大时,几乎是不可能训出来的,因为大量的easy sample覆盖了semi-hard example。
而在标准的triplet loss实现当中,经常是一个三元组输入到网络中,假设batchsize=3B,则最终产生B个triplets。但这种组合最多可能达到6B2−4B,因此存在大量的浪费。
![](http://img.blog.csdn.net/20171211195007624)
![](http://img.blog.csdn.net/20171211195349525)
但是这种改进考虑了一个batch里面的所有anchor-positive pair,因此是非常耗时的。而当训练到后期时,由于许多样例已经被正确分类,导致很多“冗余”,从而覆盖了很“宝贵”的hard exam。
![](http://img.blog.csdn.net/20171211200047152)
可想而知,这个loss的计算也是非常耗时的。
作者对这个loss的推广是
![](http://img.blog.csdn.net/20171211200537076)
这个loss不仅考虑了所有的负例,属于同一类的所有的anchor-positive pair也会考虑。
Trained from Scratch :作者称之为LuNet。
![](http://img.blog.csdn.net/20171214175426301)
没有Hard Mining的 Ltri往往模型效果不好,如果加上简单的offline hard-mining(OHM),则效果很不稳定,有时候很好有时候完全崩掉
Batch Hard形式的 LBH整体表现好于 Batch All形式的 LBA。作者猜测,训练后期很多三元组loss都是0,然后平均处理时会把仅剩的有用的信息给稀释掉。为了证明该猜想,作者计算平均loss时只考虑那些不为0的,用 LBA≠0表示,发现效果确实会变好。
在作者的Re-ID实验中,Batch Hard + soft-margin的效果最好,但是不能保证在其他任务中这种组合依然是最好的,这需要更多的实验验证。
![](http://img.blog.csdn.net/20171214191657542)
在Market-1501数据集上,pritrained model 获得了rank-1=84.92%的好成绩,经过re-ranking之后,更是达到了86.67%。而trained from scrach比pretrained要低2%~3%。但是pretrained model要受限于base model的输入大小,如果修改其输入很可能会得到相反的效果,如下表。trained from scrach则没有任何限制,因此trained from scrach通用性更强。
![](http://img.blog.csdn.net/20171214192849809)
code下载地址:https://github.com/VisualComputingInstitute/triplet-reid
Introduction
本文主要是针对triplet loss做的改进:triplet loss最重要的步骤就是hard-mining,而在选择hard-example过程中存在几个问题:耗时且无法明确定义什么是“good”hard triplets
选择太难的example会导致训练不稳定
当训练数据很大时,无法覆盖足够多的triplets
Learning Metric Embeddings
这一节主要介绍集中metric learning方法Large Margin Nearest Neighbor loss
其中,Lpull为拉近属于同一类的样本,Lpush为拉远不同类的样本。由于是采用最近邻,因此同一类中可能存在多个clusters
Triplet loss
Triplet loss是人脸识别与认证中最常用的loss,其形式为其中Da,p,Da,n分别表示anchor与positive和negative之间的距离。triplet loss能够保证给定一个anchor,属于同一类的样本之间的距离要小于不同类样本之间的距离。带来的弊端是,当训练样本数量非常大时,几乎是不可能训出来的,因为大量的easy sample覆盖了semi-hard example。
而在标准的triplet loss实现当中,经常是一个三元组输入到网络中,假设batchsize=3B,则最终产生B个triplets。但这种组合最多可能达到6B2−4B,因此存在大量的浪费。
Batch Hard Triplet loss
改进之一是在一个batch里面随机选取P类,每类随机选取K张图片,并且按照类别顺序排好,然后对每个sample,选取最难的同一类的正例(距离最大的)和最难的不同类的负例(距离最小的)组成一个triplet来计算loss,最终产生PK个有效的loss。Batch All Triplet loss
另外一种改进是将一个batch中所有的positive pairs都考虑进来,最终产生PK(PK−K)(K−1)个triplets。但是这种改进考虑了一个batch里面的所有anchor-positive pair,因此是非常耗时的。而当训练到后期时,由于许多样例已经被正确分类,导致很多“冗余”,从而覆盖了很“宝贵”的hard exam。
Lifted Embedding loss
这种形式的loss是将positive pair之外所有的负例均会考虑,然后优化Loss的平滑边界。可想而知,这个loss的计算也是非常耗时的。
作者对这个loss的推广是
这个loss不仅考虑了所有的负例,属于同一类的所有的anchor-positive pair也会考虑。
Distance Measure
在本文中,作者的所有的度量方式均为未平方的都是距离,即|a−b|2.Soft-margin
在hinge loss function中,[m+D]+能够避免修正“已经正确”的triplets,也即hard cut-off。但作者使用softplus function ln(1+exp(D)))这种更加平滑的hinge loss,目的是使“已经正确”的triplets更加接近,从而不受超参数margin的影响,作者称之为soft-margin。Experiments
作者的实验分为两部分:一,评估各种不同变种triplet loss的性能;二,选择性能好的变种triplet loss在person-ReID任务中进行实验。第二部分中使用了pretrained model 和 trained from scrach。Training
pritrained model :作者将已经在imageNet上训练好的resnet-50的最后一层换为两个全连接层,第一个全连接层有1024个输出,后面接BN和ReLU,第二个全连接层有128个输出,作者称之为TriNet。Trained from Scratch :作者称之为LuNet。
没有Hard Mining的 Ltri往往模型效果不好,如果加上简单的offline hard-mining(OHM),则效果很不稳定,有时候很好有时候完全崩掉
Batch Hard形式的 LBH整体表现好于 Batch All形式的 LBA。作者猜测,训练后期很多三元组loss都是0,然后平均处理时会把仅剩的有用的信息给稀释掉。为了证明该猜想,作者计算平均loss时只考虑那些不为0的,用 LBA≠0表示,发现效果确实会变好。
在作者的Re-ID实验中,Batch Hard + soft-margin的效果最好,但是不能保证在其他任务中这种组合依然是最好的,这需要更多的实验验证。
在Market-1501数据集上,pritrained model 获得了rank-1=84.92%的好成绩,经过re-ranking之后,更是达到了86.67%。而trained from scrach比pretrained要低2%~3%。但是pretrained model要受限于base model的输入大小,如果修改其输入很可能会得到相反的效果,如下表。trained from scrach则没有任何限制,因此trained from scrach通用性更强。
参考
【1】http://blog.csdn.net/shuzfan/article/details/70069822#experiments相关文章推荐
- 1703.In Defense of the Triplet Loss for Person Re-Identification 论文阅读笔记
- 【论文笔记】In Defense of the Triplet Loss for Person Re-Identification
- Paper Reading: In Defense of the Triplet Loss for Person Re-Identification
- 【Person Re-ID】Margin Sample Mining Loss: A Deep Learning Based Method for Person Re-identification
- 【Person Re-ID】Deep Representation Learning with Part Loss for Person Re-Identification
- 【Person Re-ID】Deep-Person: Learning Discriminative Deep Features for Person Re-Identification
- 行人检索--Beyond triplet loss: a deep quadruplet network for person re-identification
- 【Person Re-id】A Discriminatively Learned CNN Embedding for Person Re-identification
- 【Person Re-ID】AlignedReID: Surpassing Human-Level Performance in Person Re-Identification
- 【Person Re-ID】AlignedReID: Surpassing Human-Level Performance in Person Re-Identification
- 论文阅读:Multi-Scale Triplet CNN for Person Re-Identification
- 论文阅读:Joint Learning of Single-image and Cross-image Representations for Person Re-identification
- The name or security ID (SID) of the domain specified is inconsistent with the trust information for that domain
- [Paper note] Joint Learning of Single-image and Cross-image Representations for Person Re-id.
- Joint Learning of Single-image and Cross-image Representations for Person Re-identification
- Re-ID:AlignedReID: Surpassing Human-Level Performance in Person Re-Identification 论文解析
- The name or security ID (SID) of the domain specified is inconsistent with the trust information for that domain(转)
- 【论文笔记】Margin Sample Mining Loss: A Deep Learning Based Method for Person Re-identification
- 论文阅读《Joint Learning of Single-image Cross-image Representations for Person Re-identification》
- the name or security ID(SID) of the domain specified is inconsistent with the trust information for that domain