Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added few lines of code in Keras Custom model to fix the error #2278

Merged
merged 3 commits into from
Oct 18, 2023

Conversation

RenuPatelGoogle
Copy link
Contributor

Added 2 lines of code import keras,
@keras.saving.register_keras_serializable() on top of the Keras Custom model definition because it shows TypeError - "Make sure custom classes are decorated with @keras.saving.register_keras_serializable()" while reloading the model after saving as .keras.

As mentioned in this Saving Custom objects definition.

Please refer to this replicated working code gist for your reference. Thank you.

Added 2 lines of code `import keras`,
`@keras.saving.register_keras_serializable()` on top of the Keras Custom model definition because it shows typeerror - "Make sure custom classes are decorated with `@keras.saving.register_keras_serializable()`" after reloading the model when saving as `.keras`.

As mentioned in this Saving [Custom objects](https://www.tensorflow.org/guide/keras/serialization_and_saving#custom_objects) definition.

Please refer to this replicated working code [gist](https://colab.research.google.com/gist/RenuPatelGoogle/f124503c52144c5ed6e9c79cffcb593d/intro_to_modules.ipynb#scrollTo=hpW-4Dj3Q1Rb) for your reference. Thank you.
@RenuPatelGoogle RenuPatelGoogle requested a review from a team as a code owner October 16, 2023 17:27
@github-actions
Copy link

Preview

Preview and run these notebook edits with Google Colab: Rendered notebook diffs available on ReviewNB.com.

Format and style

Use the TensorFlow docs notebook tools to format for consistent source diffs and lint for style:
$ python3 -m pip install -U --user git+https://github.com/tensorflow/docs

$ python3 -m tensorflow_docs.tools.nbfmt notebook.ipynb
$ python3 -m tensorflow_docs.tools.nblint --arg=repo:tensorflow/docs notebook.ipynb
If commits are added to the pull request, synchronize your local branch: git pull origin patch-27

MarkDaoust
MarkDaoust previously approved these changes Oct 16, 2023
Copy link
Member

@MarkDaoust MarkDaoust left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: usually we put imports up in the main import cell.

Added keras import on top of the code.
@RenuPatelGoogle
Copy link
Contributor Author

Nit: usually we put imports up in the main import cell.

@MarkDaoust , Sure. Added the keras import code line on top of the code in the main import cell. Thank you.

@MarkDaoust MarkDaoust added the ready to pull Start merge process label Oct 17, 2023
@copybara-service copybara-service bot merged commit 008b211 into tensorflow:master Oct 18, 2023
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready to pull Start merge process
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants