Given groups=1, weight of size 32 1 5 5, expected input[2, 3, 96, 96] to have 1 channels, but got 3 channels instead

Why the expected channel is 1 rather than 3, I have written in conv1 that its in_channels = 3.
There might be some problem in the Model, I can’t figure it out, can somebody help me?
Thank you.

class CNN_Discriminator(nn.Module):
    def __init__(self):
        super(CNN_Discriminator, self).__init__()
        self.conv1 = nn.Sequential(
            nn.Conv2d(in_channels=3, out_channels=32, kernel_size=5, padding=2),  # batch, 32, 96,96,
            nn.LeakyReLU(0.2, True),
            nn.AvgPool2d(2, stride=2),  # batch, 32, 48, 48
        )
        self.conv2 = nn.Sequential(
            nn.Conv2d(32, 64, 5, padding=2),  # batch, 64, 48, 48
            nn.LeakyReLU(0.2, True),
            nn.AvgPool2d(2, stride=3)  # batch, 64, 16, 16
        )
        self.fc = nn.Sequential(
            nn.Linear(64 * 16 * 16, 1024),
            nn.LeakyReLU(0.2, True),
            nn.Linear(1024, 1),
            nn.Sigmoid()
        )

    def forward(self, x):
        '''
        x: batch, width, height, channel=3
        '''
        x = self.conv1(x)
        x = self.conv2(x)
        x = x.view(x.size(0), -1)
        x = self.fc(x)
        return x

Your model works fine with this input:

model = CNN_Discriminator()
x = torch.randn(2, 3, 96, 96)
out = model(x)

Are you sure you are using this model definition?

Thank you I find out that that I import a wrong local model :rofl::rofl::rofl: