提交 e584fadf 编写于 作者: C chenguowei01

add weight_decay

上级 8f0a11c5
......@@ -7,3 +7,6 @@ model:
num_classes: 19
backbone_channels: [270]
backbone_pretrained: pretrained_model/hrnet_w18_imagenet
optimizer:
weight_decay: 0.0005
......@@ -137,6 +137,12 @@ class Config(object):
lr = self.learning_rate
args = self.optimizer_args
args.setdefault('momentum', 0.9)
weight_decay = args.get('weight_decay', None)
if weight_decay is not None:
args.pop('weight_decay')
regularization = fluid.regularizer.L2DecayRegularizer(
regularization_coeff=weight_decay)
args.setdefault('regularization', None)
return fluid.optimizer.Momentum(
lr, parameter_list=self.model.parameters(), **args)
else:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册