-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcls_TIS_model_sequential.py
47 lines (39 loc) · 1.6 KB
/
cls_TIS_model_sequential.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
import torch.nn as nn
import torch
class Net(nn.Module):
def __init__(self):
super(Net, self).__init__()
# Based on TISRover Experiment 1
# 1 input image channel, 70 output channels
self.features = nn.Sequential(nn.Conv2d(1, 70, (7, 4)),
nn.ReLU(),
nn.MaxPool2d((3, 1)),
nn.Dropout2d(p=0.2),
nn.Conv2d(70, 100, (3, 1)),
nn.ReLU(),
nn.MaxPool2d((3, 1)),
nn.Dropout2d(p=0.2),
nn.Conv2d(100, 150, (3, 1)),
nn.ReLU(),
nn.MaxPool2d((3, 1)),
nn.Dropout2d(p=0.2))
self.classifier = nn.Sequential(nn.Linear(900, 512),
nn.Dropout2d(p=0.2),
nn.ReLU(),
nn.Linear(512, 2))
self.flatten = nn.Flatten()
def forward(self, x):
x = self.features(x)
x = self.flatten(x)
x = self.classifier(x)
return x
if __name__ == '__main__':
model = Net()
x = torch.randn((1, 1, 203, 4))
out = model(x)
#print(out.shape)
#print(out)
#params = list(model.parameters())
#print(len(params))
#print(params[7].size()) # conv1's .weight
#print(model.size())