"TypeError: parameters() missing 1 required positional argument: 'self'" when calling my Network class

Hi all,

This is a beginner question. I’m doing the 60 minute Blitz tutorial, but when running the cifar10 classifier, I get on line
optimizer = optim.SGD(Network.parameters(), lr=0.001, momentum=0.9)
this error:

TypeError: parameters() missing 1 required positional argument: ‘self’

I copied the tutorial line by line, so I have no clue what is going wrong.

Any help will be much appreciated!

what version of pytorch are you on? where and how did you install it from?

I installed it from the main pytorch webpage and am using pytorch version
0.1.11 for python 3.5

it doesn’t look like you copied the code as-is:

optimizer = optim.SGD(Network.parameters(), lr=0.001, momentum=0.9)

This line is not in the tutorial, the line in the tutorial is:

optimizer = optim.SGD(net.parameters(), lr=0.01)

Here net is an object of the class Net, and maybe in your case Network is a class and not an object.


Thank you! Yeah that would’ve been a problem, but I changed some other variable names too, thereby maintaining the same structure. Eventually I reinstalled pytorch and it worked for me!