-
Notifications
You must be signed in to change notification settings - Fork 13
/
net.py
90 lines (71 loc) · 2.36 KB
/
net.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
76
77
78
79
80
81
82
83
84
85
86
87
import torch.nn as nn
class SpatialNet(nn.Module):
def __init__(self):
super(SpatialNet, self).__init__()
self.features = nn.Sequential(
nn.Conv2d(3, 96, kernel_size=7, stride=2),
# nn.batchnorm2d(96),
nn.ReLU(),
nn.MaxPool2d(3, stride=2),
nn.LocalResponseNorm(2),
nn.Conv2d(96, 256, kernel_size=5, stride=2),
# nn.batchnorm2d(256),
nn.ReLU(),
nn.MaxPool2d(3, stride=2),
nn.LocalResponseNorm(2),
nn.Conv2d(256, 512, kernel_size=3),
nn.ReLU(),
nn.Conv2d(512, 512, kernel_size=3),
nn.ReLU(),
nn.Conv2d(512, 512, kernel_size=3),
# nn.batchnorm2d(512),
nn.ReLU(),
nn.MaxPool2d(3, stride=2),
)
self.classifier = nn.Sequential(
nn.Linear(2048, 4096),
nn.Dropout(),
nn.Linear(4096, 2048),
nn.Dropout(),
nn.Linear(2048, 5),
)
def forward(self, x):
x = self.features(x)
x = x.view(x.size(0), -1)
x = self.classifier(x)
return x
class TemporalNet(nn.Module):
def __init__(self):
super(TemporalNet, self).__init__()
self.features = nn.Sequential(
nn.Conv2d(3, 96, kernel_size=7, stride=2),
# nn.batchnorm2d(96),
nn.ReLU(),
nn.MaxPool2d(3, stride=2),
nn.LocalResponseNorm(2),
nn.Conv2d(96, 256, kernel_size=5, stride=2),
# nn.batchnorm2d(256),
nn.ReLU(),
nn.MaxPool2d(3, stride=2),
nn.LocalResponseNorm(2),
nn.Conv2d(256, 512, kernel_size=3),
nn.ReLU(),
nn.Conv2d(512, 512, kernel_size=3),
nn.ReLU(),
nn.Conv2d(512, 512, kernel_size=3),
# nn.batchnorm2d(512),
nn.ReLU(),
nn.MaxPool2d(3, stride=2),
)
self.classifier = nn.Sequential(
nn.Linear(2048, 4096),
nn.Dropout(),
nn.Linear(4096, 2048),
nn.Dropout(),
nn.Linear(2048, 5),
)
def forward(self, x):
x = self.features(x)
x = x.view(x.size(0), -1)
x = self.classifier(x)
return x