1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
| optimizer = t.optim.Adam(model.parameters(), lr = 0.1)
optim_group = [{'params':model.net1.parameters(),'lr':0.4}, {'params':model.net2.parameters(),'lr':0.1}] optimizer = t.optim.Adam(optim_group,lr=0.04)
ignored_params = list(map(id, model.model.fc.parameters() )) + list(map(id, model.classifier.parameters() )) base_params = filter(lambda p: id(p) not in ignored_params, model.parameters()) optimizer_ft = optim.SGD([ {'params': base_params, 'lr': 0.01}, {'params': model.model.fc.parameters(), 'lr': 0.1}, {'params': model.classifier.parameters(), 'lr': 0.1} ], weight_decay=5e-4, momentum=0.9, nesterov=True)
|