简体   繁体   English

如何在新的 Colab 笔记本中加载 SavedModel?

[英]How to load a SavedModel in a new Colab notebook?

I am using Google Colab.我正在使用谷歌 Colab。 In a first notebook, I saved my model using: model.save('my_model.h5') .在第一个笔记本中,我使用model.save('my_model.h5')保存了我的 model。 In the same notebook, I can see that the model is stored.在同一个笔记本中,我可以看到存储了 model。 Input: ls -d $PWD/* Output: /content/my_model.h5输入: ls -d $PWD/* Output: /content/my_model.h5

In the same notebook, I can restore the saved model by using: model = tf.keras.models.load_model('my_model.h5')在同一个笔记本中,我可以使用以下命令恢复保存的 model: model = tf.keras.models.load_model('my_model.h5')

But if I want to load the same model in a new notebook, I got an error message.但是,如果我想在新笔记本中加载相同的 model,则会收到一条错误消息。 Input:输入:

from keras.models import load_model
new_model = tf.keras.models.load_model('/content/my_model.h5')

Error message:错误信息:

OSError: SavedModel file does not exist at: /content/my_model.h5/{saved_model.pbtxt|saved_model.pb} OSError:SavedModel 文件不存在于:/content/my_model.h5/{saved_model.pbtxt|saved_model.pb}

Thanks for your help,谢谢你的帮助,

Boris鲍里斯

Each notebook is on a different machine.每个笔记本都在不同的机器上。 You need to save it on google drive, using drive.mount("drive").您需要使用 drive.mount("drive") 将其保存在谷歌驱动器上。 Then you can share the model across different notebooks.然后您可以在不同的笔记本电脑之间共享 model。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何将 TensorRT SavedModel 加载到 TensorFlow Estimator? - How to load a TensorRT SavedModel to a TensorFlow Estimator? 如何使用 Tensorflow 从安装的谷歌驱动器加载谷歌 Colab 笔记本中的图像 - How to load images in Google Colab notebook using Tensorflow from mounted Google drive 继续在 SavedModel 上训练或从 SavedModel 加载检查点 - Continue training on SavedModel or load checkpoint from SavedModel 如何在 google colab 上运行 notebook(抛出错误) - How to run the notebook on google colab (throws an error) 如何在 google colab 上创建一个 swift notebook - How to create a swift notebook on google colab 如何使用'predict'Sgnature Def在Java中加载Tensorflow SavedModel? - How can I load a Tensorflow SavedModel in Java with 'predict' Sgnature Def? 如何在Google Colab中将helper.py上传到Tensorflow 2.0笔记本 - How to upload helper.py to Tensorflow 2.0 notebook in Google colab 如何将 Flutter 应用程序与 ipynb/colab 笔记本集成? - How do I integrate a Flutter application with ipynb/colab notebook? 如何通过export_savedmodel保存一个tensorflow estimator,然后在本地加载和使用? - How to save a tensorflow estimator by export_savedmodel, then load and use it locally later? 如何加载在 google colab 上训练的模型 - How to load a model trained on google colab
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM