Skip to content

Commit

Permalink
None
Browse files Browse the repository at this point in the history
  • Loading branch information
muellerzr committed Nov 6, 2023
1 parent 77df925 commit 243e8aa
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/accelerate/data_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,15 @@ class SeedableRandomSampler(RandomSampler):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.epoch = 0
self.seed = 0
self.seed = None
if os.environ.get("ACCELERATE_SEED", False):
self.seed = int(os.environ["ACCELERATE_SEED"])

def __iter__(self):
if self.generator is None:
self.generator = torch.Generator()
# Allow `self.epoch` to modify the seed of the generator
seed = self.epoch + (self.seed if self.seed != 0 else self.generator.initial_seed())
seed = self.epoch + (self.seed if self.seed is not None else self.generator.initial_seed())
self.generator.manual_seed(seed)
yield from super().__iter__()
self.set_epoch(self.epoch + 1)
Expand Down

0 comments on commit 243e8aa

Please sign in to comment.