Hi, does anyone know the difference between these two definitions? Because when I tried to train the network, they had very different performances.
class Net(nn.Module):
def __init__(self):
super(Net, self).__init__()
self.conv1 = nn.Conv2d(3, 16, 5, padding=2)
self.pool = nn.MaxPool2d(2, 2)
self.dropout = nn.Dropout2d(p=0.5)
self.conv2 = nn.Conv2d(16, 16, 5, padding=2)
self.conv3 = nn.Conv2d(16, 400, 11, padding=5)
self.conv4 = nn.Conv2d(400, 200, 1)
self.conv5 = nn.Conv2d(200, 1, 1)
def forward(self, x):
x = self.dropout(self.pool(F.relu(self.conv1(x))))
x = self.dropout(self.pool(F.relu(self.conv2(x))))
x = self.conv3(x)
x = self.conv4(x)
x = F.relu(self.conv5(x))
return x
and
class Net(nn.Module):
def __init__(self):
super(Net, self).__init__()
self.single5 = nn.Sequential(
nn.Conv2d(3, 16, 5, padding=2),
nn.ReLU(),
nn.MaxPool2d(2, 2),
nn.Dropout2d(p=0.5),
nn.Conv2d(16, 16, 5, padding=2),
nn.ReLU(),
nn.MaxPool2d(2, 2),
nn.Dropout2d(p=0.5),
nn.Conv2d(16, 400, 11, padding=5),
nn.Conv2d(400, 200, 1)
)
self.conv = nn.Conv2d(200, 1, 1)
def forward(self, x):
x = self.single5(x)
x = F.relu(self.conv(x))
return x