All models

focalnet_base_lrf

FocalNet: a vision backbone where focal modulation replaces self-attention entirely.

Image classification · 1,201 operations Checked

100%

Showing the top corner; full diagram not loaded yetShowing a small copy; full diagram not loaded yetLarge diagram, not loaded yet

Open SVG

Loading diagram (20 KB)

Open in a new tab

Click or tap a spot to read it up close. Scroll or drag inside the diagram to move through it. Zoom with + and − or Ctrl and scroll. Press 0 for the whole graph. Swipe inside the diagram to move through it. Use + and − to zoom.

At a glance

Family
FocalNet
Parameters
88.7M
Operations
1,201
Framework
PyTorch
Recurrent
No
Published
NeurIPS (arXiv 2022)
Cited by
263 (as of 27 October 2026)
Authors
Jianwei Yang, Chunyuan Li, Xiyang Dai and others
License
Apache-2.0
Checked
Passed: the trace was replayed operation by operation and matched the model's own output for this input.

Files

The diagram is a drawing of a TorchLens trace of the source code. It contains no code or weights.

Details
Stable ID
m5061
Graph hash
127de03fd9b9050c5804fa5836ca91e5b9265b5356fbff021c2906e1afd7566c
Skeleton hash
195d4a8df243eac6e64cb5d77fa5545e60efe3115b19fbc579f5fb9f1eafb1be
Architecture hash
e23b8b341f09ffc6d99c03363d6aae7b4798fac2738d86598d67c34c5acf4250
Diagram SHA-256
deec43bc8d51556db695f826dedcde1e52d094ea6c3712b043a0d86239d30e17
TorchLens version
2.35.3
Renderer
graphviz 2.43.0+pyvips 3.2.0+libvips 8.18.7+render-opts@06c1f0d3
Check
Forward pass replayed in PyTorch

How this diagram was made

timm.create_model('focalnet_base_lrf', pretrained=False)

What it is

This is a large receptive field (LRF) version, using 3 focal levels.

About this model's family

FocalNets, focal modulation networks, are vision backbones in which self-attention is completely replaced by a focal modulation mechanism for modeling how tokens interact. Focal modulation has three parts: hierarchical contextualization through a stack of depth-wise convolutions that encode context from short to long range, and gated aggregation that gathers context for each query token based on its content. The aggregated context is then injected into the query by an element-wise modulation or affine transformation.

Depth-wise convolution was chosen for the contextualization because, compared to pooling, it is learnable and structure-aware, and compared to regular convolution it is channel-wise and much cheaper. To capture whole-image context, which may be high-resolution, a global average pooling is applied on the last level's feature map. A FocalNet is specified by the number of focal levels L and the kernel size at each level; kernel sizes grow by 2 from one level to the next. To match the complexity of Swin and Focal Transformers, each of the four layouts comes in a small receptive field (SRF) version with 2 focal levels and a large receptive field (LRF) version with 3. Patch embedding uses non-overlapping convolutions: 4x4 with stride 4 at the start and 2x2 with stride 2 between stages.

Tiny and base FocalNets reach 82.3% and 83.9% top-1 on ImageNet-1K; pretrained on ImageNet-22K at 224 resolution they reach 86.5% and 87.3% when fine-tuned at 224 and 384. With Mask R-CNN, FocalNet base trained on a 1x schedule beats its Swin counterpart by 2.1 points and already surpasses Swin trained 3x (49.0 vs 48.5). Using huge FocalNet and DINO, the authors report 64.3 and 64.4 mAP on COCO minival and test-dev. The timm port is fully convolutional with an NCHW tensor layout throughout, which its author found had minimal performance impact but more flexibility. It also drops input size constraints and supports feature extraction via features_only=True.

Key idea. Focal modulation, which replaces self-attention entirely: depth-wise convolutions build hierarchical context, a gate aggregates it per query, and an element-wise modulation injects it.

  • focalnet
  • focal modulation networks
  • focal modulation
  • focalnet-t
  • focalnet-b
  • srf
  • lrf
  • image classification
  • backbone
  • microsoft

AI-written summary, based on the paper and checked automatically against it; not reviewed by a person. Corrections welcome.

Cite the paper

@misc{yang2022focalmodulationnetworks,
      title={Focal Modulation Networks}, 
      author={Jianwei Yang and Chunyuan Li and Xiyang Dai and Lu Yuan and Jianfeng Gao},
      year={2022},
      eprint={2203.11926},
      archivePrefix={arXiv},
      primaryClass={cs.CV},
      url={https://arxiv.org/abs/2203.11926}, 
}