(self, assign_result, num_expected, **kwargs)
Randomly sample some positive samples.
Randomly sample some positive samples.
Randomly sample some positive samples .
def _sample_pos(self, assign_result, num_expected, **kwargs):
        """Randomly sample some positive samples."""
        pos_inds = torch.nonzero(assign_result.gt_inds > 0)
        if pos_inds.numel() != 0:
            pos_inds = pos_inds.squeeze(1)
        if pos_inds.numel() <= num_expected:
            return pos_inds
        else:
            return self.random_choice(pos_inds, num_expected)
def _sample_pos ( self , assign_result , num_expected , * * kwargs ) : pos_inds = torch . nonzero ( assign_result . gt_inds > 0 ) if pos_inds . numel ( ) != 0 : pos_inds = pos_inds . squeeze ( 1 ) if pos_inds . numel ( ) <= num_expected : return pos_inds else : return self . random_choice ( pos_inds , num_expected )