The documentation provides quite details here about CrossEntropyLoss. https://pytorch.org/docs/stable/nn.html#crossentropyloss 1
It’s better to read it carefully first and give it a try in your case to see how it goes. Keep in mind that the prediction from your model must the logits (don’t use softmax or logsoftmax at the end of your model).