One of the datasets that we'll use for this chapter is the MNIST handwritten digits dataset. The MNIST dataset contains 70,000 samples of handwritten digits, each of size 28 x 28 pixels. Each sample contains only one digit within the image, and all samples are labeled.
The MNIST dataset is provided directly in Keras, and we can import it by simply running the following code:
from keras.datasets import mnist
training_set, testing_set = mnist.load_data()
X_train, y_train = training_set
X_test, y_test = testing_set
Let's plot out each of the digits to better visualize our data. The following code snippet uses matplotlib to plot the data:
from matplotlib import pyplot as plt
fig, ((ax1, ax2, ax3, ax4, ax5), (ax6, ax7, ax8, ax9, ax10)) = plt.subplots(2, 5, figsize=(10,5))
for idx, ax in enumerate([ax1,ax2,ax3,ax4,ax5, ax6,ax7,ax8,ax9,ax10...