👣
MNIST データセットをダウンロードしたい
MNISTデータセットの公式オリジナルといえば Yann LeCun's Home Pageさんの以下 URL が知られているが、現在ここは空になっていてダウンロードできない。
http://yann.lecun.com/exdb/mnist/
PyTorch などのライブラリから自動で頻繁にダウンロードされるのがサイト的にキツかったようで 2021年ごろに削除されたようだ。
そのため界隈では一時リンク切れが問題になったようだが、現在は PyTorch 等ライブラリを使用している分には問題ない模様。
ただ、機械学習系の情報提供サイトや解説記事ページ上にある MNIST リンクの多くは、まだリンク切れのままが多く、初学者を混乱させるモトになっている。
調べても新しい公式というのも無さそうなので、その代わりとなる利用可能なミラーで主要な URL を以下に記載しておく。
PyTorch のミラーサイト
PyTorch が用意したミラー。torchvision.datasets.MNISTでのダウンロード元。
- https://ossci-datasets.s3.amazonaws.com/mnist/train-images-idx3-ubyte.gz
- https://ossci-datasets.s3.amazonaws.com/mnist/train-labels-idx1-ubyte.gz
- https://ossci-datasets.s3.amazonaws.com/mnist/t10k-images-idx3-ubyte.gz
- https://ossci-datasets.s3.amazonaws.com/mnist/t10k-labels-idx1-ubyte.gz
参考
- Always download MNIST from PyTorch mirror · Issue #4634 · pytorch/vision
- python - HTTP Error when trying to download MNIST data - Stack Overflow
Microsoft Azure オープン データセット
Microsoft が提供するデータセットより手書き数字の MNIST データベース。
- https://azureopendatastorage.blob.core.windows.net/mnist/train-images-idx3-ubyte.gz
- https://azureopendatastorage.blob.core.windows.net/mnist/train-labels-idx1-ubyte.gz
- https://azureopendatastorage.blob.core.windows.net/mnist/t10k-images-idx3-ubyte.gz
- https://azureopendatastorage.blob.core.windows.net/mnist/t10k-labels-idx1-ubyte.gz
TensorFlow アーカイブ
TensorFlow チームで管理しているもの。tf.keras.datasets.mnist.load_data()でのダウンロード元。
ダウンロードされる mnist.npz ファイルは NumPy のアーカイブで4データがまとめられている。下記参考まで。
import numpy as np
mnist_data = np.load("mnist.npz")
print(mnist_data.files) # ['x_train', 'y_train', 'x_test', 'y_test']
print(mnist_data['x_train'].shape) # (60000, 28, 28)
print(mnist_data['y_train'].shape) # (60000,)
print(mnist_data['x_test'].shape) # (10000, 28, 28)
print(mnist_data['y_test'].shape) # (10000,)
Discussion