Skip to content

Commit

Permalink
use inplace sign
Browse files Browse the repository at this point in the history
  • Loading branch information
lucidrains committed Feb 17, 2023
1 parent b67f8d8 commit 5d63c0e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions lion_pytorch/lion_pytorch.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ def update_fn(p, grad, exp_avg, lr, wd, beta1, beta2):

# weight update

update = exp_avg.clone().lerp_(grad, 1 - beta1)
p.add_(torch.sign(update), alpha = -lr)
update = exp_avg.clone().lerp_(grad, 1 - beta1).sign_()
p.add_(update, alpha = -lr)

# decay the momentum running average coefficient

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
setup(
name = 'lion-pytorch',
packages = find_packages(exclude=[]),
version = '0.0.4',
version = '0.0.5',
license='MIT',
description = 'Lion Optimizer - Pytorch',
author = 'Phil Wang',
Expand Down

0 comments on commit 5d63c0e

Please sign in to comment.