无法(手动)加载cifar10数据集

问题描述 投票:0回答:2

首先,我尝试使用以下方式加载:

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

但它给出了一个错误:

Exception: URL fetch failure on https://www.cs.toronto.edu/~kriz/cifar-10-python.tar.gz: None -- [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: certificate has expired (_ssl.c:1125)

所以我手动下载了数据集并将其放入

C:\Users\SAHAN\.keras\datasets
并将其重命名为
cifar-10-batches-py.tar.gz

但是随后它给出了一个错误:

PermissionError: [Errno 13] Permission denied: 'C:\\Users\\SAHAN\\.keras\\datasets\\cifar-10-batches-py.tar.gz'

如何加载此数据集?

python tensorflow keras
2个回答
47
投票

我在下载 CIFAR-10 时遇到类似的 CERTIFICATE_VERIFY_FAILED 错误。将其放入我的 python 文件中有效:

import ssl
ssl._create_default_https_context = ssl._create_unverified_context

参考:https://programmerah.com/python-error-certificate-verify-failed-certificate-has-expired-40374/


1
投票
import ssl
ssl._create_default_https_context = ssl._create_unverified_context

这个错误是由于安全套接字层(SSL)证书引起的,我们可以借助上面的代码行来解决这个问题。这对我有用!!

© www.soinside.com 2019 - 2024. All rights reserved.