Plotting images is often a major pain point when dealing with graphics within a Jupyter notebook. Displaying the handwritten images from the training dataset is critical, especially when comparing the actual value of the label that is associated with the handwritten image.
The only Python libraries that will be imported to visualize the handwritten images are numpy
and matplotlib
. Both should already be available through the packages in Anaconda. If for some reason they are not available, they can both be pip
installed at the Terminal using the following commands:
pip install matplotlib
pip install numpy
This section will walk through the steps to visualize the MNIST handwritten images in a Jupyter notebook:
- Import the following libraries,
numpy
andmatplotlib
, and configurematplotlib
to plotinline
using the following script:
import numpy as np import matplotlib.pyplot as plt %matplotlib inline
- Plot the first two sample images...