I followed all the steps in the video tutorial but the code blows up at
model = tf.keras.models.load_model(model_dir)
model.summary()
raise ValueError(
→ 896 f’Cannot call custom layer {layer.name} of type {type(layer)}, because ’
897 ‘the call function was not serialized to the SavedModel.’
898 ‘Please try one of the following methods to fix this issue:’
ValueError: Exception encountered when calling layer “dropout” (type Dropout).
Cannot call custom layer dropout of type <class ‘keras.saving.saved_model.load.Dropout’>, because the call function was not serialized to the SavedModel.Please try one of the following methods to fix this issue:
(1) Implement get_config
and from_config
in the layer/model class, and pass the object to the custom_objects
argument when loading the model. For more details, see: שמור וטען מודלים של Keras | TensorFlow Core
(2) Ensure that the subclassed model or layer overwrites call
and not __call__
. The input shape and dtype will be automatically recorded when the object is called, and used when saving. To manually specify the input shape/dtype, decorate the call function with @tf.function(input_signature=...)
.
Call arguments received:
• unused_args=(‘tf.Tensor(shape=(None, 784), dtype=float32)’,)
• unused_kwargs={‘training’: ‘None’}