In PyTorch nn.CrossEntropyLoss expects raw logits, since internally F.log_softmax and F.nll_loss will be used. The log_softmax operation is used for a better numerical stability compared to splitting these operations. I don’t know, if TensorFlow/Keras applies log_softmax for the user automatically (without their knowledge), stabilizes the loss calculation in another way, or just applies the operations as they are.