-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodel.py
111 lines (103 loc) · 3.07 KB
/
model.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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# import torch
# import torch.nn as nn
# import torch.nn.functional as f
#
#
# # class VGG16Net(nn.Module):
# # def __init__(self, num_classes):
# # super(VGG16Net, self).__init__()
# # self.conv1 = nn.Conv2d(3, 64, 3)
# # self.conv2 = nn.Conv2d(64, 64, 3)
# # self.pool = nn.MaxPool2d(2, 2)
# # self.conv3 = nn.Conv2d(64, 128, 3)
# # self.conv4 = nn.Conv2d(128, 128, 3)
# # self.conv5 = nn.Conv2d(128, 256, 3)
# # self.conv6 = nn.Conv2d(256, 256, 3)
# # self.conv7 = nn.Conv2d(256, 256, 3)
# # self.conv8 = nn.Conv2d(256, 256, 3)
# # self.conv9 = nn.Conv2d(256, 512, 3)
# # self.conv10 = nn.Conv2d(512, 512, 3)
# # self.conv11 = self.conv10
# # self.conv12 = self.conv10
# # self.conv13 = self.conv10
# # self.fc1 = nn.Linear(512 * 7 * 7, 4096)
# # self.fc1 = nn.Linear(4096, 4096)
# # self.fc2 = nn.Linear(4096, num_classes)
# # self.drop = nn.Dropout(p=0.5)
# #
# # def forward(self, x):
# # x = self.conv1(x)
# # x = f.relu(x)
# # x = self.conv2(x)
# # x = f.relu(x)
# # x = self.pool(x)
# #
# # x = self.conv3(x)
# # x = f.relu(x)
# # x = self.conv4(x)
# # x = f.relu(x)
# # x = self.pool(x)
# #
# # x = self.conv5(x)
# # x = f.relu(x)
# # x = self.conv6(x)
# # x = f.relu(x)
# # x = self.conv7(x)
# # x = f.relu(x)
# # x = self.pool(x)
# #
# # x = self.conv8(x)
# # x = f.relu(x)
# # x = self.conv9(x)
# # x = f.relu(x)
# # x = self.conv10(x)
# # x = f.relu(x)
# # x = self.pool(x)
# #
# # x = self.conv11(x)
# # x = f.relu(x)
# # x = self.conv12(x)
# # x = f.relu(x)
# # x = self.conv13(x)
# # x = f.relu(x)
# # x = self.pool(x)
# #
# # x = x.view(-1, 512 * 7 * 7)
# # x = self.drop(x)
# # x = self.fc1(x)
# # x = f.relu(x)
# #
# # x = self.drop(x)
# # x = self.fc2(x)
# # x = f.relu(x)
# #
# # x = self.fc3(x)
# #
# # return x
import torch.nn as nn
import torch.nn.functional as func
class Net(nn.Module):
def __init__(self):
super(Net, self).__init__()
self.conv1 = nn.Conv2d(3, 6, 5)
self.pool = nn.MaxPool2d(2, 2)
self.conv2 = nn.Conv2d(6, 16, 5)
self.fc1 = nn.Linear(16 * 5 * 5, 120)
self.fc2 = nn.Linear(120, 80)
self.fc3 = nn.Linear(80, 10)
def forward(self, img):
output0 = self.conv1(img)
output1 = func.relu(output0)
output2 = self.pool(output1)
output3 = self.conv2(output2)
output4 = func.relu(output3)
output5 = self.pool(output4)
output6 = output5.view(-1, 16 * 5 * 5)
output = self.fc1(output6)
output = func.relu(output)
output = self.fc2(output)
output = func.relu(output)
output = self.fc3(output)
# output = nn.ReLU(output)
return output
net = Net()