clinicadl.utils.seed.seed_everything¶
- clinicadl.utils.seed.seed_everything(seed: int | None = None, deterministic: bool = False) None[source]¶
To control reproducibility.
It will seed pseudo-random number generators in: PyTorch, Numpy and Python’s random module. The seed can be accessed via the environment variable
"CLINICADL_GLOBAL_SEED".Besides, if
deterministic=True, PyTorch’s operations will be configured in deterministic mode, to the extent possible. In this case, an environment variable"CLINICADL_DETERMINISTIC"will also be created.Warning
deterministic=Truedoes not guarantee fully reproducible results; it only ensures determinism within PyTorch’s current limitations;
comes with a cost in computing performances. It is advised to use this parameter only for your final experiments.
- Parameters:
Examples
from clinicadl.utils.seed import seed_everything import torch import numpy as np import random
>>> seed_everything(0) >>> torch.randn(1), np.random.randn(), random.randint(0, 100) (tensor([1.5410]), 1.764052345967664, 49) >>> seed_everything(0) >>> torch.randn(1), np.random.randn(), random.randint(0, 100) (tensor([1.5410]), 1.764052345967664, 49)