mnist数据集获取:可从Yann LeCun教授管网获取;
tensorflow中可使用input_data.read_data_sets("/worker/mnistdata/", one_hot = True)
导入下载到本地的mnist数据集; "/worker/mnistdata/"为数据集存放的位置.
import tensorflow as tf
from tensorflow.examples.tutorials.mnist import input_data #tensorflow已经包含了mnist案例的数据
mnist = input_data.read_data_sets("/worker/mnistdata/", one_hot = True) #导入已经下载好的数据集,"/worker/mnistdata/"为存放mnist数据集的文件夹
print(mnist.train.images.shape, mnist.train.labels.shape)
print(mnist.test.images.shape, mnist.test.labels.shape)
print(mnist.validation.images.shape, mnist.validation.labels.shape)
Extracting /worker/mnistdata/train-images-idx3-ubyte.gz
Extracting /worker/mnistdata/train-labels-idx1-ubyte.gz
Extracting /worker/mnistdata/t10k-images-idx3-ubyte.gz
Extracting /worker/mnistdata/t10k-labels-idx1-ubyte.gz
(55000, 784) (55000, 10)
(10000, 784) (10000, 10)
(5000, 784) (5000, 10)
网友评论