Hai*_*eng 5 deep-learning tensorflow
import tensorflow as tf
x = [[1,2,3],[4,5,6]]
y = [0,1]
z = [1,2]
x = tf.constant(x)
y = tf.constant(y)
z = tf.constant(z)
m = x[y,z]
Run Code Online (Sandbox Code Playgroud)
我期待的是 m = [2,6]
我可以通过theano或numpy获得结果.我如何使用张量流得到结果?
你会想要使用tf.gather_nd
slices = tf.gather_nd(x, [y, z])
Run Code Online (Sandbox Code Playgroud)
希望这可以帮助.
| 归档时间: |
|
| 查看次数: |
2725 次 |
| 最近记录: |