下载mnist数据集,网络失败的问题
Keras file is located into a new path in Google Cloud Storage (Before it was in AWS S3):
https://storage.googleapis.com/tensorflow/tf-keras-datasets/mnist.npz
When using:
tf.keras.datasets.mnist.load_data()
You can pass a path
parameter.
load_data()
will call get_file()
which takes as parameter fname
, if path is a full path and file exists, it will not be downloaded.
Example:
# gsutil cp gs://tensorflow/tf-keras-datasets/mnist.npz /tmp/data/mnist.npz
# python3
>>> import tensorflow as tf
>>> path = '/tmp/data/mnist.npz'
>>> (train_images, train_labels), (test_images, test_labels) = tf.keras.datasets.mnist.load_data(path)
>>> len(train_images)
>>> 60000