Why we calculate the loss between logits and target in CrossEntropyLoss? #166
-
Hello, Since Regarding to Thank you in advance! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hi @afi1289, Good questions!
Yes, you're right! This is in the documentation for "Note that this case is equivalent to the combination of LogSoftmax and NLLLoss."
In the case of how the PyTorch functions are implemented, generally, yes. This is because if you look under the hood of the output layers/how the loss formulas are implemented, the outputs are in the form of a "logit" rather than a "label" (how the ground truth labels are formatted). So there needs to be some conversion between the logit and the label so they can be properly compared. You can see more of the formulas behind each loss in this article: https://blog.paperspace.com/pytorch-loss-functions/ |
Beta Was this translation helpful? Give feedback.
Hi @afi1289,
Good questions!
Yes, you're right!
This is in the documentation for
torch.nn.CrossEntropyLoss()
with the line:"Note that this case is equivalent to the combination of LogSoftmax and NLLLoss."
In the case of how the PyTorch functions are implemented, generally, yes.
This is because if you look under the hood of the output layers/how the loss formulas are implemented, the outputs are in the form of a "logit" rather than a "label" (how the gr…