ylecun/mnist
Viewer β’ Updated β’ 70k β’ 75.9k β’ 303
This model is a Convolutional Neural Network (CNN) trained on the MNIST dataset for handwritten digit classification. It serves as the baseline model for a larger scientific ablation study.
This model was compared against:
You can download the weights from this repository (mnist_baseline_cnn.pth) and load them in your PyTorch project.
import torch
import torch.nn as nn
# Define the architecture (same as training)
class BaselineCNN(nn.Module):
def __init__(self):
super(BaselineCNN, self).__init__()
self.conv1 = nn.Conv2d(1, 32, kernel_size=3, padding=1)
self.bn1 = nn.BatchNorm2d(32)
self.relu1 = nn.ReLU()
self.pool1 = nn.MaxPool2d(kernel_size=2, stride=2)
self.conv2 = nn.Conv2d(32, 64, kernel_size=3, padding=1)
self.bn2 = nn.BatchNorm2d(64)
self.relu2 = nn.ReLU()
self.pool2 = nn.MaxPool2d(kernel_size=2, stride=2)
self.flatten = nn.Flatten()
self.fc1 = nn.Linear(64 * 7 * 7, 128)
self.dropout = nn.Dropout(0.5)
self.fc2 = nn.Linear(128, 10)
def forward(self, x):
x = self.pool1(self.relu1(self.bn1(self.conv1(x))))
x = self.pool2(self.relu2(self.bn2(self.conv2(x))))
x = self.flatten(x)
x = self.dropout(self.fc1(x))
x = self.fc2(x)
return x
model = BaselineCNN()
# Load weights from Hugging Face Hub (after downloading the .pth file)
# model.load_state_dict(torch.load('mnist_baseline_cnn.pth'))
Citation
If you use this model, please cite the GitHub repository:
Ablation Study of CNN Architectures on MNIST