def hybrid_forward(self, F, x):
match = F.contrib.bipartite_matching(x, threshold=self._threshold,
is_ascend=self._is_ascend)
return match[0]
class MaximumMatcher(gluon.HybridBlock):
A Matcher implementing maximum matching strategy.
After Change
// make sure if iou(a, y) == iou(b, y), then b should also be a good match
// otherwise positive/negative samples are confusing
// potential argmax and max
pargmax = x.argmax(axis=-1, keepdims=True) // (B, num_anchor, 1)
maxs = x.max(axis=-2, keepdims=True) // (B, 1, num_gt)
pmax = F.pick(x, pargmax, axis=-1, keepdims=True) // (B, num_anchor, 1)
mask = F.broadcast_greater_equal(pmax + self._eps, maxs) // (B, num_anchor, num_gt)
mask = F.pick(mask, pargmax, axis=-1, keepdims=True) // (B, num_anchor, 1)
new_match = F.where(mask > 0, pargmax, F.ones_like(pargmax) * -1)
result = F.where(match[0] < 0, new_match.squeeze(axis=-1), match[0])
return result
class MaximumMatcher(gluon.HybridBlock):
A Matcher implementing maximum matching strategy.