我使用这行代码加载mnist数据集,并从tensorflow文档中获取了它。
(trainX, trainY), (testX, testY) = load_data(path='mnist.npz')
但是当我执行文件时,证书出现错误
我得到的错误
Traceback (most recent call last):
File "mnist_degit.py", line 18, in <module>
(trainX, trainY), (testX, testY) = load_data(path='mnist.npz')
File "/Users/muongkimhong/Desktop/ComputerVision_project/DigitRecognize/digit_recognize_env/lib/python3.7/site-packages/tensorflow/python/keras/datasets/mnist.py", line 62, in load_data
'731c5ac602752760c8e48fbffcf8c3b850d9dc2a2aedcf2cc48468fc17b673d1')
File "/Users/muongkimhong/Desktop/ComputerVision_project/DigitRecognize/digit_recognize_env/lib/python3.7/site-packages/tensorflow/python/keras/utils/data_utils.py", line 267, in get_file
raise Exception(error_msg.format(origin, e.errno, e.reason))
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:1076)
有人可以帮忙吗?
答案 0 :(得分:1)
也许您可以尝试这个。
import tensorflow as tf
(trainX, trainY), (testX, testY) = tf.keras.datasets.mnist.load_data()
希望它可以为您提供帮助。
答案 1 :(得分:0)
您可以尝试以下方法:
import tensorflow as tf
(x_train, y_train), (x_test, y_test) = tf.keras.datasets.mnist.load_data(path='mnist.npz')
或
import tensorflow as tf
(x_train, y_train), (x_test, y_test) = tf.compat.v1.keras.datasets.mnist.load_data()