Download ml/utils/seeding.py from PRiyanshu0-1/TrackChain: direct link, hf CLI and curl.
- Browser
- Download file 435 Bytes
-
https://huggingface.co/PRiyanshu0-1/TrackChain/resolve/main/ml/utils/seeding.py
- Command line
-
hf download hf://PRiyanshu0-1/TrackChain/ml/utils/seeding.py
-
curl -L -o seeding.py https://huggingface.co/PRiyanshu0-1/TrackChain/resolve/main/ml/utils/seeding.py
435 Bytes
| # Deterministic seeding for reproducible runs. | |
| import os | |
| import random | |
| import numpy as np | |
| import torch | |
| def seed_everything(seed: int = 42): | |
| random.seed(seed) | |
| os.environ["PYTHONHASHSEED"] = str(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 | |