-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathgrid_search.py
101 lines (85 loc) · 2.83 KB
/
grid_search.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
# -*- coding: utf-8 -*-
"""
Created on Mon Mar 25 20:28:36 2019
@author: chris
"""
import torch.nn as nn
import torch.nn.functional as F
class ResNet4(nn.Module):
def __init__(self,dropout):
super(ResNet4, self).__init__()
self.name = "ResNet"
self.fc1 = nn.Linear( 86528,300)
self.fc2 = nn.Linear( 300,100)
self.fc3 = nn.Linear( 100,32)
self.fc4 = nn.Linear(32, 2)
self.dropout1 = nn.Dropout(dropout)
self.dropout2 = nn.Dropout(dropout)
self.dropout3 = nn.Dropout(dropout)
def forward(self, x):
#print(x.size())
#x = x.view(-1, 86528)
#print(x.size())
x = F.relu(self.dropout1(self.fc1(x)))
#print(x.size())
x = F.relu(self.dropout2(self.fc2(x)))
x = F.relu(self.dropout3(self.fc3(x)))
x = self.fc4(x)
#x = x.squeeze(1)
#print(x.size(),"\n\n\n")
return x
class ResNet5(nn.Module):
def __init__(self,dropout):
super(ResNet5, self).__init__()
self.name = "ResNet"
self.fc1 = nn.Linear(86528,400)
self.fc2 = nn.Linear(400,200)
self.fc3 = nn.Linear(200,90)
self.fc4 = nn.Linear(90, 32)
self.fc5 = nn.Linear(32, 2)
self.dropout1 = nn.Dropout(dropout)
self.dropout2 = nn.Dropout(dropout)
self.dropout3 = nn.Dropout(dropout)
self.dropout4 = nn.Dropout(dropout)
def forward(self, x):
#print(x.size())
#x = x.view(-1, 86528)
#print(x.size())
x = F.relu(self.dropout1(self.fc1(x)))
#print(x.size())
x = F.relu(self.dropout2(self.fc2(x)))
x = F.relu(self.dropout3(self.fc3(x)))
x = F.relu(self.dropout4(self.fc4(x)))
x = self.fc5(x)
#x = x.squeeze(1)
#print(x.size(),"\n\n\n")
return x
class ResNet6(nn.Module):
def __init__(self,dropout):
super(ResNet6, self).__init__()
self.name = "ResNet"
self.fc1 = nn.Linear(86528,500)
self.fc2 = nn.Linear(500,200)
self.fc3 = nn.Linear(200,120)
self.fc4 = nn.Linear(120, 90)
self.fc5 = nn.Linear(90, 32)
self.fc6 = nn.Linear(32, 2)
self.dropout1 = nn.Dropout(dropout)
self.dropout2 = nn.Dropout(dropout)
self.dropout3 = nn.Dropout(dropout)
self.dropout4 = nn.Dropout(dropout)
self.dropout5 = nn.Dropout(dropout)
def forward(self, x):
#print(x.size())
#x = x.view(-1, 86528)
#print(x.size())
x = F.relu(self.dropout1(self.fc1(x)))
#print(x.size())
x = F.relu(self.dropout2(self.fc2(x)))
x = F.relu(self.dropout3(self.fc3(x)))
x = F.relu(self.dropout4(self.fc4(x)))
x = F.relu(self.dropout5(self.fc5(x)))
x = self.fc6(x)
#x = x.squeeze(1)
#print(x.size(),"\n\n\n")
return x