1class Net(nn.Module):
2 def __init__(self):
3 super(Net, self).__init__()
4 self.conv1 = nn.Conv2d(1, 10, kernel_size=5)
5 self.conv2 = nn.Conv2d(10, 20, kernel_size=5)
6 self.fc1 = nn.Linear(320, 50)
7 self.fc2 = nn.Linear(50, 10)
8
9 def forward(self, x):
10 x = F.relu(F.max_pool2d(self.conv1(x), 2))
11 x = F.relu(F.max_pool2d(F.dropout2d(self.conv2(x)), 2))
12 x = x.view(-1, 320)
13 x = F.relu(self.fc1(x))
14 x = F.dropout(x)
15 x = F.log_softmax(self.fc2(x))
16 return x
17