Upload model.py with huggingface_hub
Browse files
model.py
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import torch
|
2 |
+
import torch.nn as nn
|
3 |
+
|
4 |
+
class MNISTModel(nn.Module):
|
5 |
+
def __init__(self):
|
6 |
+
super(MNISTModel, self).__init__()
|
7 |
+
self.fc1 = nn.Linear(28 * 28, 128) # MNIST images are 28x28
|
8 |
+
self.fc2 = nn.Linear(128, 10)
|
9 |
+
self.dropout = nn.Dropout(0.5)
|
10 |
+
|
11 |
+
def forward(self, x):
|
12 |
+
x = x.view(-1, 28 * 28) # Flatten the input
|
13 |
+
x = torch.relu(self.fc1(x))
|
14 |
+
x = self.dropout(x)
|
15 |
+
x = self.fc2(x)
|
16 |
+
return x
|