(self, assign_result, num_expected, **kwargs)
Randomly sample some negative samples.
Randomly sample some negative samples.
Randomly sample some negative samples .
def _sample_neg(self, assign_result, num_expected, **kwargs):
        """Randomly sample some negative samples."""
        neg_inds = torch.nonzero(assign_result.gt_inds == 0)
        if neg_inds.numel() != 0:
            neg_inds = neg_inds.squeeze(1)
        if len(neg_inds) <= num_expected:
            return neg_inds
        else:
            return self.random_choice(neg_inds, num_expected)
def _sample_neg ( self , assign_result , num_expected , * * kwargs ) : neg_inds = torch . nonzero ( assign_result . gt_inds == 0 ) if neg_inds . numel ( ) != 0 : neg_inds = neg_inds . squeeze ( 1 ) if len ( neg_inds ) <= num_expected : return neg_inds else : return self . random_choice ( neg_inds , num_expected )