# MNIST (1998)

> 70,000 handwritten digits, 28×28 grayscale, 10 classes.

Page: https://mralbu.github.io/ai-datasets/d/mnist

## Key facts

- Category: Vision
- Task: Image classification (handwritten digits)
- Creators: Yann LeCun, Corinna Cortes, Christopher J.C. Burges
- Size: 70,000 images
- Splits: train 60,000, test 10,000
- Input: 28×28 grayscale image
- Labels: Digit 0–9
- License: CC BY-SA 3.0
- Paper: [Gradient-Based Learning Applied to Document Recognition](http://yann.lecun.com/exdb/publis/pdf/lecun-98.pdf)
- Homepage: http://yann.lecun.com/exdb/mnist/
- Hugging Face: [ylecun/mnist](https://huggingface.co/datasets/ylecun/mnist)
- Sampled at Hub revision 77f3279092a1c1579b2250db8eafed0ad422088c (2026-11-07)

## Why it matters

The "hello world" of machine learning. A remix of NIST handwriting data, small enough to train on a laptop in seconds, it was the standard yardstick for neural networks from LeNet-5 to the first deep learning papers. Geoffrey Hinton called it "the drosophila of machine learning".

## Worth knowing

- Digits were size-normalized to fit a 20×20 box, then centered by center of mass in a 28×28 frame. That is why every digit sits in the middle.
- The writers were US Census Bureau employees and high-school students; train and test use disjoint sets of writers.
- LeNet-5 got about 0.95% test error in 1998. Modern models reach about 0.2%, and most remaining errors are arguably mislabeled or ambiguous digits.

## Get the data

```bash
# pip install -U huggingface_hub
hf download ylecun/mnist --repo-type dataset \
  --local-dir mnist
```

```python
from datasets import load_dataset   # pip install datasets

ds = load_dataset("ylecun/mnist", "mnist")
print(ds)
```

```python
import polars as pl

df = pl.read_parquet("hf://datasets/ylecun/mnist@~parquet/mnist/test/*.parquet")
print(df.shape)
```

## Related datasets

- NIST Special Database 1 & 3: source data
- [Fashion-MNIST](https://huggingface.co/datasets/zalando-datasets/fashion_mnist): 2017, drop-in replacement with clothing images (on this site: https://mralbu.github.io/ai-datasets/d/fashion-mnist)
- [EMNIST](https://www.nist.gov/itl/products-and-services/emnist-dataset): 2017, adds letters
- [KMNIST](https://github.com/rois-codh/kmnist): 2018, cursive Japanese characters
- [SVHN](https://huggingface.co/datasets/ufldl-stanford/svhn): 2011, digits from Street View photos (on this site: https://mralbu.github.io/ai-datasets/d/svhn)

## Landmark papers

- [Dropout: A Simple Way to Prevent Neural Networks from Overfitting](https://jmlr.org/papers/v15/srivastava14a.html) (2014)

## Papers on this site that use it

- [AdaGrad (2010)](https://mralbu.github.io/ai-datasets/p/adagrad.md): Gives every weight its own learning rate, shrinking with the gradients it has already seen, so rare but informative features still learn quickly.
- [Xavier initialization (2010)](https://mralbu.github.io/ai-datasets/p/xavier-init.md): Why deep networks were hard to train, and a way to set the starting weights so signals neither vanish nor explode.
- [SGD with momentum (2013)](https://mralbu.github.io/ai-datasets/p/sgd-momentum.md): Plain stochastic gradient descent, given a good random start and strong momentum, trains deep networks as well as second-order methods.
- [VAE (2013)](https://mralbu.github.io/ai-datasets/p/vae.md): An autoencoder whose code is a probability distribution, trained with ordinary backpropagation thanks to one change of variables.
- [Adam (2014)](https://mralbu.github.io/ai-datasets/p/adam.md): The optimizer that trains most neural networks, with defaults that work without tuning.
- [Dropout (2014)](https://mralbu.github.io/ai-datasets/p/dropout.md): Switch off random neurons during training, and a network stops memorizing its training data.
- [GAN (2014)](https://mralbu.github.io/ai-datasets/p/gan.md): Train a generator against a discriminator that tries to tell its fakes from real data.
- [Batch normalization (2015)](https://mralbu.github.io/ai-datasets/p/batch-norm.md): Normalize each layer's inputs over the mini-batch, and deep networks train many times faster.
- [DCGAN (2015)](https://mralbu.github.io/ai-datasets/p/dcgan.md): A short list of architecture rules that made convolutional GANs train reliably, and showed what their latent space had learned.
