-
Notifications
You must be signed in to change notification settings - Fork 614
RectifiedAdam: Store 'total_steps' hyperparameter as float #2369
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
Conversation
You are owner of some files modified in this pull request. |
The tests fail because |
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.
Thanks! Can you add a test that failed before the fix?
a0f3d4e
to
519cb5b
Compare
It is a little bit confusing as a float. |
That's what I thought. But if the constructor takes an int but stores it as a float internally, the tests fail because the optimizer can't be restored. |
This comment has been minimized.
This comment has been minimized.
519cb5b
to
84e67f0
Compare
All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter. We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the ℹ️ Googlers: Go here for more info. |
All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter. We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the ℹ️ Googlers: Go here for more info. |
@googlebot I consent |
Description
When restoring the RectifiedAdam optimizer from a checkpoint, restoring fails with the following error message:
ValueError: Tensor conversion requested dtype float32 for Tensor with dtype int32: <tf.Tensor: shape=(), dtype=int32, numpy=0>
The reason is that RectifiedAdam stores
total_steps
as an integer hyper-parameter:https://github.com/tensorflow/addons/blob/master/tensorflow_addons/optimizers/rectified_adam.py#L134
OptimizerV2 however creates variables by calling
add_weight
without a dtype in_create_hypers
. In other words, it assumes that all hyper-parameters are floating point parameters.Fixes #2361
Type of change
Checklist:
How Has This Been Tested?
I have trained a neural network with this optimizer and resumed training in between. Without this change, restoring fails with the error message from above. With this change, it works as intended.