使用python读取tensorflow实例中的MNIST模拟数据

来源:互联网 发布:unity大场景优化 编辑:程序博客网 时间:2024/06/01 23:03

代码可以在这里下载 https://gist.github.com/alexwang2013/a8d030cc9fa37e8d0e3fe9d92cbfd7fc

1, 从这里下载模拟的数据 http://yann.lecun.com/exdb/mnist/

tensorflow实例中的数据也是来自于http://yann.lecun.com/exdb/mnist/

所以直接下载如下4个数据就OK。

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)

2, 解压数据。

解压缩其中的训练数据, 比如 train-images-idx3-ubyte.gz 解压缩为 train-images-idx3-ubyte

3, 读取并显示。

利用MNIST_visualization.py文件的方法如下: 

$  python MNIST_visualization.py train-images-idx3-ubyte 300


其中【train-images-idx3-ubyte】是文件的路径

【300】是训练数据中对应的索引。训练数据中最大索引为59999


0 0
原创粉丝点击