下载数据集时出现此错误:ValueError:对已关闭文件的I/O操作 [英] This error while downloading datasets: ValueError: I/O operation on closed file

查看:78
本文介绍了下载数据集时出现此错误:ValueError:对已关闭文件的I/O操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经开始与Theano和Keras进行深度学习.但是,对于任何程序,我都必须加载数据集,而我却无法加载任何数据集.

I have started with deep learning with Theano and Keras. However, for any program, I will have to load the dataset, and i'm not able to load any dataset.

即使我运行这两行:-

from keras.datasets import cifar10
(X_train, y_train), (X_test, y_test) = cifar10.load_data()

我什至用最小的数据集尝试了上述方法.完全一样的错误.

I even tried the above with minst dataset. Exact same error.

我试图一个一个地运行命令,第一次导入进展顺利.在第二个命令中,它运行并开始下载python. 但是,几秒钟后,它破裂了.

I tried to run the commands one by one, the first import goes well. In the second command, it runs and python begins downloading. However, after a few seconds, it breaks.

这是确切的错误:-

(X_train,y_train),(X_test,y_test)= cifar10.load_data()正在下载 来自 http://www.cs.toronto.edu/的数据〜kriz/cifar-10-python.tar.gz
8929280/170498071 [> ......................................]-ETA:82s (最近通话最近):

(X_train, y_train), (X_test, y_test) = cifar10.load_data() Downloading data from http://www.cs.toronto.edu/~kriz/cifar-10-python.tar.gz
8929280/170498071 [>.............................] - ETA: 82sTraceback (most recent call last):

文件",第1行,在 (X_train,y_train),(X_test,y_test)= cifar10.load_data()

File "", line 1, in (X_train, y_train), (X_test, y_test) = cifar10.load_data()

文件 "C:\ Users \ Aseem \ Anaconda3 \ envs \ AnacondaAseem \ lib \ site-packages \ keras \ datasets \ cifar10.py", 第11行,在load_data中 路径= get_file(dirname,origin = origin,untar = True)

File "C:\Users\Aseem\Anaconda3\envs\AnacondaAseem\lib\site-packages\keras\datasets\cifar10.py", line 11, in load_data path = get_file(dirname, origin=origin, untar=True)

文件 "C:\ Users \ Aseem \ Anaconda3 \ envs \ AnacondaAseem \ lib \ site-packages \ keras \ utils \ data_utils.py", 第76行,在get_file中 提高e

File "C:\Users\Aseem\Anaconda3\envs\AnacondaAseem\lib\site-packages\keras\utils\data_utils.py", line 76, in get_file raise e

ValueError:对已关闭文件的I/O操作

ValueError: I/O operation on closed file

我不知道为什么会这样.似乎文件data_utils.py

I do not know why this is happening. Seems like something is wrong in the file data_utils.py

我该怎么办?

推荐答案

我尝试了您的确切代码,并且在我的计算机上可以正常工作.失败可能是由于多种原因造成的,例如互联网连接不稳定或主文件夹中的可用空间不足.

I tried your exact code and it works fine on my computer. The failure could be due to several reasons, like a unstable internet connection or not enough free space in your home folder.

您可以做的是下载文件使用下载管理器手动将其放入〜/.keras/datasets中,并将其重命名为cifar-10-batches-py.tar.gz并再次运行代码,它应该提取文件并从那里继续进行处理.

What you can do is to download the file manually using a download manager, put it in ~/.keras/datasets and rename it to cifar-10-batches-py.tar.gz and run the code again, it should pick up the file and continue processing from there.

这篇关于下载数据集时出现此错误:ValueError:对已关闭文件的I/O操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆