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

[Refactor] Ranger21 optimizer #28

Merged
merged 4 commits into from
Sep 23, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
refactor: Ranger21 optimizer
  • Loading branch information
kozistr committed Sep 23, 2021
commit 715ede880eb6f21109b50ced8e723b33484d1f9f
3 changes: 2 additions & 1 deletion pytorch_optimizer/ranger21.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ def __init__(

defaults: DEFAULTS = dict(
lr=lr,
beta0=beta0,
betas=betas,
eps=eps,
weight_decay=weight_decay,
Expand Down Expand Up @@ -222,6 +221,8 @@ def step(self, closure: CLOSURE = None) -> LOSS:

bias_correction2 = 1 - beta2 ** state['step']

# second moment estimation
# using positive-negative momentum and bias correction
variance_ma = state['variance_ma']
variance_ma.mul_(beta2).addcmul_(grad, grad, value=1 - beta2)
variance_ma_sum += (variance_ma / bias_correction2).sum()
Expand Down