
FightingCV
A PyTorch collection of attention, MLP, convolution and re-parameter modules from papers, as readable code.xmu-xiaoma666/External-Attention-pytorch
- Stars
- 12.2k
- Forks
- 1.9k
- Licence
- MIT
- Language
- Python
- Last update
- 8 months ago
- Type
- Library
What it is
This is a Python code library that reimplements many neural-network building blocks from research papers, such as attention mechanisms, MLP variants, backbones and convolution layers, in PyTorch. Each module is meant to be a self-contained piece of code you can read or drop into your own model. It is mainly used to understand papers more easily or to reuse a module without digging through a paper's full training code.
- Import an attention module such as MobileViTv2Attention and run it on a random tensor to check its shapes
- Read the implementation of a module like Squeeze-and-Excitation alongside its paper
- Insert an attention block such as CBAM into an existing convolutional network
- Browse the listed backbones and MLP variants to compare how they are structured
Great for
- Students reading deep learning papers who want to see the core code of a module
- Researchers who want a ready-made version of a published attention or MLP block
- Developers prototyping a model and looking for a drop-in layer like SE or CBAM
- Engineers comparing several attention variants in the same code style
Not ideal for
- Anyone needing pretrained weights or a finished model, since the README describes module code, not trained checkpoints
- People wanting an exact replica of an original paper's results, because the README does not claim reproduced benchmark numbers
- Beginners with no PyTorch background, who would first need basic PyTorch knowledge
How to get it
- 1
Install with a package manager
You'll need: Python · PyTorch
Install from PyPI
pip install fightingcv-attentionOr clone the repository
git clone https://github.com/xmu-xiaoma666/External-Attention-pytorch.git - 2
Run it
- Install the package with pip install fightingcv-attention, or clone the repository.
- Import a module, for example from fightingcv_attention.attention.MobileViTv2Attention import *.
- Create the module with d_model=512 and pass it a tensor of shape (50, 49, 512).
- Print the output shape to confirm it runs.
- 3
Get the most out of it
- Use the pip package's own documentation (README_pip.md, linked in the README) to see which built-in modules are available
- Start with the Attention Series examples, such as External Attention or Squeeze-and-Excitation, to learn the code pattern
- Read the paper link listed beside each implementation to compare the code against the original method
- Use the git-clone method if you want to edit or extend the module code directly
Downloads
Strengths
- Covers many papers in one consistent code base, organized by series in the README
- Install is a single pip command, and the README includes short runnable examples
- The README states a goal of making the code easy for beginners to follow
Trade-offs
- The README only shows the basic usage pattern; per-module documentation is limited in the excerpt provided
- Version badges list minimum Python and PyTorch versions only loosely ("v3.0" and "v1.4"), so check compatibility with your setup
- Implementations are community reimplementations, not official releases from the paper authors
How it compares
| Project | Stars | Type | Level | Updated | Best for |
|---|---|---|---|---|---|
| External-Attention-pytorch (this) | 12.2k | Library | beginner | 8 months ago | Students reading deep learning papers who want to see the core code of a module |
| vit-pytorch | 25.6k | Library | intermediate | 5 days ago | Developers who want to build an image classifier in PyTorch |
| nlp-tutorial | 14.9k | Learning resource | intermediate | 2.7 years ago | Students who want to see how classic NLP models work in code |
| annotated_deep_learning_paper_implementations | 67.6k | Learning resource | intermediate | 4 days ago | Students learning how transformers, GANs, or optimizers work internally |
| OpenMythos | 14.9k | Library | intermediate | 6 months ago | Researchers exploring looped or recurrent-depth transformer designs |
| stable-baselines3 | 14k | Library | intermediate | 11 days ago | Researchers who want a reliable baseline to compare a new method against |
Stats synced from GitHub. The assessment above was drafted with AI from the project's README on 2026-10-29 and may miss recent changes — check the README before relying on a command. MIT licence: free to use, modify and distribute, including commercially, as long as you keep the copyright notice.