-
Notifications
You must be signed in to change notification settings - Fork 2
/
model.py
36 lines (31 loc) · 963 Bytes
/
model.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import torch.nn as nn
from torchsummary import summary
class A2NN(nn.Module):
def __init__(self, ):
super(A2NN, self).__init__()
self.main = nn.Sequential(
nn.Conv2d(3, 16, 3, 1, 1),
nn.BatchNorm2d(16),
nn.ReLU(inplace=True),
nn.Conv2d(16, 32, 3, 1, 1),
nn.MaxPool2d(2, 2),
nn.BatchNorm2d(32),
nn.ReLU(inplace=True),
nn.Conv2d(32, 32, 3, 1, 1),
nn.MaxPool2d(2, 2),
nn.BatchNorm2d(32),
nn.ReLU(inplace=True),
nn.Conv2d(32, 64, 3, 1, 1),
nn.MaxPool2d(2, 2),
nn.BatchNorm2d(64),
nn.ReLU(inplace=True),
)
self.linear = nn.Linear(4*4*64, 9)
def forward(self, inp):
x = self.main(inp)
x = x.view(x.shape[0], -1)
x = self.linear(x)
return x
if __name__ == "__main__":
nn = A2NN()
summary(nn, (3, 32, 32))