Skip to content

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
Step-by-step guide: how to use FightingCVInstall, first run, examples, tips and FAQs

How to get it

  1. 1

    Install with a package manager

    You'll need: Python · PyTorch

    Install from PyPI

    pip install fightingcv-attention

    Or clone the repository

    git clone https://github.com/xmu-xiaoma666/External-Attention-pytorch.git
  2. 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. 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

ProjectStarsTypeLevelUpdatedBest for
External-Attention-pytorch (this)12.2kLibrarybeginner8 months agoStudents reading deep learning papers who want to see the core code of a module
vit-pytorch25.6kLibraryintermediate5 days agoDevelopers who want to build an image classifier in PyTorch
nlp-tutorial14.9kLearning resourceintermediate2.7 years agoStudents who want to see how classic NLP models work in code
annotated_deep_learning_paper_implementations67.6kLearning resourceintermediate4 days agoStudents learning how transformers, GANs, or optimizers work internally
OpenMythos14.9kLibraryintermediate6 months agoResearchers exploring looped or recurrent-depth transformer designs
stable-baselines314kLibraryintermediate11 days agoResearchers 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.