File size: 17,746 Bytes
5a90c80 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 | <!doctype html><html lang="en"><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><title>One clock’s torus — fixed final geometry</title><style>body{margin:0;background:#fcfcfb;font:14px/1.45 system-ui,sans-serif;color:#0b0b0b}main{max-width:1200px;margin:24px auto;padding:0 16px}a{color:#2a78d6}nav{margin-bottom:16px}</style><main><nav><a href="modular.html#sec-5">← Cells among the real inputs</a></nav><style>
.clock-surface { position:relative; grid-column:1 / -1; padding:12px; border:1px solid #e1e0d9; border-radius:6px; color:#0b0b0b; background:#fcfcfb; }
.clock-surface [hidden] { display:none !important; }
.clock-surface h4 { font-size:1rem; margin:0 0 6px; font-weight:600; }
.clock-surface p { margin:0 0 10px; max-width:100ch; color:#52514e; font-size:0.9rem; }
.clock-surface .ucs-controls { display:flex; align-items:center; flex-wrap:wrap; gap:10px 18px; margin:12px 0; font-size:0.9rem; }
.clock-surface label { display:flex; align-items:center; gap:6px; max-width:100%; }
.clock-surface select, .clock-surface button, .clock-surface input { font:inherit; max-width:100%; }
.clock-surface select { min-width:0; }
.clock-surface .ucs-time { display:flex; align-items:center; flex-wrap:wrap; gap:10px; margin:10px 0; font-size:0.9rem; }
.clock-surface .ucs-time input { width:210px; }
.clock-surface .ucs-geometry { color:#52514e; }
.clock-surface .ucs-maps { display:grid; grid-template-columns:minmax(0,1fr) minmax(0,1fr); gap:18px; }
.clock-surface h5 { font-size:0.9rem; margin:6px 0; }
.clock-surface canvas.ucs-map { display:block; width:100%; height:auto; cursor:crosshair; touch-action:pan-y; }
.clock-surface .ucs-bar { display:flex; align-items:center; flex-wrap:wrap; gap:8px; font-size:0.8rem; margin:4px 0 8px 50px; font-variant-numeric:tabular-nums; }
.clock-surface .ucs-bar canvas { width:140px; height:10px; }
.clock-surface .ucs-readout { min-height:3em; font-size:0.85rem; color:#52514e; margin-top:12px; font-variant-numeric:tabular-nums; }
.clock-surface .ucs-caption { font-size:0.85rem; margin-top:10px; }
.clock-surface .ucs-error { color:#b32828; }
.clock-surface details { margin:10px 0 0; font-size:0.85rem; color:#52514e; }
.clock-surface summary { cursor:pointer; }
.clock-surface details p { margin-top:6px; }
@media (max-width:860px) { .clock-surface .ucs-maps { grid-template-columns:minmax(0,1fr); } }
@media (pointer:coarse) { .clock-surface button, .clock-surface select { min-height:44px; } }
</style>
<section class="mc-wide clock-surface" id="mc-clock-surface" aria-labelledby="ucs-heading">
<h4 id="ucs-heading">one clock’s torus, unwrapped — geometry fixed at the end of training</h4>
<p>The angles and marked points stay in their final positions while the network changes. We turn the two operands in the same clock plane used by the doughnut below, keeping their final radii and the rest of each base embedding fixed. The centre is the final embedding of the base pair. Opposite edges of the full-turn map join.</p>
<div class="ucs-controls">
<label>clock <select id="ucs-clock" aria-label="Unwrapped clock" disabled></select></label>
<label>window <select id="ucs-span"><option value="360">full turn · 360°</option><option value="60">close-up · 60°</option></select></label>
<label>left <select id="ucs-left"><option value="fr_base">Fisher–Rao from the centre</option><option value="predicted">the network’s answer</option></select></label>
<label>right <select id="ucs-right"><option value="fisher_plane">largest Fisher speed</option><option value="l2_plane">largest L2 speed of logits</option></select></label>
<label>rate scale <select id="ucs-range"><option value="shared">shared across checkpoints</option><option value="own">this checkpoint</option></select></label>
<label><input type="checkbox" id="ucs-marks" checked> final positions of the 49 pairs</label>
</div>
<div class="ucs-time">
<button type="button" id="ucs-play" aria-label="Play checkpoints" disabled>▶</button>
<label>network <input type="range" id="ucs-step" min="0" max="0" value="0" aria-label="Network checkpoint on fixed final geometry" disabled></label>
<span id="ucs-step-label"></span><span class="ucs-geometry" id="ucs-geometry"></span>
</div>
<div class="ucs-maps" id="ucs-maps" hidden>
<div><h5 id="ucs-left-title">Fisher–Rao from the centre</h5><canvas class="ucs-map" id="ucs-left-map" tabindex="0" role="img" aria-label="Output on the unwrapped clock surface; arrow keys inspect points"></canvas>
<div class="ucs-bar" id="ucs-left-bar-wrap"><span id="ucs-left-lo"></span><canvas id="ucs-left-bar" width="256" height="1" aria-hidden="true"></canvas><span id="ucs-left-hi"></span><span id="ucs-left-unit"></span></div>
</div>
<div><h5 id="ucs-right-title">Largest Fisher speed</h5><canvas class="ucs-map" id="ucs-right-map" tabindex="0" role="img" aria-label="Sensitivity on the unwrapped clock surface; arrow keys inspect points"></canvas>
<div class="ucs-bar"><span id="ucs-right-lo"></span><canvas id="ucs-right-bar" width="256" height="1" aria-hidden="true"></canvas><span id="ucs-right-hi"></span><span>per unit L2 step · log scale</span></div>
</div>
</div>
<div class="ucs-readout" id="ucs-readout">Loading the fixed surface.</div>
<p class="ucs-caption" id="ucs-caption"></p>
<details><summary>What is fixed, and what do the points mean?</summary>
<p>The final checkpoint supplies the clock’s two orthonormal axes, both base radii, all embedding components outside that plane, and the marked angular positions. Every checkpoint’s downstream network receives exactly these same states, bypassing its own embedding table. Early frames therefore show responses to final embeddings, not the network’s ordinary early inputs.</p>
<p>Hollow circles show where the real pairs project onto the final clock angles. Their full embeddings usually differ from this surface in radius or in the components held fixed. Inspect a marker to read that distance. The filled centre is on the surface; its colour shows whether the current network answers that fixed final state correctly. “Other components fixed” means the orthogonal remainder; different clock planes need not be mutually orthogonal.</p>
</details>
</section>
<script>
(() => {
const root = document.getElementById("mc-clock-surface");
const $ = id => root.querySelector("#ucs-" + id);
const manifestURL = new URL("https://huggingface.co/datasets/bgradowhite/cells-developmental/resolve/main/pages/frames/modular/chords/clock_surface/index.json", document.baseURI);
const rampStops = [[68,1,84],[72,40,120],[62,74,137],[49,104,142],[38,130,142],[31,158,137],[53,183,121],[109,205,89],[180,222,44],[253,231,37]];
const decode = s => Uint8Array.from(atob(s), c => c.charCodeAt(0));
const cache = new Map();
let manifest = null, run = null, index = 0, loading = false, serial = 0, timer = null, selected = null;
const ramp = v => {
const t = Math.max(0, Math.min(1, v)) * (rampStops.length - 1), i = Math.floor(t), f = t - i;
return rampStops[i].map((a, k) => Math.round(a + f * (rampStops[Math.min(i + 1, rampStops.length - 1)][k] - a)));
};
const categorical = v => {
const h = ((v * 137.508) % 360) / 30, l = v % 2 ? .42 : .60, a = .62 * Math.min(l, 1 - l);
return [0,8,4].map(n => { const k = (n + h) % 12; return 255 * (l - a * Math.max(-1, Math.min(k - 3, 9 - k, 1))); });
};
const fmt = x => Number(x).toPrecision(3);
const fieldValue = (field, i) => field.min + field.bytes[i] / 255 * (field.max - field.min);
const actual = (field, i) => field.log ? 10 ** fieldValue(field, i) : fieldValue(field, i);
function field(view, key) {
const f = view.fields[key];
if (!f.bytes) f.bytes = decode(f.b64);
return f;
}
function limits(key, view) {
if (key === "fr_base") return [0, Math.PI];
if ($("range").value === "own") return [view.fields[key].min, view.fields[key].max];
const span = $("span").value;
return [Math.min(...run.frames.map(f => f.views[span].fields[key].min)),
Math.max(...run.frames.map(f => f.views[span].fields[key].max))];
}
function colorBar(side, lo, hi, logarithmic) {
const ctx = $(side + "-bar").getContext("2d");
for (let i = 0; i < 256; i++) { ctx.fillStyle = `rgb(${ramp(i / 255).join(",")})`; ctx.fillRect(i, 0, 1, 1); }
$(side + "-lo").textContent = fmt(logarithmic ? 10 ** lo : lo);
$(side + "-hi").textContent = fmt(logarithmic ? 10 ** hi : hi);
}
function paint(canvas, view, key) {
const categoricalMode = key === "predicted", g = view.grid, half = view.span / 2;
const f = categoricalMode ? null : field(view, key), [lo, hi] = categoricalMode ? [0, 1] : limits(key, view);
const small = document.createElement("canvas"); small.width = small.height = g;
const sc = small.getContext("2d"), pixels = sc.createImageData(g, g);
for (let r = 0; r < g; r++) for (let c = 0; c < g; c++) {
const i = (g - 1 - r) * g + c, rgb = categoricalMode ? categorical(view.pred[i]) : ramp(hi > lo ? (fieldValue(f, i) - lo) / (hi - lo) : 0);
const o = (r * g + c) * 4; pixels.data[o] = rgb[0]; pixels.data[o+1] = rgb[1]; pixels.data[o+2] = rgb[2]; pixels.data[o+3] = 255;
}
sc.putImageData(pixels, 0, 0);
const width = Math.max(220, Math.round(canvas.getBoundingClientRect().width)), L = 50, T = 12, R = 12, B = 50;
const side = width - L - R, height = side + T + B, dpr = window.devicePixelRatio || 1;
canvas.width = Math.round(width * dpr); canvas.height = Math.round(height * dpr); canvas.style.height = height + "px";
const ctx = canvas.getContext("2d"); ctx.scale(dpr, dpr); ctx.imageSmoothingEnabled = false;
ctx.drawImage(small, L, T, side, side);
const X = deg => L + (deg + half) / view.span * side;
const Y = deg => T + (half - deg) / view.span * side;
ctx.strokeStyle = "#52514e"; ctx.lineWidth = 1; ctx.strokeRect(L, T, side, side);
ctx.fillStyle = "#52514e"; ctx.font = "11px system-ui";
for (const value of [-half, 0, half]) {
ctx.textAlign = value === -half ? "left" : value === half ? "right" : "center";
ctx.fillText((value > 0 ? "+" : "") + value + "°", X(value), T + side + 17);
ctx.textAlign = "right"; ctx.fillText((value > 0 ? "+" : "") + value + "°", L - 5, Y(value) + 4);
}
ctx.font = "12px system-ui"; ctx.textAlign = "center";
ctx.fillText("a · angle from its final position", L + side / 2, height - 6);
ctx.save(); ctx.translate(12, T + side / 2); ctx.rotate(-Math.PI / 2); ctx.fillText("b · angle from its final position", 0, 0); ctx.restore();
if ($("marks").checked) {
for (const m of run.marks) {
if (Math.abs(m.da) > half || Math.abs(m.db) > half || (m.a === manifest.base[0] && m.b === manifest.base[1])) continue;
ctx.beginPath(); ctx.arc(X(m.da), Y(m.db), 3.4, 0, 2 * Math.PI);
ctx.strokeStyle = "#fcfcfb"; ctx.lineWidth = 2.5; ctx.stroke(); ctx.strokeStyle = "#52514e"; ctx.lineWidth = 1; ctx.stroke();
}
}
const correct = view.base_predicted === (manifest.base[0] + manifest.base[1]) % manifest.p;
ctx.fillStyle = correct ? "#0ca30c" : "#d03b3b"; ctx.strokeStyle = "#fcfcfb"; ctx.lineWidth = 1.5;
ctx.beginPath(); ctx.arc(X(0), Y(0), 4.5, 0, 2 * Math.PI); ctx.fill(); ctx.stroke();
canvas._plot = {L, T, side, width, height};
return [lo, hi];
}
function inspect(view, point, marker = null) {
const [c, r] = point, i = r * view.grid + c;
const da = -view.span / 2 + c / (view.grid - 1) * view.span, db = -view.span / 2 + r / (view.grid - 1) * view.span;
let text = `a turned ${da.toFixed(1)}°, b turned ${db.toFixed(1)}° · surface answer ${view.pred[i]} · Fisher–Rao from centre ${fmt(actual(field(view, "fr_base"), i))} rad · Fisher speed ${fmt(actual(field(view, "fisher_plane"), i))} · L2 speed ${fmt(actual(field(view, "l2_plane"), i))} per L2 step.`;
if (marker) text += ` Marker ${marker.a} + ${marker.b}: final embedding is ${fmt(marker.miss)} L2 from this surface at its projected angles.`;
$("readout").textContent = text;
}
function draw() {
if (!run) return;
const frame = run.frames[index], view = frame.views[$("span").value];
if (!view.pred) view.pred = decode(view.predicted);
$("maps").hidden = false;
$("step-label").textContent = "step " + frame.step.toLocaleString();
$("geometry").textContent = "geometry fixed at step " + manifest.geometry_step.toLocaleString();
for (const side of ["left", "right"]) {
const key = $(side).value, canvas = $(side + "-map");
const [lo, hi] = paint(canvas, view, key);
$(side + "-title").textContent = $(side).selectedOptions[0].textContent;
if (key !== "predicted") colorBar(side, lo, hi, view.fields[key].log);
}
$("left-bar-wrap").hidden = $("left").value === "predicted";
$("left-unit").textContent = "radians · 0 to π";
$("caption").textContent = `Clock ${$("clock").value} · centre: final embedding of (${manifest.base.join(", ")}), current network answer ${view.base_predicted} · final radii a ${fmt(view.radii[0])}, b ${fmt(view.radii[1])} · ${view.grid} × ${view.grid} sampled states. Hollow circles are the real pairs’ final angular projections; they generally lie off this surface in the full input space.`;
selected = selected || [Math.floor(view.grid / 2), Math.floor(view.grid / 2)];
inspect(view, selected);
}
function stop() { clearInterval(timer); timer = null; $("play").textContent = "▶"; $("play").setAttribute("aria-label", "Play checkpoints"); }
async function loadClock() {
const ticket = ++serial, clock = $("clock").value;
stop(); run = null; $("maps").hidden = true; $("readout").textContent = "Loading clock " + clock + "…";
$("step").disabled = $("play").disabled = true;
try {
if (!cache.has(clock)) {
const response = await fetch(new URL(manifest.files[clock], manifestURL));
if (!response.ok) throw new Error("HTTP " + response.status);
cache.set(clock, await response.json());
}
if (ticket !== serial) return;
run = cache.get(clock); index = Math.min(index, run.frames.length - 1);
$("step").max = run.frames.length - 1; $("step").value = index;
$("step").disabled = $("play").disabled = false;
selected = null; draw();
} catch (error) { if (ticket === serial) { $("readout").textContent = "Could not load this clock: " + error.message; $("readout").classList.add("ucs-error"); } }
}
async function load() {
if (loading || manifest) return; loading = true;
try {
const response = await fetch(manifestURL);
if (!response.ok) throw new Error("HTTP " + response.status);
manifest = await response.json();
for (const k of manifest.clocks) { const opt = document.createElement("option"); opt.value = k; opt.textContent = "clock " + k; $("clock").appendChild(opt); }
$("clock").value = manifest.default_clock; $("clock").disabled = false;
index = manifest.steps.length - 1; await loadClock();
} catch (error) { $("readout").textContent = "Could not load the fixed surface: " + error.message; $("readout").classList.add("ucs-error"); }
}
$("clock").addEventListener("change", loadClock);
for (const id of ["left", "right", "range", "marks"]) $(id).addEventListener("change", draw);
$("span").addEventListener("change", () => { selected = null; draw(); });
$("step").addEventListener("input", () => { index = +$("step").value; draw(); });
$("play").addEventListener("click", () => {
if (timer) { stop(); return; }
$("play").textContent = "Ⅱ"; $("play").setAttribute("aria-label", "Pause checkpoints");
timer = setInterval(() => { index = (index + 1) % run.frames.length; $("step").value = index; draw(); }, 750);
});
for (const side of ["left", "right"]) {
const canvas = $(side + "-map");
const pointer = ev => {
if (!run || !canvas._plot) return;
const view = run.frames[index].views[$("span").value], box = canvas.getBoundingClientRect(), {L, T, side: size} = canvas._plot;
const x = ev.clientX - box.left - L, y = ev.clientY - box.top - T;
if (x < 0 || y < 0 || x > size || y > size) return;
selected = [Math.round(x / size * (view.grid - 1)), Math.round((1 - y / size) * (view.grid - 1))];
const half = view.span / 2;
const near = $("marks").checked ? run.marks.find(m => Math.abs(m.da) <= half && Math.abs(m.db) <= half && Math.hypot((m.da + half) / view.span * size - x, (half - m.db) / view.span * size - y) < 7) : null;
inspect(view, selected, near);
};
canvas.addEventListener("pointermove", pointer); canvas.addEventListener("click", pointer);
canvas.addEventListener("keydown", ev => {
if (!run || !["ArrowLeft", "ArrowRight", "ArrowUp", "ArrowDown"].includes(ev.key)) return;
ev.preventDefault(); const view = run.frames[index].views[$("span").value];
const direction = {ArrowLeft:[-1,0], ArrowRight:[1,0], ArrowUp:[0,1], ArrowDown:[0,-1]}[ev.key];
selected = selected.map((v,i) => Math.max(0, Math.min(view.grid - 1, v + direction[i])));
inspect(view, selected);
});
}
let redraw;
new ResizeObserver(() => { cancelAnimationFrame(redraw); redraw = requestAnimationFrame(draw); }).observe(root);
const section = root.closest(".secwrap");
const tryLoad = () => { if (!section || section.style.display !== "none") load(); else stop(); };
if (section) new MutationObserver(tryLoad).observe(section, {attributes:true, attributeFilter:["style"]});
tryLoad();
})();
</script></main></html> |