TensorFlow IOError: [Errno socket error] [Errno 104] Connection reset by peer
TensorFlow IOError: [Errno socket error] [Errno 104] Connection reset by peer
我已经安装了 TensorFlow。当我下载 MNIST 数据集时,出现一个错误。谁能告诉我哪里出了问题?非常感谢!错误详情如下:
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
Python 无法从 lecun.com 下载 MNIST 数据集。首先,检查以确保您可以从该计算机浏览 Yann LeCun's MNIST page。如果不能,则可能是防火墙或 Internet 连接问题。如果可以,请在几分钟后再次尝试 运行 下载 - 自 Tensorflow 发布以来,我已经多次短暂地看到此错误,并且它总是在 5 分钟内消失。
如果下班后仍然无法访问该站点,您可以修改/usr/local/lib/python2.7/dist-packages/tensorflow/contrib/learn/python/learn/datasets/mnist.py并将源link更改为'https://s3.amazonaws.com/lasagne/recipes/datasets/mnist/' 和 运行 再次举例。
作为@user3851234 的回答,您可以通过更改 SOURCE_URL
下载数据集,例如:
SOURCE_URL = 'https://s3.amazonaws.com/lasagne/recipes/datasets/mnist/'
有几个选项供您选择:
- 官方来源:http://yann.lecun.com/exdb/mnist/
- Google镜像:https://storage.googleapis.com/cvdf-datasets/mnist/
- 亚马逊镜像:https://s3.amazonaws.com/lasagne/recipes/datasets/mnist/
中国程序员特别说明
Google和亚马逊提供的镜像在中国大陆经常失效,你先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
我已经安装了 TensorFlow。当我下载 MNIST 数据集时,出现一个错误。谁能告诉我哪里出了问题?非常感谢!错误详情如下:
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
Python 无法从 lecun.com 下载 MNIST 数据集。首先,检查以确保您可以从该计算机浏览 Yann LeCun's MNIST page。如果不能,则可能是防火墙或 Internet 连接问题。如果可以,请在几分钟后再次尝试 运行 下载 - 自 Tensorflow 发布以来,我已经多次短暂地看到此错误,并且它总是在 5 分钟内消失。
如果下班后仍然无法访问该站点,您可以修改/usr/local/lib/python2.7/dist-packages/tensorflow/contrib/learn/python/learn/datasets/mnist.py并将源link更改为'https://s3.amazonaws.com/lasagne/recipes/datasets/mnist/' 和 运行 再次举例。
作为@user3851234 的回答,您可以通过更改 SOURCE_URL
下载数据集,例如:
SOURCE_URL = 'https://s3.amazonaws.com/lasagne/recipes/datasets/mnist/'
有几个选项供您选择:
- 官方来源:http://yann.lecun.com/exdb/mnist/
- Google镜像:https://storage.googleapis.com/cvdf-datasets/mnist/
- 亚马逊镜像:https://s3.amazonaws.com/lasagne/recipes/datasets/mnist/
中国程序员特别说明
Google和亚马逊提供的镜像在中国大陆经常失效,你先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