reason for having labels as zeros: labels is the ground truth 'index' for the 1+len(queue) wide tensor logits. As shown in the code snippet of KaimingHe's answer, this is always index 0 (l_pos is the first column of the result tensor logits). logits later is feed into the CrossEntropy criterion, i.e. the contrasting happens through the entanglement of the logit scores by the softmax function.
But when we look at cross entropy formula, label value would be multiplied by log of predicted value. How can it be positive when it is zero and the result of that multiplication ends up being zero?
@@soroushmehraban The target that this criterion expects should contain either: Class indices in the range [0, C) where C is the number of classes. From PyTorch docs, as you can see it expects class indices 0 to C-1(C not included)
reason for having labels as zeros: labels is the ground truth 'index' for the 1+len(queue) wide tensor logits. As shown in the code snippet of KaimingHe's answer, this is always index 0 (l_pos is the first column of the result tensor logits). logits later is feed into the CrossEntropy criterion, i.e. the contrasting happens through the entanglement of the logit scores by the softmax function.
Pls keep up the great work. You will eventually have a much larger audience. Love you explanations and choice of papers. Thanks a lot Soroush 😊
Thanks for the feedback! Appreciate it🙂
Thank you! Awesome.
0 means 1st class. Generally classes in classification are indexed 0 to N-1, so label 0 means positive class
But when we look at cross entropy formula, label value would be multiplied by log of predicted value. How can it be positive when it is zero and the result of that multiplication ends up being zero?
@@soroushmehraban internally, I think it converts the batch N to one hot encoded NxC.
@@syedabdul7684 I checked the code on GitHub though. Couldn’t see that.
@@soroushmehraban
The target that this criterion expects should contain either:
Class indices in the range [0, C) where C is the number of classes.
From PyTorch docs, as you can see it expects class indices 0 to C-1(C not included)
@@syedabdul7684 I see. Now it makes sense! Thank you for the clarification.
It is perfect for me
👏👏