From 83f11ba02da50dc12d4ceef91be4968fea31fd5e Mon Sep 17 00:00:00 2001 From: Guanghua Yu <742925032@qq.com> Date: Mon, 1 Feb 2021 16:46:44 +0800 Subject: [PATCH] fix init_metrics and prune (#2153) --- dygraph/ppdet/engine/trainer.py | 3 +++ dygraph/ppdet/slim/prune.py | 3 +++ 2 files changed, 6 insertions(+) diff --git a/dygraph/ppdet/engine/trainer.py b/dygraph/ppdet/engine/trainer.py index 443e56451..33aaaaba2 100644 --- a/dygraph/ppdet/engine/trainer.py +++ b/dygraph/ppdet/engine/trainer.py @@ -110,6 +110,9 @@ class Trainer(object): self._compose_callback = None def _init_metrics(self): + if self.mode == 'test': + self._metrics = [] + return if self.cfg.metric == 'COCO': self._metrics = [COCOMetric(anno_file=self.dataset.get_anno())] elif self.cfg.metric == 'VOC': diff --git a/dygraph/ppdet/slim/prune.py b/dygraph/ppdet/slim/prune.py index 15c44a2e8..2d01e30a8 100644 --- a/dygraph/ppdet/slim/prune.py +++ b/dygraph/ppdet/slim/prune.py @@ -49,6 +49,9 @@ class Pruner(object): self.print_params = print_params def __call__(self, model): + # FIXME: adapt to network graph when Training and inference are + # inconsistent, now only supports prune inference network graph. + model.eval() paddleslim = try_import('paddleslim') from paddleslim.analysis import dygraph_flops as flops input_spec = [{ -- GitLab