加载.hdf5模型时出现问题(ValueError:未知层:FixedBatchNormalization) [英] Problem loading .hdf5 model (ValueError: Unknown layer: FixedBatchNormalization)
本文介绍了加载.hdf5模型时出现问题(ValueError:未知层:FixedBatchNormalization)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试将.hdf5模型转换为.pb模型.我一直坚持加载模型.
I'm trying to convert .hdf5 model to .pb model. I'm stuck with loading the model.
这是我的代码:
import keras
keras.models.load_model('./model_frcnn.hdf5')
这是我的错误:
Traceback (most recent call last):
File "/home/qendrim/solaborate/repos/solaborate/Solaborate.ML/scripts/solaborate_scripts/practice.py", line 2, in <module>
keras.models.load_model('./model_frcnn.hdf5')
File "/home/qendrim/anaconda3/envs/hello-ai/lib/python3.7/site-packages/keras/engine/saving.py", line 419, in load_model
model = _deserialize_model(f, custom_objects, compile)
File "/home/qendrim/anaconda3/envs/hello-ai/lib/python3.7/site-packages/keras/engine/saving.py", line 225, in _deserialize_model
model = model_from_config(model_config, custom_objects=custom_objects)
File "/home/qendrim/anaconda3/envs/hello-ai/lib/python3.7/site-packages/keras/engine/saving.py", line 458, in model_from_config
return deserialize(config, custom_objects=custom_objects)
File "/home/qendrim/anaconda3/envs/hello-ai/lib/python3.7/site-packages/keras/layers/__init__.py", line 55, in deserialize
printable_module_name='layer')
File "/home/qendrim/anaconda3/envs/hello-ai/lib/python3.7/site-packages/keras/utils/generic_utils.py", line 145, in deserialize_keras_object
list(custom_objects.items())))
File "/home/qendrim/anaconda3/envs/hello-ai/lib/python3.7/site-packages/keras/engine/network.py", line 1022, in from_config
process_layer(layer_data)
File "/home/qendrim/anaconda3/envs/hello-ai/lib/python3.7/site-packages/keras/engine/network.py", line 1008, in process_layer
custom_objects=custom_objects)
File "/home/qendrim/anaconda3/envs/hello-ai/lib/python3.7/site-packages/keras/layers/__init__.py", line 55, in deserialize
printable_module_name='layer')
File "/home/qendrim/anaconda3/envs/hello-ai/lib/python3.7/site-packages/keras/utils/generic_utils.py", line 138, in deserialize_keras_object
': ' + class_name)
ValueError: Unknown layer: FixedBatchNormalization
如何解决此问题?
推荐答案
好吧……Keras没有FixedBatchNormalization
层.因此它无法加载此层.
Well... Keras does not have a FixedBatchNormalization
layer. So it cannot load this layer.
如果您知道此层的代码,请将其传递给load_model
中的custom_objects={'FixedBatchNormalization' : FixedBatchNormalization}
参数.
If you know the code of this layer, pass it to custom_objects={'FixedBatchNormalization' : FixedBatchNormalization}
parameter in load_model
.
这篇关于加载.hdf5模型时出现问题(ValueError:未知层:FixedBatchNormalization)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文