Skip to content
This repository has been archived by the owner on Oct 31, 2023. It is now read-only.

Commit

Permalink
Update balanced_positive_negative_sampler.py (#93)
Browse files Browse the repository at this point in the history
use cuda version torch.randperm to avoid copy from gpu to cpu and a fatal bug in multi-thread cpu version
  • Loading branch information
Jiayuan-Gu authored and fmassa committed Nov 1, 2018
1 parent c547508 commit b418212
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ def __call__(self, matched_idxs):
num_neg = min(negative.numel(), num_neg)

# randomly select positive and negative examples
perm1 = torch.randperm(positive.numel())[:num_pos]
perm2 = torch.randperm(negative.numel())[:num_neg]
perm1 = torch.randperm(positive.numel(), device=positive.device)[:num_pos]
perm2 = torch.randperm(negative.numel(), device=negative.device)[:num_neg]

pos_idx_per_image = positive[perm1]
neg_idx_per_image = negative[perm2]
Expand Down

0 comments on commit b418212

Please sign in to comment.