braindecode.util.set_random_seeds¶
- braindecode.util.set_random_seeds(seed, cuda, cudnn_benchmark=None)¶
Set seeds for python random module numpy.random and torch.
For more details about reproducibility in pytorch see https://pytorch.org/docs/stable/notes/randomness.html
- Parameters
- seed: int
Random seed.
- cuda: bool
Whether to set cuda seed with torch.
- cudnn_benchmark: bool (default=None)
Whether pytorch will use cudnn benchmark. When set to None it will not modify torch.backends.cudnn.benchmark (displays warning in the case of possible lack of reproducibility). When set to True, results may not be reproducible (no warning displayed). When set to False it may slow down computations.
Notes
In some cases setting environment variable PYTHONHASHSEED may be needed before running a script to ensure full reproducibility. See https://forums.fast.ai/t/solved-reproducibility-where-is-the-randomness-coming-in/31628/14
Using this function may not ensure full reproducibility of the results as we do not set torch.use_deterministic_algorithms(True).