未验证 提交 60a0e779 编写于 作者: Y Yang Zhang 提交者: GitHub

Fix `norm_decay` in config files (#2539)

* Fix `norm_decay` in config files

should be float value now

* Clean up a bit

mostly max line length related
上级 3f8aa0f7
......@@ -21,7 +21,7 @@ FasterRCNN:
ResNet:
norm_type: affine_channel
norm_decay: true
norm_decay: 0.
depth: 50
feature_maps: [2, 3, 4, 5]
freeze_at: 2
......
......@@ -21,7 +21,7 @@ FasterRCNN:
ResNet:
norm_type: affine_channel
norm_decay: true
norm_decay: 0.
depth: 50
feature_maps: [2, 3, 4, 5]
freeze_at: 2
......
......@@ -23,7 +23,7 @@ MaskRCNN:
ResNet:
norm_type: affine_channel
norm_decay: true
norm_decay: 0.
depth: 50
feature_maps: 4
freeze_at: 2
......
......@@ -64,13 +64,16 @@ class MaskRCNN(object):
def build(self, feed_vars, mode='train'):
im = feed_vars['image']
assert mode in ['train', 'test'], "only support 'train' and 'test' mode"
assert mode in ['train', 'test'], \
"only 'train' and 'test' mode is supported"
if mode == 'train':
required_fields = ['gt_label', 'gt_box', 'gt_mask', 'is_crowd', 'im_info']
required_fields = ['gt_label', 'gt_box', 'gt_mask',
'is_crowd', 'im_info']
else:
required_fields = ['im_shape', 'im_info']
for var in required_fields:
assert var in feed_vars, "{} has no {} field".format(feed_vars, var)
assert var in feed_vars, \
"{} has no {} field".format(feed_vars, var)
im_info = feed_vars['im_info']
body_feats = self.backbone(im)
......@@ -144,7 +147,8 @@ class MaskRCNN(object):
with switch.case(cond):
fluid.layers.assign(input=bbox_pred, output=mask_pred)
with switch.default():
bbox = fluid.layers.slice(bbox_pred, [1], starts=[2], ends=[6])
bbox = fluid.layers.slice(bbox_pred, [1],
starts=[2], ends=[6])
im_scale = fluid.layers.slice(
im_info, [1], starts=[2], ends=[3])
......@@ -155,8 +159,8 @@ class MaskRCNN(object):
mask_feat = self.roi_extractor(last_feat, mask_rois)
mask_feat = self.bbox_head.get_head_feat(mask_feat)
else:
mask_feat = self.roi_extractor(body_feats, mask_rois,
spatial_scale, is_mask=True)
mask_feat = self.roi_extractor(
body_feats, mask_rois, spatial_scale, is_mask=True)
mask_out = self.mask_head.get_prediction(mask_feat, bbox)
fluid.layers.assign(input=mask_out, output=mask_pred)
......
......@@ -39,11 +39,11 @@ class ResNet(object):
Args:
depth (int): ResNet depth, should be 18, 34, 50, 101, 152.
freeze_at (int): freeze the backbone at which stage
norm_type (str): normalization type, 'bn', 'sync_bn' or 'affine_channel'
norm_type (str): normalization type, 'bn'/'sync_bn'/'affine_channel'
freeze_norm (bool): freeze normalization layers
norm_decay (float): weight decay for normalization layer weights
variant (str): ResNet variant, supports 'a', 'b', 'c', 'd' currently
feature_maps (list): index of the stages whose feature maps are returned
feature_maps (list): index of stages whose feature maps are returned
"""
def __init__(self,
......@@ -330,6 +330,7 @@ class ResNetC5(ResNet):
norm_decay=0.,
variant='b',
feature_maps=[5]):
super(ResNetC5, self).__init__(depth, freeze_at, norm_type, freeze_norm,
norm_decay, variant, feature_maps)
super(ResNetC5, self).__init__(
depth, freeze_at, norm_type, freeze_norm, norm_decay,
variant, feature_maps)
self.severed_head = True
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册