Paper · 2021-03-04 · cs.CV
Coordinate Attention for Efficient Mobile Network Design
Coordinate attention replaces the global pooling of channel attention with two 1D poolings along height and width, encodes both with one shared 1x1 conv, and gates the input per row and per column. Plugged into MobileNetV2 it reaches 74.3% ImageNet top-1 vs 73.5% for SE and 72.3% for the baseline (author-reported).
Channel attentionAttention mechanismEfficient vision backbonesSemantic segmentationattentionmobile-networksimage-classificationobject-detectionsemantic-segmentation
arXivPDFCodeMarkdown10 min read
AI-compiled by claude-haiku-5-5 on 2026-10-24, not yet reviewed by a human. Every claim cites its source; check it when a detail matters.
In plain words
Mobile image models often use a small attention module that asks "which feature channels matter for this image?" but never asks "where in the image?". The usual version squeezes each channel into one number for the whole picture, so the location of a feature is thrown away.
This paper's coordinate attention keeps the location. It averages along one axis at a time: first across each row, then across each column. The two resulting strips are mixed by one small shared layer, then split back into a row part and a column part. Each part becomes a gate between zero and one, and the input is scaled by the row gate and the column gate together. The result is a cheap block that can be dropped into the same places as the existing attention modules and that lets the network emphasise a region by its row and its column.
It is aimed at phones and other small models, where the extra cost has to stay close to zero. The authors report gains on image classification and on the detection and segmentation tasks built on those backbones.
TL;DR
Coordinate attention is a light channel-attention block that also encodes position. It pools features separately along height and width eq. 4 eq. 5, mixes them with a shared 1x1 conv and sigmoid gates eq. 6 eq. 7 eq. 8, and multiplies the input by both gates eq. 9. Inserted into MobileNetV2 with reduction ratio 32, it adds about 0.45M parameters and 10M M-Adds over the baseline, and 0.06M parameters over SE, in the authors' ImageNet table tab. 1. Its reported gains are larger on dense tasks such as segmentation §4.4.2. All numbers are author-reported.
Problem
Attention modules that help large networks are often too costly for mobile networks, which have limited size and compute §1. Squeeze-and-Excitation (SE) is cheap and widely used in mobile networks, but it computes channel weights from a global average over the whole map, so it keeps no positional information §1 §3.1. CBAM adds a spatial branch, but that branch reduces channels to one and uses a 7x7 convolution, so it sees only local relations and loses information §1 §4.3. The paper's goal is an attention block that captures channel relations and long-range positional information at a cost comparable to SE §1 §3.2.2.
Method
The block takes any intermediate feature tensor X with shape C x H x W and returns Y of the same shape §3.2. It has two steps: coordinate information embedding and coordinate attention generation §3.2.
- Direction-aware pooling. For each channel, average over the width to get a height-indexed vector, and average over the height to get a width-indexed vector §3.2.1 eq. 4 eq. 5. Unlike SE's single vector per channel, these keep one spatial axis each.
- Shared transform. Concatenate the two vectors along the spatial axis and apply one shared 1x1 conv F1 followed by a non-linearity delta §3.2.2 eq. 6. The output has C/r channels, where r is the reduction ratio. Split it back into a height part f^h and a width part f^w §3.2.2.
- Two gates. Apply two separate 1x1 convs F_h and F_w to f^h and f^w to return C channels each, then apply a sigmoid to get gates g^h and g^w §3.2.2 eq. 7 eq. 8.
- Apply. Multiply the input by both gates at each position: y(i, j) = x(i, j) * g^h(i) * g^w(j) §3.2.2 eq. 9.
The authors read each element of the two gate maps as whether the object of interest is present in that row or column §3.2.2, Discussion.
Choosing r: the block description gives 32 as an example reduction ratio §3.2.2; Table 1 uses r = 24 for the SE and X/Y variants and r = 32 for coordinate attention tab. 1. Table 4 compares r = 24 and r = 32 against r = 12 and r = 16 tab. 4.
Placement: the paper says Figure 3 shows how the block is plugged into the MobileNetV2 inverted residual block and the MobileNeXt sandglass block §3.3 fig. 3. The text does not give the exact position in words; see Paper vs code.
Pseudocode for the block (features are one sample, no batch axis):
# Coordinate attention block [§3.2] [eq. 4-9]
# Input: features X of shape (C, H, W)
# Output: Y of shape (C, H, W), the same shape as X
def coordinate_attention(features, reduction):
# Average over the width, keeping one value per row [eq. 4]
pooled_h = mean_over_width(features) # (C, H, 1)
# Average over the height, keeping one value per column [eq. 5]
pooled_w = mean_over_height(features) # (C, 1, W)
# Stack both strips on one spatial axis for a shared transform [eq. 6]
joined = concat_spatial(pooled_h, transpose(pooled_w)) # (C, H+W, 1)
# Reduce channels by the ratio r, then apply the non-linearity [eq. 6]
mixed = delta(conv1x1(joined, out_channels=C // reduction)) # (C/r, H+W, 1)
# Split the mixed map back into its row part and column part [§3.2.2]
mixed_h, mixed_w = split_spatial(mixed, sizes=[H, W])
# Expand each part back to C channels and squash to (0, 1) [eq. 7] [eq. 8]
gate_h = sigmoid(conv1x1_h(mixed_h)) # (C, H, 1)
gate_w = sigmoid(conv1x1_w(transpose(mixed_w))) # (C, 1, W)
# Scale each position by its row gate and its column gate [eq. 9]
return features * gate_h * gate_wHyperparameters
Training values are from the paper text unless a row says otherwise. The repository contains model code and weights only, not a training script README.md.
| Name | Value | Where | Notes |
|---|---|---|---|
| Reduction ratio r (default) | 32 | §3.2.2 tab. 1 coordatt.py | Code default is 32 in both files |
| Reduction ratio r (variant) | 16 for CA, 12 for SE/CBAM | tab. 4 | Smaller r gives more parameters |
| Bottleneck width | max(8, C // r) | coordatt.py mbv2_ca.py | Paper states C/r; code adds a floor of 8 |
| Non-linearity delta | not stated | §3.2.2 | Code uses BatchNorm then h-swish coordatt.py |
| Optimizer | SGD, momentum 0.9 | §4.1 | Text says "decay and momentum of 0.9"; which is which is not stated |
| Weight decay (ImageNet) | 4e-5 | §4.1 | |
| Learning rate schedule | cosine | §4.1 | |
| Initial learning rate (ImageNet) | 0.05 | §4.1 | |
| Batch size (ImageNet) | 256 | §4.1 | Four NVIDIA GPUs §4.1 |
| Epochs (ImageNet) | 200 | §4.1 | Regular setting, no label smoothing or mixup README.md |
| Data augmentation (ImageNet) | same as MobileNetV2 | §4.1 | Specific recipe not restated |
| Detection, COCO | SSDLite320; batch 256, synchronized BN, cosine, initial LR 0.01, 1,600,000 iterations | §4.4.1 | |
| Detection, Pascal VOC | batch 24; 240,000 iterations; LR 0.001, divided by 10 at 160,000 and 200,000 | §4.4.1 | Weight decay given as "0.9", see Pitfalls |
| Segmentation backbone head | DeepLabV3; ASPP branches 256 channels; depthwise separable 3x3 convs in ASPP | §4.4.2 | |
| ASPP dilation rates | {6, 12, 18} at output stride 16; {12, 24, 36} at output stride 8 | §4.4.2 | |
| Segmentation weight decay | 4e-5 | §4.4.2 | Other DeepLabV3 settings follow the original paper §4.4.2 |
| Pascal VOC 2012 data | 10,582 training images (augmented); 1,449 val | §4.4.2 | Augmented set is the original 1,464 train split plus extra images from the source the paper cites §4.4.2 |
| Cityscapes data | 2,975 train, 500 val; random crop 768 x 768; full-size test | §4.4.2 | Fine annotations only |
Results
All results are author-reported. ImageNet numbers use MobileNetV2 or MobileNeXt as the baseline, trained for 200 epochs §4.1. The EfficientNet-b0 run follows the original EfficientNet paper for other settings §4.3. Detection and segmentation numbers come from the transfer setups in §4.4.
ImageNet, MobileNetV2 baseline tab. 1:
| Setting | Params | M-Adds | r | Latency (Pixel 4) | Top-1 (%) |
|---|---|---|---|---|---|
| Baseline | 3.5M | 300M | - | 14-16 ms | 72.3 |
| + SE | 3.89M | 300M | 24 | 16-18 ms | 73.5 |
| + X attention only | 3.89M | 300M | 24 | 16-18 ms | 73.5 |
| + Y attention only | 3.89M | 300M | 24 | 16-18 ms | 73.5 |
| + Coordinate attention | 3.95M | 310M | 32 | 17-19 ms | 74.3 |
ImageNet, MobileNetV2 at three width multipliers tab. 2:
| Width | Baseline | + SE | + CBAM | + CA |
|---|---|---|---|---|
| 1.0 (params 3.5M / 3.89M / 3.89M / 3.95M) | 72.3 | 73.5 | 73.6 | 74.3 |
| 0.75 (params 2.5M / 2.86M / 2.86M / 2.89M) | 69.9 | 71.5 | 71.5 | 72.1 |
| 0.5 (params 2.0M / 2.1M / 2.1M / 2.1M) | 65.4 | 66.4 | 66.4 | 67.0 |
ImageNet, MobileNeXt at three width multipliers tab. 3:
| Width | Baseline | + SE | + CA |
|---|---|---|---|
| 1.0 (CA: 4.09M params, 330M M-Adds) | 74.0 | 74.7 | 75.2 |
| 0.75 (CA: 3.0M params, 220M M-Adds) | 72.0 | 72.6 | 73.2 |
| 0.5 (CA: 2.4M params, 110M M-Adds) | 67.7 | 68.7 | 69.4 |
Reduction ratio, MobileNetV2 tab. 4:
| Setting | Params | r | Top-1 (%) |
|---|---|---|---|
| + SE | 3.89M | 24 | 73.5 |
| + CBAM | 3.89M | 24 | 73.6 |
| + CA | 3.95M | 32 | 74.3 |
| + SE | 4.28M | 12 | 74.1 |
| + CBAM | 4.28M | 12 | 74.1 |
| + CA | 4.37M | 16 | 74.7 |
EfficientNet-b0 with SE replaced by CA tab. 5: 76.3% (SE, 5.3M params, 390M M-Adds) vs 76.9% (CA, 5.4M params, 400M M-Adds). The table also lists other methods at comparable size; the best of them is MNasNet-A3 at 76.7%.
Object detection, SSDLite320 on COCO val tab. 6:
| Backbone | Params | AP | AP50 | AP75 |
|---|---|---|---|---|
| MobileNetV2 | 4.3M | 22.3 | 37.4 | 22.7 |
| + SE | 4.7M | 23.7 | 40.0 | 24.3 |
| + CBAM | 4.7M | 23.0 | 38.6 | 23.3 |
| + CA | 4.8M | 24.5 | 40.7 | 25.4 |
Object detection, Pascal VOC 2007 test mAP tab. 7: MobileNetV2 71.7; + SE 71.7; + CBAM 71.7; + CA 73.1.
Semantic segmentation, DeepLabV3 on Pascal VOC 2012 val, mIoU tab. 8:
| Backbone | Output stride 16 | Output stride 8 |
|---|---|---|
| MobileNetV2 | 70.84 | 71.82 |
| + SE | 71.69 | 72.52 |
| + CBAM | 71.28 | 71.67 |
| + CA | 73.32 | 73.96 |
Semantic segmentation, DeepLabV3 on Cityscapes val, mIoU at output stride 8 tab. 9: MobileNetV2 71.4; + SE 72.2; + CBAM 71.4; + CA 74.0.
Paper vs code
The official repository is https://github.com/Andrew-Qibin/CoordAttention. Its owner is the first author, and its LICENSE is MIT and names Qibin (Andrew) Hou LICENSE. The repository holds the block, a MobileNetV2 model and a pretrained MobileNetV2 + CA checkpoint. It does not hold training, detection or segmentation code: the README points to pytorch-image-models for ImageNet training, to ssdlite-pytorch-mobilenext for detection and to SPNet for segmentation README.md README.md README.md. Those three repositories were not checked here.
- Core equations match. Pooling, the shared transform, two sigmoid gates and the multiplication follow eq. 4 to eq. 9 coordatt.py. The default reduction is 32 coordatt.py, as in the paper's CA rows tab. 1.
- Bottleneck width has a floor. The paper gives C/r §3.2.2. The code uses max(8, C // r) coordatt.py mbv2_ca.py.
- Non-linearity. The paper calls delta a "non-linear activation function" §3.2.2. The code applies BatchNorm and then h-swish coordatt.py coordatt.py. The README calls this activation SiLU and says it works better than ReLU6 README.md. The code's h-swish is a piecewise approximation of SiLU, not SiLU itself.
- Placement in MobileNetV2. The text does not say where the block sits. The code puts it after the depthwise conv's activation and before the pointwise projection mbv2_ca.py. It is not used in the expansion-ratio-1 block mbv2_ca.py.
- Biases. The paper does not state whether the 1x1 convs have biases. The code uses the default bias=True on conv1, conv_h and conv_w coordatt.py coordatt.py.
- Initialization and head. The code initialises convs with normal(0, sqrt(2/n)), BatchNorm weight 1 and bias 0, and linear layers with normal(0, 0.01) mbv2_ca.py. It adds Dropout(0.1) before the classifier mbv2_ca.py. The paper states neither.
- Naming. In the MobileNetV2 file the reduction argument is called
groupsmbv2_ca.py. It is the reduction ratio, not a convolution group count. - README table. The README's SSDLite320 table has an extra MobileNetV2 row at 5.0M params and 22.0 AP that the paper does not list README.md.
- Not checked. Parameter counts, M-Adds and accuracy numbers were not recomputed by running the code. The checkpoint was not loaded.
Pitfalls
- Bottleneck floor changes small layers. With max(8, C // r) and r = 32, the bottleneck is 8 for hidden widths below 256. That is 8 where C/r would be 3, 4 or 6 for widths 96, 144 and 192. For MobileNetV2 blocks with hidden widths 384, 576 and 960, the bottleneck is C/32, i.e. 12, 18 and 30 coordatt.py. A reimplementation that uses C/r alone will differ from the released code in these layers.
- Two sigmoid gates shrink the output. The input is multiplied by two sigmoid gates, each in (0, 1), so the block's output is smaller in scale than its input. The paper does not discuss how this changes activation scale. Check the gated output's scale in your own setup. (Inference from the equations.)
- Use the code's activation. The paper leaves delta open. Using ReLU6, or a plain SiLU, is a different block from the one that produced the numbers.
- Batch statistics. The bottleneck has a BatchNorm layer coordatt.py. Train and eval mode behave differently, as in any BatchNorm layer.
- Weight decay "0.9". The VOC detection text says "the weight decay is set to 0.9" §4.4.1. This is almost certainly a typo, and no value is given elsewhere. Do not use 0.9 as weight decay. The optimizer text ("decay and momentum of 0.9") is also ambiguous §4.1.
- Confounded comparison. Table 1 compares SE and X/Y attention at r = 24 against coordinate attention at r = 32 tab. 1. Parameters differ slightly (3.89M vs 3.95M). Table 4 has SE and CBAM at r = 24 and r = 12, and CA at r = 32 and r = 16; CA is never run at the same r as SE or CBAM tab. 4.
- Training recipe is not in the repo. ImageNet numbers depend on a training pipeline that is not in this repository README.md. Expect to rebuild augmentation and schedule from the paper text.
- Latency is one device. The latency column comes from a Google Pixel 4 tab. 1.
- Segmentation and detection code are elsewhere. Those numbers depend on the external repositories named above, which were not checked.
Lineage
- Builds on: the MobileNetV2 inverted residual block §3.3 fig. 3 and the MobileNeXt sandglass block §3.3 fig. 3. Both are named in the paper; this card does not use their content.
- Compared against: Squeeze-and-Excitation §1 tab. 1, CBAM §1 tab. 2, and TA (named in the related work §2.2).
- Superseded by: not stated in this card's sources.
Source and license
Adapted from “Coordinate Attention for Efficient Mobile Network Design” by Qibin Hou, Daquan Zhou, Jiashi Feng (arXiv:2103.02907), used under CC BY 4.0. Changes: condensed and restructured for implementation, with tables, equations and algorithms taken from the paper and its code, each cited to its source. Not affiliated with or endorsed by the authors. Code citations refer to https://github.com/Andrew-Qibin/CoordAttention at commit 7619bea9acbe (MIT). Any quoted code is shown under that license.