Skip to content

Commit

Permalink
fix wd for sparse
Browse files Browse the repository at this point in the history
  • Loading branch information
DenisVorotyntsev committed Oct 1, 2022
1 parent 02e6624 commit d95c8dd
Show file tree
Hide file tree
Showing 3 changed files with 168 additions and 181 deletions.
342 changes: 164 additions & 178 deletions notebooks/test_adan.ipynb

Large diffs are not rendered by default.

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="adan-tensorflow",
packages=find_packages(exclude=[]),
version="1.0.0",
version="1.0.1",
license="MIT",
description="Adan - (ADAptive Nesterov momentum algorithm) Optimizer in Tensorflow",
author="Denis Vorotyntsev",
Expand Down
5 changes: 3 additions & 2 deletions tf_adan/adan.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,10 +211,11 @@ def _resource_apply_sparse(self, grad, var, indices, apply_state=None):
(exp_avg / bias_correction1 + beta2 * exp_avg_diff / bias_correction2)
) / denom

var_update = var.assign_sub(var_update * lr) / (1 + lr * weight_decay)
var_updated = var - var_update * lr
var_updated = var_updated / (1 + lr * weight_decay)
return tf.group(
*[
var_update,
var.assign(var_updated, use_locking=self._use_locking),
exp_avg,
exp_avg_diff,
exp_avg_sq,
Expand Down

0 comments on commit d95c8dd

Please sign in to comment.