Solved by ptrblck in post #2 
              
              
                You would get approx. the same results assuming your indexing is right (I had to use [torch.arange(y.size(0), y] if y has the shape [batch_size]). 
However, you might run into numerical stability issues, as you are applying torch.log and F.softmax separately. 
You could try to use loss = -F.log_soft…