here is an example. There is a square shaped 2-dimensional matrix(ss_matrix) and I want to get the index pairs which satisfy where the value of the matrix is above 0.8. But, I do not wish to select the index pairs where the first and second index are the same. This operation can be achieved in tensorflow with the combination of tf.where
and tf.gather
sm_sel_indices = tf.where(some_matrix > 0.8, None, None) index_list_1 , index_list_2 = tf.split(sm_sel_indices, 2, axis=1) index_diff = index_list_1 - index_list_2 index_diff = tf.squeeze(index_diff) index_of_index_list_where_not_same = tf.where(tf.not_equal(index_diff, 0), None, None) index_of_index_list_where_not_same = tf.squeeze(index_of_index_list_where_not_same) sm_over_thresh_no_same_indices = tf.gather(sm_sel_indices, index_of_index_list_where_not_same)
0 Comments