Hello together,
I’m working on a dataset for semantic segmantation. I’m doing some experiments with cross-entropy loss and got some confusing results. I transformed my groundtruth-image to the out-like tensor with the shape:
out = [n, num_class, w, h].
Then I generate my target tensor with this out-tensor:
target = torch.argmax(out, dim=1)
and get tensor with the shape [n, w, h]. Finally, I tried to calculate the cross entropy loss
criterion = nn.CrossEntropyLoss()
loss = criterion(out, tareget)

and I got a loss of 2.2. Shouldn’t the loss be 0? And what if I implement this loss in my segmentation network?
Many thanks in advance!