【问题标题】:how to get value from a index value如何从索引值中获取值
【发布时间】:2021-01-09 01:32:19
【问题描述】:

张量是A_tensor,形状为[3,3,3],我想通过索引获取最后一个轴的值​​。

如何在 Tensorflow 中做到这一点?

A_tensor =tf.constant([[1,2,3],[2,3,4],[3,4,5]])

如何获取张量([[1,2],[2,3],[3,4]])

【问题讨论】:

    标签: tensorflow


    【解决方案1】:

    你可以使用tf.gather():

    A_tensor =tf.constant([[1,2,3],[2,3,4],[3,4,5]])
    tf.gather(A_tensor,[[0,1]],axis=-1)
    

    【讨论】:

      猜你喜欢
      • 2011-07-10
      • 2022-01-04
      • 1970-01-01
      • 1970-01-01
      • 2014-11-05
      • 1970-01-01
      • 2016-08-31
      • 2015-03-31
      • 1970-01-01
      相关资源
      最近更新 更多