Commit 1c4c360f authored by Jared Casper's avatar Jared Casper
Browse files

Ensure numpy random seed is within range.

parent 002cde6b
...@@ -77,7 +77,8 @@ class BertDataset(torch.utils.data.Dataset): ...@@ -77,7 +77,8 @@ class BertDataset(torch.utils.data.Dataset):
sample = [self.indexed_dataset[i] for i in range(start_idx, end_idx)] sample = [self.indexed_dataset[i] for i in range(start_idx, end_idx)]
# Note that this rng state should be numpy and not python since # Note that this rng state should be numpy and not python since
# python randint is inclusive whereas the numpy one is exclusive. # python randint is inclusive whereas the numpy one is exclusive.
np_rng = np.random.RandomState(seed=(self.seed + idx)) # We % 2**32 since numpy requres the seed to be between 0 and 2**32 - 1
np_rng = np.random.RandomState(seed=((self.seed + idx) % 2**32))
return build_training_sample(sample, seq_length, return build_training_sample(sample, seq_length,
self.max_seq_length, # needed for padding self.max_seq_length, # needed for padding
self.vocab_id_list, self.vocab_id_list,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment