andompesta:

loss.backward()
print(loss.grad)


This makes no sense. loss.backward implicitly backwards a grad_output of 1.



 andompesta:

the gradient of x is nan.


Sorry I didn’t read the entire thread when I first replied. This is a bug at https://github.com/pytorch/pytorch/issues/4320 71.