mediumStudy question · answer published in Deep Learning interview questions, so no pointspytorchloss-functions
Softmax before CrossEntropyLoss
What is wrong with this classification loss code?
probs = torch.softmax(logits, dim=1) loss = nn.CrossEntropyLoss()(probs, targets) # targets: class indices
Discussion 0
Join free to post in the discussion.
Related questions
- Dropout after eval()Machine Learning Engineer
- Expected starting loss, 10 classesMachine Learning Engineer
- Parameters in nn.Linear(10, 5)Machine Learning Engineer
- Cross-entropy loss by handMachine Learning Engineer
- Telling autograd to track a tensorMachine Learning Engineer
- Why wrap inference in no_gradMachine Learning Engineer
- Logging loss without leaking memoryMachine Learning Engineer
- Feeding a single image to a CNNMachine Learning Engineer