Don’t use the .data attribute, as the manipulation of the underlying data might yield some side effects.
If you want to check the gradient of a parameter, you could access it via print(param.grad).
Also, you are mixing p.data.grad and p.grad.data.