tuple is not a Module subclass

Kwame_Ampofo: <p>class Neural(nn.Module):<br>
def <strong>init</strong>(self):</p>
<pre><code>    super(Neural, self).__init__()
    
    self.ConvNet = nn.Sequential((nn.Conv2d(in_channels=1,
                                            out_channels=5,
                                            kernel_size=3,
                                            stride=1,
                                            padding=1), 
                                  nn.ReLU(inplace=True),
                                  nn.Conv2d(in_channels=5,
                                            out_channels=10,
                                            kernel_size=3,
                                            stride=1,
                                            padding=1), 
                                  nn.MaxPool2d(2, 2),
                                  nn.ReLU(inplace=True),
                                  
                                  ))
</code></pre>
<ul>
<li>List item</li>
</ul>
<h1>
<a name="declare-all-the-layers-for-classification" class="anchor" href="#declare-all-the-layers-for-classification"></a>Declare all the layers for classification</h1>
<pre><code>    self.classifier = nn.Sequential(
        nn.Linear(14 * 14 * 10, 128),
        nn.ReLU(inplace=True),
        nn.Linear(128, 128),
        nn.ReLU(inplace=True),
        nn.Linear(128, 10))
    
def forward(self, x):
  
    # Apply the feature extractor in the input
    x = self.ConvNet(x)
    
    # Squeeze the three spatial dimensions in one
    x = x.view(-1, 14* 14* 10)
    
    # Classify the images
    x = self.classifier(x)
    return x
</code></pre>
<p>criterion = nn.CrossEntropyLoss()<br>
model= Neural()<br>
optimizer = optim.SGD(model.parameters(), lr=0.03, momentum=0.1)</p>
<p>TypeError                                 Traceback (most recent call last)<br>
 in <br>
1 criterion = nn.CrossEntropyLoss()<br>
----&gt; 2 model= Neural()<br>
3 optimizer = optim.SGD(model.parameters(), lr=0.03, momentum=0.1)</p>
<p> in <strong>init</strong>(self)<br>
4         super(Neural, self).<strong>init</strong>()<br>
5<br>
----&gt; 6         self.ConvNet = nn.Sequential((nn.Conv2d(in_channels=1,<br>
7                                                 out_channels=5,<br>
8                                                 kernel_size=3,</p>
<p>~\Anaconda3\envs\pytorch\lib\site-packages\torch\nn\modules\container.py in <strong>init</strong>(self, *args)<br>
67         else:<br>
68             for idx, module in enumerate(args):<br>
—&gt; 69                 self.add_module(str(idx), module)<br>
70<br>
71     def _get_item_by_idx(self, iterator, idx) → T:</p>
<p>~\Anaconda3\envs\pytorch\lib\site-packages\torch\nn\modules\module.py in add_module(self, name, module)<br>
370         “”"<br>
371         if not isinstance(module, Module) and module is not None:<br>
 → 372             raise TypeError("{} is not a Module subclass".format(<br>
373                 torch.typename(module)))<br>
374         elif not isinstance(name, torch._six.string_classes):</p>
<p>TypeError: tuple is not a Module subclass</p>

crcrpar: <p>Hi,</p>
<aside class="quote no-group" data-username="Kwame_Ampofo" data-post="1" data-topic="118385">
<div class="title">
<div class="quote-controls"></div>
<img loading="lazy" alt="" width="24" height="24" src="https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/kwame_ampofo/48/30204_2.png" class="avatar"> Kwame_Ampofo:</div>
<blockquote>
<pre><code class="lang-auto">self.ConvNet = nn.Sequential((nn.Conv2d(in_channels=1,
                                            out_channels=5,
                                            kernel_size=3,
                                            stride=1,
                                            padding=1), 
                                  nn.ReLU(inplace=True),
                                  nn.Conv2d(in_channels=5,
                                            out_channels=10,
                                            kernel_size=3,
                                            stride=1,
                                            padding=1), 
                                  nn.MaxPool2d(2, 2),
                                  nn.ReLU(inplace=True),
                                  
                                  ))
</code></pre>
</blockquote>
</aside>
<p>I think removing one pair of parentheses as follows is enough to fix.</p>
<pre data-code-wrap="python"><code class="lang-python">nn.Sequential(nn.Conv2d(in_channels=1,
                                            out_channels=5,
                                            kernel_size=3,
                                            stride=1,
                                            padding=1), 
                                  nn.ReLU(inplace=True),
                                  nn.Conv2d(in_channels=5,
                                            out_channels=10,
                                            kernel_size=3,
                                            stride=1,
                                            padding=1), 
                                  nn.MaxPool2d(2, 2),
                                  nn.ReLU(inplace=True),
                                  
                                  )
</code></pre>