PyTorch: Variables and autograd - NoneType error
Closed this issue · 1 comments
filmo commented
When running the beginning autograd code on the ReadMe intro, I'm getting:
w1.grad.data.zero_()
AttributeError: 'NoneType' object has no attribute 'data'
I'm using PyTorch Version: 0.1.12_2 and python 2.7
tschoy commented
Move these two lines to the last of the for
loop (as in the README) would be ok. w1.grad
was not defined before loss.backward()
was ran for the first time.