| """Build the Figure-6a reproduction plot from the CIFAR self-distillation results JSON.""" |
| import sys, json, numpy as np, pandas as pd |
| sys.path.insert(0, "src") |
| from plotting import new_fig, save, PALETTE |
| import plotly.graph_objects as go |
|
|
| src = sys.argv[1] if len(sys.argv) > 1 else "outputs/claim5/cifar_results.json" |
| res = json.load(open(src)) |
| K = res["config"]["K"] |
| its = list(range(K + 1)) |
| fig = new_fig("Claim 5 (Fig 6a): ResNet-50 / CIFAR-10 self-distillation test error", |
| "self-distillation iteration t", "test error (%)") |
| rows = [] |
| for i, (eta, errs) in enumerate(sorted(res["curves"].items(), key=lambda kv: float(kv[0]))): |
| fig.add_trace(go.Scatter(x=its, y=errs, mode="lines+markers", |
| line=dict(color=PALETTE[i], width=2.5), |
| marker=dict(size=9, line=dict(color="white", width=1)), |
| name=f"η={eta}")) |
| tstar = int(np.argmin(errs)) |
| shape = "U-shaped" if 0 < tstar < K else ("monotone↓" if tstar == K else "↑") |
| print(f"eta={eta}: {['%.1f'%e for e in errs]} t*={tstar} ({shape})") |
| for t, e in zip(its, errs): |
| rows.append(dict(eta=float(eta), t=t, test_error=e)) |
| save(fig, pd.DataFrame(rows), "outputs/claim5", "claim5_fig6a_cifar") |
|
|