Tensorflow之快速加载MNIST数据集

from tensorflow.examples.tutorials.mnist import input_data
import tensorflow as tf

def myprint(v):
    print(v)
    print(type(v))
    try:
        print(v.shape)
    except:
        try:
            print(len(v))
        except:
            pass


if __name__ == '__main__':
    mnist = input_data.read_data_sets('./input_data', one_hot=True, validation_size=100)
    myprint(mnist.train.labels)
    myprint(mnist.validation.labels)
    myprint(mnist.test.labels)
    myprint(mnist.train.images)
    myprint(mnist.validation.images)
    myprint(mnist.test.images)

 

可能由于网络问题,程序无法把数据集下载到'./input_data'目录下,可以手动下载到对应目录:(mnist官网:http://yann.lecun.com/exdb/mnist/  The MNIST database of handwritten digits, available from this page, has a training set of 60,000 examples, and a test set of 10,000 examples.)

train-images-idx3-ubyte.gz:  training set images (9912422 bytes) 
train-labels-idx1-ubyte.gz:  training set labels (28881 bytes) 
t10k-images-idx3-ubyte.gz:   test set images (1648877 bytes) 
t10k-labels-idx1-ubyte.gz:   test set labels (4542 bytes)

 

MNIST降维可视化参考:http://www.cnblogs.com/huangshiyu13/p/6945239.html

你可能感兴趣的:(人工智能,数据库)