title: Getting error with two matrices multiplication (mat1 and mat2 shapes cannot be multiplied)
body: <p>I am getting the following error after running the training process for my network.</p>
  <blockquote>
  <p>RuntimeError: mat1 and mat2 shapes cannot be multiplied (21760x17 and 18496x512)</p>
  </blockquote>
  <p>This is the network architecture</p>
  <pre><code>self.layer1 = nn.Sequential(
      nn.Conv2d(3, 16, kernel_size=3),
      nn.ReLU(),
      nn.MaxPool2d(2)
  )
  
  self.layer2 = nn.Sequential(
      nn.Conv2d(16, 32, kernel_size=3),
      nn.ReLU(),
      nn.MaxPool2d(2)
  )
  
  self.layer3 = nn.Sequential(
      nn.Conv2d(32, 64, kernel_size=3),
      nn.ReLU(),
      nn.MaxPool2d(2)
  )
  
  self.flatten = nn.Flatten(2)
  self.fc1 = nn.Linear(18496, 512)
  self.fc2 = nn.Linear(512,1)
  self.sigmoid = nn.Sigmoid()
  
  
  def forward(self, x):
    x = self.layer1(x)
    x = self.layer2(x)
    x = self.layer3(x)
    x = self.fc1(x)
    x = self.fc2(x)
    return x
  </code></pre>
  <p>The input size image is 150x150x3. What causes this problem?</p>
  <p><strong>Edit:</strong></p>
  <p>The architecture is based on the model created in Keras. I need to convert from Keras to Pytorch.</p>
  <p><a href="https://i.stack.imgur.com/yC22r.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/yC22r.png" alt="enter image description here" /></a></p>
  <p>Based on this, I created the network shown above.</p>