-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmodel.py
More file actions
57 lines (51 loc) · 1.51 KB
/
Copy pathmodel.py
File metadata and controls
57 lines (51 loc) · 1.51 KB
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
import torch
import torch.nn as nn
class CNNModel(nn.Module):
def __init__(self):
super(CNNModel,self).__init__()
self.conv1 = nn.Conv3d(3,8,3)
self.conv2 = nn.Conv3d(8,32,3)
self.conv3 = nn.Conv3d(32,32,3)
# self.conv4 = nn.Conv3d(64,128,3)
self.relu = nn.ReLU()
self.pool1 = nn.MaxPool3d(4)
# self.pool2 = nn.MaxPool3d(2)
# self.linear1 = nn.Linear(128*8,128)
self.linear2 = nn.Linear(32,10)
self.batchnorm = nn.BatchNorm3d(32)
self.dropout = nn.Dropout(0.5)
def forward(self,x):
x = self.conv1(x)
x = self.conv2(x)
x = self.pool1(x)
x = self.conv3(x)
# x = self.conv4(x)
# x = self.pool1(x)
x = self.batchnorm(x)
x = x.view(x.size()[0],-1)
# x = self.linear1(x)
# x = self.relu(x)
x = self.dropout(x)
x = self.linear2(x)
return x
class LinearModel(nn.Module):
def __init__(self):
super(LinearModel,self).__init__()
self.l1 = nn.Linear(4096,1024)
self.l2 = nn.Linear(1024,256)
self.l3 = nn.Linear(256,64)
self.l4 = nn.Linear(64,10)
self.elu = nn.ELU()
self.dropout = nn.Dropout(0.5)
def forward(self,x):
x = x.view(-1,4096)
x = self.l1(x)
x = self.elu(x)
x = self.dropout(x)
x = self.l2(x)
x = self.elu(x)
x = self.dropout(x)
x = self.l3(x)
x = self.elu(x)
x = self.l4(x)
return x