nn.CrossEntropy combines log_softmax and NLLLoss, that’s the reason there is no need to use nn.Softmax at the end of the network when nn.CrossEntropy is used as a criterion.
Check this: https://github.com/pytorch/pytorch/blob/master/torch/nn/modules/loss.py#L826 45


Generally average loss over the entire batch is returned after criterion(outputs, targets) call. So inorder to get the sum of all losses over a batch, you do loss.item() * batch_size.