Solved by ptrblck in post #2 
              
              
                You are breaking the computation graph by recreating tensors and the deprecated Variables. 
To keep the computation graph intact you would need to apply operations on tensors only, so remove: 
... Variable(output),Variable(target)
torch.tensor(error_diff,requires_grad=True)
loss = Variable(loss)

et…