From 30cbb1832157dc75a1e8c33f9a06c696e3d0f497 Mon Sep 17 00:00:00 2001 From: HydrogenSulfate <490868991@qq.com> Date: Mon, 17 Oct 2022 15:51:48 +0800 Subject: [PATCH] update learning_rate.py --- ppcls/optimizer/learning_rate.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/ppcls/optimizer/learning_rate.py b/ppcls/optimizer/learning_rate.py index 958983f27..58195477f 100644 --- a/ppcls/optimizer/learning_rate.py +++ b/ppcls/optimizer/learning_rate.py @@ -14,7 +14,7 @@ from __future__ import (absolute_import, division, print_function, unicode_literals) - +import types from abc import abstractmethod from typing import Union @@ -466,5 +466,12 @@ class ReduceOnPlateau(LRBase): if self.warmup_steps > 0: learning_rate = self.linear_warmup(learning_rate) + # NOTE: Implement get_lr() method for class `ReduceOnPlateau`, + # which is called in `log_info` function + def get_lr(self): + return self.last_lr + + learning_rate.get_lr = types.MethodType(get_lr, learning_rate) + setattr(learning_rate, "by_epoch", self.by_epoch) return learning_rate