Skip to content

Softmax layer (page 437) #32

Answered by rasbt
ashwinshetgaonkar asked this question in Q&A
Discussion options

You must be logged in to vote

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, the CrossEntropyLoss is the multiclass equivalent of BCEWithLogitsLoss. And NLLLoss is the multiclass equivalent of BCELoss.

I have a little explanation here…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by ashwinshetgaonkar
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #28 on March 21, 2022 15:52.