How to do it...

This section will walk through the steps to visualize the MNIST handwritten images in a Jupyter notebook:

  1. Import the following libraries, numpy and matplotlib, and configure matplotlib to plot inline using the following script:
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
  1. Plot the first two sample images using the following script:
for i in range(2):
image = data.train.images[i]
image = np.array(image, dtype='float')
label = data.train.labels[i]
pixels = image.reshape((28, 28))
plt.imshow(pixels, cmap='gray')
print('-----------------')
print(label)
plt.show()