def op_copy(optimizer):
    for param_group in optimizer.param_groups:
        param_group['lr0'] = param_group['lr']
    return optimizer

lr = 1e-3
param_group = []
for k, v in net.named_parameters():
    param_group += [{'params': v, 'lr': lr * 0.1}]
for k, v in classifier.named_parameters():
    param_group += [{'params': v, 'lr': lr}]

optimizer = optim.SGD(param_group)
optimizer = op_copy(optimizer)

Hi, all.
I’m new to pytorch.
I have some questions about the above codes.


What does op_copy() do?


If I change
optimizer = optim.SGD(param_group) to
optimizer = optim.SGD(param_group, lr = 1e-3)
then the learning rate for net become 1e-4 and classifier for 1e-3 ?