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

An error in your code. #45

Open
penguinbing opened this issue Nov 1, 2019 · 3 comments
Open

An error in your code. #45

penguinbing opened this issue Nov 1, 2019 · 3 comments

Comments

@penguinbing
Copy link

penguinbing commented Nov 1, 2019

The MeanShift Conv2d you defined in your code won't freeze, there is no requires_grad attribute in Conv2d module. You should freeze it using self.weight.requires_grad=False and self.bias.requires_grad=False instead, rather than self.requires_grad=False.
However, change MeanShift Conv2d to below will be more clear and more correct. The code is following here

class MeanShift(nn.Conv2d):
    def __init__(
        self, rgb_range,
        rgb_mean=(0.4488, 0.4371, 0.4040), rgb_std=(1.0, 1.0, 1.0), sign=-1):

        super(MeanShift, self).__init__(3, 3, kernel_size=1)
        std = torch.Tensor(rgb_std)
        self.weight.data = torch.eye(3).view(3, 3, 1, 1) / std.view(3, 1, 1, 1)
        self.bias.data = sign * rgb_range * torch.Tensor(rgb_mean) / std
        for p in self.parameters():
            p.requires_grad = False
@Paper99
Copy link
Owner

Paper99 commented Nov 1, 2019

Thank you for reminding me of this mistake. I haven't noticed this yet. I will correct it as soon as possible.

@zinhoo
Copy link

zinhoo commented Nov 28, 2019

Be careful with your English: ‘a error‘ should be ‘An error’

@penguinbing penguinbing changed the title A error in your code. An error in your code. Nov 28, 2019
@penguinbing
Copy link
Author

Thank you. @zinhoo

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

No branches or pull requests

3 participants