RuntimeError: mat1 and mat2 shapes cannot be multiplied (32x73984 and 4096x1)

Hi please i need help i have a discriminator architecture of

class Discriminator(nn.Module):
    def __init__(self):
        super(Discriminator, self).__init__()

        self.main = nn.Sequential(
            nn.Conv2d(3, 16, kernel_size=3, stride=2, padding=1),
            nn.LeakyReLU(0.2),
            nn.Dropout(0.25),
            nn.Conv2d(16, 32, kernel_size=3, stride=2, padding=1),
            nn.ZeroPad2d((0, 1, 0, 1)),
            nn.BatchNorm2d(32, momentum=0.82),
            nn.LeakyReLU(0.25),
            nn.Dropout(0.25),
            nn.Conv2d(32, 64, kernel_size=3, stride=2, padding=1),
            nn.BatchNorm2d(64, momentum=0.82),
            nn.LeakyReLU(0.2),
            nn.Dropout(0.25),
            nn.Conv2d(64, 128, kernel_size=3, stride=2, padding=1),
            nn.BatchNorm2d(128, momentum=0.82),
            nn.LeakyReLU(0.25),
            nn.Dropout(0.25),
            nn.Conv2d(128, 256, kernel_size=3, stride=1, padding=1),
            nn.BatchNorm2d(256, momentum=0.8),
            nn.LeakyReLU(0.25),
            nn.Dropout(0.25),
            nn.Flatten(),
            nn.Linear(256 * 4 * 4, 1),  
            #nn.Linear(32, 73984),  
            nn.Sigmoid()
        )

    def forward(self, x):
        return self.main(x)

the nn.linear output is

 Linear(in_features=4096, out_features=1, bias=True)

i am trying to change the nn.linear to in_features=32, out_features=73984 from my architecture please help

change this line

nn.Linear(256 * 4 * 4, 1),  

to:

nn.Linear(256 * 4 * 4, 32),  

And then uncomment the line #nn.Linear(32, 73984),

That’s it, you’ll be all set

yes i have done that but this is the error

RuntimeError: mat1 and mat2 shapes cannot be multiplied (32x278784 and 32x278784)

you must’ve not done what I mentioned. that error message would come if you put the numbers in the wrong order.

yes i understand what you are saying but it will give the same error

RuntimeError: mat1 and mat2 shapes cannot be multiplied (32x73984 and 4096x3)
(16): Conv2d(128, 256, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
    (17): BatchNorm2d(256, eps=1e-05, momentum=0.8, affine=True, track_running_stats=True)
    (18): LeakyReLU(negative_slope=0.25)
    (19): Dropout(p=0.25, inplace=False)
    (20): Flatten(start_dim=1, end_dim=-1)
    (21): Linear(in_features=4096, out_features=3, bias=True)
    (22): Linear(in_features=32, out_features=73984, bias=True)
    (23): Sigmoid()
  )
)