-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodels.py
51 lines (45 loc) · 1.52 KB
/
models.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
# -*- coding: utf-8 -*-
"""Models.ipynb
Automatically generated by Colaboratory.
Original file is located at
https://colab.research.google.com/drive/1E0U11I6Ncs8fm7oqmR7mKRgLKLQm2oXp
"""
import torch
from torch.autograd import Variable
import torch.nn as nn
import torch.nn.functional as F
# can use the below import should you choose to initialize the weights of your Net
import torch.nn.init as I
class Net(nn.Module):
def __init__(self):
super().__init__()
self.conv1=nn.Conv2d(1,32,5)
self.elu=nn.ELU()
self.pool1=nn.MaxPool2d(2,2)
self.conv2=nn.Conv2d(32,64,3)
self.conv3=nn.Conv2d(64,128,3)
self.conv4=nn.Conv2d(128,256,3)
self.conv5=nn.Conv2d(256,512,1)
self.drop1=nn.Dropout(p=0.1)
self.drop2=nn.Dropout(p=0.15)
self.drop3=nn.Dropout(p=0.25)
self.drop4=nn.Dropout(p=0.35)
self.drop5=nn.Dropout(p=0.4)
self.drop6=nn.Dropout(p=0.45)
self.drop7=nn.Dropout(p=0.5)
self.dense1=nn.Linear(512*6*6,2048)
self.dense2=nn.Linear(2096,1024)
self.dense3=nn.Linear(1024,512)
self.output=nn.Linear(512,136)
def forward(self,x):
x=self.drop1(self.pool1(F.elu(self.conv1(x))))
x=self.drop2(self.pool1(F.elu(self.conv2(x))))
x=self.drop3(self.pool1(F.elu(self.conv3(x))))
x=self.drop4(self.pool1(F.elu(self.conv4(x))))
x=self.drop5(self.pool1(F.elu(self.conv5(x))))
x=x.view(x.size(0),-1)
x=self.drop4(self.elu(self.dense1(x)))
x=self.drop6(self.elu(self.dense2(x)))
x=self.drop6(self.elu(self.dense3(x)))
x=self.output(x)
return x