I'm devising a neural network model with point cloud. With n
points input, I use an NN model to get a score for each point. I use the score to decide which k
points I need to reserve and which I need to throw away. Because of gradient backprop, I could not just throw those low-score points away, I need to use a mask to set their corresponding positions 0. So, how could I define that mask in TensorFlow?
I tried to define the mask as a tensor with mask = tf.ones((batch_size, num_point))
, but I could not alter its value as 'Tensor' object does not support item assignment
.
Here's partial of my code,
score_index = tf.argsort(score, axis=1, direction='DESCENDING') # score.shape(batch_size, n)
topn_index = sort_index[:, :16] #keep 16 high score points
mask = tf.zeros((batch_size, num_point))
mask[topn_index]=1
I would appreciate if you could provide suggestions.