用分离的语义投影生成细节分支输入,以空间频谱对齐特征调节遗忘矩阵,再经局部卷积、选择性扫描和输出投影,返回细节 token 与对齐损失。
tokens 2×18×8;语义 A_log 16×3;语义投影权重 32×8细节 tokens 2×18×8;对齐损失 scalar352 个参数 · D=8,state=3,conv=3,expand=2;外部语义参数另计;视频分割状态空间细节分支。CPU 实跑,按 sum(p.numel() for p in model.parameters()) 统计。forward() 数据流顺序拆解 · 点击任意子模块方块可同步查看对应源码切片用分离的语义投影生成细节分支输入,以空间频谱对齐特征调节遗忘矩阵,再经局部卷积、选择性扫描和输出投影,返回细节 token 与对齐损失。
517 batch, seqlen, dim = hidden_states.shape 518 if seqlen != T*H*W or dim != self.d_model:519 raise ValueError('Expected hidden_states (B,T*H*W,d_model).') 520 if A_log.shape != (self.d_inner,self.d_state) or in_proj_weight.shape != (2*self.d_inner,self.d_model):521 raise ValueError('Semantic parameter dimensions must match the detail mixer.') 524 weight = in_proj_weight.detach()525 bias = in_proj_bias.detach() if in_proj_bias is not None else None 526 xz = F.linear(hidden_states,weight,bias).transpose(1,2)527 x,z = xz.chunk(2,dim=1) 399 x = rearrange(x, "b c (t h w) -> (b t) c h w", t=T, h=H, w=W)400 features = self.compute_channel_features(x) # (B, C) 402 similarity = self.compute_pairwise_similarity(features) # (B, B)
tokens 为 2×18×8;外部 semantic_A_log 为 16×3,投影权重为 32×8。图与参数统计来自内联 torch 参考扫描的真实 CPU 前向,宿主还需完整语义分支。
from RSSSMDetailMamba import RSSSMDetailMamba mixer = RSSSMDetailMamba(8, d_state=3, d_conv=3, expand=2) y, align_loss = mixer(tokens, semantic_A_log, semantic_in_proj_weight, T=2, H=3, W=3)
Method 动机参考:在语义状态压缩之外,用频谱提示与遗忘矩阵细化补充视频细节表示。
| 消融变体 | 结构配置 | 验证目的 |
|---|---|---|
| 普通细节扫描 | 使用原 A_log | 隔离矩阵细化的作用 |
| 细化无辅助损失 | 保留反转但不加 align_loss | 区分频谱条件和训练监督 |
| 完整分支 | 细化 A 与对齐损失 | 比较视频分割细节和帧间稳定性 |