Trying to learn Siamese networks for ranking tasks from here, I find it hard to understand why triplet loss was ever introduced at all, theoretically. I understand it works better in practice, but would like to understand.

The contrastive loss

$L(A, B) = y|f(A) - f(B)| + (1-y)max(0, m-|f(A) - F(B)|)$

would push similar samples together, and dissimilar samples apart.

The triplet loss

$L(A, P, N) = max(0, |f(A) - f(P)| - |f(A) - f(N)| + m) $

would push the positive close to the anchor, and the negative away from the anchor.

I fail to see the big difference, when to use one over the other, and why it is claimed in the video that triplet loss allows to learn a ranking, whereas contrastive loss only allows for similarity.

Would love a clarification on that



Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.