Keras 3 API 文件 / 內建小資料集 / CIFAR10 小圖像分類資料集

CIFAR10 小圖像分類資料集

[原始碼]

load_data 函數

keras.datasets.cifar10.load_data()

載入 CIFAR10 資料集。

這是一個包含 50,000 張 32x32 彩色訓練圖像和 10,000 張測試圖像的資料集,標記分為 10 個類別。更多資訊請參閱 CIFAR 首頁

類別如下

標籤 描述
0 飛機
1 汽車
2
3
4 鹿
5
6 青蛙
7
8
9 卡車

回傳

  • NumPy 陣列的元組(x_train, y_train), (x_test, y_test)

x_trainuint8 NumPy 陣列,包含灰階圖像資料,形狀為 (50000, 32, 32, 3),包含訓練資料。像素值範圍從 0 到 255。

y_trainuint8 NumPy 陣列,包含標籤(範圍 0-9 的整數),形狀為 (50000, 1),用於訓練資料。

x_testuint8 NumPy 陣列,包含灰階圖像資料,形狀為 (10000, 32, 32, 3),包含測試資料。像素值範圍從 0 到 255。

y_testuint8 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)