• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

SimAM: The official pytorch implemention of our ICML paper "SimAM: A Simple ...

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称:

SimAM

开源软件地址:

https://gitee.com/mirrors/SimAM

开源软件介绍:

SimAM: A Simple, Parameter-Free Attention Module for Convolutional Neural Networks

Lingxiao Yang, Ru-Yuan Zhang, Lida Li, Xiaohua Xie

Abstract

In this paper, we propose a conceptually simple but very effective attention module for Convolutional Neural Networks (ConvNets). In contrast to existing channel-wise and spatial-wise attention modules, our module instead infers 3-D attention weights for the feature map in a layer without adding parameters to the original networks. Specifically, we base on some well-known neuroscience theories and propose to optimize an energy function to find the importance of each neuron. We further derive a fast closed-form solution for the energy function, and show that the solution can be implemented in less than ten lines of code. Another advantage of the module is that most of the operators are selected based on the solution to the defined energy function, avoiding too many efforts for structure tuning. Quantitative evaluations on various visual tasks demonstrate that the proposed module is flexible and effective to improve the representation ability of many ConvNets. Our code is available at Pytorch-SimAM.


Our environments and toolkits

  • OS: Ubuntu 18.04.5
  • CUDA: 11.0
  • Python: 3.8.3
  • Toolkit: PyTorch 1.8.0
  • GPU: Quadro RTX 8000 (4x)
  • thop

Module

Our goal is to infer a 3-D attention weights (Figure (c)) with a given feature map, which is very different to previous works as shown in Figure (a) and (b).

SimAM (A pytorch-like implementation). Detail of implementations, including the module and the network, can be found in networks in this repository.

    class SimAM(nn.Module):        # X: input feature [N, C, H, W]        # lambda: coefficient λ in Eqn (5)        def forward (X, lambda):            # spatial size            n = X.shape[2] * X.shape[3] - 1            # square of (t - u)            d = (X - X.mean(dim=[2,3])).pow(2)            # d.sum() / n is channel variance            v = d.sum(dim=[2,3]) / n            # E_inv groups all importance of X            E_inv = d / (4 * (v + lambda)) + 0.5            # return attended features            return X * sigmoid(E_inv)

Training and Validation Curves

Experiments

Training and Evaluation

The following commands train models on ImageNet from scratch with 4 gpus.

# Training from scratchpython main_imagenet.py {the path of ImageNet} --gpu 0,1,2,3 --epochs 100 -j 20 -a resnet18 python main_imagenet.py {the path of ImageNet} --gpu 0,1,2,3 --epochs 100 -j 20 -a resnet18 --attention_type simam --attention_param 0.1python main_imagenet.py {the path of ImageNet} --gpu 0,1,2,3 --epochs 150 -j 20 -a mobilenet_v2--attention_type simam --attention_param 0.1 --lr .05 --cos_lr --wd 4e-5 
# Evaluating the trained modelpython main_imagenet.py {the path of ImageNet} --gpu 0,1,2,3 -j 20 -a resnet18 -e--resume {the path of pretrained .pth}

ImageNet

All the following models can be download from BaiduYunPan (extract code: teje) and Google Drive.

ModelParametersFLOPsTop-1(%)Top-5(%)
SimAM-R1811.69 M1.82 G71.3189.88
SimAM-R3421.80 M3.67 G74.4992.02
SimAM-R5025.56 M4.11 G77.4593.66
SimAM-R10144.55 M7.83 G78.6594.11
SimAM-RX50 (32x4d)25.03 M4.26 G78.0093.93
SimAM-MV23.50 M0.31 G72.3690.74

COCO Evaluation

We use mmdetection to train Faster RCNN and Mask RCNN for object detection and instance segmentation. If you want to run the following models, please firstly install mmdetection with their guide. And then put all .py in mmdetection of this repository to the corresponding folders. All the following models can be download from BaiduYunPan (extract code: 97g6) and Google Drive.

Detection with Faster RCNN (FR for short) and Mask RCNN (MR for short)

ModelAPAP_50AP_75AP_SAP_MAP_L
FR-SimAM-R5039.260.740.822.843.050.6
FR-SimAM-R10141.262.445.024.045.652.8
MR-SimAM-R5039.861.043.423.143.751.4
MR-SimAM-R10141.862.846.024.846.253.9

Instance Segmentation with Mask RCNN (MR for short)

ModelAPAP_50AP_75AP_SAP_MAP_L
MR-SimAM-R5036.057.938.219.139.748.6
MR-SimAM-R10137.659.540.120.541.550.8

Citation

If you find SimAM useful in your research, please consider citing:

@InProceedings{pmlr-v139-yang21o,    title = 	 {SimAM: A Simple, Parameter-Free Attention Module for Convolutional Neural Networks},    author =       {Yang, Lingxiao and Zhang, Ru-Yuan and Li, Lida and Xie, Xiaohua},    booktitle = 	 {Proceedings of the 38th International Conference on Machine Learning},    pages = 	 {11863--11874},    year = 	 {2021},    editor = 	 {Meila, Marina and Zhang, Tong},    volume = 	 {139},    series = 	 {Proceedings of Machine Learning Research},    month = 	 {18--24 Jul},    publisher =    {PMLR},    pdf = 	 {http://proceedings.mlr.press/v139/yang21o/yang21o.pdf},    url = 	 {http://proceedings.mlr.press/v139/yang21o.html}}

Contact Information

If you have any suggestion or question, you can contact us by: [email protected]. Thanks for your attention!


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap