-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodels.py
75 lines (40 loc) · 1.58 KB
/
models.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.nn.init as I
class Net(nn.Module):
def __init__(self):
super(Net, self).__init__()
self.conv1 = nn.Conv2d(1, 32, 5)
#self.pool1 = nn.MaxPool2d(2, 2)
#self.bn1 = nn.BatchNorm2d(32)
self.conv2 = nn.Conv2d(32, 48, 5, stride = 2)
self.pool2 = nn.MaxPool2d(2, 2)
#self.bn2 = nn.BatchNorm2d(64)
self.conv3 = nn.Conv2d(48, 64, 5, stride = 2)
self.pool3 = nn.MaxPool2d(2, 2)
self.bn3 = nn.BatchNorm2d(64)
'''
self.conv4 = nn.Conv2d(64, 80, 3)
self.pool4 = nn.MaxPool2d(2, 2)
self.bn4 = nn.BatchNorm2d(80)
self.conv5 = nn.Conv2d(256, 512, 3)
self.pool5 = nn.MaxPool2d(2, 2)
self.bn5 = nn.BatchNorm2d(512)
'''
self.linear1 = nn.Linear(64 * 12 * 12 , 512)
self.linear2 = nn.Linear(512, 256)
#self.linear3 = nn.Linear(512 , 512)
#self.linear3 = nn.Linear(512 , 512)
self.linear4 = nn.Linear(256 , 136)
def forward(self, x):
x = F.relu(self.conv1(x))
x = self.pool2(F.relu(self.conv2(x)))
x = self.bn3(self.pool3(F.relu(self.conv3(x))))
x = x.view(x.size(0) , -1)
x = F.relu(self.linear1(x))
x = F.relu(self.linear2(x))
x = self.linear4(x)
return x
#self.conv1 = nn.Conv2d(3, 32, 5)
#print(self.conv1)