I have been seeing code that uses an Adam optimizer . And the way they decrease the learning rate is as follows:
optimizer = torch.optim.Adam(net.parameters(),lr=0.01)
(training...
optimizer.step()...)
if iteration >= some_threshold:
for param_group in optimizer.param_groups:
param_group['lr'] = 0.001
I thought we have the same learning rate for all parameters. So why then iterate over the param_groups and individually set learning rate for each parameter?
Wouldn't the following be faster and have an identical effect?
optimizer = torch.optim.Adam(net.parameters(),lr=0.01)
scheduler = MultiStepLR(optimizer, milestones=[some_threshold], gamma=0.1)
(training...
optimizer.step()
scheduler.step())
Thank you