【发布时间】:2020-06-13 13:41:15
【问题描述】:
我正在做一个 ML/Tensorflow hello world,通过使用 MNIST 数据集来预测某种服装是什么,但是当我尝试使用 data.load_data() 将数据加载到我的 doe 时,它给了我这个错误:
使用 TensorFlow 后端。 从https://storage.googleapis.com/tensorflow/tf-keras-datasets/train-labels-idx1-ubyte.gz下载数据 回溯(最近一次通话最后): 文件“/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/urllib/request.py”,第 1317 行,在 do_open encode_chunked=req.has_header('传输编码')) 文件“/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py”,第 1229 行,在请求中 self._send_request(方法、url、正文、标头、encode_chunked) _send_request 中的文件“/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py”,第 1275 行 self.endheaders(正文,encode_chunked=encode_chunked) 文件“/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py”,第 1224 行,在 endheaders self._send_output(message_body, encode_chunked=encode_chunked) _send_output 中的文件“/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py”,第 1016 行 自我发送(味精) 文件“/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py”,第 956 行,在发送中 self.connect() 文件“/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py”,第 1392 行,在连接中 服务器主机名=服务器主机名) wrap_socket 中的文件“/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/ssl.py”,第 412 行 会话=会话 _create 中的文件“/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/ssl.py”,第 853 行 self.do_handshake() 文件“/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/ssl.py”,第 1117 行,在 do_handshake 中 self._sslobj.do_handshake() ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] 证书验证失败:无法获取本地颁发者证书 (_ssl.c:1056)
在处理上述异常的过程中,又发生了一个异常:
Traceback(最近一次调用最后一次): 文件“/Users/NAME/MNISTifying Clothing Predictor/lib/python3.7/site-packages/tensorflow_core/python/keras/utils/data_utils.py”,第 264 行,在 get_file urlretrieve(来源,fpath,dl_progress) 文件“/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/urllib/request.py”,第 247 行,在 urlretrieve 使用 contextlib.closing(urlopen(url, data)) 作为 fp: 文件“/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/urllib/request.py”,第 222 行,在 urlopen 返回 opener.open(url, 数据, 超时) 文件“/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/urllib/request.py”,第 525 行,打开 响应 = self._open(请求,数据) _open 中的文件“/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/urllib/request.py”,第 543 行 '_open',请求) _call_chain 中的文件“/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/urllib/request.py”,第 503 行 结果 = 函数(*args) https_open 中的文件“/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/urllib/request.py”,第 1360 行 上下文=self._context,check_hostname=self._check_hostname) 文件“/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/urllib/request.py”,第 1319 行,在 do_open 引发 URLError(err) urllib.error.URLError:
在处理上述异常的过程中,又发生了一个异常:
Traceback(最近一次调用最后一次): 文件“/Users/NAME/Python Projects/MNISTifying Clothing Predictor/MNISTifying Clothing Predictor.py”,第 10 行,在 (train_images, train_labels), (test_images, test_labels) = data.load_data() 文件“/Users/NAME/MNISTifying Clothing Predictor/lib/python3.7/site-packages/tensorflow_core/python/keras/datasets/fashion_mnist.py”,第 52 行,在 load_data path.append(get_file(fname, origin=base + fname, cache_subdir=dirname)) 文件“/Users/NAME/MNISTifying Clothing Predictor/lib/python3.7/site-packages/tensorflow_core/python/keras/utils/data_utils.py”,第 268 行,在 get_file 引发异常(error_msg.format(origin,e.errno,e.reason)) 例外:https://storage.googleapis.com/tensorflow/tf-keras-datasets/train-labels-idx1-ubyte.gz 上的 URL 获取失败:无 -- [SSL: CERTIFICATE_VERIFY_FAILED] 证书验证失败:无法获取本地颁发者证书 (_ssl.c:1056)
这是我的代码: 这是我输入的代码:
将张量流导入为 tf 从张量流导入 keras 从 keras.datasets 导入 fashion_mnist 将 numpy 导入为 np 将 matplotlib.pyplot 导入为 plt
数据 = keras.datasets.fashion_mnist
(train_images, train_labels), (test_images, test_labels) = data.load_data()
打印(train_labels1)
【问题讨论】:
标签: python python-3.x tensorflow keras