I assume scores
has the same spatial shape as your target.
If so, you would need to get rid of the channel dimension in y
.
nn.CrossEntropyLoss
expects the targets to contain the class indices in the range [0, nb_classes-1]
for a multi-class segmentation use case.
You could try y = y.squeeze(1)
, if y
already contains the class indices.