- Apache Spark Deep Learning Cookbook
- Ahmed Sherif Amrith Ravindra
- 125字
- 2025-02-26 11:49:45
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.
- Import TensorFlow into the library with an alias of tf using the following script:
import tensorflow as tf
- 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)
- 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('----------')