load_data
函數keras.datasets.mnist.load_data(path="mnist.npz")
載入 MNIST 資料集。
這是一個包含 60,000 張 28x28 灰階數字圖片(共 10 個數字)的資料集,以及包含 10,000 張圖片的測試集。更多資訊請參閱 MNIST 首頁。
參數
~/.keras/datasets
)。回傳值
(x_train, y_train), (x_test, y_test)
。x_train
:uint8
NumPy 陣列,包含形狀為 (60000, 28, 28)
的灰階圖像資料,為訓練資料。像素值範圍從 0 到 255。
y_train
:uint8
NumPy 陣列,包含形狀為 (60000,)
的數字標籤(範圍 0-9 的整數),為訓練資料。
x_test
:uint8
NumPy 陣列,包含形狀為 (10000, 28, 28)
的灰階圖像資料,為測試資料。像素值範圍從 0 到 255。
y_test
:uint8
NumPy 陣列,包含形狀為 (10000,)
的數字標籤(範圍 0-9 的整數),為測試資料。
範例
(x_train, y_train), (x_test, y_test) = keras.datasets.mnist.load_data()
assert x_train.shape == (60000, 28, 28)
assert x_test.shape == (10000, 28, 28)
assert y_train.shape == (60000,)
assert y_test.shape == (10000,)
授權條款
Yann LeCun 和 Corinna Cortes 擁有 MNIST 資料集的版權,該資料集是源自原始 NIST 資料集的衍生作品。MNIST 資料集根據 Creative Commons Attribution-Share Alike 3.0 授權條款提供使用。