【问题标题】:index rows from 2D tensor二维张量的索引行
【发布时间】:2017-11-08 20:49:42
【问题描述】:

假设我有一个浮点数的二维张量 A 和整数的一维张量 B。 B 中的数字表示 A 行的索引。如何在张量流图中有效地查找这些索引?

【问题讨论】:

    标签: tensorflow


    【解决方案1】:

    您是否已经尝试过tf.gather()

    另请参阅此问题:TensorFlow: using a tensor to index another tensor

    【讨论】:

    • 不,我没有。谢谢。原来这段代码有效tf.diag_part(tf.gather(A,B, axis=1))
    猜你喜欢
    • 2019-09-15
    • 2020-09-26
    • 2022-06-20
    • 2017-12-20
    • 2021-06-27
    • 2018-06-08
    • 2019-05-30
    • 1970-01-01
    • 2020-05-11
    相关资源
    最近更新 更多