Skip to content

Error while using CancelOut in CNN model #4

@sabajhn

Description

@sabajhn

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions