- Apache Spark Deep Learning Cookbook
- Ahmed Sherif Amrith Ravindra
- 82字
- 2025-02-26 11:49:45
How to do it...
This section will walk through the steps to visualize the MNIST handwritten images in a Jupyter notebook:
- 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
- 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()