出自 InceptionNeXt(CVPR 2024)。针对 ConvNeXt 中大核深度卷积(如 7×7 / 11×11)访存受限、实测推理偏慢的痛点,InceptionDWConv2d 将通道切分为四路:62.5% 恒等直通 + 12.5% 3×3 方核 + 12.5% 1×11 水平条带 + 12.5% 11×1 垂直条带,仅 272 参数即兼得大感受野与高吞吐。
64×224×224 → 64×224×22440 (直通) + 8 (3×3) + 8 (1×11) + 8 (11×1)272 params (80+96+96) · ConvNeXt / 轻量视觉主干通用forward() 数据流顺序拆解 · 点击任意子模块方块可同步查看对应源码切片输入 64 通道特征按 branch_ratio=0.125 沿通道维切分为 (40, 8, 8, 8) 四段:占比最大的 40 通道直接恒等映射(0 参数、0 计算);其余三组各 8 通道分别送入 3×3 局部方核、1×11 水平条带核与 11×1 垂直条带核的深度卷积;最后沿通道维重新拼回 64×224×224。
9def __init__(self, in_channels, square_kernel_size=3, band_kernel_size=11, branch_ratio=0.125): 12 gc = int(in_channels * branch_ratio) # 64 * 0.125 = 818 self.dwconv_hw = nn.Conv2d(gc, gc, 3, padding=1, groups=gc) # 80 params20 self.dwconv_w = nn.Conv2d(gc, gc, (1, 11), padding=(0, 5), groups=gc) # 96 params22 self.dwconv_h = nn.Conv2d(gc, gc, (11, 1), padding=(5, 0), groups=gc) # 96 params24 self.split_indexes = (in_channels - 3 * gc, gc, gc, gc) # (40, 8, 8, 8) 30 x_id, x_hw, x_w, x_h = torch.split(x, self.split_indexes, dim=1)32 return torch.cat((x_id, self.dwconv_hw(x_hw), self.dwconv_w(x_w), self.dwconv_h(x_h)), dim=1)
在 ConvNeXt Block 或任意深度可分离卷积块中,直接替换 nn.Conv2d(C, C, 7, padding=3, groups=C)(建议后接 1×1 卷积/MLP 融合跨分支通道):
from InceptionNext import InceptionDWConv2d self.mixer = InceptionDWConv2d(in_channels=96, square_kernel_size=3, band_kernel_size=11, branch_ratio=0.125) # x: (B, 96, H, W) -> out: (B, 96, H, W) out = self.mixer(x)
Method 动机参考:大核深度卷积(如 7×7/11×11)虽然能带来大感受野,但在 GPU 上属于内存受限算子,实际吞吐远低于理论 FLOPs 预期。通过“大部分通道恒等直通 + 少量通道 3×3/1×11/11×1 异构条带分解”,可在保持大感受野的同时显著加速训练与推理。
| 消融变体 | 结构配置 | 验证目的 |
|---|---|---|
| Baseline | ConvNeXt 7×7 DWConv | 全通道正方形大核深度卷积基线 |
| w/o Identity (ratio=1/3) | 全通道均分 3×3 / 1×11 / 11×1 | 验证保留 62.5% 恒等直通对吞吐与精度的平衡 |
| Full (InceptionDWConv2d) | Id(62.5%) + 3×3 + 1×11 + 11×1 | 验证完整条带大核分解的速度-精度帕累托最优 |
InceptionDWConv2d 在论文中是 MetaFormer/ConvNeXt Block 的 Token Mixer,后面紧跟 LayerNorm + 1×1 Conv (升维) + GELU + 1×1 Conv (降维) 的通道混合 MLP,所有 64 个通道会在 MLP 阶段充分交互;如果在普通 CNN 中单独使用,建议在其后接一层 1×1 Conv。in_channels < 8 时 gc = int(in_channels * 0.125) = 0,导致 Conv2d(0, 0, ...) 报错。输入通道小于 16 时,建议将 branch_ratio 提高到 0.25。band_kernel_size ∈ {7, 9, 11, 13, 15},11 在大感受野收益与 1D 核访存开销之间取得了最佳平衡;高分辨率遥感或医学分割场景可尝试调大至 15 或 21。