Skip to content

Commit f0c26c3

Browse files
committed
Test the opt-in PerDetHead embedding
1 parent cb85b64 commit f0c26c3

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

tests/test_consistency_heads.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ def test_perdethead_shapes_and_sigma_clamp():
6565
t_pos = torch.linspace(0.0, 12.0, T)
6666
out = head(torch.randn(B, C, T), t_pos)
6767
for field in out._fields:
68+
if field == "embedding": # opt-in, default None (checked below)
69+
continue
6870
assert getattr(out, field).shape == (B,), field
6971
# softplus parameterisation: sigma is a positive std within [sigma_min, sigma_max]
7072
for s in (out.sigma_tc, out.sigma_mc):
@@ -74,6 +76,15 @@ def test_perdethead_shapes_and_sigma_clamp():
7476
assert (out.mu_tc <= t_pos.max() + 1e-3).all()
7577

7678

79+
def test_perdethead_embedding_is_opt_in():
80+
head = PerDetHead(C)
81+
t_pos = torch.linspace(0.0, 12.0, T)
82+
x = torch.randn(B, C, T)
83+
assert head(x, t_pos).embedding is None # default: not returned
84+
emb = head(x, t_pos, return_embedding=True).embedding # opt-in: pooled feature
85+
assert emb is not None and emb.shape == (B, C)
86+
87+
7788
def test_perdethead_soft_argmax_localises():
7889
head = PerDetHead(C)
7990
t_pos = torch.linspace(0.0, 12.0, T)

0 commit comments

Comments
 (0)