About the Contrastive Loss
lixiangyu-1008 opened this issue · comments
Hi @TengdaHan,
Thanks for great work,
I haven't found the NCE Loss in your source code, Could you please show me where the implement of NCE Loss :)
Thanks for your reply,
This is a CorssEntropy Loss, where the implement of dot-production as you described in Eq.(5) in paper?
That's exactly the InfoNCE loss.
Some explanation:
score_flattened
is a square matrix having the dot product of all Pred-GT pairs, including one positive pair in each row;
target_flattened
is the index of positive pairs, the diagnal in this case.
CrossEntropyLoss
is the negative LogSoftmax
of the targeted class, which is exactly NCE loss.
Simple and beautiful, isn't it.
@WeidiXie @TengdaHan
Thanks for your prompt reply !
I think I have understand it !!