我有一个2×4tensorA = [[0,1,0,1],[1,0,1,0]]
。
我想从维度d中提取索引I。
在手电筒里我能做到: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)
但是,使用聚集似乎有点过头了。有人知道更好的方法吗?在
Tags:
您可以使用以下配方:
用分号替换除d外的所有轴,并在d轴上输入值i,例如:
然而,当我尝试这个的时候,我有一个语法错误:
^{pr2}$所以我用切片代替
此函数的作用是:
例如:
印刷品
您只需使用}
value = tensorA[d,i]
。在引擎盖下,tensorflow呼叫 ^{相关问题 更多 >
编程相关推荐