From 14573629b06a5bda01a5298fd4b2e1353ab588a5 Mon Sep 17 00:00:00 2001 From: guguguzi <48168743+guguguzi@users.noreply.github.com> Date: Tue, 19 Apr 2022 15:48:45 +0800 Subject: [PATCH] fix bug for MultiplicativeDecay (#41850) * fix bug for MultiplicativeDecay * remove changes to test_lr_scheduler.py --- python/paddle/optimizer/lr.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/python/paddle/optimizer/lr.py b/python/paddle/optimizer/lr.py index d0d5eef03c4..ea4349bc0b2 100644 --- a/python/paddle/optimizer/lr.py +++ b/python/paddle/optimizer/lr.py @@ -1587,7 +1587,7 @@ class MultiplicativeDecay(LRScheduler): verbose) def get_lr(self): - if self.last_epoch > 0: - return self.last_lr * self.lr_lambda(self.last_epoch) - else: - return self.base_lr + cur_lr = self.base_lr + for epoch in range(1, self.last_epoch + 1): + cur_lr = cur_lr * self.lr_lambda(epoch) + return cur_lr -- GitLab