From f5443278b992c366519e6f222623ad842748a3f6 Mon Sep 17 00:00:00 2001 From: lhj <403133128@qq.com> Date: Thu, 3 Dec 2026 18:19:57 +0800 Subject: [PATCH] =?UTF-8?q?fix(spatial):=20=E7=A8=B3=E5=AE=9A=E6=80=A7?= =?UTF-8?q?=E5=AE=B6=E6=97=8F=E5=8A=A0=E5=85=A5"=E6=97=A0=E5=AE=B3?= =?UTF-8?q?=E7=BC=96=E8=BE=91"=EF=BC=8C=E6=89=93=E7=A0=B4"=E7=BC=96?= =?UTF-8?q?=E8=BE=91=E2=87=92false"=E7=9A=84=E4=B8=80=E4=BD=8D=E6=8D=B7?= =?UTF-8?q?=E5=BE=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 基线表量出:三个训练家族的标签被"发生过编辑就答 false"完全可分(各 1.000), 模型在 10 个家族里有 6 个与该规则的分数逐位相同,说明四个结构件没有一个被用到。 稳定性家族此前唯一的编辑是移走基座 P,必然倒塌,于是"移走了东西"和"目标失去 支撑"在所有样本上是同一个事件。改为: - 增加诱饵块 D(坐在地面上、不承载任何东西、可见),移走它不改变结论; - 目标固定为 T;n_blocks>=3 时移走 U 也不改变结论; - 编辑分布:40% 移 P(倒塌)、35% 移无害块(无影响)、25% 不编辑。 同时把旧的可分配置留作对照 configs/cross_oneshot.json。 --- spatial/configs/cross.json | 8 +++--- spatial/configs/cross_oneshot.json | 40 ++++++++++++++++++++++++++++++ spatial/generator.py | 28 +++++++++++++++------ 3 files changed, 64 insertions(+), 12 deletions(-) create mode 100644 spatial/configs/cross_oneshot.json diff --git a/spatial/configs/cross.json b/spatial/configs/cross.json index eba0ccb..66e4645 100644 --- a/spatial/configs/cross.json +++ b/spatial/configs/cross.json @@ -5,11 +5,11 @@ "rounds": 2, "n_evidence": 4 }, "data": { - "train_families": ["cond.p1", "area.sup2", "dof.c6"], - "val_families": ["cond.p1h", "area.sup2h", "dof.c6h"], - "test_families": ["cond.p3h", "area.sup3", "dof.c6r"] + "train_families": ["cond.p1", "cond.p3", "area.sup2", "area.sup3", "dof.c6", "dof.c6r", "cond.p1h"], + "val_families": ["cond.p3h", "area.sup2h", "dof.c6h"], + "test_families": ["cond.p3h", "area.sup2h", "dof.c6h"] }, - "optim": { "lr": 0.003, "weight_decay": 0.01, "steps": 1200, "batch": 32, "log_every": 200 }, + "optim": { "lr": 0.003, "weight_decay": 0.01, "steps": 2400, "batch": 32, "log_every": 400 }, "eval": { "n": 192 }, "out_dir": "out_spatial/cross" } diff --git a/spatial/configs/cross_oneshot.json b/spatial/configs/cross_oneshot.json new file mode 100644 index 0000000..132ecda --- /dev/null +++ b/spatial/configs/cross_oneshot.json @@ -0,0 +1,40 @@ +{ + "seed": 0, + "model": { + "d": 192, + "n_layer": 4, + "n_head": 6, + "dropout": 0.1, + "max_entities": 32, + "rounds": 2, + "n_evidence": 4 + }, + "data": { + "train_families": [ + "cond.p1", + "area.sup2", + "dof.c6" + ], + "val_families": [ + "cond.p1h", + "area.sup2h", + "dof.c6h" + ], + "test_families": [ + "cond.p3h", + "area.sup3", + "dof.c6r" + ] + }, + "optim": { + "lr": 0.003, + "weight_decay": 0.01, + "steps": 1200, + "batch": 32, + "log_every": 200 + }, + "eval": { + "n": 192 + }, + "out_dir": "out_spatial/cross_oneshot" +} \ No newline at end of file diff --git a/spatial/generator.py b/spatial/generator.py index 652975a..1ca6077 100644 --- a/spatial/generator.py +++ b/spatial/generator.py @@ -99,13 +99,21 @@ def _build_connection(rng, n_paths: int, hidden: int): def _build_stability(rng, n_blocks: int, hidden: int): + # D is a decoy: it rests on the ground next to the stack and carries + # nothing. Without it "something was removed" and "the target lost support" + # are the same event on every sample, and a one-bit rule fits the whole + # family -- measured: that rule scores 1.000 here while knowing no physics. ents = [Entity("G", "ground", attrs={"plane": 0}), Entity("P", "block", attrs={"box": [40, 40, 0, 60, 60, 20]}), - Entity("T", "block", attrs={"box": [42, 42, 20, 58, 58, 36]})] - edges = [Edge("kPG", "contact", "P", "G"), Edge("kPT", "contact", "T", "P")] + Entity("T", "block", attrs={"box": [42, 42, 20, 58, 58, 36]}), + Entity("D", "block", attrs={"box": [80, 40, 0, 100, 60, 16]})] + edges = [Edge("kPG", "contact", "P", "G"), Edge("kPT", "contact", "T", "P"), + Edge("kDG", "contact", "D", "G")] + top = None if n_blocks >= 3: ents.append(Entity("U", "block", attrs={"box": [44, 44, 36, 56, 56, 48]})) edges.append(Edge("kTU", "contact", "U", "T")) + top = "U" vis_edges = {e.eid for e in edges} vis_ents = {e.eid for e in ents} layers = set() @@ -118,12 +126,16 @@ def _build_stability(rng, n_blocks: int, hidden: int): vis_edges.discard(e.eid) vis_ents.discard("P") - target = "U" if n_blocks >= 3 else "T" - query = Query(kind="stability", a=target) - # an edit can only name something the observation shows; with the pedestal - # hidden the only legal edit is "nothing changes" - if not hidden and rng.random() < 0.5: - query.edit = {"op": "remove_entity", "entity": "P"} + # the target is T on purpose: it survives every legal edit except the one + # that removes P, so "removed something" no longer implies "answer false" + query = Query(kind="stability", a="T") + r = rng.random() + if not hidden: + harmless = top or "D" + if r < 0.4: + query.edit = {"op": "remove_entity", "entity": "P"} # collapses + elif r < 0.75: + query.edit = {"op": "remove_entity", "entity": harmless} # no effect return ents, edges, query, vis_edges, vis_ents, layers, ["front", "iso"], {"length": "mm", "per_unit": 1}