From 600caff5b1aa50b49507e1214b688bcd9426a809 Mon Sep 17 00:00:00 2001 From: Bobholamovic Date: Thu, 17 Aug 2023 19:40:50 +0800 Subject: [PATCH] Suppress scalar teensor warning --- paddlers/utils/stats.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/paddlers/utils/stats.py b/paddlers/utils/stats.py index 33519c75..214b5f19 100644 --- a/paddlers/utils/stats.py +++ b/paddlers/utils/stats.py @@ -49,7 +49,12 @@ def update(self, stats): for k in stats.keys() } for k, v in self.meters.items(): - v.update(stats[k].numpy()) + stat = stats[k] + if stat.ndim == 0: + stat = float(stat) + else: + stat = stat.numpy() + v.update(stat) def get(self, extras=None): stats = collections.OrderedDict()