Solved by Nikronic in post #2 
              
              
                Hi, 
You can only pass float tensors to calculate gradient using MSELoss. Try to add float() at the end of predicted_y and true_y tensors like below: 

The reason is when you use .max() it returns Long or simply integer not float numbers. So you have to cast them before passing to the loss function. …