门信号 g 与跳接 x 分成两个通道分支,各自做 Mamba 状态建模。两侧深度卷积生成互相作用的 sigmoid 门,交叉混合后投影并拼接,生成单通道空间掩码,最终只乘原始跳接 x。
[2×8×3×5; 2×8×3×5]2×8×3×51,579 个总参数,其中 1,579 个可训练;UNet 跳接融合。forward() 数据流顺序拆解 · 点击任意子模块方块可同步查看对应源码切片门信号 g 与跳接 x 分成两个通道分支,各自做 Mamba 状态建模。两侧深度卷积生成互相作用的 sigmoid 门,交叉混合后投影并拼接,生成单通道空间掩码,最终只乘原始跳接 x。 本页张量形状来自真实模块 CPU 前向、forward_hook 与源码行局部变量追踪;参数按 sum(p.numel() for p in model.parameters()) 统计。
551 # Cross gating using depthwise convs: 552 g_i_conv = self.conv_g_dw[i](g_i_mamba) # (B, c_g, H, W)553 x_i_conv = self.conv_x_dw[i](x_i_mamba) # (B, c_x, H, W)554 cross_i = x_i_mamba * torch.sigmoid(g_i_conv) + g_i_mamba * torch.sigmoid(x_i_conv)555 556 # Project cross_i => F_int with branch_proj[i] 557 cross_i_proj = self.branch_proj[i](cross_i) # (B, F_int, H, W)558 cross_branch_list.append(cross_i_proj)559 560 # Combine across branches => (B, F_int * num_branches, H, W) 561 cross_cat = torch.cat(cross_branch_list, dim=1)
先将 g 和 x 对齐为相同通道与空间尺寸,再放入跳接融合前。两路均为 (2,8,3,5)。
from MambaLiteCrossGatedSkip import CrossGatedAttentionGate layer = CrossGatedAttentionGate(8, 8, 4, num_branches=2, d_state=3, d_conv=3) y = layer(g, x)
Method 动机参考:跳接特征容易带入背景纹理;让解码上下文与编码细节先互相筛选,再用统一空间门调节原跳接。
| 消融变体 | 结构配置 | 验证目的 |
|---|---|---|
| 原跳接 | 直接使用 x | 建立跳接基线 |
| 单向门 | 仅保留 g 对 x 的门控项 | 测双向交互贡献 |
| 完整门 | 双向扫描 + 多支投影 | 比较分割质量与 CPU/GPU 各自耗时 |