From c32e2b098aaf2e45dae8c97d133283931f5e4ee5 Mon Sep 17 00:00:00 2001 From: Yang Nie Date: Thu, 9 Mar 2023 05:03:24 +0800 Subject: [PATCH] Revert "Speedup EMA" This reverts commit 35fc732dadac4761852b18512b5c5df8785e36df. --- ppcls/utils/ema.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/ppcls/utils/ema.py b/ppcls/utils/ema.py index 7f356b88..9a3b65cc 100644 --- a/ppcls/utils/ema.py +++ b/ppcls/utils/ema.py @@ -32,14 +32,11 @@ class ExponentialMovingAverage(): @paddle.no_grad() def _update(self, model, update_fn): - for ema_v, model_v in zip(self.module.state_dict().values(), - model.state_dict().values()): - ema_v.set_value(update_fn(ema_v.numpy(), model_v.numpy())) + for ema_v, model_v in zip(self.module.state_dict().values(), model.state_dict().values()): + ema_v.set_value(update_fn(ema_v, model_v)) def update(self, model): - self._update( - model, - update_fn=lambda e, m: self.decay * e + (1. - self.decay) * m) + self._update(model, update_fn=lambda e, m: self.decay * e + (1. - self.decay) * m) def set(self, model): - self._update(model, update_fn=lambda e, m: m) + self._update(model, update_fn=lambda e, m: m) \ No newline at end of file -- GitLab