CancelOut icon indicating copy to clipboard operation
CancelOut copied to clipboard

Error while using CancelOut in CNN model

Open sabajhn opened this issue 2 years ago • 0 comments

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

sabajhn avatar Oct 27 '23 17:10 sabajhn