title: Pytorch CNN mat1 and mat2 shapes cannot be multiplied ( (128x29040 and 2048x50)
body: <p>Building a CNN on Pytorch i have this error about dimensions of matrix and i cannot resolve it since iam a bit new to Pytorch and CNNs , i know it's a problem with the values of in features in my layers but not exactly what wrong with these dimensions , here is the model and the trace of error , my batch size is 128 , my data are images transformed to tensors , images are 100*100 px:</p>
  <pre><code>     def __init__(self,classes):
         super(roadModel, self).__init__()
         self.conv1 = Conv2d(3,30,kernel_size=(5,5))
         self.relu1 = ReLU()
         self.maxpool1 = MaxPool2d(kernel_size=(2,2), stride=(2,2))
         self.conv2 = Conv2d(30,60,kernel_size=(5,5))
         self.relu2 = ReLU()
         self.maxpool2 = MaxPool2d(kernel_size=(2,2), stride=(2,2)) 
         self.fc1 = Linear(in_features=128*4*4, out_features=50)
         self.relu3 = ReLU()
         self.fc2 = Linear(in_features=50, out_features=43)
         
      
      def forward(self, x):
  
          x = self.conv1(x)
          x = self.relu1(x)
          x = self.maxpool1(x)
  
          x = self.conv2(x)
          x = self.relu2(x)
          x = self.maxpool2(x)
  
          x = flatten(x, 1)
          x = self.fc1(x)
          x = self.relu3(x)
  
          out = self.fc2(x)
          
  
          return out
      
      RuntimeError                              Traceback (most recent call last)
  &lt;ipython-input-15-978518dfa1ac&gt; in &lt;module&gt;
       12     for (inputs, labels) in trainDataLoader:
       13         (inputs, labels) = (inputs.to(device), labels.to(device))
  ---&gt; 14         prediction = model(inputs)
       15         loss = lossFunction(prediction, labels)
       16         opt.zero_grad()
  
  ~/anaconda3/lib/python3.8/site-packages/torch/nn/modules/module.py in _call_impl(self, *input, **kwargs)
     1100         if not (self._backward_hooks or self._forward_hooks or self._forward_pre_hooks or _global_backward_hooks
     1101                 or _global_forward_hooks or _global_forward_pre_hooks):
  -&gt; 1102             return forward_call(*input, **kwargs)
     1103         # Do not call functions when jit is used
     1104         full_backward_hooks, non_full_backward_hooks = [], []
  
  &lt;ipython-input-13-58a66aa14326&gt; in forward(self, x)
       24 
       25         x = flatten(x, 1)
  ---&gt; 26         x = self.fc1(x)
       27         x = self.relu3(x)
       28 
  
  ~/anaconda3/lib/python3.8/site-packages/torch/nn/modules/module.py in _call_impl(self, *input, **kwargs)
     1100         if not (self._backward_hooks or self._forward_hooks or self._forward_pre_hooks or _global_backward_hooks
     1101                 or _global_forward_hooks or _global_forward_pre_hooks):
  -&gt; 1102             return forward_call(*input, **kwargs)
     1103         # Do not call functions when jit is used
     1104         full_backward_hooks, non_full_backward_hooks = [], []
  
  ~/anaconda3/lib/python3.8/site-packages/torch/nn/modules/linear.py in forward(self, input)
      101 
      102     def forward(self, input: Tensor) -&gt; Tensor:
  --&gt; 103         return F.linear(input, self.weight, self.bias)
      104 
      105     def extra_repr(self) -&gt; str:
  
  ~/anaconda3/lib/python3.8/site-packages/torch/nn/functional.py in linear(input, weight, bias)
     1846     if has_torch_function_variadic(input, weight, bias):
     1847         return handle_torch_function(linear, (input, weight, bias), input, weight, bias=bias)
  -&gt; 1848     return torch._C._nn.linear(input, weight, bias)
     1849 
     1850 
  
  RuntimeError: mat1 and mat2 shapes cannot be multiplied (128x29040 and 2048x50)
  </code></pre>