MNIST数据集简介

MNIST Dataset Introduction

大多数示例使用手写数字的MNIST数据集。 该数据集包含60,000个用于培训的示例和10,000个用于测试的示例。 这些数字已经标准化,并以固定大小的图像(28x28像素)为中心,其值为0到1.为简单起见,每个图像都被展平并转换为784个特征(28 * 28)的一维 numpy数组)。

Overview

MNIST Digits

Usage

在我们的示例中,我们使用TensorFlow input_data.py脚本来加载该数据集。 它对于管理和处理我们的数据非常有用:

  • 数据集下载

  • 将整个数据集加载到numpy数组中:

# Import MNIST
from tensorflow.examples.tutorials.mnist import input_data
mnist = input_data.read_data_sets("/tmp/data/", one_hot=True)

# Load data
X_train = mnist.train.images
Y_train = mnist.train.labels
X_test = mnist.test.images
Y_test = mnist.test.labels
  • next_batch函数,可以遍历整个数据集并仅返回所需的数据集样本部分(以节省内存并避免加载整个数据集)。
# Get the next 64 images array and labels
batch_X, batch_Y = mnist.train.next_batch(64)

Link: http://yann.lecun.com/exdb/mnist/

猜你喜欢

转载自blog.csdn.net/qq_40061421/article/details/85013926
今日推荐