indexing in tensorflow slower than gather
问题 I am trying to index into a tensor to get a slice or single element from 1d tensors. I find that there is significant performance difference when using the numpy way of indexing [:] and slice vs tf.gather (almost 30-40% ). Also I observe that tf.gather has significant overhead when used on scalars (looping over unstacked tensor) as opposed to tensor . Is this a known issue ? example code (inefficient) : for node_idxs in graph.nodes(): node_indice_list = tf.unstack(node_idxs) result = [] for