Spaces:
Running
The condition number κ has extreme dynamic range across layers:
Browse files- Layer 0: κ ~ thousands (ill-conditioned)
- Deep layers: κ ~ single digits (well-conditioned)
On a linear y-axis, the deep-layer variation is completely invisible —
the early-layer spikes dominate the scale and compress everything else
into a flat line at the bottom. This defeats the purpose of the plot.
Switch the κ(Q) & κ(K) dual-line panel (row 2, col 3) to **log scale**
in both rendering engines.
Single-model figure — added after the two `draw()` calls:
```python
ax.set_yscale("log")
```
Compare figure — same addition:
```python
ax.set_yscale("log")
```
Title updated to reflect the scale:
```
"Law 3 — Condition Number κ (log scale)"
y-label: "Condition number κ (log)"
```
Added inside the per-panel loop, after `fig.update_yaxes(title_text=...)`,
for both `plotly_single()` and `plotly_compare()`:
```python
if col == "cond_dual":
fig.update_yaxes(type="log", row=row_idx, col=1)
```
```
set_yscale("log") found 2× in core/plotter.py ✅
type="log" found 2× in core/plotter_plotly.py ✅
ast.parse() both files ✅
```
`ui/tab_plot.py`, `db/`, `app.py` — untouched.
- core/plotter.py +5 -3
- core/plotter_plotly.py +6 -0
|
@@ -204,8 +204,9 @@ def plot_single_model(
|
|
| 204 |
ax = axes[1, 2]
|
| 205 |
draw(ax, "cond_Q", C["Q"], "κ(Q)")
|
| 206 |
draw(ax, "cond_K", C["K"], "κ(K)")
|
| 207 |
-
|
| 208 |
-
|
|
|
|
| 209 |
|
| 210 |
# ── Row 2: Law 4 ─────────────────────────────────────────────────────────
|
| 211 |
# Share y-axis across this row
|
|
@@ -374,7 +375,8 @@ def plot_compare_models(
|
|
| 374 |
f"{name_a} κ(K)", "-", show_band, None)
|
| 375 |
_draw_line(ax, lay_b, med_b, q25_b, q75_b, C["K"],
|
| 376 |
f"{name_b} κ(K)", "--", show_band, None)
|
| 377 |
-
|
|
|
|
| 378 |
|
| 379 |
# ── Row 2: Law 4 ─────────────────────────────────────────────────────────
|
| 380 |
u_cols = [("cosU_QK", C["QK"], "Q–K"),
|
|
|
|
| 204 |
ax = axes[1, 2]
|
| 205 |
draw(ax, "cond_Q", C["Q"], "κ(Q)")
|
| 206 |
draw(ax, "cond_K", C["K"], "κ(K)")
|
| 207 |
+
ax.set_yscale("log")
|
| 208 |
+
_finalize_ax(ax, "Law 3 — Condition Number κ (log scale)",
|
| 209 |
+
"Condition number κ (log)")
|
| 210 |
|
| 211 |
# ── Row 2: Law 4 ─────────────────────────────────────────────────────────
|
| 212 |
# Share y-axis across this row
|
|
|
|
| 375 |
f"{name_a} κ(K)", "-", show_band, None)
|
| 376 |
_draw_line(ax, lay_b, med_b, q25_b, q75_b, C["K"],
|
| 377 |
f"{name_b} κ(K)", "--", show_band, None)
|
| 378 |
+
ax.set_yscale("log")
|
| 379 |
+
_finalize_ax(ax, "Law 3 — Condition Number κ (log scale)", "Condition number κ (log)")
|
| 380 |
|
| 381 |
# ── Row 2: Law 4 ─────────────────────────────────────────────────────────
|
| 382 |
u_cols = [("cosU_QK", C["QK"], "Q–K"),
|
|
@@ -247,6 +247,9 @@ def plotly_single(
|
|
| 247 |
title_font=dict(size=11))
|
| 248 |
fig.update_xaxes(title_text="Layer index", row=row_idx, col=1,
|
| 249 |
title_font=dict(size=11))
|
|
|
|
|
|
|
|
|
|
| 250 |
|
| 251 |
# ── shared Y for cosU row (panels 6,7,8) ─────────────────────────────────
|
| 252 |
_sync_yrange(fig, df, ["cosU_QK", "cosU_QV", "cosU_KV"],
|
|
@@ -411,6 +414,9 @@ def plotly_compare(
|
|
| 411 |
title_font=dict(size=11))
|
| 412 |
fig.update_xaxes(title_text="Layer index", row=row_idx, col=1,
|
| 413 |
title_font=dict(size=11))
|
|
|
|
|
|
|
|
|
|
| 414 |
|
| 415 |
_sync_yrange_compare(fig, df_a, df_b,
|
| 416 |
["cosU_QK", "cosU_QV", "cosU_KV"], [7, 8, 9])
|
|
|
|
| 247 |
title_font=dict(size=11))
|
| 248 |
fig.update_xaxes(title_text="Layer index", row=row_idx, col=1,
|
| 249 |
title_font=dict(size=11))
|
| 250 |
+
# ── log scale for condition number panel (row 6) ─────────────────────
|
| 251 |
+
if col == "cond_dual":
|
| 252 |
+
fig.update_yaxes(type="log", row=row_idx, col=1)
|
| 253 |
|
| 254 |
# ── shared Y for cosU row (panels 6,7,8) ─────────────────────────────────
|
| 255 |
_sync_yrange(fig, df, ["cosU_QK", "cosU_QV", "cosU_KV"],
|
|
|
|
| 414 |
title_font=dict(size=11))
|
| 415 |
fig.update_xaxes(title_text="Layer index", row=row_idx, col=1,
|
| 416 |
title_font=dict(size=11))
|
| 417 |
+
# ── log scale for condition number panel (row 6) ─────────────────────
|
| 418 |
+
if col == "cond_dual":
|
| 419 |
+
fig.update_yaxes(type="log", row=row_idx, col=1)
|
| 420 |
|
| 421 |
_sync_yrange_compare(fig, df_a, df_b,
|
| 422 |
["cosU_QK", "cosU_QV", "cosU_KV"], [7, 8, 9])
|