TensorFlow IOError:[Errno套接字错误] [Errno 104]由对等方重置连接

时间:2015-11-16 09:18:43

标签: python-2.7 tensorflow

我已经安装了TensorFlow。当我下载MNISTdataset时,存在一个错误。谁能告诉我出了什么问题?非常感谢!错误详情如下:

Python 2.7.9 (default, Apr  2 2015, 15:33:21) 
[GCC 4.9.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import input_data
>>> mnist = input_data.read_data_sets("MNIST_data/", False, False)
Extracting MNIST_data/train-images-idx3-ubyte.gz
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "input_data.py", line 162, in read_data_sets
    local_file = maybe_download(TRAIN_LABELS, train_dir)
  File "input_data.py", line 22, in maybe_download
    filepath, _ = urllib.request.urlretrieve(SOURCE_URL + filename, filepath)
  File "/usr/lib/python2.7/urllib.py", line 98, in urlretrieve
    return opener.retrieve(url, filename, reporthook, data)
  File "/usr/lib/python2.7/urllib.py", line 245, in retrieve
    fp = self.open(url, data)
  File "/usr/lib/python2.7/urllib.py", line 213, in open
    return getattr(self, name)(url)
  File "/usr/lib/python2.7/urllib.py", line 351, in open_http
    errcode, errmsg, headers = h.getreply()
  File "/usr/lib/python2.7/httplib.py", line 1202, in getreply
    response = self._conn.getresponse()
  File "/usr/lib/python2.7/httplib.py", line 1127, in getresponse
    response.begin()
  File "/usr/lib/python2.7/httplib.py", line 453, in begin
    version, status, reason = self._read_status()
  File "/usr/lib/python2.7/httplib.py", line 409, in _read_status
    line = self.fp.readline(_MAXLINE + 1)
  File "/usr/lib/python2.7/socket.py", line 480, in readline
    data = self._sock.recv(self._rbufsize)
IOError: [Errno socket error] [Errno 104] Connection reset by peer

3 个答案:

答案 0 :(得分:5)

Python无法从lecun.com下载MNIST数据集。首先,检查以确保您可以从该计算机浏览Yann LeCun's MNIST page。如果不能,则可能是防火墙或Internet连接问题。如果可以,请尝试在几分钟内再次运行下载 - 自Tensorflow发布以来,我已经短暂地看到了这个错误,并且它总是在5分钟内消失。

答案 1 :(得分:0)

如果网站即使在数小时后仍然无法访问,您可以修改/usr/local/lib/python2.7/dist-packages/tensorflow/contrib/learn/python/learn/datasets/mnist.py并更改源链接到&#39; https://s3.amazonaws.com/lasagne/recipes/datasets/mnist/&#39;并再次运行该示例。

答案 2 :(得分:0)

作为@ user3851234的回答,您可以通过更改SOURCE_URL来下载数据集,例如:

SOURCE_URL = 'https://s3.amazonaws.com/lasagne/recipes/datasets/mnist/'

您的选择很少:

中国程序员的特别说明

谷歌和亚马逊提供的镜子在中国大陆经常失败,你应该先试试Yann LeCun's page

制作自己的MNIST镜像

的制备:将

无论你在哪里获得4个MNIST数据文件:

  • train-images-idx3-ubyte.gz:训练集图像(9912422字节)
  • train-labels-idx1-ubyte.gz:训练集标签(28881字节)
  • t10k-images-idx3-ubyte.gz:测试集图像(1648877字节)
  • t10k-labels-idx1-ubyte.gz:测试集标签(4542字节)

并将它们放在您的域名下,例如:

https://github.com/Amy/mnistrepo/mnist/train-images-idx3-ubyte.gz

并将SOURCE_URL更改为您的域名:

SOURCE_URL = 'https://github.com/Amy/mnistrepo/mnist