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

Fix legacy optimizer handling in compile_from_config(). #18492

Merged
merged 2 commits into from Sep 25, 2023

Conversation

nkovela1
Copy link
Contributor

if (
hasattr(self, "optimizer")
# Exempt legacy optimizers.
and isinstance(self.optimizer, optimizer.Optimizer)
Copy link
Member

Choose a reason for hiding this comment

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

Is it every possible to pass an optimizer that isn't an Optimizer instance? Wouldn't that blow up?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

All custom optimizers that need to be built on deserialization must subclass from Optimizer afaik, and legacy optimizers (which do not) are exempted here because they do not have a corresponding build method.

Is there any edge case in particular you are referring to? The corresponding CL did not cause any TGP issues.

Copy link
Member

Choose a reason for hiding this comment

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

Legacy optimizers simply don't exist in Keras 3, do they?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This PR is actually for the Keras 2.15 release, so legacy optimizers still exist in this revision actually (merging into the cherrypick branch).

Copy link
Member

Choose a reason for hiding this comment

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

Got it, I had not noticed this was in the 2.15 branch.

Copy link
Member

@fchollet fchollet left a comment

Choose a reason for hiding this comment

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

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants