簡體   English   中英

MNIST 時尚數據集未加載

[英]MNIST fashion dataset not loading

我正在通過使用 MNIST 數據集來預測某種衣服是什么類型的 ML/Tensorflow hello world,但是當我嘗試使用 data.load_data() 將數據加載到我的母鹿時,它給了我這個錯誤:

使用 TensorFlow 后端。 https://storage.googleapis.com/tensorflow/tf-keras-datasets/train-labels-idx1-ubyte.gz Traceback 下載數據(最近一次調用):文件“/Library/Frameworks/Python.framework/Versions /3.7/lib/python3.7/urllib/request.py", line 1317, in do_open encode_chunked=req.has_header('Transfer-encoding')) 文件 "/Library/Frameworks/Python.framework/Versions/3.7/lib /python3.7/http/client.py", line 1229, in request self._send_request(method, url, body, headers, encode_chunked) File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3. 7/http/client.py”,第 1275 行,在 _send_request self.endheaders(body, 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) 文件“/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py”,第 1016 行,在 _send_output self.send(msg) 文件 "/Library/Frameworks/Python.framework/Versi ons/3.7/lib/python3.7/http/client.py”,第 956 行,發送 self.connect() 文件“/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/ client.py", line 1392, in connect server_hostname=server_hostname) 文件 "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/ssl.py", line 412, in wrap_socket session=session File " /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/ssl.py", line 853, in _create self.do_handshake() 文件"/Library/Frameworks/Python.framework/Versions/3.7/lib /python3.7/ssl.py", line 1117, in do_handshake self._sslobj.do_handshake() ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] 證書驗證失敗:無法獲得本地頒發者證書 (_ssl.c:1056)

在處理上述異常的過程中,又發生了一個異常:

回溯(最近一次通話):文件“/Users/ NAME /MNISTifying Clothing Predictor/lib/python3.7/site-packages/tensorflow_core/python/keras/utils/data_utils.py”,第 264 行,在 get_file urlretrieve(origin , fpath, dl_progress) 文件“/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/urllib/request.py”,第 247 行,在 urlretrieve 中,帶有 contextlib.closure(urlopen(url, data))作為 fp: File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/urllib/request.py", line 222, in urlopen return opener.open(url, data, timeout) File "/ Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/urllib/request.py", line 525, in open response = self._open(req, data) File "/Library/Frameworks/Python.framework /Versions/3.7/lib/python3.7/urllib/request.py", line 543, in _open '_open', req) 文件"/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/ urllib/request.py", line 503, in _call_chain result = func(*args) File "/Library/Frameworks/Python.framework/Versions/3.7/l ib/python3.7/urllib/request.py", line 1360, in https_open context=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:

在處理上述異常的過程中,又發生了一個異常:

回溯(最近一次調用):文件“/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 路徑中.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)

這是我的代碼: 這是我輸入的代碼:

將 tensorflow 作為 tf 從 tensorflow 導入 keras 從 keras.datasets import fashion_mnist import numpy as np import matplotlib.pyplot as plt

數據 = keras.datasets.fashion_mnist

(train_images, train_labels), (test_images, test_labels) = data.load_data()

打印(train_labels 1

您在下面提供的代碼工作正常,

import tensorflow as tf 
from tensorflow import keras 
from keras.datasets import fashion_mnist 
import numpy as np 
import matplotlib.pyplot as plt

data = keras.datasets.fashion_mnist

(train_images, train_labels), (test_images, test_labels) = data.load_data()

print(train_labels)

但是當您從特定網站下載數據時,該瀏覽器會限制您。請參考此鏈接以修復 SSLCertVerificationError。 關聯

轉到您的 Python 文件夾並找到一個名為Install Certificates.command的腳本。 雙擊運行它,它將安裝一個名為certifi 此工具將為您處理 SSL 認證。

如果您使用的是 Mac,它位於: /Applications/Python\\ 3.6/Install\\ Certificates.command

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM