I want to test if my code correctly calculates the loss value. I think I first need to get a correct fixed loss value from CrossEntropyLoss.
But …
Why is the output of the following code not 0?
import torch
import torch.nn as nn
inputs = torch.tensor([[1., 0., 0.],
[0., 1., 0.],
[0., 0., 1.]])
labels = torch.tensor([0, 1, 2])
criterion = nn.CrossEntropyLoss()
loss = criterion(inputs, labels)
print(loss)