python - 为什么我会收到以下 mnist = fetch_mldata 的连接重置错误?
问题描述
每当我尝试从 mnist 获取数据时,我都会收到一个连接重置错误,不确定它为什么会发生。这是来自 sklearn 的用于执行 PCA 和 t-sne 数据降维的教程。我认为这可能是 python 版本的问题,但在 2.6、3.5 或 3.7 中不起作用
from sklearn.datasets import fetch_mldata
mnist = fetch_mldata("MNIST original")
X = mnist.data / 255.0
y = mnist.target
ConnectionResetError Traceback (most recent call last)
<ipython-input-11-781ac9f03cc8> in <module>()
----> 1 mnist = fetch_mldata("MNIST original")
2 X = mnist.data / 255.0
3 y = mnist.target
/anaconda3/envs/py35/lib/python3.5/site-packages/sklearn/datasets/mldata.py in fetch_mldata(dataname, target_name, data_name, transpose_data, data_home)
152 urlname = MLDATA_BASE_URL % quote(dataname)
153 try:
--> 154 mldata_url = urlopen(urlname)
155 except HTTPError as e:
156 if e.code == 404:
ConnectionResetError: [Errno 54] Connection reset by peer
解决方案
fetch_mldata
自 scikit-learn v0.20 起已弃用,并替换为fetch_openml
; 以下是在 v0.21 中您应该如何将其用于 MNIST:
from sklearn.datasets import fetch_openml
X, y = fetch_openml('mnist_784', version=1, return_X_y=True)
有关示例,请参阅文档。
推荐阅读
- python - 如何监控多个进程并在一个退出时启动新的进程?
- c# - Excel 数据阅读器:变量列表使用 Clear() 方法丢失列表内容
- javascript - 如何获取对象内部的值?
- javascript - 奇怪的警告:已声明但它的值从未被读取
- javascript - Google App脚本根据该单元格的字体颜色清除单元格值
- xcode - Xcode 10.3 不适用于 MacOS Big Sur 11.0.1(非测试版)
- python - 爬取数据和调整数据时列表索引超出范围
- google-cloud-platform - 如何查找 GCP 永久磁盘使用情况?
- font-size - RDKit:如何更改原子标签字体大小?
- windows - 当用户点击离开时隐藏托盘弹出菜单