feat: vary kernel sharpness and hold-out structure -- both readings change
Four teacher families on one axis (how predictable the kernel is from its neighbours): smooth, high-frequency, a rule-generated sparse knight, and iid noise as the negative control, which is asserted to have neighbour correlation below 0.2 where the smooth teacher's is above 0.8. The knight teacher forced a new hold-out: most of its cells are exactly zero, so withholding uniformly asks nothing and the floor collapses. --holdout support withholds cells the kernel uses, closed under negation since a pair contributes r and -r. Under it the CPPN beats a lookup plus blur 4.4x on smooth and 3.0x on high-frequency, 6/6 seeds, reversing the earlier headline. And on the knight nothing generalises at all -- both arms at or above the floor. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HCydQraDSoZ9WoTm2v23Eb
This commit is contained in:
7 files changed
+279
-34
No files matched your search
@@ -89,3 +89,46 @@ def test_diffusion_reaches_every_held_cell_in_both_holdouts():
|
||||
w[~held] = 1.0
|
||||
unseen.fill_by_diffusion(w, held)
|
||||
assert (w[held] > 0).all() # no held cell was left stranded at its init
|
||||
|
||||
|
||||
def _support(kind, frac=0.25, seed=0):
|
||||
W = unseen.gabor_kernel(seed=seed, kind=kind)
|
||||
return unseen.holdout_cells("support", frac, seed, W), W
|
||||
|
||||
|
||||
def test_support_holdout_is_closed_under_negation():
|
||||
# A pair contributes r and -r. An asymmetric hold-out would leave pair_batch with nothing
|
||||
# to evaluate and it would spin forever rather than fail.
|
||||
for kind in ("smooth", "knight", "highfreq"):
|
||||
held, _ = _support(kind)
|
||||
for c in held.nonzero().flatten().tolist():
|
||||
dy, dx = divmod(c, unseen.G)
|
||||
assert held[(2 * unseen.R - dy) * unseen.G + (2 * unseen.R - dx)]
|
||||
|
||||
|
||||
def test_support_holdout_only_withholds_cells_that_carry_signal():
|
||||
# The whole reason this hold-out exists: withholding a zero cell of the knight kernel asks
|
||||
# nothing, the floor collapses, and the arms tie at a number that means nothing.
|
||||
for kind in ("smooth", "knight"):
|
||||
held, W = _support(kind)
|
||||
mag = W.abs().mean(1)
|
||||
assert (mag[held] > 0.2 * mag.max()).all()
|
||||
|
||||
|
||||
def test_knight_kernel_lives_on_exactly_the_eight_l_squares():
|
||||
W = unseen.gabor_kernel(kind="knight", seed=0)
|
||||
live = (W.abs().mean(1) > 0).nonzero().flatten().tolist()
|
||||
expect = {(dy + unseen.R) * unseen.G + (dx + unseen.R) for dx, dy in unseen.KNIGHT}
|
||||
assert set(live) == expect and len(expect) == 8
|
||||
|
||||
|
||||
def test_noise_teacher_has_no_neighbour_structure():
|
||||
# The negative control is only a control if it really is unpredictable from neighbours:
|
||||
# correlation between a cell and its right-hand neighbour should be near zero, where the
|
||||
# smooth teacher's is high.
|
||||
def neighbour_corr(kind):
|
||||
W = unseen.gabor_kernel(seed=0, kind=kind).view(unseen.G, unseen.G, -1)
|
||||
a, b = W[:, :-1].flatten(), W[:, 1:].flatten()
|
||||
return abs(float(torch.corrcoef(torch.stack([a, b]))[0, 1]))
|
||||
assert neighbour_corr("smooth") > 0.8
|
||||
assert neighbour_corr("noise") < 0.2
|
||||
Reference in new issue
Block a user