Solved by ptrblck in post #2 
              
              
                Wrapping a tensor into Variable didn’t change the requires_grad attribute to True. 
You had to specify it while creating the Variable: 
x = Variable(torch.randn(1), requires_grad=True)

Usually you don’t need gradients in your input. However, gradients in the input might be needed for some special u…