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

Error while using CancelOut in CNN model #4

Open
sabajhn opened this issue Oct 27, 2023 · 0 comments
Open

Error while using CancelOut in CNN model #4

sabajhn opened this issue Oct 27, 2023 · 0 comments

Comments

@sabajhn
Copy link

sabajhn commented Oct 27, 2023

I'm using CancelOut in my CNN model in pytorch. My input shape is torch.Size([16, 11, 81, 60]) (16 batch size, 11 number of channels, 81 height and 60 width). So I wrote the following model using CancelOut like this:

class CNN(nn.Module):
    def __init__(self):
        super().__init__()
        self.cancelout = CancelOut(16)
        self.conv1 = nn.Conv2d(11, 64, (1,1))
        self.pool = nn.MaxPool2d(2, 2)
   def forward(self, x):
        x = self.cancelout(x)
        x = self.pool(F.relu(self.conv1(x)))
   return x

but got this error:

in forward
    return (x *torch.sigmoid(self.weights.float()))
RuntimeError: The size of tensor a (60) must match the size of tensor b (16) at non-singleton dimension 3

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

1 participant