coarse-grained-forecasting-benchmark's picture
Add anonymous reproduction code
41dd7e0 verified
Raw History Blame Contribute Delete
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)