[英]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.