In [1]:
from tensorflow.examples.tutorials.mnist import input_data
mnist=input_data.read_data_sets('MNIST_data',one_hot=True)


Extracting MNIST_data\train-images-idx3-ubyte.gz
Extracting MNIST_data\train-labels-idx1-ubyte.gz
Extracting MNIST_data\t10k-images-idx3-ubyte.gz
Extracting MNIST_data\t10k-labels-idx1-ubyte.gz

In [2]:
batch=mnist.train.next_batch(3)

In [3]:
batch


Out[3]:
(array([[ 0.,  0.,  0., ...,  0.,  0.,  0.],
        [ 0.,  0.,  0., ...,  0.,  0.,  0.],
        [ 0.,  0.,  0., ...,  0.,  0.,  0.]], dtype=float32),
 array([[ 1.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.],
        [ 0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  1.,  0.],
        [ 0.,  1.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.]]))

In [5]:
x=batch[0]
y=batch[1]

In [7]:
y[0]


Out[7]:
array([ 1.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.])

In [9]:
x[0].shape


Out[9]:
(784,)

In [20]:
import numpy as np
img=np.reshape(x[0], newshape=(28, -1))

In [21]:
%matplotlib inline
from matplotlib import pyplot as plt
plt.imshow(img,cmap='gray')


Out[21]:
<matplotlib.image.AxesImage at 0x250b59bb438>

In [ ]: