From dcadaff8622e6c8b3450f12f45447f605c68556a Mon Sep 17 00:00:00 2001 From: YurenHao0426 Date: Wed, 22 Jul 2026 03:33:44 -0500 Subject: method: condition apical vectorizers on neural state --- experiments/smoke.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'experiments/smoke.py') diff --git a/experiments/smoke.py b/experiments/smoke.py index 025d3cc..fcc0e9c 100644 --- a/experiments/smoke.py +++ b/experiments/smoke.py @@ -132,6 +132,29 @@ def check_traffic_seed_isolation(): print("CHECK0d traffic seed changes feedback only: passed") +def check_state_conditioned_vectorizers(): + """Gated apical features must start as linear feedback and learn locally.""" + torch.manual_seed(17) + x = torch.randn(48, 6) + y = torch.randint(0, 2, (48,)) + yoh = onehot(y, 2) + for mode in ("soma_gated", "context_gated"): + net = SDILNet([6, 8, 8, 2], act="relu", device="cpu", seed=9, + residual=True, vectorizer_mode=mode) + fwd = net.forward(x) + c = net.output_error(fwd["h"][-1], yoh) + context = fwd["h"][-2] + before = net.vectorizer(0, c, fwd["h"][1], context) + assert torch.allclose(before, c @ net.A[0].t()) + gates_before = [gate.clone() for gate in net.A_gate] + cfg = SDILConfig(eta=0.01, eta_A=0.02, pert_every=1, + pert_ndirs=2, pert_mode="simultaneous") + sdil_step(net, x, y, yoh, cfg, step=0) + assert any(not torch.equal(old, new) + for old, new in zip(gates_before, net.A_gate)) + print("CHECK0e state-conditioned vectorizers: zero-init and local calibration passed") + + def main(): torch.manual_seed(0) dev = "cpu" @@ -139,6 +162,7 @@ def main(): check_neutral_predictor() check_topdown_predictor() check_traffic_seed_isolation() + check_state_conditioned_vectorizers() print("loading MNIST subset...") tr, te, n_in, n_out = get_dataset("mnist", batch_size=128, device=dev) xb, yb = next(iter(tr)) -- cgit v1.2.3