Spaces:
Running
Running
Download plot_training.py from WideChaos/tiny-hash-intent: direct link, hf CLI and curl.
- Browser
- Download file 1.85 kB
-
https://huggingface.co/spaces/WideChaos/tiny-hash-intent/resolve/main/plot_training.py
- Command line
-
hf download hf://spaces/WideChaos/tiny-hash-intent/plot_training.py
-
curl -L -o plot_training.py https://huggingface.co/spaces/WideChaos/tiny-hash-intent/resolve/main/plot_training.py
1.85 kB
| """Plot every saved epoch and temperature candidate without opening a GUI.""" | |
| import json | |
| from pathlib import Path | |
| import matplotlib | |
| matplotlib.use("Agg") | |
| import matplotlib.pyplot as plt | |
| r = Path(__file__).resolve().parent | |
| trace = json.loads((r / "run-001/trace.json").read_text()) | |
| cal = json.loads((r / "run-001/calibration.json").read_text()) | |
| fig, axes = plt.subplots(1, 2, figsize=(11, 4.4), layout="constrained") | |
| axes[0].plot( | |
| [x["epoch"] for x in trace], | |
| [x["train_epoch_end_nll"] for x in trace], | |
| label="Train, epoch end", | |
| color="#335f9c", | |
| ) | |
| axes[0].plot( | |
| [x["epoch"] for x in trace], | |
| [x["validation_nll"] for x in trace], | |
| label="Validation", | |
| color="#ad5b26", | |
| ) | |
| axes[0].axvline( | |
| cal["selected_epoch"], | |
| color="#566358", | |
| ls="--", | |
| label=f"Selected epoch {cal['selected_epoch']}", | |
| ) | |
| axes[0].set( | |
| xlabel="Epoch (all 30 retained)", | |
| ylabel="Uncalibrated cross-entropy / NLL", | |
| ylim=(0, None), | |
| title="One CPU fit, fixed configuration", | |
| ) | |
| axes[0].legend(fontsize=9) | |
| grid = cal["temperature_grid"] | |
| axes[1].plot( | |
| [x["temperature"] for x in grid], | |
| [x["validation_nll"] for x in grid], | |
| marker="o", | |
| color="#335f9c", | |
| ) | |
| selected = next(x for x in grid if x["temperature"] == cal["selected_temperature"]) | |
| axes[1].scatter( | |
| [selected["temperature"]], | |
| [selected["validation_nll"]], | |
| s=80, | |
| color="#ad5b26", | |
| label=f"Selected T={selected['temperature']}", | |
| zorder=4, | |
| ) | |
| axes[1].set( | |
| xlabel="Temperature (fixed finite grid)", | |
| ylabel="Validation NLL", | |
| ylim=(0, None), | |
| title="Selected float model, validation only", | |
| ) | |
| axes[1].legend(fontsize=9) | |
| for ax in axes: | |
| ax.grid(alpha=0.2) | |
| fig.suptitle( | |
| "Tiny Hash Intent · BANKING77 · 8,998 fit / 1,005 validation rows", fontsize=12 | |
| ) | |
| fig.savefig(r / "training-curves.png", dpi=170) | |
| plt.close(fig) | |