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}