Something Wrong in the latest pytorch!

username: QianMuluo
cooked: <p>I have used the pytorch for my own neural network, but the model don’t look like what I want it be. It’s architecture not like what I write in the forward() but just like the definition in the <strong>init</strong>. I don’t know what happens.<div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/0/b/0be63690f7922af888a13fc98ebabd754a1757b0.png" data-download-href="https://discuss.pytorch.org/uploads/default/0be63690f7922af888a13fc98ebabd754a1757b0" title="image"><img src="https://discuss.pytorch.org/uploads/default/original/3X/0/b/0be63690f7922af888a13fc98ebabd754a1757b0.png" alt="image" data-base62-sha1="1HgtRal3MgXos81gk6LRjznWeJi" width="540" height="500" data-dominant-color="F6F4F5"><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">image</span><span class="informations">929×859 42.3 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>

username: QianMuluo
cooked: <p><div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/3/b/3bcd8f6167bbf7f8f1f9f0fc8d4b921371b537fc.png" data-download-href="https://discuss.pytorch.org/uploads/default/3bcd8f6167bbf7f8f1f9f0fc8d4b921371b537fc" title="image"><img src="https://discuss.pytorch.org/uploads/default/original/3X/3/b/3bcd8f6167bbf7f8f1f9f0fc8d4b921371b537fc.png" alt="image" data-base62-sha1="8x2A27ttVhM9S97EiOg1o87pwOU" width="690" height="250" data-dominant-color="F5F4F4"><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">image</span><span class="informations">824×299 7.67 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><br>
This is what it look like and I want the ‘timeconv1’ before the dropout but now it after the fc</p>

username: beaupreda
cooked: <p>Hello,</p>
<p>When you print your model, the <code>nn.Module</code> function <code>__repr__</code> is called (<a href="https://github.com/pytorch/pytorch/blob/master/torch/nn/modules/module.py#L1116" rel="nofollow noopener">PyTorch repo</a>). The function basically goes through all the defined modules (done in your <code>__init__</code> function) to construct a string that you can <code>print</code>. That is the way that it is meant to work, so nothing is wrong with PyTorch and, as defined in your <code>forward</code> function, <code>timeconv1</code> is applied before <code>dropout</code> <img src="https://discuss.pytorch.org/images/emoji/apple/slight_smile.png?v=9" title=":slight_smile:" class="emoji" alt=":slight_smile:">.</p>

username: QianMuluo
cooked: <p>Thank you! and I also has some question else.<br>
I had say something wrong. When I use the nn.Sequential(*list(model.children())[:-2]) to get some layers and don’t use the last two layers, and it will flows what in the init instead of what I wrote in the forward function, and I don’t know why</p>

username: ptrblck
cooked: <p><code>model.children()</code> will return all layers sequentially based on their initialization in the <code>__init__</code>.<br>
Since you are wrapping it into an <code>nn.Sequential</code> container, this will be basically the order of execution.</p>
<p>As <a class="mention" href="/u/beaupreda">@beaupreda</a> said, printing the model will also give you the initialized layers, not the actual <code>forward</code> pass.<br>
This is not the case for <code>nn.Sequential</code> modules, as the order of passed modules is kept in the <code>forward</code> pass.</p>

username: QianMuluo
cooked: <p>Thank you so much. Now I will try some way else to make it look like what I want it should be.</p>