Keras 2 API 文档 / 内置小型数据集 / CIFAR10 小型图像分类数据集

CIFAR10 小型图像分类数据集

[源码]

load_data 函数

tf_keras.datasets.cifar10.load_data(cache_dir=None)

加载 CIFAR10 数据集。

这是一个包含 50,000 张 32x32 彩色训练图像和 10,000 张测试图像的数据集,分为 10 个类别。更多信息请参见 CIFAR 主页

类别如下:

标签 描述
0 飞机
1 汽车
2
3
4 鹿
5
6 青蛙
7
8
9 卡车

参数

  • cache_dir: 数据集本地缓存目录。如果为 None,则默认为 ~/.keras/datasets

返回值

  • NumPy 数组元组(x_train, y_train), (x_test, y_test)

x_train: uint8 NumPy 数组,图像数据,形状为 (50000, 32, 32, 3),包含训练数据。像素值范围是 0 到 255。

y_train: uint8 NumPy 数组,标签数据(范围 0-9 的整数),形状为 (50000, 1),用于训练数据。

x_test: uint8 NumPy 数组,图像数据,形状为 (10000, 32, 32, 3),包含测试数据。像素值范围是 0 到 255。

y_test: uint8 NumPy 数组,标签数据(范围 0-9 的整数),形状为 (10000, 1),用于测试数据。

示例

(x_train, y_train), (x_test, y_test) = keras.datasets.cifar10.load_data()
assert x_train.shape == (50000, 32, 32, 3)
assert x_test.shape == (10000, 32, 32, 3)
assert y_train.shape == (50000, 1)
assert y_test.shape == (10000, 1)