Download experiments/train_all.py from fahadhafeezofficial/clsa-code: direct link, hf CLI and curl.
- Browser
- Download file 1.82 kB
-
https://huggingface.co/datasets/fahadhafeezofficial/clsa-code/resolve/main/experiments/train_all.py
- Command line
-
hf download hf://datasets/fahadhafeezofficial/clsa-code/experiments/train_all.py
-
curl -L -o train_all.py https://huggingface.co/datasets/fahadhafeezofficial/clsa-code/resolve/main/experiments/train_all.py
1.82 kB
| # Copyright (c) 2026 CLSA contributors | |
| # SPDX-License-Identifier: MIT | |
| """Build the dataset and train all artefacts for one backbone. | |
| Usage: | |
| PYTHONPATH=src python experiments/train_all.py --model primary | |
| """ | |
| from __future__ import annotations | |
| import argparse | |
| import json | |
| import sys | |
| import time | |
| from pathlib import Path | |
| sys.path.insert(0, str(Path(__file__).resolve().parents[1] / "src")) | |
| from clsa.transcoder.dataset import build_dataset # noqa: E402 | |
| from clsa.util import load_config, write_result # noqa: E402 | |
| from clsa.world_model.train import train_all # noqa: E402 | |
| def main() -> None: | |
| ap = argparse.ArgumentParser() | |
| ap.add_argument("--model", default="primary") | |
| ap.add_argument("--skip-dataset", action="store_true") | |
| args = ap.parse_args() | |
| tcfg = load_config("transcoder") | |
| wcfg = load_config("world_model") | |
| wcfg["threads"] = tcfg.get("threads", 4) | |
| wcfg["admission"] = tcfg.get("admission", {}) | |
| wcfg["probe"] = tcfg.get("probe", {}) | |
| name = tcfg["backbones"].get(args.model, args.model) | |
| t0 = time.time() | |
| ds_meta = None if args.skip_dataset else build_dataset(name, tcfg) | |
| print("dataset:", json.dumps(ds_meta, indent=2)[:600] if ds_meta else "cached") | |
| art = train_all(name, wcfg) | |
| path = write_result( | |
| f"train_{name.replace('/', '__')}", | |
| {"dataset": ds_meta, "artifacts": art}, | |
| config=wcfg, | |
| seed=int(wcfg.get("seed", 0)), | |
| notes=f"world-model training on {name}", | |
| ) | |
| print(json.dumps(art["world_model"], indent=2)[:1200]) | |
| print("admission:", json.dumps({k: art["admission"].get(k) for k in ("n_shared", "n_probe_only", "flip_rate_shared", "flip_rate_probe_only", "flip_rate_random")}, indent=2)) | |
| print("seconds:", round(time.time() - t0, 1), "->", path) | |
| if __name__ == "__main__": | |
| main() | |