Perform the following steps:
- First, we'll load the necessary libraries and start a graph session:
import matplotlib.pyplot as pltimport numpy as npimport tensorflow as tffrom tensorflow.examples.tutorials.mnist import input_datafrom tensorflow.python.framework import opsops.reset_default_graph()sess = tf.Session()
- Next, we will load the data and transform the images into 28x28 arrays:
data_dir = 'temp' mnist = input_data.read_data_sets(data_dir, one_hot=False) train_xdata = np.array([np.reshape(x, (28,28)) for x in mnist.train.images]) test_xdata = np.array([np.reshape(x, (28,28)) for x in mnist.test.images]) train_labels = mnist.train.labels test_labels = mnist.test.labels