Open kk701710 opened 3 years ago
...... Initialize the network done!!! ....... Traceback (most recent call last): File "/home/jiannan/project/pytorch_classification-master/train.py", line 76, in optimizer = optim.Adam(filter(lambda p: p.requires_grad, model.parameters()), lr=cfg.LR) File "/home/jiannan/anaconda3/envs/pt-gpu/lib/python3.6/site-packages/torch/optim/adam.py", line 42, in init super(Adam, self).init(params, defaults) File "/home/jiannan/anaconda3/envs/pt-gpu/lib/python3.6/site-packages/torch/optim/optimizer.py", line 46, in init raise ValueError("optimizer got an empty parameter list") ValueError: optimizer got an empty parameter list 这个问题要怎么解决???
你好,请问你解决了吗?我是在用densenet的时候出现了和你一样的问题。
我弄好了,把优化器改成SGD,然后在loss = criterion(out, labels.long())这一行的下面添加: loss.requiresgrad(True) 就能正常跑起来了。
...... Initialize the network done!!! ....... Traceback (most recent call last): File "/home/jiannan/project/pytorch_classification-master/train.py", line 76, in
optimizer = optim.Adam(filter(lambda p: p.requires_grad, model.parameters()), lr=cfg.LR)
File "/home/jiannan/anaconda3/envs/pt-gpu/lib/python3.6/site-packages/torch/optim/adam.py", line 42, in init
super(Adam, self).init(params, defaults)
File "/home/jiannan/anaconda3/envs/pt-gpu/lib/python3.6/site-packages/torch/optim/optimizer.py", line 46, in init
raise ValueError("optimizer got an empty parameter list")
ValueError: optimizer got an empty parameter list
这个问题要怎么解决???