Closed ChloeEHKim closed 7 years ago
It is neg_dist > pos_dist
. The purpose is to avoid triplets that are too hard.
Refer the FaceNet paper for more details:
FaceNet: A Unified Embedding for Face Recognition and Clustering
Florian Schroff, Dmitry Kalenichenko, James Philbin
Hi, @wanji , in BatchTripletLossLayer:Forward_cpu(), the rank loss is normalized by num_tri
(the number of triplets no matter fullfill the constraint). However, in Backwardcpu(), the scale related to ranking loss is set to `Dtype(2) / triplets.size(), where
triplets_.size()is not equal to
num_triactually.
num_tri` should by adopted in both functions, am I right ? Hoping for your reply, and thank you very much.
Hi, @liuyuyuil
The code may seem a bit confusing. Actually, rank_loss
is averaged over all triplets, but only some the triplets, which are neither too hard nor too easy, are chosen for updating the model.
Thanks for explanation @wanji
Hi, I'm looking through the batch_triplet_loss_layer source for triplet embedding vgg-face model. I'd like to filter only hard negative samples so I set the sample parameter "true". But, I found that in the file, line 164 looks like below if (!sample || neg_dist > pos_dist) { smp_rank_loss += cur_rankloss; triplets.push_back(Triplet(i, j, k)); } Is this should be " if (!sample || pos_dist > neg_dist) "? since the distance is euclidean. Thanks for your help in advance.