Question in pytorch :

randinoo: <p>I tested this code in order to make this architecture<br>
<div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/e/a/eacecf8c2383cd50fea8eb6b4904580b1c95e799.jpeg" data-download-href="https://discuss.pytorch.org/uploads/default/eacecf8c2383cd50fea8eb6b4904580b1c95e799" title="Capture"><img src="https://discuss.pytorch.org/uploads/default/optimized/3X/e/a/eacecf8c2383cd50fea8eb6b4904580b1c95e799_2_690x115.jpeg" alt="Capture" data-base62-sha1="xvcOIwFjNSlTj6PxFwB3Z9VRrvz" width="690" height="115" srcset="https://discuss.pytorch.org/uploads/default/optimized/3X/e/a/eacecf8c2383cd50fea8eb6b4904580b1c95e799_2_690x115.jpeg, https://discuss.pytorch.org/uploads/default/optimized/3X/e/a/eacecf8c2383cd50fea8eb6b4904580b1c95e799_2_1035x172.jpeg 1.5x, https://discuss.pytorch.org/uploads/default/original/3X/e/a/eacecf8c2383cd50fea8eb6b4904580b1c95e799.jpeg 2x" data-dominant-color="E2E5E4"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">Capture</span><span class="informations">1061×177 18.5 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div></p>
<pre><code class="lang-auto">
class Net(nn.Module):
    def __init__(self):
        super(Net,self).__init__()
        self.cnn1 = nn.Conv2d(in_channels=1, out_channels=8, kernel_size=3,stride=1, padding=1)
        self.batchnorm1 = nn.BatchNorm2d(8)        
        self.relu = nn.ReLU()                
        self.maxpool1 = nn.MaxPool2d(kernel_size=2)   
        self.cnn2 = nn.Conv2d(in_channels=8,out_channels=10, kernel_size=5, stride=1, padding=1)
        self.batchnorm2 = nn.BatchNorm2d(10)
        self.relu = nn.ReLU() 
        self.maxpool2 = nn.MaxPool2d(kernel_size=2)  
        self.cnn3 = nn.Conv2d(in_channels=18, out_channels=32, kernel_size=5, stride=1, padding=1)
        self.batchnorm3 = nn.BatchNorm2d(32)
        self.relu = nn.ReLU() 
        self.fc1 = nn.Linear(in_features=32, out_features=20)  
        self.fc2 = nn.Linear(in_features=20, out_features=10)
        self.fc3 = nn.Linear(in_features=10, out_features=2)   
   
    def forward(self,x):
        out = self.cnn1(x)
        out = self.batchnorm1(out)
        out = self.relu(out)
        out = self.maxpool1(out)
        print(out.size())
        out1 = self.cnn2(out)
        out1 = self.batchnorm2(out1)
        out1 = self.relu(out1)
        out1= self.maxpool2(out1)
        print(out1.size())
        out2 = torch.cat((out,out1), dim=2)
        out = self.cnn3(out2)
        out = self.batchnorm3(out)
        out = self.relu(out)
        out = out.view(out.size(0),-1)  
        out = self.fc1(out)
        out = self.relu(out)
        out = self.fc2(out)
        out = self.relu(out)
        out = self.fc3(out)
        out = self.relu(out)
        return out

</code></pre>
<p>this problem is displayed</p>
<pre><code class="lang-auto">RuntimeError: Calculated padded input size per channel: (4 x 4). Kernel size: (5 x 5). Kernel size can't be greater than actual input size
</code></pre>

randinoo: <p>HELP ME PLEASE <img src="https://discuss.pytorch.org/images/emoji/apple/pensive.png?v=9" title=":pensive:" class="emoji" alt=":pensive:"></p>

InnovArul: <p>Can you mention your input shape too?<br>
Itseems, the feature maps become smaller than kernel size at some convolution.</p>

randinoo: <p>I solved my problem thanks <img src="https://discuss.pytorch.org/images/emoji/apple/slightly_smiling_face.png?v=9" title=":slightly_smiling_face:" class="emoji" alt=":slightly_smiling_face:"></p>

randinoo: <p>how to display the final image when i do the test and train?</p>

InnovArul: <p>I am not sure what you mean by “final” image.<br>
Either way, you can search about it to display the image in python:</p>
<aside class="onebox stackexchange">
  <header class="source">
      <a href="https://stackoverflow.com/questions/35286540/display-an-image-with-python" target="_blank" rel="noopener">stackoverflow.com</a>
  </header>
  <article class="onebox-body">
      <a href="https://stackoverflow.com/users/5256563/firetiti" target="_blank" rel="noopener">
    <img alt="FiReTiTi" src="https://i.stack.imgur.com/eWfIu.gif?s=128&amp;g=1" class="thumbnail onebox-avatar" width="128" height="128">
  </a>
<h4>
  <a href="https://stackoverflow.com/questions/35286540/display-an-image-with-python" target="_blank" rel="noopener">Display an image with Python</a>
</h4>

<div class="tags">
  <strong>python, matplotlib, ipython</strong>
</div>

<div class="date">
  asked by
  
  <a href="https://stackoverflow.com/users/5256563/firetiti" target="_blank" rel="noopener">
    FiReTiTi
  </a>
  on <a href="https://stackoverflow.com/questions/35286540/display-an-image-with-python" target="_blank" rel="noopener">07:50AM - 09 Feb 16 UTC</a>
</div>

  </article>
  <div class="onebox-metadata">
    
    
  </div>
  <div style="clear: both"></div>
</aside>