Download dpacman/utils/models.py from ChatterjeeLab/DPACMAN: direct link, hf CLI and curl.
- Browser
- Download file 548 Bytes
-
https://huggingface.co/ChatterjeeLab/DPACMAN/resolve/main/dpacman/utils/models.py
- Command line
-
hf download hf://ChatterjeeLab/DPACMAN/dpacman/utils/models.py
-
curl -L -o models.py https://huggingface.co/ChatterjeeLab/DPACMAN/resolve/main/dpacman/utils/models.py
548 Bytes
| """ | |
| Model-related utilities, such as setting seed | |
| """ | |
| import torch | |
| import numpy as np | |
| import random | |
| import os | |
| def set_seed(seed: int = 42) -> None: | |
| np.random.seed(seed) | |
| random.seed(seed) | |
| torch.manual_seed(seed) | |
| torch.cuda.manual_seed(seed) | |
| # When running on the CuDNN backend, two further options must be set | |
| torch.backends.cudnn.deterministic = True | |
| torch.backends.cudnn.benchmark = False | |
| # Set a fixed value for the hash seed | |
| os.environ["PYTHONHASHSEED"] = str(seed) | |
| print(f"Random seed set as {seed}") | |