0

I have a CNN that I pruned using Tensorflow. Keras and saved it as a .h5 file.

Now when I try to load it with pr_model=load_model('Pruned_CNN.h5'), I always get the following error:

/tmp/ipykernel_4729/1589964011.py in <module>
----> 1 pmod = tensorflow.keras.models.load_model('Pruned_CNN.h5')

/usr/local/lib/python3.8/dist-packages/keras/utils/traceback_utils.py in error_handler(*args, **kwargs)
     68             # To get the full stack trace, call:
     69             # `tf.debugging.disable_traceback_filtering()`
---> 70             raise e.with_traceback(filtered_tb) from None
     71         finally:
     72             del filtered_tb

/usr/local/lib/python3.8/dist-packages/keras/utils/generic_utils.py in class_and_config_for_serialized_keras_object(config, module_objects, custom_objects, printable_module_name)
    603     cls = get_registered_object(class_name, custom_objects, module_objects)
    604     if cls is None:
--> 605         raise ValueError(
    606             f"Unknown {printable_module_name}: {class_name}. "
    607             "Please ensure this "

ValueError: Unknown layer: PruneLowMagnitude. Please ensure this object is passed to the `custom_objects` argument. See https://www.tensorflow.org/guide/keras/save_and_serialize#registering_the_custom_object for details.

How can I possibly fix this issue?

nechi
  • 53
  • 6

0 Answers0