大多数例子使用了手写数字的MNIST数据集。它包含了60000个训练数据和10000个测试数据。这些数字的尺寸已标准化,同时做了居中处理,所以每个数据可以表示成一个值为0到1大小为28 * 28矩阵。
在例子中,我们使用TFinput_data.py脚本来加载数据集。这对管理数据相当好用,具体操作:
In [20]:
# 导入MNIST
from tensorflow.examples.tutorials.mnist import input_data
# 加载数据
X_train = mnist.train.images
Y_train = mnist.train.labels
X_test = mnist.test.images
Y_test = mnist.test.labels
print(X_train.shape)
print(Y_train.shape)
print(X_test.shape)
print(Y_test.shape)
In [16]:
# 获取下一组64张图像数组与分类列表
batch_X, batch_Y = mnist.train.next_batch(64)
print(batch_X.shape)
print(batch_Y.shape)