Download src/utils/seed.py from pratik-250620/MultiModal-Coherence-AI: direct link, hf CLI and curl.
- Browser
- Download file 335 Bytes
-
https://huggingface.co/spaces/pratik-250620/MultiModal-Coherence-AI/resolve/main/src/utils/seed.py
- Command line
-
hf download hf://spaces/pratik-250620/MultiModal-Coherence-AI/src/utils/seed.py
-
curl -L -o seed.py https://huggingface.co/spaces/pratik-250620/MultiModal-Coherence-AI/resolve/main/src/utils/seed.py
335 Bytes
| import random | |
| import numpy as np | |
| import torch | |
| def set_global_seed(seed: int = 42) -> None: | |
| random.seed(seed) | |
| np.random.seed(seed) | |
| torch.manual_seed(seed) | |
| if torch.cuda.is_available(): | |
| torch.cuda.manual_seed_all(seed) | |
| torch.backends.cudnn.deterministic = True | |
| torch.backends.cudnn.benchmark = False | |