Issue
Tested the documentation example of nn.CrossEntropyLoss. It doesn't seem to work.
loss = nn.CrossEntropyLoss()
input = torch.randn(3, 5, requires_grad=True)
target = torch.randn(3, 5).softmax(dim=1)
output = loss(input, target)
print(output)
error:
RuntimeError: 1D target tensor expected, multi-target not supported
Solution
You might need to upgrade your torch version.
pip install torch --upgrade
Answered By - joe32140
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.