How to do it...

The TensorFlow library has a conveniently built-in set of examples that can be used directly. One of those example datasets is MNIST. This section will walk through the steps of accessing those images.

  1. Import TensorFlow into the library with an alias of tf using the following script:
import tensorflow as tf
  1. Download and extract images from the library and save to a local folder using the following script:
from tensorflow.examples.tutorials.mnist import input_data
data = input_data.read_data_sets('MNIST/', one_hot=True)
  1. Retrieve a final count of the training and testing datasets that will be used to evaluate the accuracy of the image classification using the following script:
print('Image Inventory')
print('----------')
print('Training: ' + str(len(data.train.labels)))
print('Testing: '+ str(len(data.test.labels)))
print('----------')