Download model.py from Udayan012/tiny-cnn-classifier: direct link, hf CLI and curl.
- Browser
- Download file 624 Bytes
-
https://huggingface.co/Udayan012/tiny-cnn-classifier/resolve/main/model.py
- Command line
-
hf download hf://Udayan012/tiny-cnn-classifier/model.py
-
curl -L -o model.py https://huggingface.co/Udayan012/tiny-cnn-classifier/resolve/main/model.py
624 Bytes
| import torch.nn as nn | |
| class CustomCNN(nn.Module): | |
| def __init__(self): | |
| super(CustomCNN, self).__init__() | |
| self.conv1 = nn.Conv2d(3, 16, 3, padding=1) | |
| self.pool = nn.MaxPool2d(2, 2) | |
| self.conv2 = nn.Conv2d(16, 32, 3, padding=1) | |
| self.fc1 = nn.Linear(32 * 8 * 8, 128) | |
| self.fc2 = nn.Linear(128, 10) | |
| def forward(self, x): | |
| x = self.pool(nn.functional.relu(self.conv1(x))) | |
| x = self.pool(nn.functional.relu(self.conv2(x))) | |
| x = x.view(-1, 32 * 8 * 8) | |
| x = nn.functional.relu(self.fc1(x)) | |
| x = self.fc2(x) | |
| return x | |