The target tensor for nn.CrossEntropyLoss is expected to contain class indices in the range [0, nb_classes-1], which seems to fail in your script.
Check its values via print(target.min(), target.max()) and make sure they are valid.
The target tensor for nn.CrossEntropyLoss is expected to contain class indices in the range [0, nb_classes-1], which seems to fail in your script.
Check its values via print(target.min(), target.max()) and make sure they are valid.