From 0adc553aaa10f105bb338d4505c8bdc447025724 Mon Sep 17 00:00:00 2001 From: wangxinxin08 <69842442+wangxinxin08@users.noreply.github.com> Date: Fri, 7 May 2021 11:52:16 +0800 Subject: [PATCH] fix problem while applying ema without training (#2839) --- ppdet/optimizer.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ppdet/optimizer.py b/ppdet/optimizer.py index dfb49e9cc..1fcfbf856 100644 --- a/ppdet/optimizer.py +++ b/ppdet/optimizer.py @@ -248,6 +248,8 @@ class ModelEMA(object): self.step += 1 def apply(self): + if self.step == 0: + return self.state_dict state_dict = dict() for k, v in self.state_dict.items(): v = v / (1 - self._decay**self.step) -- GitLab