Upload model.py
Browse files
model.py
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import torch.nn as nn
|
2 |
+
import torch.nn.functional as F
|
3 |
+
import torch.optim as optim
|
4 |
+
|
5 |
+
class Net(nn.Module):
|
6 |
+
def __init__(self):
|
7 |
+
super(Net, self).__init__()
|
8 |
+
self.conv1 = nn.Conv2d(1, 10, kernel_size=5)
|
9 |
+
self.conv2 = nn.Conv2d(10, 20, kernel_size=5)
|
10 |
+
self.conv2_drop = nn.Dropout2d()
|
11 |
+
self.fc1 = nn.Linear(320, 50)
|
12 |
+
self.fc2 = nn.Linear(50, 10)
|
13 |
+
def forward(self, x):
|
14 |
+
x = F.relu(F.max_pool2d(self.conv1(x), 2))
|
15 |
+
x = F.relu(F.max_pool2d(self.conv2_drop(self.conv2(x)), 2))
|
16 |
+
x = x.view(-1, 320)
|
17 |
+
x = F.relu(self.fc1(x))
|
18 |
+
x = F.dropout(x, training=self.training)
|
19 |
+
x = self.fc2(x)
|
20 |
+
return F.log_softmax(x)
|