problem on reload model
rslu2000 opened this issue · comments
Dear Ashrefm,
The problem comes when I try to reload the model:
“reloaded = tf.keras.models.load_model(export_path, custom_objects={‘KerasLayer’:hub.KerasLayer})”
It return the error message: “ValueError: Unable to restore custom object of type _tf_keras_metric currently. Please make sure that the layer implements get_config
and from_config
when saving. In addition, please use the custom_objects
arg when calling load_model()
.”
Could you give me some help? thanks a lot.
_Raymond Lu
BTW, the command "tf.keras.experimental.load_from_saved_model" is not workig. then I comment it out.
reloaded = tf.keras.experimental.load_from_saved_model(export_path, custom_objects={'KerasLayer':hub.KerasLayer})
So, I used "tf.keras.models.load_model" instead of "tf.keras.experimental.load_from_saved_model".
like as following:
tf.keras.models.load_model(export_path, custom_objects={'loss':macro_soft_f1,'metrics':[macro_f1]}, compile='False')
above problem happened on tensorflow 2.2