前提・実現したいこと
tensorflow の学習中にmnistのデータセットを用いようとしたのですが、以下のようなエラーが発生しました。なぜ発生するのかお教えいただきたいです。
発生している問題・エラーメッセージ
Downloading data from https://storage.googleapis.com/tensorflow/tf-keras-datasets/mnist.npz --------------------------------------------------------------------------- SSLCertVerificationError Traceback (most recent call last) /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/urllib/request.py in do_open(self, http_class, req, **http_conn_args) 1318 try: -> 1319 h.request(req.get_method(), req.selector, req.data, headers, 1320 encode_chunked=req.has_header('Transfer-encoding')) /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/http/client.py in request(self, method, url, body, headers, encode_chunked) 1229 """Send a complete request to the server.""" -> 1230 self._send_request(method, url, body, headers, encode_chunked) 1231 /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/http/client.py in _send_request(self, method, url, body, headers, encode_chunked) 1275 body = _encode(body, 'body') -> 1276 self.endheaders(body, encode_chunked=encode_chunked) 1277 /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/http/client.py in endheaders(self, message_body, encode_chunked) 1224 raise CannotSendHeader() -> 1225 self._send_output(message_body, encode_chunked=encode_chunked) 1226 /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/http/client.py in _send_output(self, message_body, encode_chunked) 1003 del self._buffer[:] -> 1004 self.send(msg) 1005 /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/http/client.py in send(self, data) 943 if self.auto_open: --> 944 self.connect() 945 else: /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/http/client.py in connect(self) 1398 -> 1399 self.sock = self._context.wrap_socket(self.sock, 1400 server_hostname=server_hostname) /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/ssl.py in wrap_socket(self, sock, server_side, do_handshake_on_connect, suppress_ragged_eofs, server_hostname, session) 499 # ctx._wrap_socket() --> 500 return self.sslsocket_class._create( 501 sock=sock, /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/ssl.py in _create(cls, sock, server_side, do_handshake_on_connect, suppress_ragged_eofs, server_hostname, context, session) 1039 raise ValueError("do_handshake_on_connect should not be specified for non-blocking sockets") -> 1040 self.do_handshake() 1041 except (OSError, ValueError): /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/ssl.py in do_handshake(self, block) 1308 self.settimeout(None) -> 1309 self._sslobj.do_handshake() 1310 finally: SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1108) During handling of the above exception, another exception occurred: URLError Traceback (most recent call last) /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/tensorflow/python/keras/utils/data_utils.py in get_file(fname, origin, untar, md5_hash, file_hash, cache_subdir, hash_algorithm, extract, archive_format, cache_dir) 262 try: --> 263 urlretrieve(origin, fpath, dl_progress) 264 except HTTPError as e: /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/urllib/request.py in urlretrieve(url, filename, reporthook, data) 246 --> 247 with contextlib.closing(urlopen(url, data)) as fp: 248 headers = fp.info() /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/urllib/request.py in urlopen(url, data, timeout, cafile, capath, cadefault, context) 221 opener = _opener --> 222 return opener.open(url, data, timeout) 223 /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/urllib/request.py in open(self, fullurl, data, timeout) 524 sys.audit('urllib.Request', req.full_url, req.data, req.headers, req.get_method()) --> 525 response = self._open(req, data) 526 /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/urllib/request.py in _open(self, req, data) 541 protocol = req.type --> 542 result = self._call_chain(self.handle_open, protocol, protocol + 543 '_open', req) /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/urllib/request.py in _call_chain(self, chain, kind, meth_name, *args) 501 func = getattr(handler, meth_name) --> 502 result = func(*args) 503 if result is not None: /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/urllib/request.py in https_open(self, req) 1361 def https_open(self, req): -> 1362 return self.do_open(http.client.HTTPSConnection, req, 1363 context=self._context, check_hostname=self._check_hostname) /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/urllib/request.py in do_open(self, http_class, req, **http_conn_args) 1321 except OSError as err: # timeout error -> 1322 raise URLError(err) 1323 r = h.getresponse() URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1108)> During handling of the above exception, another exception occurred: Exception Traceback (most recent call last) <ipython-input-17-49e15817fb9c> in <module> ----> 1 m_data=mnist.load_data() /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/tensorflow/python/keras/datasets/mnist.py in load_data(path) 56 """ 57 origin_folder = 'https://storage.googleapis.com/tensorflow/tf-keras-datasets/' ---> 58 path = get_file( 59 path, 60 origin=origin_folder + 'mnist.npz', /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/tensorflow/python/keras/utils/data_utils.py in get_file(fname, origin, untar, md5_hash, file_hash, cache_subdir, hash_algorithm, extract, archive_format, cache_dir) 265 raise Exception(error_msg.format(origin, e.code, e.msg)) 266 except URLError as e: --> 267 raise Exception(error_msg.format(origin, e.errno, e.reason)) 268 except (Exception, KeyboardInterrupt) as e: 269 if os.path.exists(fpath): Exception: URL fetch failure on https://storage.googleapis.com/tensorflow/tf-keras-datasets/mnist.npz: None -- [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1108)
該当のソースコード
python
1import tensorflow as tf 2mnist = tf.keras.datasets.mnist 3m_data=mnist.load_data()
試したこと
Exceptionで挙げられているurlに飛んでみると、no such objectと返されます。
しかし、書籍を見ても、他のサイトを見てもソースコードは同じなので困惑しています。
補足情報(FW/ツールのバージョンなど)
実行環境 Jupyter Notebook
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2020/07/05 01:55
2020/07/05 02:05
2020/07/05 02:27