I have encountered a strange behavior. The following piece of code works as expected
model = models.resnet152(pretrained=True)

params_to_update = [{'params': model.fc.parameters(), 'lr': 0.001}]

optimizer = optim.Adam(params_to_update) 

print(optimizer.param_groups)

However if I do something like this:
params_to_update = [{'params': model.fc.parameters(), 'lr': 0.001}]

for d in params_to_update:
    for param in d['params']:
        print(param.requires_grad)

optimizer = optim.Adam(params_to_update) 

print(optimizer.param_groups)

I get:
True
True
[{'params': [], 'lr': 0.001, 'betas': (0.9, 0.999), 'eps': 1e-08, 'weight_decay': 0, 'amsgrad': False}]

where the 'params': [] is empty now (before inserting the for-loops it was not empty). I find it very strange since I haven’t altered the params_to_update dictionary and just made some print statements in the for-loop.