How can I use the index array in tensorflow? How can I use the index array in tensorflow? numpy numpy

How can I use the index array in tensorflow?


This feature is not currently implemented in TensorFlow. GitHub issue #4638 is tracking the implementation of NumPy-style "advanced" indexing. However, you can use the tf.gather_nd() operator to implement your program:

a = tf.placeholder(tf.float32, shape=(5, 3))b = tf.placeholder(tf.int32, (5,))row_indices = tf.range(5)# `indices` is a 5 x 2 matrix of coordinates into `a`.indices = tf.transpose([row_indices, b])c = tf.gather_nd(a, indices)