ylecun/mnist
Viewer โข Updated โข 70k โข 99.2k โข 297
A small convolutional neural network that recognizes handwritten digits (0-9). Built as a beginner learning project.
2 x (Conv2d + ReLU + MaxPool) -> Flatten -> Linear(3136, 128) -> ReLU -> Dropout(0.3) -> Linear(128, 10)
A 1 x 28 x 28 grayscale image, white digit on a black background, normalized as above.
import torch
from huggingface_hub import hf_hub_download
from model import MNISTCNN
weights = hf_hub_download("EMERA2/mnist-cnn-pytorch", "mnist_cnn.pth")
model = MNISTCNN()
model.load_state_dict(torch.load(weights, map_location="cpu"))
model.eval()