Unable to save and load RoBERTa model using tensorflow
I have trained my model with Roberta-base and tested, it works.
But when i try to save the model I get following error:

/usr/local/lib/python3.6/dist-packages/tensorflow/python/saved_model/save.py in list_dependencies(self, obj)
    126                   obj._object_identifier,  # pylint: disable=protected-access
    127                   name,
--> 128                   extra_dependencies.keys()))
    129         yield base.TrackableReference(name, extra_dependencies[name])
    130       else:

ValueError: Error when exporting object <tensorflow.python.keras.layers.core.Activation object at 0x7fef7d287128> of with identifier=_tf_keras_layer. The object has an attribute named regularization_losses, which is reserved. List of all reserved attributes: dict_keys(['regularization_losses', 'variables', 'trainable_variables', 'keras_api'])


Unable to solve it.

Is it some obvious mistake am doing?


# Code:


path = '/path/model_1'
tf.keras.models.save_model(model_roberta_base,path, overwrite=True,include_optimizer=False,save_format='tf')
new_model = tf.keras.models.load_model(path)
result =predct_func(new_model,"Technology driven by Medical imaging and Artificial Intellignence")
plot_result(result)
Hey @kiruthiga-A,

Could you post a complete code example so that we can reproduce the error? If the complete code is too long, a google colab would be super useful.<|||||>This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
<|||||>I have this same exact issue importing a model from HuggingFace