SLIDE 38 (A variant of) AlexNet
class AlexNet(torch.nn.Module): def init (self): super(AlexNet, self). init () self.features = torch.nn.Sequential( torch.nn.Conv2d(3, 64, kernel size=3, stride=2, padding=1), torch.nn.ReLU(), torch.nn.MaxPool2d(kernel size=2), torch.nn.Conv2d(64, 192, kernel size=3, padding=1), torch.nn.ReLU(), torch.nn.MaxPool2d(kernel size=2), torch.nn.Conv2d(192, 384, kernel size=3, padding=1), torch.nn.ReLU(), torch.nn.Conv2d(384, 256, kernel size=3, padding=1), torch.nn.ReLU(), torch.nn.Conv2d(256, 256, kernel size=3, padding=1), torch.nn.ReLU(), torch.nn.MaxPool2d(kernel size=2), ) self.classifier = torch.nn.Sequential(
# torch.nn.Dropout(),
torch.nn.Linear(256 ∗ 2 ∗ 2, 4096), torch.nn.ReLU(),
# torch.nn.Dropout(),
torch.nn.Linear(4096, 4096), torch.nn.ReLU(), torch.nn.Linear(4096, 10), ) def forward(self, x): x = self.features(x) x = x.view(x.size(0), 256 ∗ 2 ∗ 2) x = self.classifier(x) return x 34 / 41