0

I'm trying to convert .hdf5 model to .pb model. I'm stuck with loading the model.

Here is my code:

import keras
keras.models.load_model('./model_frcnn.hdf5')

Here is my error:

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

How can I fix this problem?

Qendrim Krasniqi
  • 162
  • 1
  • 10

1 Answers1

0

Well... Keras does not have a FixedBatchNormalization layer. So it cannot load this layer.

If you know the code of this layer, pass it to custom_objects={'FixedBatchNormalization' : FixedBatchNormalization} parameter in load_model.

Daniel Möller
  • 84,878
  • 18
  • 192
  • 214
  • I assume that FixedBatchNormalization corresponds to keras.layers.BatchNormalization. Now I have the next problem, and I can't find it's corresponding layer: ``` ValueError: Unknown layer: RoiPoolingConv ``` Any idea? – Qendrim Krasniqi Nov 14 '19 at 13:23
  • Another custom layer, you need the code for all custom layers. Unfortunately Keras will not be able to load custom layers without their custom codes. – Daniel Möller Nov 14 '19 at 14:16
  • @DanielMöller Can you please take a look into this question? https://stackoverflow.com/q/58900947/5904928 I am struggling for hours, couldn't find an answer. – Aaditya Ura Nov 17 '19 at 13:38