我有一個關於如何在TensorFlow中建立索引的基本問題。TensorFlow:使用張量來索引另一個張量
在numpy的:
x = np.asarray([1,2,3,3,2,5,6,7,1,3])
e = np.asarray([0,1,0,1,1,1,0,1])
#numpy
print x * e[x]
我能得到
[1 0 3 3 0 5 0 7 1 3]
我怎樣才能做到這一點TensorFlow?
x = np.asarray([1,2,3,3,2,5,6,7,1,3])
e = np.asarray([0,1,0,1,1,1,0,1])
x_t = tf.constant(x)
e_t = tf.constant(e)
with tf.Session():
????
謝謝!
http://stackoverflow.com/questions/33736795/tensorflow-numpy-like-tensor-indexing?rq=1 是不是你在問什麼? – Alleo