-
Notifications
You must be signed in to change notification settings - Fork 19.5k
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
Conversation
if ( | ||
hasattr(self, "optimizer") | ||
# Exempt legacy optimizers. | ||
and isinstance(self.optimizer, optimizer.Optimizer) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Piper revision: 567432507
Github issues:
https://github.com/keras-team/keras/issues/18278
https://github.com/keras-team/keras/issues/18359