Pretrained ResNet has a 'str' parameter error

Hi, I’m facing a weird problem.

using pretrained ResNet34. But in optimizer, it raises type error:

Code:

model = models.resnet34(pretrained = True)
optimizer = torch.optim.Adam(
            {'params': model.parameters()}, 
                lr=0.001, betas=(0.9, 0.999), eps=1e-08, weight_decay=0)

Error:

TypeError: optimizer can only optimize Variables, but one of the params is str

I know I can pass in each layer’s parameter to get around this
(e.g.
{‘params’: model.conv1.parameters()},

etc.)

But any ideas why this would happen?

Thanks

Edit:

Nvm, made a mistake. If just one learning rate, shouldn’t put the parameter generator in a bracket ‘{}’.

Change to :

optimizer = torch.optim.Adam(
            model.parameters(),
                lr=0.001, betas=(0.9, 0.999), eps=1e-08, weight_decay=0)

solved this error.