Error Downloading MNIST解决方案

Updated on in 菜鸟江湖之算法 with 516 views and 0 comments

问题描述

在下载 MNIST 数据集的时候报错,报错信息如下:

 1/usr/local/lib/python3.7/dist-packages/sklearn/utils/deprecation.py:77: DeprecationWarning: Function fetch_mldata is deprecated; fetch_mldata was deprecated in version 0.20 and will be removed in version 0.22
 2  warnings.warn(msg, category=DeprecationWarning)
 3/usr/local/lib/python3.7/dist-packages/sklearn/utils/deprecation.py:77: DeprecationWarning: Function mldata_filename is deprecated; mldata_filename was deprecated in version 0.20 and will be removed in version 0.22
 4  warnings.warn(msg, category=DeprecationWarning)
 5Traceback (most recent call last):
 6  File "classification_sklearn.py", line 2, in <module>
 7    mnist = fetch_mldata('MNIST original')
 8  File "/usr/local/lib/python3.7/dist-packages/sklearn/utils/deprecation.py", line 78, in wrapped
 9    return fun(*args, **kwargs)
10  File "/usr/local/lib/python3.7/dist-packages/sklearn/datasets/mldata.py", line 133, in fetch_mldata
11    mldata_url = urlopen(urlname)
12  File "/usr/lib/python3.7/urllib/request.py", line 222, in urlopen
13    return opener.open(url, data, timeout)
14  File "/usr/lib/python3.7/urllib/request.py", line 525, in open
15    response = self._open(req, data)
16  File "/usr/lib/python3.7/urllib/request.py", line 543, in _open
17    '_open', req)
18  File "/usr/lib/python3.7/urllib/request.py", line 503, in _call_chain
19    result = func(*args)
20  File "/usr/lib/python3.7/urllib/request.py", line 1345, in http_open
21    return self.do_open(http.client.HTTPConnection, req)
22  File "/usr/lib/python3.7/urllib/request.py", line 1320, in do_open
23    r = h.getresponse()
24  File "/usr/lib/python3.7/http/client.py", line 1321, in getresponse
25    response.begin()
26  File "/usr/lib/python3.7/http/client.py", line 296, in begin
27    version, status, reason = self._read_status()
28  File "/usr/lib/python3.7/http/client.py", line 257, in _read_status
29    line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
30  File "/usr/lib/python3.7/socket.py", line 589, in readinto
31    return self._sock.recv_into(b)
32ConnectionResetError: [Errno 104] Connection reset by peer
33

下载数据集的代码如下:

1from sklearn.datasets import fetch_mldata
2mnist = fetch_mldata('MNIST original')
3mnist

解决方案

下载 mnist-original.mat 并且保存到 ~/scikit_learn_data/mldata/(scikit data home dir)下面即可

查找 scikit data home dir 的代码:

1from sklearn.datasets.base import get_data_home 
2print (get_data_home())

标 题:Error Downloading MNIST解决方案
作 者:ZEEKLING
描 述:Stay simple, stay naive. 十年之约