Contrastive Loss

  • This is the first loss used for Contrastive Learning
  • Only one pair of data points are given
    • The points are similar or different

[!def] Contrastive Loss Formula
$$
Loss = (1-Y) * |x_i - x_j|^2 + Y * max(0, m - |x_i - x_j|^2)
$$
Here,

  • Y = 0 if sample is similar
  • Y = 1 if sample is different
  • m is a hyper-parameter

This loss mainly minimized the Euclidian Distance between similar points and increases the Euclidian Distance between different points till some limit m.