Skip to content
AI360Xpert
Beta

CoAtNet Stacks Conv Then Attention

CoAtNet runs MBConv blocks early for locality then transformer blocks late for range, joining both strengths in one backbone.

Two MBConv stages feed two relative attention stages for local plus global strength
Two MBConv stages feed two relative attention stages for local plus global strength

Why Does This Exist?

Pure convs lack range and pure transformers lack bias. Either alone needs more data or depth to match the pair.

CoAtNet orders them. It extends convolutional layers, beats efficientnet efficiency fronts, and informs convnext era hybrids.

Think of It Like This

Masons then surveyors on one crew

Masons lay local bricks fast with tight rules. Surveyors then sight across the whole site for alignment. One crew does both in order.

MBConv blocks are masons, attention blocks are surveyors. Where it stops: surveyors cost more, so you call them only after walls stand.

How It Actually Works

Stages follow C-C-T-T: two MBConv with squeeze-excite, then two transformers with relative position bias BB:

y=softmax(QKT/d+B)Vy = softmax(QK^T/\sqrt{d} + B)V

BB depends on dx,dydx, dy offsets, so translation holds. Downsample between stages. Late attention sees 14×1414 \times 14 maps, not 56×5656 \times 56, keeping cost sane.

Worked example

224224 input gives 112112, 5656, 2828, 1414 maps across four stages. Late attention on 14×14=19614 \times 14 = 196 tokens costs 1962=38,416196^2 = 38{,}416 pairs versus 31362=9.83136^2 = 9.8M early, about 256256 times cheaper. Relative bias adds 2×13−1=252 \times 13 - 1 = 25 offsets per axis for a 1414 span, tiny tables with large effect.

Watch Out For

Putting attention too early in the stack

Early 56×5656 \times 56 attention blows memory and learns noisy geometry. Symptom: slow steps with flat accuracy. Fix: keep the C-C-T-T order and downsample before the first transformer.

The Quick Version

  • CoAtNet stacks two MBConv stages then two relative attention stages.
  • Relative bias BB encodes offsets while keeping translation behavior.
  • Fixture late 1962196^2 pairs cost 256 times less than early 313623136^2.
  • Order matters: convs first for bias, attention late for range.
  • Downsample before attention to hold the budget.