diff --git a/python/paddle/fluid/imperative/learning_rate_scheduler.py b/python/paddle/fluid/imperative/learning_rate_scheduler.py index b698e6200739f04cb56cc2c2219acfbc493bcff4..3209fa76d95c35c6c5a1bb36801b9f9354b1a927 100644 --- a/python/paddle/fluid/imperative/learning_rate_scheduler.py +++ b/python/paddle/fluid/imperative/learning_rate_scheduler.py @@ -20,7 +20,7 @@ from .. import unique_name __all__ = [ 'NoamDecay', 'PiecewiseDecay', 'NaturalExpDecay', 'ExponentialDecay', - 'InverseTimeDecay', 'CosineDecay' + 'InverseTimeDecay', 'PolynomialDecay', 'CosineDecay' ] @@ -173,12 +173,10 @@ class PolynomialDecay(LearningRateDecay): tmp_decay_steps = self.decay_steps if self.cycle: div_res = layers.ceil( - self.create_lr_var(tmp_step_num / self.decay_steps)) - zero_var = 0.0 - one_var = 1.0 + self.create_lr_var(tmp_step_num / float(self.decay_steps))) - if float(tmp_step_num) == zero_var: - div_res = one_var + if tmp_step_num == 0: + div_res = self.create_lr_var(1.0) tmp_decay_steps = self.decay_steps * div_res else: tmp_step_num = self.create_lr_var(tmp_step_num