MNIST Handwritten Digit Classifier (PyTorch CNN)

A small convolutional neural network that recognizes handwritten digits (0-9). Built as a beginner learning project.

Results

  • Test accuracy on MNIST: 99.30%

Architecture

2 x (Conv2d + ReLU + MaxPool) -> Flatten -> Linear(3136, 128) -> ReLU -> Dropout(0.3) -> Linear(128, 10)

Training details

  • Optimizer: Adam, learning rate 0.001
  • Loss: CrossEntropyLoss
  • Epochs: 5, batch size: 64
  • Input normalization: mean 0.1307, std 0.3081

Input format

A 1 x 28 x 28 grayscale image, white digit on a black background, normalized as above.

How to use

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()
Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐Ÿ™‹ Ask for provider support

Dataset used to train EMERA2/mnist-cnn-pytorch