Trying to learn Siamese networks for ranking tasks from here, I find it hard to understand why triplet loss and contrastive losses have the "margin" element in them.
The contrastive loss
$L(A, B) = y|f(A) - f(B)| + (1-y)max(0, m-|f(A) - F(B)|)$
The triplet loss
$L(A, P, N) = max(0, |f(A) - f(P)| - |f(A) - f(N)| + m) $
both have the margin m
, which doesn't allow samples to be pushed passed it.
In the lecture, Prof. Laura Leal-Taixé says:
I want to keep separating them (the samples), until we hit a margin
m
. And the idea is that it makes no sense to actually push $f(A)$ and $f(B)$ further apart if they are already as far as the marginm
. ... I am not going to spend any energy in pulling them even further away.
Here it is explained why we want to bound the loss.
Still, I would like to understand how does changing the value of m
change the output, from the user's perspective, meaning, how does it affect clustering, or classification accuracy or other metrics? Why choose large or small m
when engineering a system?