You can use tf.boolean_mask and tf.scatter_nd to create a boolean vector for your (repeated)data. First, you create an indices tensor to indicate the value to mask :
row = tf.constant([0,1,2,3,4,5,6,7,8] ,dtype = tf.int64)
mask_for_each_row = tf.stack([row ,presentIndices[: , 1]],axis = 1 )
and then you use mask_for_each_row as indices in tf.scatter_nd method :
samples =tf.boolean_mask(data ,~tf.scatter_nd(mask_for_each_row ,
tf.ones((9,),dtype = tf.bool),(9,5)))
samples = tf.reshape(samples ,(9,4))
the samples tensor :
<tf.Tensor: shape=(9, 4), dtype=int32, numpy=
array([[ 1, 10, 10, 2],
[ 4, 10, 10, 2],
[ 4, 1, 10, 10],
[10, 9, 10, 10],
[10, 7, 10, 10],
[ 8, 10, 3, 5],
[ 6, 10, 3, 5],
[ 6, 8, 10, 5],
[ 6, 8, 10, 3]])>
CLICK HERE to find out more related problems solutions.