External Attention Usage

2022/8/12

# 1.1 GitHub完整代码

ExternalAttention.py (opens new window)

# 1.2. arxiv论文

"Beyond Self-attention: External Attention using Two Linear Layers for Visual Tasks" (opens new window)

# 1.3. Overview

# 1.4. Usage Code

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)