From 41c2b7a0b9855b443d8e1ea87b65e44e873dd76a Mon Sep 17 00:00:00 2001 From: Guanghua Yu <742925032@qq.com> Date: Thu, 9 Jul 2020 13:03:28 +0800 Subject: [PATCH] Add conv_decay and relu6 in mobilenet (#1039) --- configs/ssd/ssdlite_mobilenet_v1.yml | 2 +- ppdet/modeling/backbones/mobilenet.py | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/configs/ssd/ssdlite_mobilenet_v1.yml b/configs/ssd/ssdlite_mobilenet_v1.yml index dea79a13a..3624a3f6b 100644 --- a/configs/ssd/ssdlite_mobilenet_v1.yml +++ b/configs/ssd/ssdlite_mobilenet_v1.yml @@ -22,7 +22,7 @@ SSD: score_threshold: 0.01 MobileNet: - norm_decay: 0.0 + conv_decay: 0.00004 conv_group_scale: 1 extra_block_filters: [[256, 512], [128, 256], [128, 256], [64, 128]] with_extra_blocks: true diff --git a/ppdet/modeling/backbones/mobilenet.py b/ppdet/modeling/backbones/mobilenet.py index e275fe1f1..b2a0eb45f 100644 --- a/ppdet/modeling/backbones/mobilenet.py +++ b/ppdet/modeling/backbones/mobilenet.py @@ -34,6 +34,7 @@ class MobileNet(object): Args: norm_type (str): normalization type, 'bn' and 'sync_bn' are supported norm_decay (float): weight decay for normalization layer weights + conv_decay (float): weight decay for convolution layer weights. conv_group_scale (int): scaling factor for convolution groups with_extra_blocks (bool): if extra blocks should be added extra_block_filters (list): number of filter for each extra block @@ -43,6 +44,7 @@ class MobileNet(object): def __init__(self, norm_type='bn', norm_decay=0., + conv_decay=0., conv_group_scale=1, conv_learning_rate=1.0, with_extra_blocks=False, @@ -51,6 +53,7 @@ class MobileNet(object): weight_prefix_name=''): self.norm_type = norm_type self.norm_decay = norm_decay + self.conv_decay = conv_decay self.conv_group_scale = conv_group_scale self.conv_learning_rate = conv_learning_rate self.with_extra_blocks = with_extra_blocks @@ -70,6 +73,7 @@ class MobileNet(object): parameter_attr = ParamAttr( learning_rate=self.conv_learning_rate, initializer=fluid.initializer.MSRA(), + regularizer=L2Decay(self.conv_decay), name=name + "_weights") conv = fluid.layers.conv2d( input=input, @@ -139,6 +143,7 @@ class MobileNet(object): stride=1, num_groups=int(num_groups), padding=0, + act='relu6', name=name + "_extra1") normal_conv = self._conv_norm( input=pointwise_conv, @@ -147,6 +152,7 @@ class MobileNet(object): stride=2, num_groups=int(num_groups), padding=1, + act='relu6', name=name + "_extra2") return normal_conv -- GitLab