@nafizh1
Try this:

Manually zero the gradients before running the backward pass
if t:
w1.grad.data.zero_()
w2.grad.data.zero_()

I had this issue too and found out that in the latest the grad data is not created (not just initialized but its not even created) until backward is called and gradients need to be computed. The above code basically checks:
If first iteration (i.e, t = 0) then don’t zero the data else zero out the grad data.