danieltan07/learning-to-reweight-examples

ValueError: optimizer got an empty parameter list

Opened this issue ยท 5 comments

eeric commented

LeNet model used,
Traceback (most recent call last):
File "main.py", line 155, in
optimizer = optim.SGD(model.parameters(), lr=args.lr, momentum=args.momentum)
File "/usr/local/lib/python3.6/dist-packages/torch/optim/sgd.py", line 64, in init
super(SGD, self).init(params, defaults)
File "/usr/local/lib/python3.6/dist-packages/torch/optim/optimizer.py", line 38, in init
raise ValueError("optimizer got an empty parameter list")
ValueError: optimizer got an empty parameter list

why?

@eeric I am not sure. May I ask what version of pytorch you are using. It works fine on mine.

it should be:
optimizer = optim.SGD(model.params(), lr=args.lr, momentum=args.momentum)

use model.params() instead of model.parameters()

model.params() works, but why, what's the difference

If Adam optimizer is used, how to change ? @hansbu @hackershi @danieltan07

Got the same problem. If Adam optimizer is used, how to change ? @hansbu @hackershi @danieltan07