| 698 | # ``reshape``) |
| 699 | |
| 700 | class Mnist_CNN(nn.Module): |
| 701 | def __init__(self): |
| 702 | super().__init__() |
| 703 | self.conv1 = nn.Conv2d(1, 16, kernel_size=3, stride=2, padding=1) |
| 704 | self.conv2 = nn.Conv2d(16, 16, kernel_size=3, stride=2, padding=1) |
| 705 | self.conv3 = nn.Conv2d(16, 10, kernel_size=3, stride=2, padding=1) |
| 706 | |
| 707 | def forward(self, xb): |
| 708 | xb = xb.view(-1, 1, 28, 28) |
| 709 | xb = F.relu(self.conv1(xb)) |
| 710 | xb = F.relu(self.conv2(xb)) |
| 711 | xb = F.relu(self.conv3(xb)) |
| 712 | xb = F.avg_pool2d(xb, 4) |
| 713 | return xb.view(-1, xb.size(1)) |
| 714 | |
| 715 | lr = 0.1 |
| 716 | |