torch.log(torch.softmax(tensor)) is less numerically stable than F.log_softmax, which is used internally in nn.CrossEntropyLoss. The numerical stability is increased by applying the log-sum-exp trick 26. You should get the same values, if you use F.log_softmax instead of the separate function calls.