MNIST is a standard benchmark for classifying grayscale handwritten digits. It contains 60,000 training images and 10,000 test images, each a 28 × 28 image labeled with a digit from 0 through 9. Solving MNIST is a practical first check that a neural-network workflow is functioning. section 2.1
Loading and inspecting MNIST
Keras loads MNIST into four NumPy arrays: train_images, train_labels, test_images, and test_labels. The training images have shape (60000, 28, 28); test images have shape (10000, 28, 28). Each image is a rank-3 collection of 28 × 28 uint8 grayscale matrices, with pixel values from 0 to 255. The matching label is an integer digit, such as train_labels[4] = 9. section 2.1 section 2.2.5
Listing 2.1 Loading the MNIST dataset in Keras
from keras.datasets import mnist (train_images, train_labels), (test_images, test_labels) = mnist.load_data()
Shows the compact Keras call that loads the training and test arrays used throughout the workflow. section 2.1
A typical MNIST experiment prepares the arrays before training:
- Flatten each 28 × 28 image into 784 values and convert pixel values to float32 in the 0–1 range. section 2.1
- Train a neural network on train_images and train_labels, then evaluate it on the separate test arrays. section 2.1
- Interpret predictions as ten class scores; the largest score selects the predicted digit. section 2.1




