From bcad78007e03a66b3994ad74a355dfb2879fc609 Mon Sep 17 00:00:00 2001 From: Guanghua Yu <742925032@qq.com> Date: Tue, 25 Jun 2019 13:20:04 +0800 Subject: [PATCH] Fix resnet.py for ResNet18 and ResNet34 (#2532) * Fix ResNet18 and ResNet34 config. --- PaddleCV/object_detection/ppdet/modeling/backbones/resnet.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/PaddleCV/object_detection/ppdet/modeling/backbones/resnet.py b/PaddleCV/object_detection/ppdet/modeling/backbones/resnet.py index c902b8ac..7d879ba7 100644 --- a/PaddleCV/object_detection/ppdet/modeling/backbones/resnet.py +++ b/PaddleCV/object_detection/ppdet/modeling/backbones/resnet.py @@ -152,8 +152,7 @@ class ResNet(object): ch_in = input.shape[1] # the naming rule is same as pretrained weight name = self.na.fix_shortcut_name(name) - - if ch_in != ch_out or stride != 1: + if ch_in != ch_out or stride != 1 or (self.depth < 50 and is_first): if max_pooling_in_short_cut and not is_first: input = fluid.layers.pool2d( input=input, @@ -252,6 +251,8 @@ class ResNet(object): conv = input for i in range(count): conv_name = self.na.fix_layer_warp_name(stage_num, count, i) + if self.depth < 50: + is_first = True if i == 0 and stage_num == 2 else False conv = block_func( input=conv, num_filters=ch_out, -- GitLab