I am using tensorflow to import some MNIST input data. I followed this tutorial...https://www.tensorflow.org/get_started/mnist/beginners
I am importing them as so...
from tensorflow.examples.tutorials.mnist import input_data
mnist = input_data.read_data_sets("/tmp/data/", one_hot=True)
I want to be able to display any of the images from the training set. I know the location of the images is mnist.train.images
, so I try to access the first images and display it like so...
with tf.Session() as sess:
#access first image
first_image = mnist.train.images[0]
first_image = np.array(first_image, dtype='uint8')
pixels = first_image.reshape((28, 28))
plt.imshow(pixels, cmap='gray')
I a attempt to convert the image to a 28 by 28 numpy array because I know that each image is 28 by 28 pixels.
However, when I run the code all I get is the following...
Clearly I am doing something wrong. When I print out the matrix, everything seems to look good, but I think I am incorrectly reshaping it.
np
,mnist
,plt
etc are defined so that someone searching for a quick answer can quickly copy and paste what you have verbatim. Thanks – Blowsy