liveBook · Manning

MNIST dataset

As explained in Bayesian Optimization in Action

The MNIST dataset is a labeled collection of handwritten digit images commonly used for machine-learning training and evaluation.

The MNIST dataset contains labeled images of handwritten digits. Each image is a 28-by-28 matrix of integer pixel values from 0 to 255; zero represents white and 255 represents dark. Although digit recognition is classification, the numeric labels can also serve as continuous regression targets. section 13.1

A practical MNIST workflow represents and prepares the data as follows:

  • Load the images with PyTorch and torchvision, convert them to tensors, and normalize pixel values using mean 0.1307 and standard deviation 0.3081. section 13.2.2 section 13.2.4
  • Flatten each 28-by-28 image into 784 features while retaining its digit label as the target. section 13.2.2 section 13.2.4
  • Train and test a Gaussian process by selecting 1,000 training images and 500 test images, then evaluate mean absolute prediction error. section 13.2.4
Figure 13.2 A data point from the MNIST dataset, which is an image with 28 rows and 28 columns of pixels, represented as a PyTorch tensor

Inspect a representative digit as both a 28-by-28 image and a PyTorch tensor of pixel values. section 13.1 section 13.2.2

How Bayesian Optimization in Action covers it

How deep it goes
Defines pixel structure, demonstrates tensor preparation, and works through a 1,000-image Gaussian-process experiment.
Examples
Shows a handwritten five, a 784-element tensor, and a train-test experiment using 1,000 training and 500 test images.
What you can do after
Apply it via PyTorch and torchvision to load, normalize, flatten, visualize, and split handwritten-digit data for GP prediction.
How it connects
Connects structured data, image classification, regression, Gaussian processes, PyTorch tensors, normalization, and RBF kernels.

Also explained in

Compare how 5 books explain MNIST dataset →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Bayesian Optimization in Action. The section links point to the parts of the book it draws on.