英文:
miniconda3 -> Jupyter -> tensorflow-hub -> [SSL: CERTIFICATE_VERIFY_FAILED]
问题
当我尝试从tensorflow hub加载模型时:
```python
输入形状 = [无,IMG_SIZE,IMG_SIZE,3]
输出形状 = len(unique_labels)
模型网址 = "https://tfhub.dev/google/imagenet/mobilenet_v2_130_224/classification/5"
def create_model(input_shape, output_shape, model_url):
print("使用以下构建模型:", model_url)
model = tf.keras.Sequential([
hub.KerasLayer(model_url), # 第1层,输入层
tf.keras.layers.Dense(units=output_shape,
activation="softmax")
])
model.compile(
loss = tf.keras.losses.CategoricalCrossentropy(),
optimizer = tf.keras.optimizers.Adam(),
metrics=["accuracy"]
)
model.build(input_shape)
return model
model = create_model(INPUT_SHAPE, OUTPUT_SHAPE, MODEL_URL)
我收到以下错误信息:“SSLCertVerificationError ...”,最后显示:“URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1129)>”。
我知道这里曾经有过类似的问题,但我没有安装Certificate.command脚本(可能是因为我在Windows上),而且我已经安装了certifi。
我刚刚下载了64位的miniconda3 for windows,并按照Microsoft的教程安装了tensorflow-directml-plugin。
之后我执行了:pip install jupyter pandas numpy scikit-learn tensorflow-hub matplotlib
在启动jupyter notebook并尝试运行我的代码后,出现了这个错误。
certifi.where()返回:'C:\Users\djord\miniconda3\envs\tfdml_plugin\lib\site-packages\certifi\cacert.pem'。
我不知道如何解决这个问题。
<details>
<summary>英文:</summary>
When I try to load a model from tensorflow hub like:
```python
INPUT_SHAPE = [None, IMG_SIZE, IMG_SIZE, 3]
OUTPUT_SHAPE = len(unique_labels)
MODEL_URL = "https://tfhub.dev/google/imagenet/mobilenet_v2_130_224/classification/5"
def create_model(input_shape, output_shape, model_url):
print("Building model with:", model_url)
model = tf.keras.Sequential([
hub.KerasLayer(model_url), # Layer 1, the input layer
tf.keras.layers.Dense(units=output_shape,
activation="softmax")
])
model.compile(
loss = tf.keras.losses.CategoricalCrossentropy(),
optimizer = tf.keras.optimizers.Adam(),
metrics=["accuracy"]
)
model.build(input_shape)
return model
model = create_model(INPUT_SHAPE, OUTPUT_SHAPE, MODEL_URL)
I get the following error: "SSLCertVerificationError ..." and at the end of it: "URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1129)>" .
I know there have been similar problems posted here, but i dont have the install Certificate.command script(meybe because I'm on windows), and I have installed certifi.
I just downloaded 64 bit miniconda3 for windows, and I followed Microsoft tutorial for tensorflow-directml-plugin.
After that I did: pip install jupyter pandas numpy scikit-learn tensorflow-hub matplotlib
And after launching jupyter notebook and trying to run my code this error popped up.
certifi.where() returns: 'C:\Users\djord\miniconda3\envs\tfdml_plugin\lib\site-packages\certifi\cacert.pem'
I have no idea how to fix this.
答案1
得分: 0
我简单地通过删除python、miniconda3和所有缓存来解决了这个问题。重新安装后,一切都正常工作。
英文:
For anyone seeing this, I simply solved the issue by deleting python, miniconda3 and all caches. After installing it all back, it just worked.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论