手动加载数据集要写一堆代码,直接下载又失败
所以我直接到load_data() 函数中去,https://storage.googleapis.com/tensorflow/tf-keras-datasets/mnist.npz 这个网址将数据集下载出来放在跟目录中,然后
# origin_folder = 'https://storage.googleapis.com/tensorflow/tf-keras-datasets/'
# path = get_file(
# path,
# origin=origin_folder + 'mnist.npz',
# file_hash=
# '731c5ac602752760c8e48fbffcf8c3b850d9dc2a2aedcf2cc48468fc17b673d1')
path="./mnist.npz"
with np.load(path, allow_pickle=True) as f:
x_train, y_train = f['x_train'], f['y_train']
x_test, y_test = f['x_test'], f['y_test']
return (x_train, y_train), (x_test, y_test)
把原来的path注释掉,加上path="./mnist.npz",搞定