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 the value error typo of AdamW's betas' valid values checking #14780

Merged

Conversation

dourgey
Copy link
Contributor

@dourgey dourgey commented Dec 15, 2021

What does this PR do?

Fixes the value error typo of AdamW's betas' valid values checking(raise ValueError())
"should be in [0.0, 1.0[" -> "should be in [0.0, 1.0]"

Before submitting

  • This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
  • Did you read the contributor guideline,
    Pull Request section?
  • Was this discussed/approved via a Github issue or the forum? Please add a link
    to it if that's the case.
  • Did you make sure to update the documentation with your changes? Here are the
    documentation guidelines, and
    here are tips on formatting docstrings.
  • Did you write any new necessary tests?

Who can review?

Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.

Copy link
Collaborator

@sgugger sgugger left a comment

Choose a reason for hiding this comment

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

The test asserts that betas[0] < 1.0 so it seems like the current error is correct.

@dourgey
Copy link
Contributor Author

dourgey commented Dec 18, 2021

The test asserts that betas[0] < 1.0 so it seems like the current error is correct.

Thanks for your reply.
I mean, that there is a incorrect format of the interval indicates, as shown below:

if I initialize a AdamW optimizer with error betas' values like [0.1, 2], there would raise a ValueError like this:
image

It seems like a incorrect format of the interval indicates. The correct format may should be Invalid beta parameter: 2 - should be in [0.0, 1.0], but the current version is Invalid beta parameter: 2 - should be in [0.0, 1.0[. Is my understanding correct?

And after fixed, the error is shown as follows:

image

@sgugger
Copy link
Collaborator

sgugger commented Dec 20, 2021

No, both beta1 and beta2 are tests to be < 1.0, not <= 1.0, so the upper bound needs to be excluded. If you put 1.0 as a value, you will get the error.

@dourgey
Copy link
Contributor Author

dourgey commented Dec 21, 2021

No, both beta1 and beta2 are tests to be < 1.0, not <= 1.0, so the upper bound needs to be excluded. If you put 1.0 as a value, you will get the error.

Yeah you are right. I made a mistake on this. Besides, my question is the error message should be in [0.0, 1.0[ is a correct expression form of [0.0, 1.0) or a spelling mistake? I see that the expression form in original paper of Adam is:

image

If it's a spelling mistake, I submit a new commit, please have a look, thanks a lot.

@sgugger
Copy link
Collaborator

sgugger commented Dec 21, 2021

It's the European (or at least French, not sure about all the neighbors!) way of writing an interval without the upper bound, yours is the American way ;-)

It's more inline with the paper so let's take yours.

@sgugger sgugger merged commit 0062058 into huggingface:master Dec 21, 2021
Albertobegue pushed a commit to Albertobegue/transformers that referenced this pull request Jan 27, 2022
…gingface#14780)

* Fix the value error typo of AdamW's betas value check

* error fixed
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.

2 participants