feat(spatial): 加 declared 输入模式,训练时就不给泄漏通道,再谈充分性
This commit is contained in:
1 parent
efe1ee6801
commit
7e73e9286a
5 files changed
+75
-13
No files matched your search
+11
-5
@@ -124,7 +124,7 @@ def edge_features(sc: Scenario, ed, removed: bool, dangling: bool = False) -> li
|
||||
return f
|
||||
|
||||
|
||||
def scene_features(sc: Scenario) -> list:
|
||||
def scene_features(sc: Scenario, availability: str = "leaked") -> list:
|
||||
"""The observation's own admission of what it is missing.
|
||||
|
||||
``hidden_layers`` and ``hidden_faces`` are in the digest but were never in
|
||||
@@ -170,13 +170,19 @@ def scene_features(sc: Scenario) -> list:
|
||||
f[base + 5] = 1.0 if (scope.get("layers") or []) and (
|
||||
tot_parts > sum(rendered.values()) or tot_rel > sum(rel_r.values())
|
||||
or missing_layers) else 0.0
|
||||
if availability != "leaked":
|
||||
# training-time, not eval-time: the model must never see a channel it
|
||||
# could not be given at inference. Zeroing at eval only measures whether
|
||||
# a channel was necessary, never whether the rest is sufficient.
|
||||
f[0:base] = [0.0] * base
|
||||
return f
|
||||
|
||||
|
||||
def collate(batch, max_entities: int = 32):
|
||||
def collate(batch, max_entities: int = 32, availability: str = "leaked"):
|
||||
B = len(batch)
|
||||
N = max(1, max(len(sc.obs.entities) for sc in batch))
|
||||
E = max(1, max(len(sc.obs.edges) + len(sc.obs.dangling) for sc in batch))
|
||||
E = max(1, max(len(sc.obs.edges) + (len(sc.obs.dangling) if availability == "leaked"
|
||||
else 0) for sc in batch))
|
||||
if N > max_entities:
|
||||
raise ValueError(f"scene needs {N} entity slots > max_entities {max_entities}; "
|
||||
"bucket it instead of truncating")
|
||||
@@ -200,7 +206,7 @@ def collate(batch, max_entities: int = 32):
|
||||
|
||||
for i, sc in enumerate(batch):
|
||||
ids = {e.eid: j for j, e in enumerate(sc.obs.entities)}
|
||||
scene[i] = torch.tensor(scene_features(sc))
|
||||
scene[i] = torch.tensor(scene_features(sc, availability))
|
||||
for j, e in enumerate(sc.obs.entities):
|
||||
feat[i, j] = torch.tensor(entity_features(sc, e))
|
||||
pad_mask[i, j] = False
|
||||
@@ -218,7 +224,7 @@ def collate(batch, max_entities: int = 32):
|
||||
# dangling relations go after the real ones and point at the unknown
|
||||
# slot via the sentinel endpoint ``N``; their far end is never an entity,
|
||||
# so they can never be mistaken for a traversable edge
|
||||
for j, dl in enumerate(sc.obs.dangling):
|
||||
for j, dl in enumerate(sc.obs.dangling if availability == "leaked" else ()):
|
||||
k = len(sc.obs.edges) + j
|
||||
edge_index[i, k, 0] = ids.get(dl.a, 0)
|
||||
edge_index[i, k, 1] = N
|
||||
|
||||
Reference in new issue
Block a user