File size: 722 Bytes
fe8202e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import os
import sys

import torch

sys.path.append(os.path.join(os.path.dirname(__file__), "..", "src"))

from gliomasam3_moe.models.gliomasam3_moe import GliomaSAM3_MoE


def test_model_shapes():
    model = GliomaSAM3_MoE(
        patch_size=16,
        token_dim=64,
        depth=2,
        heads=4,
        slice_attn_k=4,
        spectral_bins=8,
        spectral_q=3,
        moe_experts=5,
        moe_topk=2,
        decoder_hidden=32,
        prompt_mlp_hidden=64,
    )
    x = torch.randn(2, 4, 16, 128, 128)
    logits, aux = model(x)
    assert logits.shape == (2, 3, 16, 128, 128)
    assert "pi_et" in aux
    assert "moe_gamma" in aux
    assert "spectral_stats" in aux
    assert "et_prob_gated" in aux