提交 ae96c979 编写于 作者: G gaotingquan 提交者: Tingquan Gao

always log 'topk=1' when k < output_dims to ensure consistent log formatting

上级 eddba911
......@@ -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.
先完成此消息的编辑!
想要评论请 注册