未验证 提交 b34ed837 编写于 作者: T Tingquan Gao 提交者: GitHub

always log 'topk=1' when k < output_dims to ensure consistent log formatting (#2925)

上级 28ef1c00
......@@ -54,8 +54,9 @@ class TopkAcc(AvgMetrics):
metric_dict = dict()
for idx, k in enumerate(self.topk):
if output_dims < k:
msg = f"The output dims({output_dims}) is less than k({k}), and the argument {k} of Topk has been removed."
msg = f"The output dims({output_dims}) is less than k({k}), so the Top-{k} metric is meaningless."
logger.warning(msg)
metric_dict[f"top{k}"] = 1
self.avg_meters.pop(f"top{k}")
continue
metric_dict[f"top{k}"] = paddle.metric.accuracy(x, label, k=k)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册