MetaFormer Baselines for Vision

24 Oct 2022  ·  Weihao Yu, Chenyang Si, Pan Zhou, Mi Luo, Yichen Zhou, Jiashi Feng, Shuicheng Yan, Xinchao Wang ·

MetaFormer, the abstracted architecture of Transformer, has been found to play a significant role in achieving competitive performance. In this paper, we further explore the capacity of MetaFormer, again, without focusing on token mixer design: we introduce several baseline models under MetaFormer using the most basic or common mixers, and summarize our observations as follows: (1) MetaFormer ensures solid lower bound of performance. By merely adopting identity mapping as the token mixer, the MetaFormer model, termed IdentityFormer, achieves >80% accuracy on ImageNet-1K. (2) MetaFormer works well with arbitrary token mixers. When specifying the token mixer as even a random matrix to mix tokens, the resulting model RandFormer yields an accuracy of >81%, outperforming IdentityFormer. Rest assured of MetaFormer's results when new token mixers are adopted. (3) MetaFormer effortlessly offers state-of-the-art results. With just conventional token mixers dated back five years ago, the models instantiated from MetaFormer already beat state of the art. (a) ConvFormer outperforms ConvNeXt. Taking the common depthwise separable convolutions as the token mixer, the model termed ConvFormer, which can be regarded as pure CNNs, outperforms the strong CNN model ConvNeXt. (b) CAFormer sets new record on ImageNet-1K. By simply applying depthwise separable convolutions as token mixer in the bottom stages and vanilla self-attention in the top stages, the resulting model CAFormer sets a new record on ImageNet-1K: it achieves an accuracy of 85.5% at 224x224 resolution, under normal supervised training without external data or distillation. In our expedition to probe MetaFormer, we also find that a new activation, StarReLU, reduces 71% FLOPs of activation compared with GELU yet achieves better performance. We expect StarReLU to find great potential in MetaFormer-like models alongside other neural networks.

PDF Abstract

Datasets


Results from the Paper


Ranked #54 on Image Classification on ImageNet (using extra training data)

     Get a GitHub badge
Task Dataset Model Metric Name Metric Value Global Rank Uses Extra
Training Data
Result Benchmark
Image Classification ImageNet CAFormer-B36 (224 res, 21K) Top 1 Accuracy 87.4% # 75
Number of params 99M # 736
GFLOPs 23.2 # 349
Image Classification ImageNet CAFormer-M36 (384 res, 21K) Top 1 Accuracy 87.5% # 68
Number of params 56M # 630
GFLOPs 42 # 385
Image Classification ImageNet CAFormer-M36 (224 res, 21K) Top 1 Accuracy 86.6% # 110
Number of params 56M # 630
GFLOPs 13.2 # 302
Image Classification ImageNet ConvFormer-M36 (384 res, 21K) Top 1 Accuracy 86.9% # 95
Number of params 57M # 636
GFLOPs 37.7 # 379
Image Classification ImageNet ConvFormer-M36 (224 res, 21K) Top 1 Accuracy 86.1% # 143
Number of params 57M # 636
GFLOPs 12.8 # 299
Image Classification ImageNet CAFormer-S36 (384 res, 21K) Top 1 Accuracy 86.9% # 95
Number of params 39M # 553
GFLOPs 26.0 # 356
Image Classification ImageNet CAFormer-S36 (224 res, 21K) Top 1 Accuracy 85.8% # 156
Number of params 39M # 553
GFLOPs 8.0 # 248
Image Classification ImageNet ConvFormer-S36 (384 res, 21K) Top 1 Accuracy 86.4% # 121
Number of params 40M # 565
GFLOPs 22.4 # 345
Image Classification ImageNet ConvFormer-S36 (224 res, 21K) Top 1 Accuracy 85.4% # 185
Number of params 40M # 565
GFLOPs 7.6 # 239
Image Classification ImageNet CAFormer-S18 (384 res, 21K) Top 1 Accuracy 85.4% # 185
Number of params 26M # 497
GFLOPs 13.4 # 305
Image Classification ImageNet CAFormer-S18 (224 res, 21K) Top 1 Accuracy 84.1% # 271
Number of params 26M # 497
GFLOPs 4.1 # 178
Image Classification ImageNet ConvFormer-S18 (384 res, 21K) Top 1 Accuracy 85.0% # 215
Number of params 27M # 505
GFLOPs 11.6 # 290
Image Classification ImageNet ConvFormer-S18 (224 res, 21K) Top 1 Accuracy 83.7% # 302
Number of params 27M # 505
GFLOPs 3.9 # 172
Image Classification ImageNet CAFormer-M36 (384 res) Top 1 Accuracy 86.2% # 139
Number of params 56M # 630
GFLOPs 42.0 # 385
Image Classification ImageNet CAFormer-S18 (224 res) Top 1 Accuracy 83.6% # 312
Number of params 26M # 497
GFLOPs 4.1 # 178
Image Classification ImageNet CAFormer-S36 (384 res) Top 1 Accuracy 85.7% # 166
Number of params 39M # 553
GFLOPs 26.0 # 356
Image Classification ImageNet CAFormer-S36 (224 res) Top 1 Accuracy 84.5% # 243
Number of params 39M # 553
GFLOPs 8.0 # 248
Image Classification ImageNet CAFormer-B36 (384 res, 21K) Top 1 Accuracy 88.1% # 54
Number of params 99M # 736
GFLOPs 72.2 # 410
Image Classification ImageNet ConvFormer-S18 (224 res) Top 1 Accuracy 83.0% # 365
Number of params 27M # 505
GFLOPs 3.9 # 172
Image Classification ImageNet ConvFormer-S36 (224 res) Top 1 Accuracy 84.1% # 271
Number of params 40M # 565
GFLOPs 7.6 # 239
Image Classification ImageNet ConvFormer-S18 (384 res) Top 1 Accuracy 84.4% # 248
Number of params 27M # 505
GFLOPs 11.6 # 290
Image Classification ImageNet ConvFormer-M36 (224 res) Top 1 Accuracy 84.5% # 243
Number of params 57M # 636
GFLOPs 12.8 # 299
Image Classification ImageNet CAFormer-S18 (384 res) Top 1 Accuracy 85.0% # 215
Number of params 26M # 497
GFLOPs 13.4 # 305
Image Classification ImageNet CAFormer-M36 (224 res) Top 1 Accuracy 85.2% # 200
Number of params 56M # 630
GFLOPs 13.2 # 302
Image Classification ImageNet ConvFormer-S36 (384 res) Top 1 Accuracy 85.4% # 185
Number of params 40M # 565
GFLOPs 22.4 # 345
Image Classification ImageNet ConvFormer-M36 (384 res) Top 1 Accuracy 85.6% # 174
Number of params 57M # 636
GFLOPs 37.7 # 379
Image Classification ImageNet ConvFormer-B36 (384 res, 21K) Top 1 Accuracy 87.6% # 66
Number of params 100M # 743
GFLOPs 66.5 # 407
Image Classification ImageNet ConvFormer-B36 (224 res, 21K) Top 1 Accuracy 87.0% # 92
Number of params 100M # 743
GFLOPs 22.6 # 347
Image Classification ImageNet ConvFormer-B36 (224 res) Top 1 Accuracy 84.8% # 225
Number of params 100M # 743
GFLOPs 22.6 # 347
Image Classification ImageNet CAFormer-B36 (224 res) Top 1 Accuracy 85.5% # 177
Number of params 99M # 736
GFLOPs 23.2 # 349
Image Classification ImageNet ConvFormer-B36 (384 res) Top 1 Accuracy 85.7% # 166
Number of params 100M # 743
GFLOPs 66.5 # 407
Image Classification ImageNet CAFormer-B36 (384 res) Top 1 Accuracy 86.4% # 121
Number of params 99M # 736
GFLOPs 72.2 # 410

Methods