我试图使用tf.gather_nd(params, indices, name=None)
从特征映射张量中检索元素
有没有办法把这个张量[[0,2,2]]
转换成[[0,0],[1,2],[2,2]]
因为我需要它在函数中用作索引
我只有[[0,2,2]]
应该是这个结构
indices = [[0,0],[1,2],[2,2]]
params = [['3', '1','2','-1'], ['0.3', '1.4','5','0'],['5', '6','7','8']]
t=tf.gather_nd(params, indices, name=None)
with tf.Session() as sess:
sess.run(tf.initialize_all_variables())
print(sess.run(t)) # outputs 3 5 7
假设您试图将张量
t0 = [[x0, x1, x2, ... xn]]
转换为张量[[0, x0], [1, x1], [2, x2], ..., [n, xn]]
,您可以将其与范围张量连接起来,如下所示:这应该给你你想要的指数
相关问题 更多 >
编程相关推荐