Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update resnet_in.py #5

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

DiggyBee
Copy link

@DiggyBee DiggyBee commented Aug 5, 2021

Corrected issue with resnet_in.py where initial_kernel_size argument was missing from the ResNet class. This caused num_classes argument to be overwritten by the intended initial_kernel_size value.

Corrected issue with resnet_in.py where initial_kernel_size argument was missing from the ResNet class. This caused num_classes argument to be overwritten by the intended initial_kernel_size value.
@DiggyBee DiggyBee marked this pull request as ready for review August 5, 2021 10:01
@DiggyBee
Copy link
Author

DiggyBee commented Aug 5, 2021

Sorry if I have messed up the pull request. It is my first time doing it. I have corrected an issue with resnet_in.py which caused any model using resnet_in.py to use the inital_kernel_size argument, in the R50_ImgNet example (see below), to be used for the num_classes.

elif model=='R50_ImgNet':

        from models import resnet_in as resnet

        rnet_hr = resnet.ResNet(resnet.BasicBlock, [3,4,6,3], **7**, 1000)
        rnet_lr = resnet.ResNet(resnet.BasicBlock, [3,4,6,3], **7**, 1000)
        agent = resnet.ResNet(resnet.BasicBlock, [2,2,2,2], **3**, 16)

The third argument, either 3 or 7, in the example above is passed into the ResNet class below.

class ResNet(nn.Module):

    def __init__(self, block, layers, num_classes=1000, zero_init_residual=False,
                 groups=1, width_per_group=64, replace_stride_with_dilation=None,
                 norm_layer=None):
        super(ResNet, self).__init__()
        if norm_layer is None:
            norm_layer = nn.BatchNorm2d
        self._norm_layer = norm_layer

...

The third argument of ResNet is num_classes. By passing a value of 3 or 7, as found in the utils.py file, we find that the intended inital_kernel_size argument ends up being used for the num_classes argument.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant