delu.random.seed

delu.random.seed(base_seed, one_cuda_seed=False)[source]

Set seeds in random, numpy and torch.

For all libraries, different seeds (which are _deterministically_ calculated based on the base_seed argument) are set.

Note

Different seed are set to avoid situations where different libraries or devices generate the same random sequences. For example, see this comment on setting the same seed for the standard library and NumPy.

Parameters
  • base_seed (int) – the number used to determine random seeds for all libraries and hardware. Must be a non-negative number less than 2 ** 32 - 10000.

  • one_cuda_seed (bool) – if True, then the same seed will be set for all cuda devices, otherwise, different seeds will be set for all cuda devices.

Raises

AssertionError – if the seed is not within the required interval

Return type

None

Examples

delu.random.seed(0)