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

Change add_noise to match the target variance by scaling by its sqrt. #294

Merged
merged 4 commits into from
Feb 2, 2022
Merged

Conversation

Rupt
Copy link
Contributor

@Rupt Rupt commented Jan 31, 2022

Resolve issue #281.

Add a test for this noise scaling which fails prior to this change.

@Rupt
Copy link
Contributor Author

Rupt commented Jan 31, 2022

Edited to avoid sqrt after type casting.

Copy link
Member

@mkunesch mkunesch left a comment

Choose a reason for hiding this comment

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

Looks great! Thank you so much for this bug fix and the associated test!
I just left a few very minor comments/nits.

optax/_src/transform.py Outdated Show resolved Hide resolved
optax/_src/transform_test.py Outdated Show resolved Hide resolved
optax/_src/transform_test.py Outdated Show resolved Hide resolved
optax/_src/transform_test.py Outdated Show resolved Hide resolved
Copy link
Member

@mkunesch mkunesch left a comment

Choose a reason for hiding this comment

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

Thanks a lot for making the changes! I forgot to check for chex.all_variants last time so I have one more comment. Otherwise looks good to me!

optax/_src/transform_test.py Outdated Show resolved Hide resolved
optax/_src/transform_test.py Outdated Show resolved Hide resolved
std -> standard_deviation
shape update like params
rename test_add_noise -> test_add_noise_has_correct_variance_scaling
remove parameterization; hard code parameters locally

update with variants
Copy link
Member

@mkunesch mkunesch left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks a lot!

There is a test failure now in the (recently added) test for noisy_sgd in alias_test.py which uses add_noise. Do you have time to look into this? It's probably just a matter of changing the parameters so that with the slower decay of the noise it doesn't affect the test results but we should make sure this is indeed the reason.

@Rupt
Copy link
Contributor Author

Rupt commented Feb 1, 2022

It's probably just a matter of changing the parameters

I've rebased and changed eta to match the previous initial variance. It survives the test with the different decay rate.

but we should make sure this is indeed the reason.

The test passes now (and also passed if just removing the noisy_sgd line).

Copy link
Member

@mkunesch mkunesch left a comment

Choose a reason for hiding this comment

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

Great, thanks a lot for doing this!

@copybara-service copybara-service bot merged commit 877ed66 into google-deepmind:master Feb 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants