import torch
from spotoptim.utils.seed import seed_everything
seed_everything(42)
a = torch.rand(3)
seed_everything(42)
b = torch.rand(3)
print(torch.equal(a, b))True
Seed every random number generator relevant to a torch experiment.
Seeds Python’s random, PYTHONHASHSEED, NumPy, and torch (CPU and CUDA unconditionally, MPS when available), and sets torch.backends.cudnn.deterministic = True and torch.backends.cudnn.benchmark = False.
| Name | Type | Description | Default |
|---|---|---|---|
| seed | int | The seed value. | required |