| 120 | |
| 121 | |
| 122 | class Net(nn.Module): |
| 123 | def __init__(self): |
| 124 | super(Net, self).__init__() |
| 125 | self.conv1 = nn.Conv2d(3, 6, 5) |
| 126 | self.pool = nn.MaxPool2d(2, 2) |
| 127 | self.conv2 = nn.Conv2d(6, 16, 5) |
| 128 | self.fc1 = nn.Linear(16 * 5 * 5, 120) |
| 129 | self.fc2 = nn.Linear(120, 84) |
| 130 | self.fc3 = nn.Linear(84, 10) |
| 131 | |
| 132 | def forward(self, x): |
| 133 | x = self.pool(F.relu(self.conv1(x))) |
| 134 | x = self.pool(F.relu(self.conv2(x))) |
| 135 | x = x.view(-1, 16 * 5 * 5) |
| 136 | x = F.relu(self.fc1(x)) |
| 137 | x = F.relu(self.fc2(x)) |
| 138 | x = self.fc3(x) |
| 139 | return x |
| 140 | |
| 141 | |
| 142 | net = Net() |