Solved by ptrblck in post #2 
              
              
                I’ve fixed your PyTorch code as there were some minor issues: 
loss = nn.CrossEntropyLoss(reduction='none')
input = torch.tensor([[0.5, 1.5, 0.1], [2.2, 1.3, 1.7]], requires_grad=True)
target = torch.tensor([1, 2], dtype=torch.long)
print(type(input), type(target))
output = loss(input, target)
outpu…