weight_p, bias_p = [],[]
for name, p in model.named_parameters():
if ‘bias’ in name:
bias_p += [p]
else:
weight_p += [p]
optim.SGD([
{‘params’: weight_p, ‘weight_decay’:1e-5},
{‘params’: bias_p, ‘weight_decay’:0}
], lr=1e-2, momentum=0.9)
{}内优先级最高
embedding=[]
for name,p in model.named_parameters():
if ‘embedding1.weight’ in name:
embedding+=[p]
参考:
https://zhuanlan.zhihu.com/p/259159952