From 332469f002332a147b8bbd5a82113142b17fe31b Mon Sep 17 00:00:00 2001 From: juncaipeng <13006307475@163.com> Date: Thu, 16 Jun 2022 21:18:06 +0800 Subject: [PATCH 1/2] subtract the warmup iters for PolynomialDecay --- paddleseg/cvlibs/config.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/paddleseg/cvlibs/config.py b/paddleseg/cvlibs/config.py index 0cefb55701..1597440e42 100644 --- a/paddleseg/cvlibs/config.py +++ b/paddleseg/cvlibs/config.py @@ -155,7 +155,7 @@ def lr_scheduler(self) -> paddle.optimizer.lr.LRScheduler: params = self.dic.get('lr_scheduler') use_warmup = False - if 'warmup_iters' in params: + if 'warmup_iters' in params and 'warmup_start_lr' in params: use_warmup = True warmup_iters = params.pop('warmup_iters') warmup_start_lr = params.pop('warmup_start_lr') @@ -163,7 +163,8 @@ def lr_scheduler(self) -> paddle.optimizer.lr.LRScheduler: lr_type = params.pop('type') if lr_type == 'PolynomialDecay': - params.setdefault('decay_steps', self.iters) + iters = self.iters - warmup_iters if use_warmup else self.iters + params.setdefault('decay_steps', iters) params.setdefault('end_lr', 0) params.setdefault('power', 0.9) lr_sche = getattr(paddle.optimizer.lr, lr_type)(**params) From b34ca0ef5aab87f313a4e018a1fa5157264f5a64 Mon Sep 17 00:00:00 2001 From: juncaipeng <13006307475@163.com> Date: Thu, 16 Jun 2022 21:25:18 +0800 Subject: [PATCH 2/2] up --- paddleseg/cvlibs/config.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/paddleseg/cvlibs/config.py b/paddleseg/cvlibs/config.py index 1597440e42..4f924f324a 100644 --- a/paddleseg/cvlibs/config.py +++ b/paddleseg/cvlibs/config.py @@ -155,9 +155,10 @@ def lr_scheduler(self) -> paddle.optimizer.lr.LRScheduler: params = self.dic.get('lr_scheduler') use_warmup = False - if 'warmup_iters' in params and 'warmup_start_lr' in params: + if 'warmup_iters' in params: use_warmup = True warmup_iters = params.pop('warmup_iters') + assert 'warmup_start_lr' in params, "Please set warmup_start_lr in lr_scheduler" warmup_start_lr = params.pop('warmup_start_lr') end_lr = params['learning_rate']