对比损失

Published: 12 May 2019 Category: algo

Contrasive loss即对比损失,性质比较有趣,简单记录之。

Contrasive Loss

图像检索任务中,经常会用到对比损失,该损失可以跟如下intuition对齐,即相同label的图像距离越近越好,不同label的图像距离越远越好,看如下Loss的巧妙设计。

  • label=1 距离d越小,loss越小
  • label=0 距离d越大,loss越小,超过margin,loss为零

优化上述Loss,那么模型参数的调整可以使相同label的样本更近,不同label的样本更远。

Contrastive Loss is often used in image retrieval tasks to learn discriminative features for images. The margin term is used to “tighten” the constraint: if two images in a pair are dissimilar, then their distance shoud be at least margin, or a loss will be incurred.

algo-contrasive-loss

基于距离的Loss可以借鉴该思路,比如DSSM中,有了query和doc的embedding向量,是否可构造contrasive loss训练,使query和相关doc距离更近,和不相关query距离更远?

Ref