| 479 | # |
| 480 | |
| 481 | class Net(nn.Module): |
| 482 | def __init__(self): |
| 483 | super(Net, self).__init__() |
| 484 | self.conv1 = nn.Conv2d(3, 6, 5) |
| 485 | self.pool = nn.MaxPool2d(2, 2) |
| 486 | self.conv2 = nn.Conv2d(6, 16, 5) |
| 487 | self.fc1 = nn.Linear(16 * 5 * 5, 120) |
| 488 | self.fc2 = nn.Linear(120, 84) |
| 489 | self.fc3 = nn.Linear(84, 10) |
| 490 | |
| 491 | def forward(self, x): |
| 492 | x = self.pool(F.relu(self.conv1(x))) |
| 493 | x = self.pool(F.relu(self.conv2(x))) |
| 494 | x = x.view(-1, 16 * 5 * 5) |
| 495 | x = F.relu(self.fc1(x)) |
| 496 | x = F.relu(self.fc2(x)) |
| 497 | x = self.fc3(x) |
| 498 | return x |
| 499 | |
| 500 | |
| 501 | net = Net() |