google-deepmind/multi_object_datasets

A possible solution to handle more corner cases when computing ARI scores

jinyangyuan opened this issue · 0 comments

The adjusted_rand_index funcion in segmentation_metrics.py may return NaN values when true_mask[b, :, g] or pred_mask[b, :, g] is 0 for some b and g. I think a possible solution is to return 1 if (n_points * (n_points - 1)) or (max_rindex - expected_rindex) is 0.

invalid = tf.logical_or(
    tf.equal(n_points * (n_points - 1), 0), tf.equal(max_rindex - expected_rindex, 0))
return tf.where(invalid, tf.ones_like(ari), ari)