Download and use data sets MNIST

TensorFlow provides a library, can be directly used to automatically download and install MNIST.

MNIST contains three data sets: a first set of training data is (mnist.train.images), the other two being the test data set (mnist.test.images), and validation data set (mnist.validation).

Code one_hot = True, the label indicates the sample into one_hot coding.
Print information is the beginning of the decompressed data collection means. The first time you run, will display related messages downloaded data.
Then print out a training set of picture information, it is a 55,000 line 784 of the matrix. That is, the training set, there are 55,000 pictures.

1 from tensorflow.examples.tutorials.mnist import input_data
2 mnist = input_data.read_data_sets("MNIST_data/",one_hot=True)
3 print ('输入数据:',mnist.train.images)
4 print ('输入打印shape:',mnist.train.images.shape)
5 import pylab
6 im = mnist.train.images[1]
7 im = im.reshape(-1,28)
8 pylab.imshow(im)
9 pylab.show()


FIG output of the code:

Guess you like

Origin www.cnblogs.com/Jesse-Cavendish/p/11646985.html