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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM