From 03511689670ee3d4652fd36d8e610703b3c6fb7b Mon Sep 17 00:00:00 2001 From: LielinJiang <50691816+LielinJiang@users.noreply.github.com> Date: Thu, 29 Oct 2020 09:36:34 +0800 Subject: [PATCH] Fix lr scheduler step error in hapi when use static mode (#28297) * fix lr scheduler * fix code style --- python/paddle/hapi/model.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/python/paddle/hapi/model.py b/python/paddle/hapi/model.py index ff962fb1c1d..aa99d698bc7 100644 --- a/python/paddle/hapi/model.py +++ b/python/paddle/hapi/model.py @@ -454,7 +454,8 @@ class StaticGraphAdapter(object): rets.insert(i, feed[name]) # step learning rate scheduler on each batch end - if self.model._optimizer and \ + if self.model._optimizer and self.mode == 'train' and \ + hasattr(self.model._optimizer, '_learning_rate') and \ isinstance(self.model._optimizer._learning_rate, paddle.optimizer.lr.LRScheduler): self.model._optimizer._learning_rate.step() -- GitLab