feat: omega curve and unseen-N, the two steps before psi

omega.md: a plateau at [1,4] that does not track the domain across a 4.7x range,
so the bandwidth is a knob that was set wrong rather than a defect to design
around. omega=8 is an optimisation cliff, not a mis-tune. The project default of
10 is outside the plateau.

scale.md: one parameter set works at an entity count it never trained on --
trained on N<=16 it beats the oracle at N=32 -- and a lookup table does it too.
Read against an oracle because the mse/floor ratio is not comparable across N,
which is asserted as a test rather than claimed in prose. The cost runs
large->small only, at 2.28x, which makes it the pooling's 1/deg dilution rather
than a degree-distribution shift.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HCydQraDSoZ9WoTm2v23Eb
This commit is contained in:
chrnxandClaude Opus 5 committed 2026-09-07 17:45:41 -05:00
1 parent 6c545fd035
commit d95383f8a2
8 files changed
+467 -19

No files matched your search

+14 -8
View File
@@ -48,7 +48,7 @@ def cell_of(r: torch.Tensor) -> torch.Tensor:
return dy * G + dx
def gabor_kernel(sigma: float = 3.0, seed: int = 0) -> torch.Tensor:
def gabor_kernel(sigma: float = 3.0, seed: int = 0, kfreq: float = 0.35) -> torch.Tensor:
"""(CELLS, D) true kernel: a smooth, band-limited function of the displacement.
Smooth on purpose. A CPPN that cannot interpolate THIS has not failed a hard case, it has
@@ -57,7 +57,7 @@ def gabor_kernel(sigma: float = 3.0, seed: int = 0) -> torch.Tensor:
g = torch.Generator().manual_seed(seed)
ys, xs = torch.meshgrid(torch.arange(-R, R + 1), torch.arange(-R, R + 1), indexing="ij")
r = torch.stack([xs, ys], -1).reshape(CELLS, 2).float()
k = torch.randn(D, 2, generator=g) * 0.35 # spatial frequencies, low by design
k = torch.randn(D, 2, generator=g) * kfreq # spatial frequencies of the domain
phi = torch.rand(D, generator=g) * 6.2831853
env = torch.exp(-(r * r).sum(-1) / (2 * sigma * sigma))[:, None]
return env * torch.cos(r @ k.T + phi)
@@ -120,10 +120,14 @@ def fill_by_diffusion(w: torch.Tensor, held: torch.Tensor) -> None:
w.copy_(grid.view(CELLS, D))
def teacher(seed: int) -> nn.Module:
def teacher(seed: int, kfreq: float = 0.35) -> nn.Module:
"""kfreq is the DOMAIN's length scale, not the model's. Sweeping it against the CPPN's omega
is what separates a knob that wants calibrating per domain from a defect in the
architecture: if the best omega tracks kfreq, core.py's own comment was right all along and
nobody had calibrated it; if it sits still, the default can simply be corrected."""
m = make_model("table", seed + 1000)
with torch.no_grad():
m["rp"].cppn.w.copy_(gabor_kernel(seed=seed))
m["rp"].cppn.w.copy_(gabor_kernel(seed=seed, kfreq=kfreq))
for p in m.parameters():
p.requires_grad_(False)
return m
@@ -209,8 +213,9 @@ def floor_mse(tea, data) -> float:
return ((ys - ys.mean(0)) ** 2).mean().item()
def one_seed(arm: str, kind: str, frac: float, steps: int, seed: int, omega: float = 1.0) -> dict:
tea = teacher(seed)
def one_seed(arm: str, kind: str, frac: float, steps: int, seed: int, omega: float = 1.0,
kfreq: float = 0.35) -> dict:
tea = teacher(seed, kfreq)
held = holdout_cells(kind, frac, seed)
gen = torch.Generator().manual_seed(seed)
model = make_model(arm, seed, omega)
@@ -228,7 +233,7 @@ def one_seed(arm: str, kind: str, frac: float, steps: int, seed: int, omega: flo
ev = torch.Generator().manual_seed(seed + 5000)
seen = pair_batch(held, False, ev)
unseen = pair_batch(held, True, ev)
return {"seed": seed, "arm": arm, "omega": omega, "seen": evaluate(model, tea, seen),
return {"seed": seed, "arm": arm, "omega": omega, "kfreq": kfreq, "seen": evaluate(model, tea, seen),
"unseen": evaluate(model, tea, unseen),
"floor_seen": floor_mse(tea, seen), "floor_unseen": floor_mse(tea, unseen),
"n_held": int(held.sum())}
@@ -242,13 +247,14 @@ def main():
ap.add_argument("--seeds", default="0,1,2,3,4,5,6,7")
ap.add_argument("--arms", default="rp,table")
ap.add_argument("--omega", type=float, default=1.0)
ap.add_argument("--kfreq", type=float, default=0.35, help="the DOMAIN's spatial frequency")
ap.add_argument("--out", default="results/unseen.json")
args = ap.parse_args()
rows = []
for arm in args.arms.split(","):
for s in (int(x) for x in args.seeds.split(",")):
rows.append(one_seed(arm, args.holdout, args.frac, args.steps, s, args.omega))
rows.append(one_seed(arm, args.holdout, args.frac, args.steps, s, args.omega, args.kfreq))
r = rows[-1]
print(f"{arm:6s} seed {s} seen {r['seen']:.5f} unseen {r['unseen']:.5f}"
f" floor {r['floor_unseen']:.5f}", flush=True)