Skip to content
RED SAGSkills
medium10 pts · first answer countspytorchloss-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
Choose one answer

Discussion 0

Join free to post in the discussion.

Related questions