MCPcopy Create free account
hub / github.com/ZhugeKongan/Attention-mechanism-implementation

github.com/ZhugeKongan/Attention-mechanism-implementation @main

Chat with this repo
repository ↗ · DeepWiki ↗ · + Follow
124 symbols 240 edges 17 files 12 documented · 10% updated 4y ago★ 4921 open issues

Browse by type

Functions 81 Types & classes 43
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Attention-mechanism-implementation

pytorch for Self-attention、Non-local、SE、SK、CBAM、DANet

According to the different application domains of the attention mechanism, that is, the different ways and positions of attention weights are applied, the article divides the attention mechanism into spatial domain, channel domain and hybrid domain, and introduces some advanced aspects of these different attentions. Attention model, carefully analyzed their design methods and application fields, and finally proved the effectiveness of these attention mechanisms and the improvement of the results brought by CV tasks with experimental methods.

  1. Spatial attention method

1.1 Self-Attention

image

1.2 Non-local Attention

image

  1. Channel domain attention method

2.1 SENet

image

2.2 SKNet

image

  1. Hybrid domain attention method

3.1 CBAM

image image

3.2 DANet

image

  1. RESULT For each set of experiments, we use Resnet18 as the Baseline, training 160 epoch, the initial learning rate is 0.1, 80 epoch is adjusted to 0.01, and 160 epoch is adjusted to 0.001. The batch size is set to 128, and the SGD optimizer with momentum is experimented. When reading the input, first perform random cropping and random flipping data enhancement. In particular, in order to maximize the attention effect, we all perform a warm-up operation of 1 epoch at the beginning of the experiment, and take the average of the best 5 epochs as the final result. image

reference Self-Attention Non-local Attention SENet SKNet CBAM DANet

Core symbols most depended-on inside this repo

browse all functions →

Shape

Method 76
Class 43
Function 5

Languages

Python100%

Modules by API surface

train.py19 symbols
models/non_local_gaussian.py9 symbols
models/non_local_embedded_gaussian.py9 symbols
models/non_local_dot_product.py9 symbols
models/non_local_concatenation.py9 symbols
models/SK_block.py9 symbols
models/SEvariants.py9 symbols
models/DaNet.py9 symbols
models/CBAM_blocks.py9 symbols
models/ANN.py9 symbols
models/TripletAttention.py8 symbols
models/GlobalContextBlock.py4 symbols

For agents

$ claude mcp add Attention-mechanism-implementation \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page