Skip to content
AI360Xpert
Beta

PVT Builds Pyramids for Transformers

PVT shrinks keys with spatial reduction so transformers output pyramid maps, fitting dense tasks like detection and segmentation.

Spatial reduction cuts 3136 keys to 49, so attention drops 64 times while keeping pyramids
Spatial reduction cuts 3136 keys to 49, so attention drops 64 times while keeping pyramids

Why Does This Exist?

Plain ViT outputs one 14×1414 \times 14 map. Detection needs 56×5656 \times 56 down to 7×77 \times 7 pyramids, but full attention on 56×5656 \times 56 costs 313623136^2 pairs.

PVT keeps pyramids affordable. It feeds object detection and semantic segmentation backbones past image classification only use.

Think of It Like This

Reading a map at four zoom levels

You keep country, region, city, and street maps of one area. For a country question you scan the small map, for a street question you open the large one.

Stages are zooms, reduction is folding the large map before comparing. Where it stops: folding blurs alleys, just as reduction blurs tiny objects.

How It Actually Works

Four stages output strides 44, 88, 1616, 3232. Stage ii has HiWiH_i W_i queries. Spatial reduction with ratio RiR_i reshapes keys to Hi/Ri×Wi/RiH_i/R_i \times W_i/R_i, so keys drop by Ri2R_i^2. Attention is softmax(QKT/d)Vsoftmax(QK^T/\sqrt{d})V with KK reduced.

Worked example

Stage 1 on 224224 input gives 56×56=313656 \times 56 = 3136 tokens. Full pairs are 31362=9,834,4963136^2 = 9{,}834{,}496. With R=8R = 8, keys reshape to 7×7=497 \times 7 = 49. Pairs drop to 3136×49=153,6643136 \times 49 = 153{,}664. Ratio 9,834,496/153,664=649{,}834{,}496 / 153{,}664 = 64. Four stages then emit 5656, 2828, 1414, 77 maps for dense heads.

Watch Out For

Setting reduction so high small objects vanish

Ratio 88 on early stages erases 44-pixel lights. Symptom: good classification with weak small AP. Fix: use smaller RR early (8,4,2,18,4,2,1 schedule from the paper) and keep high resolution for small splits.

The Quick Version

  • PVT emits four pyramid maps at strides 4, 8, 16, and 32 for dense tasks.
  • Reduction ratio RR cuts keys by R2R^2 before attention.
  • Fixture 3136 to 49 keys cuts pairs 64 times from 9.8M to 0.15M.
  • Early stages need smaller RR to protect tiny objects.
  • Pyramids let transformers replace CNN backbones directly.