Partial Channel Network
原文链接:2502.01303
本文提出的Partial Channel Network (PartialNet) 核心围绕部分通道机制(PCM) 解决神经网络在参数、计算量与精度、推理速度之间的平衡问题,通过创新的部分注意力卷积(PATConv)和动态部分卷积(DPConv),在 ImageNet-1K 分类、COCO 检测与分割任务上实现了比 SOTA 模型更优的精度 - 速度权衡。
摘要
1. 研究问题
设计能在不牺牲精度和吞吐量的前提下,保持低参数、低 FLOPs 的网络模块 / 机制,是计算机视觉高效网络设计的核心挑战,现有方法存在特征通道冗余未充分利用、卷积与注意力结合效率低等问题。
2. 核心解法
提出部分通道机制(PCM):将特征图通道分割为不同部分,为各部分分配卷积、注意力、池化、恒等映射等不同操作,充分挖掘通道冗余的价值。
3. 关键创新模块
PATConv(部分注意力卷积):高效融合卷积与视觉注意力,可完全替代常规卷积和视觉注意力,同时降低参数与 FLOPs,并衍生出 3 种新模块(PAT_ch、PAT_sp、PAT_sf)
DPConv(动态部分卷积):能自适应学习不同层的通道分割比例,实现精度与推理速度的更优权衡。

4. 实验结果
基于上述模块构建PartialNet混合网络家族,在 ImageNet-1K 分类任务上实现更高的 Top-1 精度和推理速度,在 COCO 检测 / 分割任务上同样表现优异,代码开源。
方法:核心机制与网络架构
本文方法层围绕部分通道机制(PCM) 展开,从基础模块设计(PATConv + 三类子模块)、自适应优化(DPConv) 到整体网络架构(PartialNet) 形成完整体系,核心是对特征通道做 “分而治之”,为不同通道分配适配的轻量操作,并行融合卷积与注意力。
1. 核心基础:部分通道机制(PCM)
核心思想
利用特征图通道间的大量冗余性,通过分割(split) 将输入特征通道分为多个部分,为每个部分分配计算成本不同的操作(如卷积做局部特征提取、注意力做全局信息交互),最后通过拼接(concat) 整合特征;相比现有仅对部分通道计算、其余通道直接保留的方法(如 FasterNet、ShuffleNet V2),PCM 充分利用所有通道的潜在价值,在降低计算量的同时提升特征表达能力。
核心优势
用轻量高效的算子部分替代昂贵的稠密算子(如稠密卷积),并通过并行操作优化 GPU 资源利用率,实现推理速度与精度的双重提升。
2. 核心创新模块:部分注意力卷积(PATConv)
PATConv 是 PCM 的核心落地形式,并行融合部分卷积与部分视觉注意力,而非现有方法的串行结合,可定义为:

其中,rp为通道分割比例(超参数,后由 DPConv 自适应学习),∪为拼接操作,Conv对rp比例通道做局部特征提取,Atten对剩余1−rp比例通道做全局信息交互,兼顾局部归纳偏置与全局特征融合。
基于 PATConv 衍生出三类针对不同注意力类型的子模块,适配网络不同层的需求:
| 子模块 | 核心设计 | 功能与应用 |
|---|---|---|
| PAT_ch(通道注意力模块) | 融合 Conv3×3 与增强型高斯通道注意力(计算通道均值 + 方差,而非 SENet 仅用均值),充分利用特征的高斯分布特性 | 实现更丰富的通道间全局信息交互,可替代常规卷积和深度可分离卷积(DWConv),用于网络前三层 |
| PAT_sp(空间注意力模块) | 融合 Conv1×1 与空间注意力(通过点卷积将全局通道信息压缩为单通道,经 Hard-Sigmoid 生成空间注意力图) | 以极小成本强化 MLP 层的通道混合能力,推理时可与 MLP 的 Conv1×1 融合,进一步降低延迟,用于网络前三层 |
| PAT_sf(自注意力模块) | 融合局部卷积与带相对位置编码(RPE)的全局自注意力 | 扩展模型的全局感受野,因自注意力计算复杂度与特征图尺寸平方成正比,仅用于网络最后一层 |
3. 自适应优化:动态部分卷积(DPConv)
解决的问题
PATConv 的通道分割比例rp是关键超参数:rp过大会退化为常规卷积,注意力失效;rp过小则缺乏局部归纳偏置,现有方法为所有层设置固定rp(如 FasterNet 固定 1/4),无法适配不同层的特征学习需求。
核心设计
让rp成为可学习参数,模型在训练中为不同层自适应学习最优分割比例,核心是通过二进制关系矩阵 U和Kronecker 积实现通道分割的可微学习,并加入正则化约束控制模型计算复杂度:
- 将矩阵U分解为多个 2×2 子矩阵Uk,通过可学习门向量g控制Uk为全 1 矩阵或单位矩阵,进而生成通道掩码;
- 设计资源约束正则项ζ,限制模型总计算量,避免过拟合;
- 设计门向量正则项ψ,约束门向量的有序性,保证 Kronecker 积的有效性。
优化目标
在计算量约束下,最小化训练损失,同时对违规的门向量施加惩罚,实现精度与计算量的帕累托最优:

4. 整体网络:PartialNet 架构
PartialNet 采用四层分层结构,整体为混合网络(CNN + 注意力),适配不同尺度的特征学习,核心设计如下:
- 下采样与通道扩展:每层前通过嵌入层(Conv4×4,步长 4) 或合并层(Conv2×2,步长 2) 实现空间下采样和通道数翻倍;
- 模块搭配:前三层使用PartialNet Block v1(融合 PAT_ch+PAT_sp),最后一层使用PartialNet Block v2(将 PAT_ch 替换为 PAT_sf,修改残差连接保证训练稳定性);
- 归一化 / 激活策略:仅在中间 Conv1×1 后保留归一化 / 激活层,相邻卷积融合批归一化(BN),小模型用 GELU、大模型用 ReLU,兼顾特征多样性与推理速度;
- 分类头:全局平均池化 + Conv1×1 + 全连接层,完成特征变换与分类;
- 模型变体:提供 T0/T1/T2(轻量)、S/M/L(中大型),仅在深度和宽度上差异,架构保持一致,适配不同硬件场景。
三、实验:数据集、设置与核心结果
本文实验围绕ImageNet-1K 分类(主任务)、COCO2017 检测 / 分割(下游任务) 展开,同时做了大量消融实验验证各模块有效性,实验硬件覆盖 Nvidia V100/AMD MI250 GPU、AMD EPYC CPU,全面评估模型的精度、参数、FLOPs、吞吐量(FPS)、延迟(ms)。
1. 实验设置
(1)ImageNet-1K 分类
- 数据集:1K 类,130 万训练图,5 万验证图;
- 训练:300 个 epoch,AdamW 优化器,20 个 epoch 线性暖启,采用与 FasterNet 一致的正则化和数据增强(随机裁剪、水平翻转、Mixup/Cutmix 等);
- 推理:V100/MI250 GPU(批大小 256)测试吞吐量,AMD EPYC CPU(单核心)测试延迟。
(2)COCO2017 检测 / 分割
- 数据集:11.8 万训练图,5 千验证图;
- 框架:以 PartialNet 为骨干,搭配 Mask R-CNN 检测器,不额外调参;
- 训练:12 个 epoch,AdamW 优化器,批大小 16,图像尺寸 1333×800。
(3)消融实验
围绕部分注意力 vs 全注意力、三类 PAT 子模块的有效性、PATConv vs 常规卷积 / DWConv、不同计算量约束下的 DPConv 性能展开,验证核心模块的必要性。
2. 核心实验结果
(1)ImageNet-1K 分类:超越 SOTA 的精度 - 速度权衡
PartialNet 所有变体均显著优于 FasterNet、MobileNetV2、Swin-T、ConvNeXt 等 SOTA 模型,在更低的参数 / FLOPs 下实现更高的精度和吞吐量,核心案例:
- PartialNet-T2:Top-1 精度 80.2%,比 FasterNet-T2 高 1.3%,V100 吞吐量提升 25.2%,MI250 吞吐量提升 13.7%,CPU 延迟降低 24.1%;
- PartialNet-S:Top-1 精度 82.1%,比 FasterNet-S 高 0.8%,FLOPs 从 4.56G 降至 2.71G,CPU 延迟从 96.0ms 降至 72.5ms;
- PartialNet-L:Top-1 精度 83.9%,为所有对比模型最高,同时 FLOPs(11.91G)远低于 FasterNet-L(15.52G),吞吐量更高。
(2)COCO 检测 / 分割:优异的下游任务泛化能力
PartialNet 作为骨干网络,在检测(APb) 和分割(APm) 上均优于 ResNet、FasterNet、PoolFormer 等骨干,在相似吞吐量下实现更高的平均精度,核心案例:
- PartialNet-S:AP$^b^m$39.3%,比 FasterNet-S 分别高 7%、6.5%,FLOPs 从 258G 降至 216G;
- PartialNet-L:AP$^b^m$41.0%,为所有对比模型最高,吞吐量 39FPS 高于 FasterNet-L 的 35FPS。
(3)消融实验:验证各模块的核心价值
- 部分注意力 vs 全注意力:PATConv 的部分注意力在精度基本相当的前提下,推理吞吐量更高、延迟更低,且 GradCAM 可视化显示部分注意力能精准聚焦目标物体,验证了通道分割的有效性;
- 三类 PAT 子模块的有效性:逐步添加 PAT_ch→PAT_sp→PAT_sf,模型精度从 76.0% 提升至 80.2%,证明三类模块的叠加增益;
- PATConv vs 常规卷积 / DWConv:PAT_ch 在参数、FLOPs、吞吐量、精度上全面超越 Conv3×3 和 DWConv,如 Top-1 精度 80.2%(Conv3×3 为 79.9%、DWConv 为 79.6%),FLOPs 仅 1.03G(Conv3×3 为 2.12G);
- DPConv 的自适应能力:不同计算量约束下,模型自动为第一层和最后一层分配更小的通道稀疏度(更高的rp),与模型量化的结论一致(网络首尾层对精度更重要),验证了 DPConv 的自适应合理性;
- PATConv 的通用性:将 PATConv 迁移至 ResNet50、MobileNetV2、ConvNext-tiny 等现有模型,均能实现精度提升 + 吞吐量提升,如 ResNet50 精度从 76.13% 升至 77.64%,吞吐量从 1258FPS 升至 2832FPS。
四、结论:核心发现与研究价值
- 特征冗余的利用价值:特征选择理论表明特征通道间存在冗余和相关性,冗余不仅增加计算复杂度,还易导致过拟合,对通道做 “分而治之” 的部分操作,是挖掘冗余价值、平衡精度与效率的有效方式;
- 卷积与注意力的融合方式:并行融合部分卷积与部分注意力,比串行融合更高效,既保留卷积的局部归纳偏置,又通过注意力实现全局信息交互,同时降低元素级乘法对推理速度的影响;
- 动态通道分割的必要性:不同网络层的特征学习需求不同,自适应学习通道分割比例,比固定比例更能实现精度 - 计算量的最优权衡,且网络首尾层需保留更多卷积操作,保证基础特征提取和最终特征融合;
- PartialNet 的泛化能力:基于 PCM、PATConv、DPConv 构建的 PartialNet,在分类、检测、分割等不同视觉任务上均实现 SOTA 性能,证明了部分通道机制的通用性和有效性。
五、可借鉴之处:方法与设计的工程 / 研究启发
本文的设计思路和实验结论,对高效神经网络设计、现有模型的轻量化改造、跨任务骨干网络开发具有重要的借鉴意义,核心可落地点如下:
1. 特征通道的设计思路:从 “整体操作” 到 “分而治之”
摒弃对特征图所有通道执行相同操作的传统思路,利用通道冗余性做差异化操作分配:对部分通道用卷积做局部特征提取,对其余通道用轻量注意力做全局信息交互,既降低计算量,又提升特征表达能力;该思路可直接应用于现有 CNN/Transformer 模型的轻量化改造。
2. 卷积与注意力的融合策略:并行替代串行
现有方法多采用卷积→注意力的串行融合,导致推理延迟叠加;本文并行分割通道、分别执行卷积 / 注意力,并通过拼接整合特征,充分利用 GPU 的并行计算能力,该融合方式可作为高效网络设计的通用范式。
3. 超参数的自适应学习:从 “人工固定” 到 “模型自学习”
将网络的关键超参数(如通道分割比例、分组数)设计为可学习的可微参数,并加入合理的正则化约束,让模型在训练中自适应适配不同层 / 不同任务的需求,避免大量的人工调参,该思路可推广至分组卷积、注意力头数等超参数的优化。
4. 注意力的轻量化改造:部分通道 + 特征融合
针对注意力计算成本高的问题,仅对部分通道执行注意力操作,并让注意力模块与现有卷积 / MLP 层融合(如 PAT_sp 与 MLP 的 Conv1×1 融合),在不损失精度的前提下降低推理延迟,该方法可用于 Transformer/Vit 的轻量化解耦。
5. 网络分层设计:适配不同层的特征学习需求
根据网络层的功能差异,差异化搭配模块:前三层用通道 / 空间注意力(局部 + 中全局),最后一层用带 RPE 的自注意力(全局),兼顾局部特征提取与全局感受野扩展,该分层设计思路可指导跨任务骨干网络的开发(如分类 / 检测 / 分割的骨干适配)。
6. 实验验证的完整性:多维度 + 多硬件 + 下游任务
本文的实验不仅验证了主任务的精度 - 速度,还覆盖了多硬件(GPU/CPU)、多下游任务(检测 / 分割)、模块通用性(迁移至其他模型),并通过可视化(GradCAM)和消融实验验证核心设计的必要性,为高效网络的实验设计提供了标准化参考。
7. 工程实现的细节优化
- 相邻卷积融合 BN,减少推理时的层间交互;
- 轻量模型用 GELU、大模型用 ReLU,平衡特征多样性与计算速度;
- 对自注意力做层级限制(仅最后一层),规避其高计算复杂度的问题;这些细节优化可直接应用于工程落地,提升模型的实际推理性能。
论文可借鉴话术(按研究环节分类)
整理论文中摘要、引言、方法、实验、结论各核心环节的通用可借鉴话术,兼顾学术表达规范性与研究逻辑的适配性,可直接迁移至计算机视觉、深度学习相关论文写作中,部分话术做了通用化调整,适配不同研究主题。
一、摘要:核心问题 + 解法 + 创新 + 结果
- Designing a module or mechanism that enables [模型 / 网络] to maintain [低参数 / 低计算量 / 高鲁棒性] without sacrificing [精度 / 吞吐量 / 泛化能力] remains a challenge. To address this challenge and exploit [核心研究切入点,如特征冗余 / 局部特征信息 / 跨尺度交互], we propose a new solution: [提出的机制 / 模块名称].
- Specifically, through [核心操作,如分割 / 融合 / 自适应学习], [研究对象,如特征图 / 通道 / 注意力权重] are [处理方式,如划分 / 整合 / 优化], with each part corresponding to different operations, such as [相关基础操作,如卷积 / 注意力 / 池化].
- Based on this assumption, we introduce a novel [核心模块名称] that can efficiently combine [技术 A] with [技术 B]. Our exploration indicates that the [模块名称] can completely replace both the [传统模块 A] and the [传统模块 B] while reducing [模型指标,如参数 / FLOPs / 延迟].
- Moreover, [核心模块] can derive three new types of blocks: [子模块 1], [子模块 2] and [子模块 3]. In addition, we propose a novel [辅助模块名称] that can [模块核心功能,如自适应学习 / 动态调整 / 精准建模] to achieve better trade-offs.
- Building on [核心模块 1] and [核心模块 2], we propose a new [网络 / 模型家族名称], named [模型名], which achieves superior [核心指标 1] and [核心指标 2] compared to some SOTA models on [数据集 1] and excels in [下游任务] on the [数据集 2].
- Our code is available at [开源地址].
二、引言:研究背景 + 现有问题 + 本文贡献
(一)研究背景与领域现状
- Designing an efficient and effective [研究对象,如神经网络 / 视觉模型 / 特征提取器] has remained a prominent topic in [研究领域,如计算机视觉 / 深度学习 / 目标检测] research.
- To design an efficient [模型 / 网络], many prior works adopt [传统技术 / 模块] as a substitute for [原有技术 / 模块]. For instance, some [模型类型,如 CNN-based/Transformer-based] models leverage [技术 A] to reduce the model’s [指标,如 FLOPs / 参数 / 延迟], while [另一模型类型] employ [技术 A] to simulate [技术 B] operations to decrease [计算复杂度 / 内存占用].
- Considering the [核心问题本质,如大量特征冗余 / 有限的局部感受野 / 低效的信息交互] between [研究对象,如特征图 / 通道 / 像素], to further reduce the [计算成本 / 参数规模] while improving the model’s [推理速度 / 精度 / 泛化能力], we introduce the [核心机制名称] to fully exploit the value of [研究对象].
(二)现有方法的不足
- However, some studies have revealed that [传统技术] may suffer from [问题 1,如频繁的内存访问 / 低并行性 / 高计算复杂度] during [推理 / 训练], which leads to [问题 2,如低吞吐量 / 慢收敛 / 过拟合].
- Some recent works [现有研究方向] , but they use a naive approach, where [现有方法的核心缺陷,如仅对部分对象处理 / 忽略另一部分的潜在价值 / 采用串行融合方式].
- This makes [现有模块] faster in [指标,如推理速度] compared to both [传统模块 A] and [传统模块 B]. However, they merely consider improving the model’s performance from the perspective of [现有研究的单一视角], neglecting the potential value of [被忽视的研究点].
- Nevertheless, [现有模型 / 方法] does not outperform other [同领域模型] in [核心指标,如精度 / 泛化能力], which limits its practical application.
(三)本文研究思路与核心贡献
- Therefore, we believe that it is more reasonable to account for the overall [指标 1], [指标 2], and [指标 3] from a global perspective by exploiting [被忽视的研究点 / 未充分利用的特征信息].
- Specifically, we propose to combine [技术 A] and [技术 B], applying them to [研究对象的局部 / 部分] respectively. Since there are no effective [相关技术] for [研究细分点], we invent [数量] efficient [子模块 / 方法] for [研究目标].
- Although the above improvements can provide a stronger [模型 / 模块], considering the limitations of [约束条件,如延迟 / 参数 / 硬件资源], the [核心超参数 / 比例 / 结构] needs to be further optimal.
- To address this problem, we refer to [相关经典方法 / 技术] and propose a novel [辅助模块 / 方法], which can effectively and adaptively [核心功能] according to the constraints (e.g., [约束指标,如参数 / 延迟 / 计算量]) to achieve the optimal tradeoff between [模型指标 A] and [模型指标 B].
- Our main contributions can be described as:
- We propose a [核心机制名称] and introduce a [核心模块名称] that integrates [技术 A] into [技术 B] in a [融合方式,如并行 / 端到端 / 分层] way, which differs from the [传统融合方式,如串行 / 单一] way of previous works and can improve model performance while increasing [模型指标].
- Based on the [核心模块], we develop [数量] [子模块类型] blocks: [子模块 1] exhibits high potential as a replacement for [传统模块 A] and [传统模块 B], [子模块 2] can effectively [功能] at minimal cost, while [子模块 3] integrates [信息 A] and [信息 B], achieving higher [模型指标].
- To achieve a better trade-off between [模型指标 A] and [模型指标 B], we propose a novel [辅助模块名称], which can [核心功能] according to the constraints (e.g., [约束指标]).
- Building upon the above methods, we design a new [模型类型,如 hybrid-based/lightweight] model family named [模型名] that shows improved performance on standard [领域基准,如 vision benchmarks/nlp benchmarks] over most efficient SOTA models.
三、方法:机制阐述 + 模块设计 + 架构说明
(一)核心机制整体阐述
- Generally, designing an efficient [神经网络 / 模型] necessitates comprehensive consideration and optimization from various perspectives, including [设计目标,如更少的 FLOPs / 更小的模型尺寸 / 更低的内存访问].
- In contrast, we comprehensively exploit the potential value within [研究对象,如特征图的通道 / 注意力权重 / 局部特征]. For different [研究对象的部分 / 子集], we use different operations to further reduce the model [指标] while improving [另一指标]. It can be called the [核心机制名称].
- Based on this, we propose a new type of [模块类型,如卷积 / 注意力 / 池化] that replaces computationally expensive [传统操作] with cost-effective [新操作 / 技术], called [核心模块名称].
- Previous research has demonstrated that [研究基础结论,如特征通道间存在冗余 / 注意力具有全局建模能力], making [本文操作] a form of [核心功能,如全局信息交互 / 局部特征提取 / 跨尺度融合].
(二)模块数学定义与功能说明
- Suppose the input and output of our [模块名称] is denoted as 维度 and 维度 respectively, where [符号] and [符号] represent the number of [指标 A] and [指标 B], [符号] , [符号] is the [维度 C] and [维度 D] of [研究对象], respectively.
- [模块名称] can be defined as: [数学公式], where the symbol [符号] and [符号] denote the [操作 A] and [操作 B] respectively. The [符号] is a hyperparameter representing the [超参数含义,如通道分割比例 / 注意力权重系数] and can be learned adaptively.
- [子模块名称]: We first propose to integrate [技术 A] and [技术 B] involving [核心功能,如全局空间信息交互 / 通道混合 / 特征增强], and using [辅助模块 / 方法] compute [研究对象]’s [特征信息,如均值和方差 / 权重 / 相似度] to squeeze [全局 / 局部] information.
- Unlike [传统模型 / 模块], it only considers the [传统方法的单一信息] and ignores the [被忽视的信息]. Considering that the [研究对象,如特征图 / 权重] obey an approximately [分布,如高斯 / 正态] during [训练 / 推理], we fully utilize the [理论 / 方法] to express the [特征 / 信息] representation.
- Notably, unlike conventional [模型 / 技术] combined with [另一技术], which process steps one after the other, we process steps simultaneously on the same input, improving the balance between [指标 A] and [指标 B]. Moreover, our [核心模块] is not limited to the above [数量] combinations, it can be efficiently combined with more [相关模块 / 技术].
(三)自适应 / 动态模块设计
- For the [核心模块], the [核心超参数 / 符号] is a critical hyperparameter that significantly influences the [模型指标 A] and [模型指标 B] of a model. A too-large [超参数] causes [模块] to degenerate into a [传统模块], rendering the [功能模块] ineffective at [核心功能]. Conversely, a too-small [超参数] results in [模块] lacking essential [信息 / 特征 / 偏置].
- Achieving higher [指标 A] and [指标 B] at similar [复杂度 / 规模] often necessitates extensive experimentation to identify an optimal [超参数]. In [现有模型], a default [超参数值] is for all variants. In contrast, we propose a [动态 / 自适应模块名称] in which the [超参数] is learnable.
- This approach allows a model to adaptively determine the optimal [超参数] for different [模型结构,如层 / 块 / 阶段] during training. The strategies can be modeled by a [数学工具,如矩阵 / 向量 / 函数] [符号] ∈ [取值范围].
- Since the [函数 / 操作] is not differentiable, the [参数 / 门向量 / 权重] are optimized using a [优化方法,如 straight-through estimator / 梯度下降], similar to the [相关经典方法], to ensure convergence.
(四)整体网络架构设计
- The overall architecture of [模型名] is depicted in Fig. [编号], consists of [数量] hierarchical stages, each of which precedes an [层名称 A] or a [层名称 B]. These layers serve for [层功能,如空间下采样 / 通道数扩展 / 特征融合].
- Each stage comprises a set of [模型块名称]. In the first [数量] stages of the [模型名], we employ [块类型 A] including [子模块 1] and [子模块 2]. Similarly, we employ [块类型 B] by replacing [子模块 1] with [子模块 3] in the last stage and modifying the [结构,如残差连接 /shortcut] way to achieve stable training.
- In addition, we maintain [层类型,如归一化 / 激活] layers only after each intermediate [模块 / 层] to preserve [特征 / 信息] diversity and achieve higher [模型指标]. We also incorporate [层类型] into adjacent [模块 / 层] to expedite [推理 / 训练] without sacrificing performance.
- For the [层类型,如激活 / 归一化] layer, the smaller [模型名] variants uses [激活函数 A], while the larger [模型名] variants employs [激活函数 B].
- The last [数量] layers consist of [层 1], [层 2], and a [层 3]. These layers collectively serve for [功能,如特征变换 / 分类 / 回归].
- We offer [轻量 / 中 / 大] variants of [模型名], which are denoted as [模型变体名]. These variants share a similar architecture but differ in [结构差异,如深度和宽度 / 块数量 / 通道数].
四、实验:实验设置 + 结果分析 + 消融实验
(一)实验设置
- [数据集名称] is one of the most extensively used datasets in [研究领域]. It encompasses [类别数] common classes, consisting of approximately [训练样本数] training images and [验证 / 测试样本数] validation/test images.
- We train our models on the [数据集名称] for [epoch 数] epochs using [优化器] optimizer with [warm-up 数] epochs linear warm-up. And we use the same [正则化 / 数据增强 / 训练策略] as [对比模型 / 经典方法].
- For [推理 / 训练] speed, we test the model’s [指标,如吞吐量 / 延迟] in [硬件 1] and [硬件 2] with [批大小] batch size, we test [另一指标] in [硬件 3] with [硬件参数,如单核心 / 多 GPU].
- We utilize the pre-trained [模型名] as the [骨干 / 基础模块] within the [检测器 / 模型框架] for [下游任务 1] and [下游任务 2] on the [数据集名称]. To highlight the effectiveness of the [骨干 / 模块] itself, we follow the [经典方法 / 对比模型] approach and employ the [优化器] optimizer, conduct training of [epoch 数] epochs, use a batch size of [批大小], image size of [尺寸], and maintain other training settings without further hyperparameter tuning.
(二)实验结果分析
- Tab. [编号] provides a comparison of our [模型名] variants with previous SOTA [模型类型] and [另一模型类型] models. The experimental results demonstrate that [模型名] consistently surpasses recent models like [对比模型] across all model variants.
- For example, [模型变体名] achieves [数值] higher [指标] than [对比模型变体名] while exhibiting around [数值]% increase in [硬件 1] [指标] and [数值]% lower [硬件 2] [指标].
- The results demonstrate that the combination of [技术 A] and [技术 B] significantly improves model performance while increasing [模型指标].
- There is a certain difference in hardware architecture between [硬件 1] and [硬件 2] because [硬件 1] is better suited for [任务类型 A,如计算密集型], while [硬件 2] excels in [任务类型 B,如带宽密集型]. This may explain why our [模型名] has slightly lower [指标] than [对比模型] in the [模型变体] on the [硬件].
- As our [模型名] variants gradually increase from [变体 1] to [变体 N], both [指标 A] and [指标 B] increase, but the improvement in [指标 A] relative to the increase in [指标 B] is more pronounced. This further demonstrates that our [模型名] achieves better [指标 A] with less [指标 B].
- Tab. [编号] presents a comparison of [模型名] with representative models, reporting performance in terms of [评价指标] for both [任务 1] and [任务 2]. The results show that [模型名] consistently outperforms mainstream SOTA models, achieving higher [指标] while maintaining similar [另一指标].
- The results further confirm the generalization capabilities of our proposed [模型名] across various tasks.
(三)消融实验
- To prove the superiority of our [模块 / 方法] over [对比模块 / 方法], we conduct comparative experiments on the [模型变体名], as shown in Tab. [编号]. Specifically, we replace [本文模块] with corresponding regular [对比模块] for comparison.
- The results indicate that our [本文模块] achieves a superior balance between [指标 A] and [指标 B] compared to the [对比模块] counterpart. In addition, we adopt [可视化方法,如 GradCAM / 热力图] to visualize the [研究对象,如注意力 / 特征]. Results in Fig. [编号] show that [本文方法] can [核心效果,如精准聚焦目标 / 有效提取特征], which confirms the effectiveness of our improved [模块 / 方法].
- To confirm the individual effects of our proposed [数量] [子模块 / 块], we conducted ablation studies by progressively adding each block one by one, as indicated in Tab. [编号]. The results indicate that the [数量] proposed [子模块 / 块] consistently enhance model performance.
- Tab. [编号] also provides a reproduced comparison of the [本文模块] applied to other models. The results further demonstrate the effectiveness of our proposed [模块 / 方法].
- To further verify the advantages of our proposed [本文模块] over [传统模块 A] and [传统模块 B], we conduct ablation experiments on [模型变体名], as is shown in Tab. [编号]. To make a fair comparison, we [调整方法,如拓宽 / 优化 / 重新训练] [对比模块] to keep the [指标] of the [数量] [模块类型] in the same range.
- The results show that our proposed [本文模块] surpasses [传统模块 A] and [传统模块 B] in all metrics including [指标 1], [指标 2], [指标 3] and [指标 4], which validates the efficiency and effectiveness of [本文模块].
- For different constraints [符号 / 参数] and other parameters fixed, we conduct different experiments on [模型变体名], as is shown in Fig. [编号]. We find that the learned [超参数 / 比例] across different [模型结构,如层 / 块] exhibit a consistent pattern: [规律总结], which is consistent with the conclusion of [相关经典研究 / 方法], that [经典结论].
五、结论:研究总结 + 核心发现 + 研究价值
- [相关理论,如特征选择理论 / 注意力机制理论] shows that there may be a certain degree of [特性,如冗余 / 相关性 / 差异性] between [研究对象,如特征 / 通道 / 权重]. While this [特性] does not provide additional [价值,如信息增益 / 特征表达], it can increase [问题,如计算复杂度 / 内存占用] and heighten the risk of [问题,如过拟合 / 欠拟合].
- Our research builds on this theory from an implementation perspective, achieving a balance of [目标 A,如最优性能] and [目标 B,如计算效率].
- Specifically, we introduce the [核心机制名称] and propose [核心模块名称], which strategically integrates [技术 A] into the [技术 B] process to enhance [研究对象,如特征 / 信息] utility. Furthermore, we present [辅助模块名称], an adaptive approach that [核心功能,如学习最优比例 / 动态调整结构] for [研究对象] across different [模型结构,如层 / 块] in the model.
- With these innovations, we develop the [模型名] architecture, which surpasses recent efficient [模型 / 方法] on [数据集 1] [任务 1] as well as [数据集 2] [任务 2] and [任务 3].
- This underscores the effectiveness of the [核心机制 / 模块名称] in achieving an optimal balance between [指标 A] and [指标 B] across a range of [领域,如视觉 / 自然语言处理] tasks.
PartialNet 源码分析
PartialNet 是针对 “以更少计算量实现更优性能” 设计的网络架构,核心是部分通道卷积(Partial Conv) 机制,同时融合注意力、蒸馏、动态卷积等技术,支持分类、检测 / 分割等任务。以下从项目结构、核心模块、训练 / 测试流程、关键配置四个维度分析源码。

二、核心模块解析
1. 部分通道卷积(Partial Conv)
这是 PartialNet 的核心创新,核心逻辑:仅对部分通道执行卷积操作,其余通道保持不变,从而减少计算量,同时通过注意力机制补偿性能损失。
class Partial_conv3(nn.Module):
def __init__(self, dim, n_div, forward_type, use_attn='', channel_type='', patnet_t0=False):
super().__init__()
self.dim_conv3 = dim // n_div # 要卷积的通道数(n_div是分割系数,如4则1/4通道卷积)
self.dim_untouched = dim - self.dim_conv3 # 不卷积的通道数
self.partial_conv3 = nn.Conv2d(self.dim_conv3, self.dim_conv3, 3, 1, 1, bias=False)
# 可选:为“不卷积的通道”添加注意力(SE/Self-Attention)
if use_attn:
if channel_type == 'se':
self.attn = SRM(self.dim_untouched) # 自定义SE变体
self.norm = nn.BatchNorm2d(self.dim_untouched)
elif channel_type == 'self':
self.attn = RPEAttention(...) # 带相对位置编码的自注意力
self.norm = LayerNorm2d(self.dim_untouched)
# 前向传播:分两种模式(训练/推理)
def forward_split_cat(self, x: Tensor) -> Tensor:
# 训练模式:分割通道→卷积部分通道→拼接
x1, x2 = torch.split(x, [self.dim_conv3, self.dim_untouched], dim=1)
x1 = self.partial_conv3(x1)
x = torch.cat((x1, x2), 1)
return x
def forward_slicing(self, x: Tensor) -> Tensor:
# 推理模式:直接切片修改(减少内存拷贝)
x1 = x.clone()
x1[:, :self.dim_conv3, :, :] = self.partial_conv3(x1[:, :self.dim_conv3, :, :])
return x1
关键设计:
n_div:分割系数(如 4 表示仅 1/4 通道参与卷积),是控制计算量的核心超参;forward_type:前向模式(split_cat用于训练,slicing用于推理优化);use_attn/channel_type:为 “不卷积的通道” 添加 SE/Self-Attention,弥补信息损失。
2. 注意力模块
(1)SRM(Style-based Recalibration Module)
自定义 SE 变体,融合均值 / 标准差的风格信息:
class SRM(nn.Module):
def forward(self, x):
b, c, h, w = x.shape
# 风格池化:均值+标准差
mean = x.reshape(b, c, -1).mean(-1).view(b,c,1,1)
std = x.reshape(b, c, -1).std(-1).view(b,c,1,1)
u = torch.cat([mean, std], dim=-1)
# 风格整合+门控
z = self.cfc1(u)
z = self.bn(z)
g = self.sigmoid(z)
return x * g.expand_as(x)
(2)RPEAttention(带相对位置编码的自注意力)
为注意力模块添加图像相对位置编码,提升空间建模能力:
class RPEAttention(nn.Module):
def forward(self, x):
B, C, h, w = x.shape
x = x.view(B, C, h*w).transpose(1,2)
# QKV计算 + 注意力分数
qkv = self.qkv(x).reshape(...)
q, k, v = qkv[0], qkv[1], qkv[2]
attn = (q @ k.transpose(-2, -1)) * self.scale
# 加入相对位置编码(RPE)
if self.rpe_k is not None:
attn += self.rpe_k(q, h, w)
# 后续注意力计算...
3. MLPBlock(网络基本单元)
PartialNet 的基础块,融合 Partial Conv + MLP + DropPath 等:
class MLPBlock(nn.Module):
def __init__(self, dim, n_div, mlp_ratio, drop_path, ...):
super().__init__()
self.dim = dim
self.mlp_ratio = mlp_ratio
self.drop_path = DropPath(drop_path) if drop_path>0 else nn.Identity()
# 嵌入Partial Conv
self.partial_conv = Partial_conv3(dim, n_div, pconv_fw_type, ...)
# MLP层(扩展→激活→压缩)
self.fc1 = nn.Conv2d(dim, dim*mlp_ratio, 1)
self.fc2 = nn.Conv2d(dim*mlp_ratio, dim, 1)
4. 检测任务适配
在 detection/backbones/partialnet.py 中注册不同规模的 PartialNet 骨干网络(s/m/l),适配 MMDetection 框架:
@det_BACKBONES.register_module()
def PartialNet_s(**kwargs):
model = PartialNet(
mlp_ratio=2.0, embed_dim=128, depths=(1,2,13,2), drop_path_rate=0.15,
act_layer='RELU', fork_feat=True, **kwargs)
return model
三、训练 / 测试流程
1. 分类任务(train_test.py)
基于 PyTorch Lightning 实现,核心流程:
步骤 1:参数解析 + 配置加载
parser = ArgumentParser()
parser.add_argument('--cfg', type=str, default='cfg/cifar10-PartialNet_to.yaml')
args = parser.parse_args()
cfg = load_cfg(args.cfg)
args = merge_args_cfg(args, cfg)
步骤 2:数据加载(LitDataModule)
支持 CIFAR10/ImageNet,自动处理数据增强、批次划分。
步骤 3:模型初始化 + 性能指标计算
model = LitModel(num_classes=dm.num_classes, hparams=args)
flops, params = get_flops_params(model.model, args.image_size) # 计算FLOPs/参数量
步骤 4:训练器配置(多 GPU/DDP)
trainer = pl.Trainer(
accelerator="gpu", devices=args.gpus,
strategy=DDPStrategy(find_unused_parameters=find_unused_para),
max_epochs=args.epochs, callbacks=[checkpoint_callback, ...]
)
trainer.fit(model, dm) # 训练
trainer.test(ckpt_path="best", datamodule=dm) # 测试
关键功能:
- 支持模型权重格式转换(ckpt→pth);
- 延迟 / 吞吐量测量(
measure_latency函数); - BN+Conv 融合(
fuse_conv_bn),提升推理速度; - WandB 日志记录(训练过程可视化)。
2. 检测 / 分割任务(detection/train.py/test.py)
基于 MMDetection 框架适配,核心流程:
- 配置加载(MMCV Config);
- 分布式环境初始化;
- 模型构建(注册的 PartialNet 骨干网络);
- 数据集构建(COCO2017);
- 训练 / 测试(调用 MMDet 的
train_detector/single_gpu_test等接口); - 基准测试(benchmark.py):测量推理速度、FLOPs 等。
3. 关键配置(cfg/cifar10-PartialNet_to.yaml)
核心超参解释:
# 模型基本参数
model_name: partialnet
embed_dim: 32 # 嵌入维度
depths: [1,2,8,2] # 各阶段Block数
n_div: 4 # Partial Conv分割系数(1/4通道卷积)
# 注意力开关
use_channel_attn: True # 启用通道注意力
use_spatial_attn: False# 禁用空间注意力
# 动态卷积参数
auto_div: False # 禁用动态分割(固定n_div)
pre_epoch: 0 # 固定Partial Conv的预训练轮数
# 蒸馏参数
distillation_alpha: 0.5# 蒸馏损失权重
distillation_tau: 1.0 # 蒸馏温度
四、核心设计亮点
- 计算量 - 性能平衡:仅对部分通道卷积,减少 FLOPs / 参数量,同时通过注意力补偿信息损失;
- 多任务适配:同时支持分类(ImageNet/CIFAR10)、检测 / 分割(COCO2017);
- 训练 / 推理优化:
- 训练用
split_cat模式,稳定梯度; - 推理用
slicing模式,减少内存拷贝; - 支持 BN+Conv 融合,提升推理速度;
- 训练用
- 模块化设计:Partial Conv、注意力、MLP 等模块解耦,易于扩展;
- 蒸馏支持:配置文件中可设置蒸馏参数,支持知识蒸馏进一步提升性能。
五、运行指令示例
1. 分类任务(ImageNet)
python train_test.py --gpus [0,1,2,3] --cfg cfg/PartialNet_t0.yaml
2. 分类任务(CIFAR10)
python train_test.py --gpus [0,1,2,3] --cfg cfg/cifar10-PartialNet_to.yaml
3. 检测任务(COCO2017)
python detection/train.py --gpus [0,1,2,3] --cfg cfg/PartialNet_t0.yaml
六、总结
PartialNet 的核心是 **“部分通道计算”** 思想:通过牺牲少量通道的计算,换取整体计算量的大幅降低,同时通过注意力、蒸馏等技术保证性能。源码设计上遵循模块化、易扩展原则,适配多任务,且针对训练 / 推理做了针对性优化,是轻量化网络设计的典型实践。
更多推荐


所有评论(0)