I’d like to calculate cross entropy for batch of two tensors:
x = torch.tensor([[[ 2.1137, -1.3133, 0.7930, 0.3330, 0.9407],
[-0.8380, -2.0299, -1.1218, 0.3150, 0.4797],
[-0.7439, 0.0753, -0.1121, 0.0096, -1.2621]]])
y = torch.tensor([[1,2,3]])
loss = nn.CrossEntropyLoss()(x, y)
but receive exception:
RuntimeError: Expected target size [1, 5], got [1, 3]
Please explain what is wrong…