百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
E

External-Attention-pytorch

> DevOps
开源

Pytorch 执行各种关注机制, MLP,再参数, Convolution, 这有助于进一步理解论文

12.2K stars0 点赞0 次浏览
访问官网GitHub

工具介绍

Pytorch 执行各种关注机制, MLP,再参数, Convolution, 这有助于进一步理解论文

简体中文 | English

FightingCV 代码库, 包含 Attention,Backbone, MLP, Re-parameter, Convolution

Star History

使用

安装

直接通过 pip 安装

bash
pip install fightingcv-attention

或克隆该仓库

bash
git clone https://github.com/xmu-xiaoma666/External-Attention-pytorch.git

cd External-Attention-pytorch

演示

使用 pip 方式

python
import torch
from torch import nn
from torch.nn import functional as F

# 使用 pip 方式

from fightingcv_attention.attention.MobileViTv2Attention import *

if __name__ == '__main__':
    input=torch.randn(50,49,512)
    sa = MobileViTv2Attention(d_model=512)
    output=sa(input)
    print(output.shape)
  • pip包 内置模块使用参考: fightingcv-attention 说明文档

使用 git 方式

python
import torch
from torch import nn
from torch.nn import functional as F

# 与 pip方式 区别在于 将 `fightingcv_attention` 替换 `model`

from model.attention.MobileViTv2Attention import *

if __name__ == '__main__':
    input=torch.randn(50,49,512)
    sa = MobileViTv2Attention(d_model=512)
    output=sa(input)
    print(output.shape)

目录

  • Attention Series

    • 1. External Attention Usage

    • 2. Self Attention Usage

    • 3. Simplified Self Attention Usage

    • 4. Squeeze-and-Excitation Attention Usage

    • 5. SK Attention Usage

    • 6. CBAM Attention Usage

    • 7. BAM Attention Usage

    • 8. ECA Attention Usage

    • 9. DANet Attention Usage

    • 10. Pyramid Split Attention (PSA) Usage

    • 11. Efficient Multi-Head Self-Attention(EMSA) Usage

    • 12. Shuffle Attention Usage

    • 13. MUSE Attention Usage

    • 14. SGE Attention Usage

    • 15. A2 Attention Usage

    • 16. AFT Attention Usage

    • 17. Outlook Attention Usage

    • 18. ViP Attention Usage

    • 19. CoAtNet Attention Usage

    • 20. HaloNet Attention Usage

    • 21. Polarized Self-Attention Usage

    • 22. CoTAttention Usage

    • 23. Residual Attention Usage

    • 24. S2 Attention Usage

    • 25. GFNet Attention Usage

    • 26. Triplet Attention Usage

    • 27. Coordinate Attention Usage

    • 28. MobileViT Attention Usage

    • 29. ParNet Attention Usage

    • 30. UFO Attention Usage

    • 31. ACmix Attention Usage

    • 32. MobileViTv2 Attention Usage

    • 33. DAT Attention Usage

    • 34. CrossFormer Attention Usage

    • 35. MOATransformer Attention Usage

    • 36. CrissCrossAttention Attention Usage

    • 37. Axial_attention Attention Usage

  • Backbone Series

    • 1. ResNet Usage

    • 2. ResNeXt Usage

    • 3. MobileViT Usage

    • 4. ConvMixer Usage

    • 5. ShuffleTransformer Usage

    • 6. ConTNet Usage

    • 7. HATNet Usage

    • 8. CoaT Usage

    • 9. PVT Usage

    • 10. CPVT Usage

    • 11. PIT Usage

    • 12. CrossViT Usage

    • 13. TnT Usage

    • 14. DViT Usage

    • 15. CeiT Usage

    • 16. ConViT Usage

    • 17. CaiT Usage

    • 18. PatchConvnet Usage

    • 19. DeiT Usage

    • 20. LeViT Usage

    • 21. VOLO Usage

    • 22. Container Usage

    • 23. CMT Usage

    • 24. EfficientFormer Usage

    • 25. ConvNeXtV2 Usage

  • MLP Series

    • 1. RepMLP Usage

    • 2. MLP-Mixer Usage

    • 3. ResMLP Usage

    • 4. gMLP Usage

    • 5. sMLP Usage

    • 6. vip-mlp Usage

  • Re-Parameter(ReP) Series

    • 1. RepVGG Usage

    • 2. ACNet Usage

    • 3. Diverse Branch Block(DDB) Usage

  • Convolution Series

    • 1. Depthwise Separable Convolution Usage

    • 2. MBConv Usage

    • 3. Involution Usage

    • 4. DynamicConv Usage

    • 5. CondConv Usage


Attention Series

  • Pytorch implementation of "Beyond Self-attention: External Attention using Two Linear Layers for Visual Tasks---arXiv 2021.05.05"

  • Pytorch implementation of "Attention Is All You Need---NIPS2017"

  • Pytorch implementation of "Squeeze-and-Excitation Networks---CVPR2018"

  • Pytorch implementation of "Selective Kernel Networks---CVPR2019"

  • Pytorch implementation of "CBAM: Convolutional Block Attention Module---ECCV2018"

  • Pytorch implementation of "BAM: Bottleneck Attention Module---BMCV2018"

  • Pytorch implementation of "ECA-Net: Efficient Channel Attention for Deep Convolutional Neural Networks---CVPR2020"

  • Pytorch implementation of "Dual Attention Network for Scene Segmentation---CVPR2019"

  • Pytorch implementation of "EPSANet: An Efficient Pyramid Split Attention Block on Convolutional Neural Network---arXiv 2021.05.30"

  • Pytorch implementation of "ResT: An Efficient Transformer for Visual Recognition---arXiv 2021.05.28"

  • Pytorch implementation of "SA-NET: SHUFFLE ATTENTION FOR DEEP CONVOLUTIONAL NEURAL NETWORKS---ICASSP 2021"

  • Pytorch implementation of "MUSE: Parallel Multi-Scale Attention for Sequence to Sequence Learning---arXiv 2019.11.17"

  • Pytorch implementation of "Spatial Group-wise Enhance: Improving Semantic Feature Learning in Convolutional Networks---arXiv 2019.05.23"

  • Pytorch implementation of "A2-Nets: Double Attention Networks---NIPS2018"

  • Pytorch implementation of "An Attention Free Transformer---ICLR2021 (Apple New Work)"

  • Pytorch implementation of VOLO: Vision Outlooker for Visual Recognition---arXiv 2021.06.24" 【论文解析】

  • Pytorch implementation of Vision Permutator: A Permutable MLP-Like Architecture for Visual Recognition---arXiv 2021.06.23 【论文解析】

  • Pytorch implementation of CoAtNet: Marrying Convolution and Attention for All Data Sizes---arXiv 2021.06.09 【论文解析】

  • Pytorch implementation of Scaling Local Self-Attention for Parameter Efficient Visual Backbones---CVPR2021 Oral 【论文解析】

  • Pytorch implementation of Polarized Self-Attention: Towards High-quality Pixel-wise Regression---arXiv 2021.07.02 【论文解析】

  • Pytorch implementation of Contextual Transformer Networks for Visual Recognition---arXiv 2021.07.26 【论文解析】

  • Pytorch implementation of Residual Attention: A Simple but Effective Method for Multi-Label Recognition---ICCV2021

  • Pytorch implementation of S²-MLPv2: Improved Spatial-Shift MLP Architecture for Vision---arXiv 2021.08.02 【论文解析】

  • Pytorch implementation of Global Filter Networks for Image Classification---arXiv 2021.07.01

  • Pytorch implementation of Rotate to Attend: Convolutional Triplet Attention Module---WACV 2021

  • Pytorch implementation of Coordinate Attention for Efficient Mobile Network Design ---CVPR 2021

  • Pytorch implementation of MobileViT: Light-weight, General-purpose, and Mobile-friendly Vision Transformer---ArXiv 2021.10.05

  • Pytorch implementation of Non-deep Networks---ArXiv 2021.10.20

  • Pytorch implementation of UFO-ViT: High Performance Linear Vision Transformer without Softmax---ArXiv 2021.09.29

  • Pytorch implementation of Separable Self-attention for Mobile Vision Transformers---ArXiv 2022.06.06

  • Pytorch implementation of On the Integration of Self-Attention and Convolution---ArXiv 2022.03.14

  • Pytorch implementation of CROSSFORMER: A VERSATILE VISION TRANSFORMER HINGING ON CROSS-SCALE ATTENTION---ICLR 2022

  • Pytorch implementation of Aggregating Global Features into Local Vision Transformer

  • Pytorch implementation of CCNet: Criss-Cross Attention for Semantic Segmentation

  • Pytorch implementation of Axial Attention in Multidimensional Transformers


1. External Attention Usage

1.1. Paper

"Beyond Self-attention: External Attention using Two Linear Layers for Visual Tasks"

1.2. Overview

1.3. Usage Code

python
from model.attention.ExternalAttention import ExternalAttention
import torch

input=torch.randn(50,49,512)
ea = ExternalAttention(d_model=512,S=8)
output=ea(input)
print(output.shape)

2. Self Attention Usage

2.1. Paper

"Attention Is All You Need"

1.2. Overview

1.3. Usage Code

python
from model.attention.SelfAttention import ScaledDotProductAttention
import torch

input=torch.randn(50,49,512)
sa = ScaledDotProductAttention(d_model=512, d_k=512, d_v=512, h=8)
output=sa(input,input,input)
print(output.shape)

3. Simplified Self Attention Usage

3.1. Paper

[N

Issues· 69 开放

查看全部 Issues在 GitHub 打开
  • #13

    使用 ExternalAttention 出现错误

    更新于 2025年12月29日
  • #121

    HaloAttention 掩码问题

    更新于 2024年12月19日
  • #120

    MobileViTv2Attention 是否可以整合到 yolov8 中?

    更新于 2024年10月16日
  • #119

    MUSE Attention 中的 pointwise 是如何实现的呢? 没有看到

    更新于 2024年9月17日
  • #118

    DMSANet: 双多尺度注意力网络

    更新于 2024年9月3日
  • #116

    MobileViT 中的 MV2 块问题

    更新于 2024年5月14日
  • #114

    关于ECA是先sigmoid还是后sigmoid的问题

    更新于 2024年4月21日
  • #115

    更好地可视化/说明正在发生的事情 - torchviz

    更新于 2024年4月5日
  • #91

    亲爱的作者,一维卷积神经网络是否可以使用ECA 或 SE 关注机制?

    更新于 2024年4月3日
  • #113

    SK 关注中的非正常参数

    更新于 2023年12月30日

> 标签

Pythonattentioncbamexcitation-networkslinear-layers

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月28日
分类DevOps
定价开源

> 相关工具

D
Docker
容器化平台,标准化应用交付
G
GitHub Actions
GitHub 原生 CI/CD 工作流
N
Nginx
高性能 Web 服务器与反向代理