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

Clarification regarding adding 1e-12 while calculating the scale #14

Closed
sayakpaul opened this issue Feb 23, 2021 · 3 comments
Closed

Clarification regarding adding 1e-12 while calculating the scale #14

sayakpaul opened this issue Feb 23, 2021 · 3 comments
Labels
question Further information is requested

Comments

@sayakpaul
Copy link

Hi @davda54. Thank you for open-sourcing this implementation.

Wanted to know the reason behind adding 1e-12 in https://github.com/davda54/sam/blob/main/sam.py#L18?

@davda54
Copy link
Owner

davda54 commented Feb 23, 2021

Hi, thanks! :) A small positive number is added to the denominator for numerical stability — to avoid division by zero when grad_norm == 0.0.

@sayakpaul
Copy link
Author

I see. That is what I had thought too. Thank you for confirming.

I am also assuming your e_w calculation is with respect to L2 norm as the authors assert that they get the optimal results with that?

@davda54
Copy link
Owner

davda54 commented Feb 23, 2021

Exactly, I assume that p == q == 2 (similarly to the paper), which simplifies the equations.

@davda54 davda54 added the question Further information is requested label Mar 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants