gpt4 book ai didi

python - keras中的只读模式

转载 作者:太空狗 更新时间:2023-10-29 20:15:01 28 4
gpt4 key购买 nike

我已经从这个链接 human pose estimation keras 克隆了人体姿势估计 keras 模型

当我尝试在 google colab 上加载模型时,出现以下错误

代码

from keras.models import load_model
model = load_model('model.h5')

错误

ValueError                                Traceback (most recent call 

last)
<ipython-input-29-bdcc7d8d338b> in <module>()
1 from keras.models import load_model
----> 2 model = load_model('model.h5')

/usr/local/lib/python3.6/dist-packages/keras/engine/saving.py in load_model(filepath, custom_objects, compile)
417 f = h5dict(filepath, 'r')
418 try:
--> 419 model = _deserialize_model(f, custom_objects, compile)
420 finally:
421 if opened_new_file:

/usr/local/lib/python3.6/dist-packages/keras/engine/saving.py in _deserialize_model(f, custom_objects, compile)
219 return obj
220
--> 221 model_config = f['model_config']
222 if model_config is None:
223 raise ValueError('No model found in config.')

/usr/local/lib/python3.6/dist-packages/keras/utils/io_utils.py in __getitem__(self, attr)
300 else:
301 if self.read_only:
--> 302 raise ValueError('Cannot create group in read only mode.')
303 val = H5Dict(self.data.create_group(attr))
304 return val

ValueError: Cannot create group in read only mode.

有人可以帮我理解这种只读模式吗?如何加载此模型?

最佳答案

这是在 Google Collab 上为您创建的 Git 要点示例:https://gist.github.com/kolygri/835ccea6b87089fbfd64395c3895c01f

据我了解:

You have to set and define the architecture of your model and then use model.load_weights('alexnet_weights.h5').

这是一个有用的 Github 对话链接,希望能帮助您更好地理解问题: https://github.com/keras-team/keras/issues/6937

关于python - keras中的只读模式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53212672/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com