From b06d80a3fccf47b823539931a21a4e46cb87177f Mon Sep 17 00:00:00 2001 From: yunhui <38786521+CloudyDory@users.noreply.github.com> Date: Fri, 29 Mar 2024 14:52:45 +0800 Subject: [PATCH] Fix "amsgrad" is used before being defined when initializing the AdamW optimizer (#660) * Fix delayvar not correct in concat mode * Update AdamW in optimizer.py Fixed "amsgrad" is used before being defined. --- brainpy/_src/optimizers/optimizer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/brainpy/_src/optimizers/optimizer.py b/brainpy/_src/optimizers/optimizer.py index c2aec25a0..75dfef124 100644 --- a/brainpy/_src/optimizers/optimizer.py +++ b/brainpy/_src/optimizers/optimizer.py @@ -901,6 +901,7 @@ def __init__( amsgrad: bool = False, name: Optional[str] = None, ): + self.amsgrad = amsgrad super(AdamW, self).__init__(lr=lr, train_vars=train_vars, weight_decay=weight_decay, @@ -919,7 +920,6 @@ def __init__( self.beta2 = beta2 self.eps = eps self.weight_decay = weight_decay - self.amsgrad = amsgrad def __repr__(self): return (f"{self.__class__.__name__}(lr={self.lr}, "