【发布时间】:2018-08-04 22:46:29
【问题描述】:
例如,
import tensorflow as tf
index = tf.constant([[1],[1]])
values = tf.constant([[0.2, 0.8],[0.4, 0.6]])
如果我使用extract = tf.gather_nd(values, index)
回报是
[[0.4 0.6]
[0.4 0.6]]
但是,我想要的结果是
[[0.8], [0.6]]
索引沿axis = 1的地方,但是tf.gather_nd中没有axis参数设置。
我该怎么办?谢谢!
【问题讨论】:
-
嗨,我是 Google 的一名软件工程师,我想在我们正在撰写的一篇研究论文中引用这个问题,以展示一些关于 TensorFlow 的代表性问题。你会这样吗?谢谢,大卫
-
@DavidBieber 当然,感谢您的提问 :) 也感谢您构建这个神奇的工具
标签: python tensorflow tensor