我正在尝试将.hdf5模型转换为.pb模型。我一直在加载模型。
这是我的代码:
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
如何解决此问题?
答案 0 :(得分:0)
好吧……Keras没有FixedBatchNormalization
层。因此它无法加载此层。
如果您知道该层的代码,请将其传递给custom_objects={'FixedBatchNormalization' : FixedBatchNormalization}
中的load_model
参数。