CoAtNet Stacks Conv Then Attention
CoAtNet runs MBConv blocks early for locality then transformer blocks late for range, joining both strengths in one backbone.
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 :
depends on offsets, so translation holds. Downsample between stages. Late attention sees maps, not , keeping cost sane.
Worked example
input gives , , , maps across four stages. Late attention on tokens costs pairs versus M early, about times cheaper. Relative bias adds offsets per axis for a span, tiny tables with large effect.
Watch Out For
Putting attention too early in the stack
Early 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 encodes offsets while keeping translation behavior.
- Fixture late pairs cost 256 times less than early .
- Order matters: convs first for bias, attention late for range.
- Downsample before attention to hold the budget.