【发布时间】:2018-03-07 18:29:55
【问题描述】:
我有一个 2 x 4 tensorA = [[0,1,0,1],[1,0,1,0]]。
我想从维度 d 中提取索引 i。
在 Torch 我可以做到:tensorA:select(d,i)。
例如,tensorA:select(0,0) 将返回 [0,1,0,1] 和
tensorA:select(1,1) 将返回 [1,0]。
如何在 TensorFlow 中做到这一点?
我能找到的最简单的方法是:tf.gather(tensorA, indices=[i], axis=d)
但是为此使用 collect 似乎有点过头了。有谁知道更好的方法吗?
【问题讨论】:
-
tensorA[d,i]怎么样? -
this 回答对你有用吗?
标签: python matrix tensorflow tensor