'Create classification weights for each anchor.
Positive (matched) anchors are associated with a weight of
positive_class_weight and negative (unmatched) anchors are associated with
a weight of negative_class_weight. When anchors are ignored, weights are set
to zero. By default, both positive/negative weights are set to 1.0,
but they can be adjusted to handle class imbalance (which is almost always
the case in object detection).
Args:
match: a matcher.Match object that provides a matching between anchors
and groundtruth boxes.
positive_class_weight: weight to be associated to positive anchors
negative_class_weight: weight to be associated to negative anchors
Returns:
cls_weights: a float32 tensor with shape [num_anchors] representing
classification weights.'

def _create_classification_weights(self, match, positive_class_weight=1.0, negative_class_weight=1.0):

    matched_indicator = tf.cast(match.matched_column_indicator(), tf.float32)
    ignore_indicator = tf.cast(match.ignored_column_indicator(), tf.float32)
    unmatched_indicator = ((1.0 - matched_indicator) - ignore_indicator)
    cls_weights = ((positive_class_weight * matched_indicator) + (negative_class_weight * unmatched_indicator))
    return cls_weights
