【问题标题】:Get class with highest score获得最高分的班级
【发布时间】:2017-08-18 02:03:55
【问题描述】:

我使用以下代码来获得预测。

for node_id in top_k:
    score = predictions[0][node_id]
    human_string = label_lines[node_id]
    print('%s (score = %.5f)' % (human_string, score))

上面的代码打印了所有类的分数预测。但是,如何获得得分最高的标签?

【问题讨论】:

  • 你能添加一些示例数据吗?
  • 这里缺少很多代码来做假设

标签: python tensorflow


【解决方案1】:

这是使用max的解决方案

score, key = max((v, k) for k, v in predictions[0].items())
print('{} (score = {:.5f})'.format(label_lines[key], score))

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-02-26
    • 2018-06-21
    • 2020-02-04
    • 2013-10-26
    • 2011-03-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多