k23064919 commited on
Commit
8e500b2
·
1 Parent(s): bf11e09

add first CNN, gitignore and requirements.txt

Browse files
Files changed (2) hide show
  1. .gitignore +0 -0
  2. modelOne.py +31 -0
.gitignore ADDED
File without changes
modelOne.py ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import torch
2
+ import torch.nn as nn
3
+ import torch.nn.functional as F
4
+
5
+ class modelOne(nn.Module) :
6
+ def __init__(self, noOfClasses=39):
7
+ super(modelOne, self).__init__()
8
+
9
+ self.conv1 = nn.Conv2d(3, 6, 5)
10
+ self.batchNorm1 = nn.BatchNorm2d(6)
11
+ self.pool = nn.MaxPool2d(2, 2)
12
+
13
+ self.conv2 = nn.Conv2d(6, 16, 5, padding=2)
14
+ self.batchNorm2 = nn.BatchNorm2d(16)
15
+
16
+ self.fc1 = nn.Linear(16*64*64, 512)
17
+ self.dropout = nn.Dropout(0.5)
18
+
19
+ self.fc2 = nn.Linear(512, 84)
20
+ self.fc3 = nn.Linear(84, noOfClasses)
21
+
22
+ def forward(self, x) :
23
+ x = self.pool(F.relu(self.batchNorm1(self.conv1(x))))
24
+ x = self.pool(F.relu(self.batchNorm2(self.conv2(x))))
25
+ x = torch.flatten(x, 1)
26
+ x = self.dropout(x)
27
+ x = F.relu(self.fc1(x))
28
+ x = F.relu(self.fc2(x))
29
+ x = self.fc3(x)
30
+
31
+ return x