triplet-reid icon indicating copy to clipboard operation
triplet-reid copied to clipboard

soft-margin formula question

Open ronghuaiyang opened this issue 8 years ago • 7 comments

Hi, I am new to this subject, in the paper the soft-margin formula is ln(1+exp(x)), I don't understand what the x stand for? how to caculate it ? thank you very much !

ronghuaiyang avatar Sep 13 '17 10:09 ronghuaiyang

Hi and sorry for the late answer, I'm traveling.

The analogous hard-margin formula would be max(m + x, 0), where m is the margin. So what exactly x is depends on which loss formulation you use. For regular triplets, x would be Dpos - Dneg, and for any of the more advanced formulations, it would be the corresponding part in the equations (5), (6) and (7) of the paper.

Closing the issue, but feel free to reopen if that didn't help.

lucasb-eyer avatar Sep 18 '17 01:09 lucasb-eyer

Actually, I decided it would be good to keep issues open for visibility, and just tag them with "discussion" if it's something that can help others. Re-opening.

lucasb-eyer avatar Sep 20 '17 08:09 lucasb-eyer

hi, thank you very much for the answer. I followed your paper to do a face verification task, i finetune it in a softmax model, but the result becomes worse than the original softmax model. The dataset i use contains a large number of classes , about 300000 person, but there only 4~6 images per person. so, is it possible to use triplet loss on this kind of dataset? is there anything need to notice to implement the triplet loss?

ronghuaiyang avatar Sep 27 '17 09:09 ronghuaiyang

I've heard people successfully fine-tuning a softmax model with triplets, but I'm not sure about which details one should follow. For example, in that case it might (or might not) be important to use normalized embeddings and squared-euclidean distance.

I have never tried learning on such a dataset with this few images per identity, so I cannot say whether it should work or not, but I would be curious to know! Is it a public dataset? If so, which one, so I could try?

lucasb-eyer avatar Sep 27 '17 11:09 lucasb-eyer

thanks for the answer. I will try the normalized embeddings and the squared-euclidean distance. The dataset is collected by a company and it is not public. so i am afraid i can't share it to you. The softmax is effective for the dataset when the identity number is about 150000, but when i try to train the softmax model using 300000 identities, the training is not converge. i think maybe there is too much classes for the softmax to converge. that's why i want to try triplet loss.

ronghuaiyang avatar Sep 28 '17 01:09 ronghuaiyang

Hi, i am also new to this subject and read a few papers about person re-identification. I noticed that some people are using both softmax regression function with a cross-entropy identity loss and triplet-loss to separate different classes. What value will be added with the cross-entropy identity loss?? Thank you for your answer.

Aslizy avatar Dec 04 '19 10:12 Aslizy

Hello @Aslizy

In the future, please open a new issue instead of reusing an old one, given that your question is rather unrelated. While I don't have any real experiments to prove it, I have some intuitions why using the additional loss improves results. One reason could be the fact that early on during training the batch hard triplet loss sometimes finds too hard triplets and training gets stuck (see the discussion in our supplementary material) and here the cross-entropy loss can prevent collapsing models. But another reason could be that the cross-entropy identity loss, optimizes the embedding space by pushing all other identities further away from the ground truth identity, whereas the triplet loss can only optimize the space over the classes represented within the triplets of one batch.

In my opinion any form of a triplet loss can be used to directly learn the embedding space such that the metric that you want to use during inferences is meaningful, whereas the cross-entropy loss does not do that in such an elegant way. I think it's a great development that with the combination of the two, the best of both worlds can be used.

Pandoro avatar Dec 08 '19 13:12 Pandoro