Skip to content

bias=False not passed in ResNet downsampling layer (shortcut='B') #5465

@thatgeeman

Description

@thatgeeman

Hi!

conv_type(self.in_planes, planes * block.expansion, kernel_size=1, stride=stride),

In the above line in the implementation of the ResNet, the downsampling layer is not expected to have a bias parameter (bias=True by default). The argument is explicitly set to False in the 2D torchvision, the 3D MedicalNet paper and the kenshohara implementations on which it is based. Is there any particular reason why bias is not set to False?

To reproduce

If we compare the implementations for a 3D and 2D resnet18:

from torchvision import models 
from monai.networks import nets
d2net_torch = models.resnet18()
d2net_monai = nets.resnet18(spatial_dims=2)
d3net_monai = nets.resnet18(spatial_dims=3)
len(list(d2net_torch.parameters())), len(list(d2net_monai.parameters())), len(list(d3net_monai.parameters())) 
# 62, 65, 65

The 2D implementation of the ResNet does not match the torch implementation due to the same reason. The same occurs for other deeper resnet variants.
What do you guys think? If this is something that needs fixing, I'd be happy to work on it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions