# Our Own MNIST Library

Interact with the sample code to create a custom MNIST library.

## We'll cover the following

## 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 $X$ and a set of labels $Y$. Let’s start with the matrix of examples $X$.

$X$ is supposed to have one line per example and one column per input variable, plus a bias column full of **1s**. (Remember the bias column? We talked about it in the Bye-bye, bias section)

To fit MNIST’s images to this format, we can reshape each image to a single line of pixels so that each pixel becomes an input variable. MNIST images are 28 by 28 pixels, so squashing them results in lines of 784 elements. And throw in the bias column, and that makes 785. So, X should look like a matrix of 60,000 lines (the number of examples) and 785 columns (one per pixel, plus the bias). Check out the following graph:

Create a free account to view this lesson.

By signing up, you agree to Educative's Terms of Service and Privacy Policy