Download ultrasparse/utils.py from bala5046/UltraSparse-10M: direct link, hf CLI and curl.
- Browser
- Download file 449 Bytes
-
https://huggingface.co/bala5046/UltraSparse-10M/resolve/main/ultrasparse/utils.py
- Command line
-
hf download hf://bala5046/UltraSparse-10M/ultrasparse/utils.py
-
curl -L -o utils.py https://huggingface.co/bala5046/UltraSparse-10M/resolve/main/ultrasparse/utils.py
449 Bytes
| import json | |
| import random | |
| from pathlib import Path | |
| import numpy as np | |
| import torch | |
| def seed_everything(seed: int): | |
| random.seed(seed) | |
| np.random.seed(seed) | |
| torch.manual_seed(seed) | |
| def save_json(path, obj): | |
| Path(path).parent.mkdir(parents=True, exist_ok=True) | |
| Path(path).write_text(json.dumps(obj, indent=2), encoding="utf-8") | |
| def count_parameters(model): | |
| return sum(p.numel() for p in model.parameters() if p.requires_grad) | |