Download code/bifurcation/utils.py from coarse-grained-forecasting-benchmark/forecasting-models: direct link, hf CLI and curl.
- Browser
- Download file 600 Bytes
-
https://huggingface.co/coarse-grained-forecasting-benchmark/forecasting-models/resolve/main/code/bifurcation/utils.py
- Command line
-
hf download hf://coarse-grained-forecasting-benchmark/forecasting-models/code/bifurcation/utils.py
-
curl -L -o utils.py https://huggingface.co/coarse-grained-forecasting-benchmark/forecasting-models/resolve/main/code/bifurcation/utils.py
600 Bytes
| """Seeding and YAML helpers.""" | |
| from __future__ import annotations | |
| import os | |
| import random | |
| from typing import Any, Dict | |
| import numpy as np | |
| import torch | |
| import yaml | |
| def seed_everything(seed: int) -> None: | |
| random.seed(seed) | |
| np.random.seed(seed) | |
| torch.manual_seed(seed) | |
| torch.cuda.manual_seed_all(seed) | |
| def load_yaml(path: str | os.PathLike) -> Dict[str, Any]: | |
| with open(path) as f: | |
| return yaml.safe_load(f) | |
| def save_resolved_config(cfg: Dict[str, Any], path: str | os.PathLike) -> None: | |
| with open(path, "w") as f: | |
| yaml.safe_dump(cfg, f, sort_keys=False) | |