Spaces:
Runtime error
Runtime error
Download model.py from Jugal-sheth/MNIST-classifier: direct link, hf CLI and curl.
- Browser
- Download file 782 Bytes
-
https://huggingface.co/spaces/Jugal-sheth/MNIST-classifier/resolve/main/model.py
- Command line
-
hf download hf://spaces/Jugal-sheth/MNIST-classifier/model.py
-
curl -L -o model.py https://huggingface.co/spaces/Jugal-sheth/MNIST-classifier/resolve/main/model.py
782 Bytes
| # model.py | |
| import torch.nn as nn | |
| # neural network architecture | |
| class Net(nn.Module): | |
| def __init__(self): | |
| super(Net, self).__init__() | |
| self.conv1 = nn.Conv2d(1, 10, kernel_size=5) | |
| self.conv2 = nn.Conv2d(10, 20, kernel_size=5) | |
| self.dropout = nn.Dropout2d() | |
| self.fc1 = nn.Linear(320, 50) | |
| self.fc2 = nn.Linear(50, 10) | |
| def forward(self, x): | |
| x = nn.functional.relu(nn.functional.max_pool2d(self.conv1(x), 2)) | |
| x = nn.functional.relu(nn.functional.max_pool2d(self.dropout(self.conv2(x)), 2)) | |
| x = x.view(-1, 320) | |
| x = nn.functional.relu(self.fc1(x)) | |
| x = nn.functional.dropout(x, training=self.training) | |
| x = self.fc2(x) | |
| return nn.functional.log_softmax(x, dim=1) | |
| model = Net() | |