Efficient Multi-order Gated Aggregation Network
导读
今天分享一篇发在arxiv上的backbone基础网络创新论文【MogaNet】,作者来自于西湖大学和浙江大学。MogaNet 将DNN的表征能力表示为lens of interaction complexities
。MogaNet为纯卷积网络,通过类似于人类视觉系统的多阶特征聚集模块同时具备局部感知和全局上下文聚集能力,通过特殊设计的SMixer和CMixer 分别从Spatial维度和Channel维度聚集上下文信息,实现了计算复杂度-性能间的平衡,在分类、检测、分割任务上取得了不错性能指标。
背景
卷积层利用区域密集连接和平移不变性约束对输入图像的邻域相关性进行编码。卷积网络通过级联的卷积层逐渐增加感受野,自适应的识别语义特征。但是卷积网络学习到的特征更关注于图像局部纹理特征,缺乏对图像全局上下文信息的获取。通过宏观网络设计(ASPP,FPN)和增加全局上下文aggregation (SE-Block,GC-Block) 可以部分解决该问题。
基于自注意力的Transformer更关注于图像全局依赖,在很多领域都超过了CNN的性能,
但是Transformer的二次方计算复杂度限制了网络的计算效率和在下游密集预测任务上的应用。由于缺少CNN的归纳偏置特性,Transformer学习图像相关邻域关系能力较弱。最近有研究将CNN中的FPN金字塔结构和重新引入ViT。
人类视觉系统不仅提取局部特征,同时也聚集全局感知特征,比深度学习更紧凑和高效。大多数现代DNN倾向于编码极低或极高复杂性的相互作用,而不是信息最丰富的中间作用。
如图所示,人类视觉特征在遮挡50%左右时即可获取几乎全部图像的信息,而DNN在10%以下/90%以上时获取更多的信息。
网络结构
MogaNet 提出的宏观网络结构
。经过stem调整输入维度,SMixer获取空间特征,CMixer 混合channel。
整体网络结构
消融实验
特征可视化
实验结果
官方代码库
https://github.com/Westlake-AI/openmixup
ElementScale
class ElementScale(nn.Module):
"""A learnable element-wise scaler."""
def __init__(self, embed_dims, init_value=0., requires_grad=True):
super(ElementScale, self).__init__()
self.scale = nn.Parameter(
init_value * torch.ones((1, embed_dims, 1, 1)),
requires_grad=requires_grad
)
def forward(self, x):
return x * self.scale
Moga Block
class MogaBlock(BaseModule):
"""A block of MogaNet.
Args:
embed_dims (int): Number of input channels.
ffn_ratio (float): The expansion ratio of feedforward network hidden
layer channels. Defaults to 4.
drop_rate (float): Dropout rate after embedding. Defaults to 0.
drop_path_rate (float): Stochastic depth rate. Defaults to 0.1.
act_cfg (dict, optional): The activation config for projections and FFNs.
Default: dict(type='GELU').
norm_cfg (dict): Config dict for normalization layer.
Defaults to ``dict(type='BN')``.
init_value (float): Init value for Layer Scale. Defaults to 1e-5.
attn_dw_dilation (list): Dilations of three DWConv layers.
attn_channel_split (list): The raletive ratio of splited channels.
attn_act_cfg (str): The activation config for the gating branch.
Default: dict(type='SiLU').
init_cfg (obj:`mmcv.ConfigDict`): The Config for initialization.
Default: None.
"""
def __init__(self,
embed_dims,
ffn_ratio=4.,
drop_rate=0.,
drop_path_rate=0.,
act_cfg=dict(type='GELU'),
norm_cfg=dict(type='BN', eps=1e-5),
init_value=1e-5,
attn_dw_dilation=[1, 2, 3],
attn_channel_split=[1, 3, 4],
attn_act_cfg=dict(type='SiLU'),
attn_force_fp32=False,
init_cfg=None):
super(MogaBlock, self)