-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathmodel.py
More file actions
39 lines (28 loc) · 974 Bytes
/
model.py
File metadata and controls
39 lines (28 loc) · 974 Bytes
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
37
38
39
import torch
import torch.nn as nn
import torch.nn.functional as F
class Net(nn.Module):
def __init__(self):
super(Net, self).__init__()
self.conv1 = nn.Conv2d(1, 80, kernel_size = 5)
self.conv2 = nn.Conv2d(80, 80, kernel_size = 5)
self.pool1 = nn.MaxPool2d(kernel_size = 2, stride = 2, padding = 0)
self.pool2 = nn.MaxPool2d(kernel_size = 2, stride = 2, padding = 0)
self.batch_norm1 = nn.BatchNorm2d(80)
self.batch_norm2 = nn.BatchNorm2d(80)
self.fc1 = nn.Linear(1280, 250)
self.fc2 = nn.Linear(250, 25)
def forward(self, x):
x = self.conv1(x)
x = self.batch_norm1(x)
x = F.relu(x)
x = self.pool1(x)
x = self.conv2(x)
x = self.batch_norm2(x)
x = F.relu(x)
x = self.pool2(x)
x = x.view(x.size(0), -1)
x = F.relu(self.fc1(x))
x = self.fc2(x)
x = F.log_softmax(x, dim=1)
return x