File size: 8,501 Bytes
020f489 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 | """Post-unblinding verification: LOO-NN baseline + H2 evidence checks against the blinded text files."""
import glob, os, re, numpy as np
KEY = {"net-05494c": "breakout", "net-2e9b8d": "pong", "net-56a28c": "cannot", "net-5e5f0b": "pacman",
"net-624dd8": "cannot", "net-6572b1": "pong", "net-666835": "pacman", "net-728dfa": "breakout",
"net-762ca5": "cannot", "net-7a6b35": "pong", "net-805802": "freeway", "net-90f124": "breakout",
"net-9516ed": "freeway", "net-9a9bc9": "freeway", "net-a14969": "pacman", "net-d8c51c": "cannot"}
MAZE = ["##########", "#........#", "#.##..##.#", "#.#....#.#", "#...##...#",
"#.#....#.#", "#.##..##.#", "#........#", "#........#", "##########"]
WALL = np.array([[c == "#" for c in r] for r in MAZE])
def load(f):
W1 = np.zeros((32, 5, 10, 10)); u = ch = -1; sec = None
b1 = W2 = b2 = Wo = bo = None; W2r = []; Wor = []
lines = open(f).read().splitlines()
for i, l in enumerate(lines):
m = re.match(r"### fc1 unit (\d+)", l)
if m: u = int(m.group(1)); continue
m = re.match(r"channel (\d)", l)
if m: ch = int(m.group(1)); continue
m = re.match(r" r(\d): (.*)", l)
if m and sec is None: W1[u, ch, int(m.group(1))] = [float(v) for v in m.group(2).split()]; continue
if l.startswith("## fc1.bias"): b1 = np.array(lines[i + 1].split(), float); sec = "b1"
elif l.startswith("## fc2.weight"): sec = "W2"
elif l.startswith("## fc2.bias"): b2 = np.array(lines[i + 1].split(), float); sec = "b2"
elif l.startswith("## out.weight"): sec = "Wo"
elif l.startswith("## out.bias"): bo = np.array(lines[i + 1].split(), float); sec = "bo"
elif sec == "W2" and re.match(r"u\d+:", l): W2r.append([float(v) for v in l.split(":")[1].split()])
elif sec == "Wo" and re.match(r"a\d", l): Wor.append([float(v) for v in l.split(":")[1].split()])
return dict(W1=W1, b1=b1, W2=np.array(W2r), b2=b2, Wo=np.array(Wor), bo=bo)
nets = {os.path.basename(f)[:-4]: load(f) for f in sorted(glob.glob("/b/net-*.txt"))}
assert len(nets) == 16
# ---------- Baseline (ii): leave-one-out nearest neighbour (same features as k-means) ----------
ids = sorted(nets)
def feat(n):
m = np.abs(n["W1"]).sum(0).reshape(500)
f = np.concatenate([m.reshape(5, 100).sum(1), m]); return f / np.linalg.norm(f)
X = np.array([feat(nets[i]) for i in ids])
correct = 0; trained = [i for i in ids if KEY[i] != "cannot"]
for i, a in enumerate(ids):
if KEY[a] == "cannot": continue
d = np.linalg.norm(X - X[i], axis=1); d[i] = np.inf
nb = ids[int(np.argmin(d))]; correct += KEY[nb] == KEY[a]
print(f"BASELINE LOO-NN (all 16 as reference, nulls labelled 'cannot'): {correct}/12 trained correct")
# ---------- H2: specific quoted values (attempt-1 readers, the primary condition) ----------
def v(nid, what):
n = nets[nid]; kind = what[0]
if kind == "fc1": _, u, c, r, col = what; return n["W1"][u, c, r, col]
if kind == "out": _, a, h = what; return n["Wo"][a, h]
if kind == "bo": return n["bo"][what[1]]
Q = [ # (net, location, quoted value)
("net-05494c", ("fc1", 0, 0, 9, 0), 0.126), ("net-05494c", ("fc1", 5, 1, 7, 1), 0.385), ("net-05494c", ("fc1", 25, 4, 6, 6), -0.307),
("net-2e9b8d", ("fc1", 0, 0, 6, 9), 0.128), ("net-2e9b8d", ("fc1", 13, 1, 6, 8), -0.338), ("net-2e9b8d", ("fc1", 27, 1, 6, 8), 0.313),
("net-5e5f0b", ("fc1", 0, 0, 2, 1), 0.36), ("net-5e5f0b", ("out", 2, 12), 0.80), ("net-5e5f0b", ("out", 4, 4), 0.756),
("net-6572b1", ("fc1", 0, 0, 5, 9), 0.182), ("net-6572b1", ("fc1", 11, 4, 3, 7), -0.302), ("net-6572b1", ("fc1", 29, 4, 2, 7), 0.299),
("net-666835", ("fc1", 3, 0, 2, 1), 0.30), ("net-666835", ("fc1", 3, 0, 2, 4), 0.49),
("net-728dfa", ("fc1", 0, 0, 9, 0), 0.186), ("net-728dfa", ("fc1", 0, 0, 9, 8), -0.236), ("net-728dfa", ("out", 4, 16), 1.062), ("net-728dfa", ("fc1", 0, 1, 8, 9), 0.396),
("net-7a6b35", ("fc1", 27, 0, 4, 9), -0.2295), ("net-7a6b35", ("fc1", 25, 0, 4, 9), 0.2126), ("net-7a6b35", ("fc1", 16, 1, 9, 8), -0.268),
("net-805802", ("fc1", 0, 0, 6, 4), 0.0884), ("net-805802", ("bo", 1), 0.138), ("net-805802", ("bo", 3), -0.243),
("net-90f124", ("fc1", 0, 0, 9, 1), 0.199), ("net-90f124", ("fc1", 7, 1, 7, 1), 0.41), ("net-90f124", ("fc1", 0, 1, 7, 1), -0.38),
("net-9516ed", ("fc1", 30, 0, 4, 4), -0.087), ("net-9516ed", ("fc1", 6, 0, 7, 4), -0.083), ("net-9516ed", ("out", 1, 15), -0.45),
("net-9a9bc9", ("fc1", 3, 0, 6, 4), -0.087), ("net-9a9bc9", ("fc1", 19, 0, 5, 4), 0.085), ("net-9a9bc9", ("fc1", 5, 0, 4, 4), 0.083),
("net-a14969", ("fc1", 0, 0, 2, 5), 0.50), ("net-a14969", ("fc1", 3, 0, 4, 2), 0.41), ("net-a14969", ("out", 2, 31), 0.852),
]
ok = 0
print("\nQUOTED VALUES (tolerance: within 0.02 absolute or 10% relative)")
for nid, loc, q in Q:
got = v(nid, loc); hit = abs(got - q) <= max(0.02, 0.1 * abs(q)); ok += hit
print(f" {'OK ' if hit else 'BAD'} {nid} {loc} quoted {q:+.4f} actual {got:+.4f}")
print(f"QUOTED VALUES: {ok}/{len(Q)} check out")
# ---------- H2: structural claims ----------
print("\nSTRUCTURAL CLAIMS")
S = []
def claim(text, cond): S.append(cond); print(f" {'OK ' if cond else 'BAD'} {text}")
INIT = 1 / np.sqrt(500)
for nid in ids:
g = KEY[nid]; n = nets[nid]; a0 = np.abs(n["W1"][:, 0]) # agent channel |w| [32,10,10]
big = a0 > 0.06
if g == "breakout":
claim(f"{nid} breakout: agent-channel weights >0.06 lie only in row 9 ({big[:, 9].sum()}/{big.sum()})", big[:, :9].sum() == 0)
claim(f"{nid} breakout: left/right out rows dominate (max|L,R| {np.abs(n['Wo'][3:]).max():.2f} vs max|noop,up,down| {np.abs(n['Wo'][:3]).max():.2f})",
np.abs(n["Wo"][3:]).max() > 1.5 * np.abs(n["Wo"][:3]).max())
if g == "pong":
claim(f"{nid} pong: agent-channel weights >0.06 lie only in column 9 ({big[:, :, 9].sum()}/{big.sum()})", big[:, :, :9].sum() == 0)
claim(f"{nid} pong: up/down out rows dominate left/right (max|U,D| {np.abs(n['Wo'][1:3]).max():.2f} vs max|L,R| {np.abs(n['Wo'][3:]).max():.2f})",
np.abs(n["Wo"][1:3]).max() > np.abs(n["Wo"][3:]).max())
if g == "freeway":
claim(f"{nid} freeway: agent-channel weights >0.06 lie only in column 4 ({big[:, :, 4].sum()}/{big.sum()})", big[:, :, [0,1,2,3,5,6,7,8,9]].sum() == 0)
t = np.abs(n["W1"][:, 2])
claim(f"{nid} freeway: target-channel weights >0.06 lie only in row 0 ({(t[:,0]>0.06).sum()}/{(t>0.06).sum()})", (t[:, 1:] > 0.06).sum() == 0)
if g == "pacman":
border = np.zeros((10, 10), bool); border[[0, 9], :] = True; border[:, [0, 9]] = True
claim(f"{nid} pacman: agent-channel border cells stay at init (max {a0[:, border].max():.3f})", a0[:, border].max() <= INIT + 1e-4)
inner_wall = WALL & ~border
claim(f"{nid} pacman: interior wall cells (true maze) stay at init (max {a0[:, inner_wall].max():.3f})", a0[:, inner_wall].max() <= INIT + 1e-4)
open_ = ~WALL
claim(f"{nid} pacman: every open corridor cell is used (min over cells of max|w| {a0[:, open_].max(0).min():.3f})", a0[:, open_].max(0).min() > 0.06)
if g in ("breakout", "pong", "freeway"):
o = np.abs(n["W1"][:, 3]).max()
claim(f"{nid} {g}: readers' 'obstacles channel looks untrained' (max |w| {o:.3f}, init bound {INIT:.4f})", o <= 0.06)
if nid in ("net-56a28c", "net-d8c51c"):
m = np.abs(n["W1"]).max()
claim(f"{nid} random-init: all fc1 within init bound 0.0447 (max {m:.5f})", m <= INIT + 1e-4)
print(f"STRUCTURAL: {sum(S)}/{len(S)} check out")
# ---------- Specific factual claims worth checking individually ----------
print("\nSPECIFIC CLAIMS")
n = nets["net-666835"]; a0 = np.abs(n["W1"][:, 0])
print(f" 666835 attempt-2 drew row 7 cols 4,5 as walls. True maze row 7 is fully open. Max|w| there: c4 {a0[:,7,4].max():.3f}, c5 {a0[:,7,5].max():.3f}")
for nid in ("net-5e5f0b", "net-a14969"):
a0 = np.abs(nets[nid]["W1"][:, 0]); print(f" {nid} row7 c4/c5 max|w| {a0[:,7,4].max():.3f}/{a0[:,7,5].max():.3f}")
o = np.abs(nets["net-7a6b35"]["W1"][:, 3]); print(f" 7a6b35 reader: faint obstacles signal col 0 rows 6-8 (opponent paddle is in ch3 col 0). max there {o[:,6:9,0].max():.3f}, max elsewhere {np.delete(o.reshape(32,100), [60,70,80], axis=1).max():.3f}")
for nid in ("net-05494c", "net-728dfa", "net-90f124"):
t = np.abs(nets[nid]["W1"][:, 2]); print(f" {nid} breakout targets(bricks) ch2: max rows0-2 {t[:,:3].max():.3f}, max rows3-9 {t[:,3:].max():.3f}")
|