philipperemy / keras-tcn

Keras Temporal Convolutional Network.
MIT License
1.87k stars 454 forks source link

ValueError: Unknown layer: TCN when trying to load saved model #235

Closed soso-maitha closed 2 years ago

soso-maitha commented 2 years ago

Hello,

I get the following error after loading the model. I don't get this error with other saved models. Kindly advise as I have sumbssion shortly and I took more than 5 hours to train a complex model I don't have time.

Thank you very much in advance

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
[<ipython-input-15-acb631543b3f>](https://localhost:8080/#) in <module>()
      1 from tensorflow.keras.models import load_model
----> 2 savedModel=load_model("drive/MyDrive/Colab Notebooks/models/tcn_model7.h5")
      3 #savedModel.summary()

1 frames
[/usr/local/lib/python3.7/dist-packages/keras/utils/generic_utils.py](https://localhost:8080/#) in class_and_config_for_serialized_keras_object(config, module_objects, custom_objects, printable_module_name)
    561   if cls is None:
    562     raise ValueError(
--> 563         f'Unknown {printable_module_name}: {class_name}. Please ensure this '
    564         'object is passed to the `custom_objects` argument. See '
    565         'https://www.tensorflow.org/guide/keras/save_and_serialize'

ValueError: Unknown layer: TCN. 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.
psomers3 commented 2 years ago

Take a look how this is done here: https://github.com/philipperemy/keras-tcn/blob/master/tasks/save_reload_sequential_model.py

soso-maitha commented 2 years ago

thanks a lot for your prompt support it is working. i will reference your code and paper in my report. Great work!

philipperemy commented 2 years ago

@psomers3 Thanks a lot for helping out!