Skip to content

a small bug in resnet model _make_layer() implementation #706

@dakjin

Description

@dakjin

Hi guys,

I think there is a small bug in the "_make_layer(self, block, planes, blocks, stride=1)" function (in charge of generating residual blocks at certain resolution) in the ResNet model. This function will just simply discard the odd number of rows and columns in the feature maps in the identity path at the first residual block in a resolution stage when the stride=2 (the case where feature maps get downsampled by 2).

def _make_layer(self, block, planes, blocks, stride=1):
    downsample = None
    if stride != 1 or self.inplanes != planes * block.expansion:
        downsample = nn.Sequential(
            #this 1x1 conv with stride 2 will simply discard the odd number of rows and columns in the feature maps in the identity path
            conv1x1(self.inplanes, planes * block.expansion, stride), 
            nn.BatchNorm2d(planes * block.expansion),
        )

Please let me know what do you think.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions