Skip to content

Commit e65a857

Browse files
xiaohu2015datumbox
andauthoredJan 2, 2022
only set random generator if shuffle=true (#5135)
Co-authored-by: Vasilis Vryniotis <datumbox@users.noreply.github.com>
1 parent 1abb56a commit e65a857

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed
 

‎references/classification/sampler.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@ def __init__(self, dataset, num_replicas=None, rank=None, shuffle=True, seed=0,
3636
self.repetitions = repetitions
3737

3838
def __iter__(self):
39-
# Deterministically shuffle based on epoch
40-
g = torch.Generator()
41-
g.manual_seed(self.seed + self.epoch)
4239
if self.shuffle:
40+
# Deterministically shuffle based on epoch
41+
g = torch.Generator()
42+
g.manual_seed(self.seed + self.epoch)
4343
indices = torch.randperm(len(self.dataset), generator=g).tolist()
4444
else:
4545
indices = list(range(len(self.dataset)))

0 commit comments

Comments
 (0)