Support multiple seeds in data_utils.numpy_seed
Summary: Pull Request resolved:
@@ -44,12 +44,14 @@ def collate_tokens(values, pad_idx, eos_idx=None, left_pad=False, move_eos_to_be
@contextlib.contextmanager
-def numpy_seed(seed):
+def numpy_seed(seed, *addl_seeds):
"""Context manager which seeds the NumPy PRNG with the specified seed and
restores the state afterward"""
if seed is None:
yield
return
+ if len(addl_seeds) > 0:
+ seed = int(hash((seed, *addl_seeds)) % 1e6)
state = np.random.get_state()
np.random.seed(seed)
try:
