I'm trying to run the following code:
l = torch.tensor([0, 1, 1, 1], requires_grad=False)
r = torch.rand(4, 2)
torch.nn.CrossEntropyLoss(r, l)
And I'm getting error:
RuntimeError: Boolean value of Tensor with more than one value is ambiguous
I looked here: Bool value of Tensor with more than one value is ambiguous in Pytorch but didn't understand the answers.
What do I need to change in order to run the code ?