-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_net.py
60 lines (51 loc) · 1.57 KB
/
test_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
import torch
import torch.nn as nn
from environment import ActionType
class TestNet(nn.Module):
def __init__(self):
super(TestNet, self).__init__()
self.conv = nn.Sequential(
nn.Conv2d(1, 16, kernel_size=2, stride=1),
nn.BatchNorm2d(16),
nn.ReLU(),
nn.Conv2d(16, 8, kernel_size=3, stride=1),
nn.BatchNorm2d(8),
# nn.Linear(64, 64),
# nn.ReLU(),
# nn.Linear(64, 64),
# nn.ReLU(),
# nn.Linear(64, len(ActionType)),
)
# nn.Conv2d(1, 8, kernel_size=3, stride=1, padding=2),
# nn.ReLU(),
# nn.Conv2d(8, 8, kernel_size=2, stride=1),
# nn.ReLU(),
# nn.Conv2d(8, 8, kernel_size=2, stride=1),
self.c1 = nn.Sequential(
nn.Conv2d(1, 8, kernel_size=3, stride=1, padding=2),
nn.ReLU(),
)
self.c2 = nn.Sequential(
nn.Conv2d(8, 8, kernel_size=2, stride=1),
nn.ReLU(),
)
self.c3 = nn.Sequential(
nn.Conv2d(8, 8, kernel_size=2, stride=1),
nn.ReLU(),
)
self.flatten = nn.Flatten()
self.lin = nn.Sequential(
nn.Flatten(),
nn.Linear(9, 64),
nn.ReLU(),
nn.Linear(64, 64),
nn.ReLU(),
nn.Linear(64, len(ActionType)),
)
def forward(self, x):
# result = self.conv(x)
y1 = self.c1(x)
y2 = self.c2(y1)
y3 = self.c3(y2)
y4 = self.flatten(y3)
return y3