Search⌘ K

Our Own MNIST Library

Explore how to convert MNIST images and labels into input matrices for a binary classifier, focusing on recognizing the digit 5. Understand reshaping images into feature vectors, encoding labels for binary output, and developing a small library to load and preprocess this data effectively.

Goal of the lesson

In the previous lessons, we built a binary classifier. Now we want to apply that program to MNIST.

The first step is to reshape MNIST’s images and labels into an input for our program. Let’s see how to do that.

Prepare the input matrices

Our binary classifier program expects its input formatted as two matrices: a set of examples XX and a set of labels YY. Let’s start with the matrix of examples XX.

XX is supposed to have one line per example and one column per input variable, plus a bias column full of 1s. (Remember ...