summaryrefslogtreecommitdiff
path: root/experiments/smoke.py
diff options
context:
space:
mode:
Diffstat (limited to 'experiments/smoke.py')
-rw-r--r--experiments/smoke.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/experiments/smoke.py b/experiments/smoke.py
index 83ee896..025d3cc 100644
--- a/experiments/smoke.py
+++ b/experiments/smoke.py
@@ -113,12 +113,32 @@ def check_topdown_predictor():
assert final[-1] < 0.03
+def check_traffic_seed_isolation():
+ """Traffic-family seeds must not change feedforward initialization/data."""
+ net_a = SDILNet([20, 32, 32, 32, 5], device="cpu", seed=6, nuis_rho=1.0,
+ nuis_seed=41, residual=True, traffic_mode="topdown")
+ net_b = SDILNet([20, 32, 32, 32, 5], device="cpu", seed=6, nuis_rho=1.0,
+ nuis_seed=42, residual=True, traffic_mode="topdown")
+ x = torch.randn(64, 20)
+ for wa, wb in zip(net_a.W, net_b.W):
+ assert torch.equal(wa, wb)
+ ha = net_a.forward(x)["h"]
+ hb = net_b.forward(x)["h"]
+ for xa, xb in zip(ha, hb):
+ assert torch.equal(xa, xb)
+ traffic_a = net_a.apical_traffic(0, ha[1], ha[-2])
+ traffic_b = net_b.apical_traffic(0, hb[1], hb[-2])
+ assert not torch.equal(traffic_a, traffic_b)
+ print("CHECK0d traffic seed changes feedback only: passed")
+
+
def main():
torch.manual_seed(0)
dev = "cpu"
check_residual_local_jacobian()
check_neutral_predictor()
check_topdown_predictor()
+ check_traffic_seed_isolation()
print("loading MNIST subset...")
tr, te, n_in, n_out = get_dataset("mnist", batch_size=128, device=dev)
xb, yb = next(iter(tr))