Mnist数据集导入出错解决方案

匿名 (未验证) 提交于 2019-12-02 22:56:40

Mnist数据集导入出错

在进行Mnist手写识别的项目中,出现了Mnist数据集下载出错的问题,报出以下错误:

Exception: URL fetch failure on https://s3.amazonaws.com/img-datasets/mnist.npz: None -- [WinError 10060] 由于连接方在一段时间后没有正确答复或连接的主机没有反应,连接尝试失败。

解决方案如下:

在浏览器输入网址https://s3.amazonaws.com/img-datasets/mnist.npz,下载minst.npz数据集,保存到某个文件夹下,在这里,我保存到了"F:\Anaconda"下,然后进入minst.load_data(),将代码改成如下:

 def load_data():     """Loads the MNIST dataset.      # Arguments         path: path where to cache the dataset locally             (relative to ~/.keras/datasets).      # Returns         Tuple of Numpy arrays: `(x_train, y_train), (x_test, y_test)`.         """     path='F://Anaconda//mnist.npz'     f = np.load(path)     x_train, y_train = f['x_train'], f['y_train']     x_test, y_test = f['x_test'], f['y_test']     f.close()     return (x_train, y_train), (x_test, y_test)

即可将mnist数据集导入成功,并能够成功运行。

运行过程如上图所示。

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!