Softmax layer (page 437) #32
-
Here you have not defined the softmax layer while building the Sequential model. Is is taken by default when we choose loss to be:nn.CrossEntropyLoss()? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Great question. Yes, you are right, it's done by default. This is one of the unintuitive parts about PyTorch, but under the hood, it takes care of the softmax. I am currently writing a blog article to discuss this in more detail. What's a bit unintuitive about that is that the binary cross entropy loss ( However, with the multiclass cross entropy loss (unlike the binary version) there is no I have a little explanation here from my deep learning class if useful:
|
Beta Was this translation helpful? Give feedback.
Great question. Yes, you are right, it's done by default. This is one of the unintuitive parts about PyTorch, but under the hood, it takes care of the softmax. I am currently writing a blog article to discuss this in more detail.
What's a bit unintuitive about that is that the binary cross entropy loss (
BCELoss
) accepts probabilities (after activation), and there is a version that accepts the logits:BCEWithLogitsLoss
However, with the multiclass cross entropy loss (unlike the binary version) there is no
WithLogits
version. In fact, theCrossEntropyLoss
is the multiclass equivalent ofBCEWithLogitsLoss
. AndNLLLoss
is the multiclass equivalent ofBCELoss
.I have a little explanation here…