RuntimeError: multi-target not supported (newbie)

Your outputs should keep the size (minibatch, C).

Try this code snippet:

criterion = nn.CrossEntropyLoss()

output = Variable(torch.randn(10, 120).float())
target = Variable(torch.FloatTensor(10).uniform_(0, 120).long())

loss = criterion(output, target)
11 Likes