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 "amsgrad" is used before being defined when initializing the AdamW optimizer #660

Merged
merged 3 commits into from
Mar 29, 2024

Conversation

CloudyDory
Copy link
Contributor

When initializing the "AdamW" optimizer, property "amsgrad" is used before it is defined. Therefore the following code generates error: AttributeError: 'AdamW' object has no attribute 'amsgrad'.

import brainpy as bp
import brainpy.math as bm

weights = {'weight': bm.TrainVar(bm.zeros(10))}
optimizer = bp.optim.AdamW(lr=0.01, train_vars=weights)

This PR fixes this error.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)

Checklist

  • Code follows the code style of this project.
  • Changes follow the CONTRIBUTING guidelines.
  • Update necessary documentation accordingly.
  • Lint and tests pass locally with the changes.
  • Check issues and pull requests first. You don't want to duplicate effort.

@chaoming0625 chaoming0625 self-requested a review March 29, 2024 06:52
Copy link
Collaborator

@chaoming0625 chaoming0625 left a comment

Choose a reason for hiding this comment

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

Thanks for the fixing.

@chaoming0625 chaoming0625 merged commit b06d80a into brainpy:master Mar 29, 2024
16 of 18 checks passed
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