【问题标题】:tf.argmax() for more than one index Tensorflowtf.argmax() 用于多个索引 Tensorflow
【发布时间】:2018-10-29 15:31:33
【问题描述】:

在 Tensorflow 中,tf.argmax() 返回数组中最大元素的索引。

但是,对于多标签分类任务,返回数组中 N 个最大元素的函数会非常方便。

predicted_array: [0.4, 0.6, 0.7, 0.2, 0.9]
tf.something(predicted_array, N = 2): [2,4]

然后将其与真实的热编码数组进行比较

one_hot_array: [0, 0, 1, 0, 1]
tf.something(one_hot_array, N = 2): [2,4]

有这样的功能吗?或者类似的东西?

感谢您的帮助

【问题讨论】:

    标签: python tensorflow multilabel-classification


    【解决方案1】:

    是的,有。它是tf.nn.top_k(来自here)。

    您可以使用它作为tf.nn.top_k(predicted_array, k=2)

    【讨论】:

    • 它不是差异,因此不能在TF图中使用。是否有任何可分辨率的替代方案? span>
    • 对tf.argmax的调用树,使用第一个调用的索引输出来分解原始张量。 span>
    猜你喜欢
    • 2017-06-02
    • 2018-03-03
    • 2018-02-19
    • 2016-06-04
    • 1970-01-01
    • 1970-01-01
    • 2015-07-06
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多