Solved by ptrblck in post #2 
              
              
                argmax is not differentiable and will detach the resulting tensor from the computation graph, so you would have to remove it. 
I’m not familiar with your use case, but if you are working on e.g. a multi-class classification you should pass the raw logits to nn.CrossEntropyLoss instead.