Solved by rasbt in post #2 
              
              
                The problem is that you created 2 tensors that have no grad function by calling the clone operation on the .data.grad tensor. 
Below is a simplified, working example: 
a = torch.tensor([-2.], requires_grad=True)
b = torch.tensor([-2.], requires_grad=True)


for i in range(1):

    var_loss = torch.t…