If you’re using this loss specifically: CrossEntropyLoss — PyTorch 1.9.0 documentation 1
Then you do not need to do a softmax operation. The loss, internally, will use a logsoftmax for computational stability reasons before the NLL. It mentions this at the top of the documentation.
You can just feed it the output of your network along with the labels.