Unfortunately I dont know how to formulate the title of this questions, maybe someone can change it?
How to replace the following for loop in an elegant way?
#tensor.shape -> (batchsize,100)
#indices.shape -> (batchsize,100)
liste = []
for i in range(tensor.shape[0]):
liste.append(tf.gather(tensor[i,:], indices[i,:10]))
new_tensor = tf.stack(liste)