Positive loss with respect to anchor statement in siamese network

In the loss equation for siamese model it is mentioned as:

max(-cos(A, P) + cos(A, N) + alpha, 0)

which means it is bounded by 0 for minimum but why no such consideration is done in case of maximum value, for some cases is might as well can go to positive infinity if distance(A, N) is very large and distance(A, P) is ~ 0 ?

Hi @Anand_Kumar3

In loss function there’s no upper bound because the loss needs to increase if the model fails to separate dissimilar pairs (A, N) from similar pairs (A, P). The value of loss becoming large is to force the model to maximize the separation between dissimilar pairs.

Hope it helps! Feel free to ask if you need further assistance.

1 Like

Hi @Alireza_Saei ,

Thanks for your response.

But in that case why then restrict the loss on negative side ? It was also expanding only. we could have taken the mod(diff(A, N) - diff(A, P) + alpha) ?

Loss is non-negative by definition.

1 Like