Udayan012 commited on
Commit
5853966
·
verified ·
1 Parent(s): f4a8e13

Upload model.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. model.py +18 -0
model.py ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import torch.nn as nn
2
+
3
+ class CustomCNN(nn.Module):
4
+ def __init__(self):
5
+ super(CustomCNN, self).__init__()
6
+ self.conv1 = nn.Conv2d(3, 16, 3, padding=1)
7
+ self.pool = nn.MaxPool2d(2, 2)
8
+ self.conv2 = nn.Conv2d(16, 32, 3, padding=1)
9
+ self.fc1 = nn.Linear(32 * 8 * 8, 128)
10
+ self.fc2 = nn.Linear(128, 10)
11
+
12
+ def forward(self, x):
13
+ x = self.pool(nn.functional.relu(self.conv1(x)))
14
+ x = self.pool(nn.functional.relu(self.conv2(x)))
15
+ x = x.view(-1, 32 * 8 * 8)
16
+ x = nn.functional.relu(self.fc1(x))
17
+ x = self.fc2(x)
18
+ return x