-
Notifications
You must be signed in to change notification settings - Fork 0
/
Othello_CNN.py
77 lines (62 loc) · 2.08 KB
/
Othello_CNN.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
import torch
from torch.nn import Linear, ReLU, CrossEntropyLoss, Sequential, Conv2d, MaxPool2d, MaxUnpool2d, Module, Softmax, BatchNorm2d, Dropout
class OthelloCNN(Module):
def __init__(self):
super(OthelloCNN, self).__init__()
self.conv1 = Sequential(
Conv2d(3, 64, kernel_size=3, padding=1, stride=1),
BatchNorm2d(64),
ReLU() )
self.conv2 = Sequential(
Conv2d(64, 64, kernel_size=3, padding=1, stride=1),
BatchNorm2d(64),
ReLU())
self.conv3 = Sequential(
Conv2d(64, 128, kernel_size=3, padding=1, stride=1),
BatchNorm2d(128),
ReLU())
self.conv4 = Sequential(
Conv2d(128, 128, kernel_size=3, padding=1, stride=1),
BatchNorm2d(128),
ReLU())
self.conv5 = Sequential(
Conv2d(128, 256, kernel_size=3, padding=1, stride=1),
BatchNorm2d(256),
ReLU())
self.conv6 = Sequential(
Conv2d(256, 256, kernel_size=3, padding=1, stride=1),
BatchNorm2d(256),
ReLU())
self.conv7 = Sequential(
Conv2d(256, 256, kernel_size=3, padding=1, stride=1),
BatchNorm2d(256),
ReLU())
self.conv8 = Sequential(
Conv2d(256, 256, kernel_size=3, padding=1, stride=1),
BatchNorm2d(256),
ReLU())
self.fc1 = Linear( 256 * 8 * 8, 128 )
self.fc2 = Linear( 128, 60 )
def forward(self, x):
x = self.conv1(x)
# print(x.size())
x = self.conv2(x)
# print(x.size())
x = self.conv3(x)
# print(x.size())
x = self.conv4(x)
# print(x.size())
x = self.conv5(x)
# print(x.size())
x = self.conv6(x)
# print(x.size())
x = self.conv7(x)
# print(x.size())
x = self.conv8(x)
# print(x.size())
x = x.view(x.size(0), -1)
x = self.fc1(x)
# print(x.size())
x = self.fc2(x)
# print(x.size())
return x