test(spatial): 跨家族 digest 一致性检查——同一观测不许有两个标签
"没有隐藏支路"和"有隐藏支路但看不见"产生完全相同的观测,于是前者标可判、 后者标 unknown,是模型永远无法复现的标签:证据缺失不等于不存在。原来的 hidden_pair 只在一个家族内部查,查不到这件事。
This commit is contained in:
1 parent
6af4cb8799
commit
1e0dcd6fb4
1 file changed
+37
-1
+37
-1
@@ -121,11 +121,47 @@ def check_invariances() -> bool:
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
def check_cross_family_digest() -> bool:
|
||||||
|
"""Two samples with the same ``input_digest`` must carry the same label.
|
||||||
|
|
||||||
|
This is the whole contract, and it has to hold *across* families, not only
|
||||||
|
inside one: "no hidden branch exists" and "a hidden branch exists but is not
|
||||||
|
visible" produce the same observation, so a label that says "decidable" in
|
||||||
|
the first case and "unknown" in the second is a label the model can never
|
||||||
|
reproduce -- absence of evidence is not evidence of absence. Samples whose
|
||||||
|
scores differ are still a bug, just a quieter one.
|
||||||
|
"""
|
||||||
|
seen = {}
|
||||||
|
bad = []
|
||||||
|
n = 0
|
||||||
|
for fam in generator.FAMILIES:
|
||||||
|
for i in range(40):
|
||||||
|
sc = generator.make(fam, seed=71, index=i)
|
||||||
|
n += 1
|
||||||
|
d = sc.input_digest()
|
||||||
|
prev = seen.get(d)
|
||||||
|
if prev is None:
|
||||||
|
seen[d] = (fam, sc.label.answer, sc.label.change)
|
||||||
|
elif (prev[1], prev[2]) != (sc.label.answer, sc.label.change):
|
||||||
|
bad.append((prev, (fam, sc.label.answer, sc.label.change)))
|
||||||
|
if bad:
|
||||||
|
# collapse to the distinct family pairs, the list itself is long
|
||||||
|
pairs = sorted({(a[0], b[0]) for a, b in bad})
|
||||||
|
print(f" {len(bad)} samples share an input digest with a different label")
|
||||||
|
for a, b in pairs[:6]:
|
||||||
|
print(f" {a:11s} vs {b:11s}")
|
||||||
|
return _fail("same input, different label -- the observation does not "
|
||||||
|
"determine the answer, so both cannot be decidable")
|
||||||
|
print(f"ok {n} samples: no two families assign different labels to "
|
||||||
|
f"the same observation ({len(seen)} distinct inputs)")
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
def cmd_smoke(args) -> int:
|
def cmd_smoke(args) -> int:
|
||||||
cfg = _load_config(args.config)
|
cfg = _load_config(args.config)
|
||||||
print(f"config {args.config} out {cfg['out_dir']}")
|
print(f"config {args.config} out {cfg['out_dir']}")
|
||||||
results = [check_splits(cfg), check_determinism(), check_labels(),
|
results = [check_splits(cfg), check_determinism(), check_labels(),
|
||||||
check_insufficient(), check_invariances()]
|
check_insufficient(), check_invariances(), check_cross_family_digest()]
|
||||||
|
|
||||||
# one update, then interrupt and resume: the step counter must advance
|
# one update, then interrupt and resume: the step counter must advance
|
||||||
from . import train as trainer
|
from . import train as trainer
|
||||||
|
|||||||
Reference in new issue
Block a user