-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patharchitecture.py
71 lines (41 loc) · 1.42 KB
/
architecture.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
import torch
import torch.nn as nn
import torch.nn.functional as F
class architectureMNIST(nn.Module):
def __init__(self,dropout_layer):
super(architectureMNIST, self).__init__()
self.conv1 = nn.Conv2d(1,32,3)
self.maxpool1 = nn.MaxPool2d(2)
self.conv2 = nn.Conv2d(32,10,3)
self.flat = nn.Flatten()
self.batchnorm = nn.BatchNorm1d(1210)
self.dropout = dropout_layer
self.classification = nn.Linear(1210,10)
def forward(self, x):
x = F.relu(self.conv1(x))
x = self.maxpool1(x)
x = F.relu(self.conv2(x))
x = self.flat(x)
x = self.batchnorm(x)
x = self.dropout(x)
x = self.classification(x)
return x
class architectureCIFAR10(nn.Module):
def __init__(self,dropout_layer):
super(architectureCIFAR10, self).__init__()
self.conv1 = nn.Conv2d(3,32,3)
self.maxpool1 = nn.MaxPool2d(2)
self.conv2 = nn.Conv2d(32,10,3)
self.flat = nn.Flatten()
self.batchnorm = nn.BatchNorm1d(1690)
self.dropout = dropout_layer
self.classification = nn.Linear(1690,10)
def forward(self, x):
x = F.relu(self.conv1(x))
x = self.maxpool1(x)
x = F.relu(self.conv2(x))
x = self.flat(x)
x = self.batchnorm(x)
x = self.dropout(x)
x = self.classification(x)
return x