feat: learned-frame arm and an orbit-consistency diagnostic
rp_learn_K learns K linear maps on the displacement and averages the CPPN over them, so a set closed under the domain's group makes the kernel invariant to it without anyone naming the group. orbit_consistency measures that invariance from the kernel's behaviour rather than its parameters, validated against the two kernels whose answers are known exactly. Both false-positive modes are instrumented: fit-versus-held-out separates extra capacity from discovery, and the spread of the learned maps catches a collapse to K=1. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HCydQraDSoZ9WoTm2v23Eb
This commit is contained in:
4 files changed
+226
-9
No files matched your search
@@ -165,3 +165,29 @@ def test_knight_sym_is_one_orbit_and_knight_is_not():
|
||||
asym = unseen.gabor_kernel(kind="knight", seed=0)[cells]
|
||||
assert (sym.std(0) == 0).all() # same value on all eight squares, per channel
|
||||
assert (asym.std(0) > 0).any() # the control shares support but not a rule
|
||||
|
||||
|
||||
def test_orbit_consistency_reads_zero_for_a_kernel_that_is_invariant_by_construction():
|
||||
# Validates the metric itself against the one kernel whose answer is known exactly.
|
||||
inv = unseen.make_model("rp_inv", 0)["rp"].cppn
|
||||
raw = unseen.make_model("rp", 0)["rp"].cppn
|
||||
assert unseen.orbit_consistency(inv) < 1e-6
|
||||
assert unseen.orbit_consistency(raw) > 0.1
|
||||
|
||||
|
||||
def test_learned_frame_starts_spread_and_can_collapse():
|
||||
# The null hypothesis for the learned arm is that the maps collapse to one, making it K=1
|
||||
# with more compute. They start apart, and a deliberate collapse must read as one.
|
||||
k = unseen.make_model("rp_learn_4", 0)["rp"].cppn
|
||||
assert unseen.frame_spread(k) > 0.1
|
||||
with torch.no_grad():
|
||||
k.T.copy_(k.T[0].expand_as(k.T))
|
||||
assert unseen.frame_spread(k) < 1e-6
|
||||
|
||||
|
||||
def test_learned_frame_averages_over_its_maps():
|
||||
k = unseen.make_model("rp_learn_2", 0)["rp"].cppn
|
||||
r = torch.randint(-3, 4, (4, 4, 2)).float()
|
||||
edge, ctx = torch.ones(4, 4, 1), torch.zeros(2)
|
||||
manual = torch.stack([k.cppn(r @ t.T, edge, ctx) for t in k.T]).mean(0)
|
||||
assert torch.allclose(k(r, edge, ctx), manual, atol=1e-6)
|
||||
Reference in new issue
Block a user