Difference between two model?

Md_Shahriar: <p>I have two models. Is there any difference between two models?</p>
<p><strong>First one ------</strong></p>
<pre><code>model = nn.Sequential(
nn.Conv2d(3, 16, 3, padding=1),
nn.ReLU(),
nn.MaxPool2d(2, 2),

nn.Conv2d(16, 32, 3, padding=1),
nn.ReLU(),
nn.MaxPool2d(2, 2),

nn.Conv2d(32, 64, 3, padding=1),
nn.ReLU(),
nn.MaxPool2d(2, 2),

nn.Flatten(1, -1),
    
nn.Dropout(0.25),
nn.Linear(4*4*64, 500),
nn.ReLU(),

nn.Dropout(0.25),
nn.Linear(500, 10))
</code></pre>
<p><strong>Second one ----</strong></p>
<pre><code>class Net(nn.Module):
    def __init__(self):
        super().__init__()
        
        self.conv1 = nn.Conv2d(3, 16, 3, padding=1)
        
        self.conv2 = nn.Conv2d(16, 32, 3, padding=1)
       
        self.conv3 = nn.Conv2d(32, 64, 3, padding=1)
        
        self.pool = nn.MaxPool2d(2, 2)
       
        self.fc1 = nn.Linear(64 * 4 * 4, 500)
        
        self.fc2 = nn.Linear(500, 10)
        
        self.dropout = nn.Dropout(0.25)

    def forward(self, x):
        
        x = self.pool(F.relu(self.conv1(x)))
        x = self.pool(F.relu(self.conv2(x)))
        x = self.pool(F.relu(self.conv3(x)))
        
        x = x.view(-1, 64 * 4 * 4)
        
        x = self.dropout(x)
        
        x = F.relu(self.fc1(x))
        
        x = self.dropout(x)
        
        x = self.fc2(x)
        return x
    
model = Net()
</code></pre>
<p>When i load the save model of Second one to the first one, it shows error.</p>

Sadegh_ab: <p>-------------------------------------- First Model Parameters----------------------------------------<br>
&lt;bound method Module.parameters of Sequential(<br>
(0): Conv2d(3, 16, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))<br>
(1): ReLU()<br>
(2): MaxPool2d(kernel_size=2, stride=2, padding=0, dilation=1, ceil_mode=False)<br>
(3): Conv2d(16, 32, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))<br>
(4): ReLU()<br>
(5): MaxPool2d(kernel_size=2, stride=2, padding=0, dilation=1, ceil_mode=False)<br>
(6): Conv2d(32, 64, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))<br>
(7): ReLU()<br>
(8): MaxPool2d(kernel_size=2, stride=2, padding=0, dilation=1, ceil_mode=False)<br>
(9): Flatten(start_dim=1, end_dim=-1)<br>
(10): Dropout(p=0.25, inplace=False)<br>
(11): Linear(in_features=1024, out_features=500, bias=True)<br>
(12): ReLU()<br>
(13): Dropout(p=0.25, inplace=False)<br>
(14): Linear(in_features=500, out_features=10, bias=True)<br>
)&gt;<br>
-------------------------------------- Second Model Parameters ----------------------------------------<br>
&lt;bound method Module.parameters of Net(<br>
(conv1): Conv2d(3, 16, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))<br>
(conv2): Conv2d(16, 32, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))<br>
(conv3): Conv2d(32, 64, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))<br>
(pool): MaxPool2d(kernel_size=2, stride=2, padding=0, dilation=1, ceil_mode=False)<br>
(fc1): Linear(in_features=1024, out_features=500, bias=True)<br>
(fc2): Linear(in_features=500, out_features=10, bias=True)<br>
(dropout): Dropout(p=0.25, inplace=False)<br>
)&gt;<br>
As you see, these two model parameters are not the same</p>