Much of machine learning is just operations on matrices. We will start that process next by converting our images into a series of matrices—essentially, a 3D matrix as wide as the number of images we have.
Almost all matrix operations that we will perform in this chapter, and the entire book, use NumPy—the most popular scientific computing package in the Python landscape. NumPy is available at http://www.numpy.org/. You should install it before running the next series of operations.
The following code opens images and creates the matrices of data (note the three extra imports now required):
import numpy as np from IPython.display import display, Image from scipy import ndimage image_size = 28 # Pixel width and ...