{"notes":[{"id":"vision-transformers/convmixer","category":"vision-transformers","legacyPath":"vision-transformers/2201-convmixer","legacySlug":"2201-convmixer","legacyPaths":[],"title":"ConvMixer","subtitle":"Convolutional Mixer","author":"Z. Yuan","paperDate":"2022-01-24","publishedOn":"2024-08-25","paperTitle":"Patches Are All You Need?","paperUrl":"https://arxiv.org/abs/2201.09792","bibliography":{"title":"Patches Are All You Need?","authors":["Asher Trockman","J. Zico Kolter"],"url":"https://arxiv.org/abs/2201.09792","pdfUrl":"https://arxiv.org/pdf/2201.09792","codeUrl":"https://github.com/locuslab/convmixer","preprint":{"id":"2201.09792","submittedOn":"2022-01-24","url":"https://arxiv.org/abs/2201.09792"},"publication":{"venue":"Transactions on Machine Learning Research","shortVenue":"TMLR","year":2023,"kind":"journal","url":"https://openreview.net/forum?id=rAnB7JSMXL"},"citation":"@misc{visiontransformersconvmixer2022,\n  title = {{Patches Are All You Need?}},\n  author = {Asher Trockman and J. Zico Kolter},\n  year = {2022},\n  eprint = {2201.09792},\n  archivePrefix = {arXiv},\n  url = {https://arxiv.org/abs/2201.09792}\n}\n","citationPath":"/content/papers/citations/vision-transformers/convmixer.575f26e378ef.bib"},"thumbnail":{"src":"/content/papers/assets/8285cbfd0782146934fa48acf57a480e4e1296cc35e4e251077fa165f8a659f6.jpg","width":852,"height":704},"locale":"en","path":"/content/papers/en/vision-transformers/convmixer.048c8ad1115f.md","headings":[{"id":"problem-definition","text":"Problem Definition","depth":2},{"id":"solution","text":"Solution","depth":2},{"id":"model-architecture","text":"Model Architecture","depth":3},{"id":"training-strategy","text":"Training Strategy","depth":3},{"id":"model-design-parameters","text":"Model Design Parameters","depth":3},{"id":"discussion","text":"Discussion","depth":2},{"id":"performance-on-imagenet","text":"Performance on ImageNet","depth":3},{"id":"conclusion","text":"Conclusion","depth":2}],"anchorAliases":{},"guide":null,"tags":["vision-transformers","image-classification","classic-cnns","cmu"],"relatedReading":[{"id":"classic-cnns/convnext","relation":"comparison","topic":"Convolution for mixing visual patches"},{"id":"vision-transformers/caformer","relation":"comparison","topic":"Convolution for mixing visual patches"}]},{"id":"classic-cnns/convnext","category":"classic-cnns","legacyPath":"classic-cnns/2201-convnext","legacySlug":"2201-convnext","legacyPaths":[],"title":"ConvNeXt","subtitle":"Making Convolutions Great Again","author":"Z. Yuan","paperDate":"2022-01-10","publishedOn":"2024-06-30","paperTitle":"A ConvNet for the 2020s","paperUrl":"https://arxiv.org/abs/2201.03545","bibliography":{"title":"A ConvNet for the 2020s","authors":["Zhuang Liu","Hanzi Mao","Chao-Yuan Wu","Christoph Feichtenhofer","Trevor Darrell","Saining Xie"],"url":"https://arxiv.org/abs/2201.03545","pdfUrl":"https://arxiv.org/pdf/2201.03545","codeUrl":"https://github.com/facebookresearch/ConvNeXt","preprint":{"id":"2201.03545","submittedOn":"2022-01-10","url":"https://arxiv.org/abs/2201.03545"},"publication":{"venue":"CVPR","year":2022,"kind":"conference","url":"https://arxiv.org/abs/2201.03545"},"citation":"@misc{classiccnnsconvnext2022,\n  title = {{A ConvNet for the 2020s}},\n  author = {Zhuang Liu and Hanzi Mao and Chao-Yuan Wu and Christoph Feichtenhofer and Trevor Darrell and Saining Xie},\n  year = {2022},\n  eprint = {2201.03545},\n  archivePrefix = {arXiv},\n  url = {https://arxiv.org/abs/2201.03545}\n}\n","citationPath":"/content/papers/citations/classic-cnns/convnext.801b4060b807.bib"},"thumbnail":{"src":"/content/papers/assets/37882616c5c72df33699003256d14bf7c58c8ea5d1e9e4fb5b1c33268c9a6923.jpg","width":1224,"height":432},"locale":"en","path":"/content/papers/en/classic-cnns/convnext.1a8312c7b164.md","headings":[{"id":"defining-the-problem","text":"Defining the Problem","depth":2},{"id":"solving-the-problem","text":"Solving the Problem","depth":2},{"id":"redesigning-network-architecture","text":"Redesigning Network Architecture","depth":3},{"id":"introducing-modern-training-techniques","text":"Introducing Modern Training Techniques","depth":3},{"id":"macro-design","text":"Macro Design","depth":3},{"id":"resnext-ify","text":"ResNeXt-ify","depth":3},{"id":"inverted-bottleneck","text":"Inverted Bottleneck","depth":3},{"id":"large-kernel-convolution","text":"Large Kernel Convolution","depth":3},{"id":"micro-design","text":"Micro Design","depth":3},{"id":"discussion","text":"Discussion","depth":2},{"id":"summary-of-model-configurations","text":"Summary of Model Configurations","depth":3},{"id":"performance-on-imagenet","text":"Performance on ImageNet","depth":3},{"id":"conclusion","text":"Conclusion","depth":2}],"anchorAliases":{},"guide":null,"tags":["classic-cnns","image-classification","vision-transformers","meta","berkeley"],"relatedReading":[{"id":"vision-transformers/convmixer","relation":"comparison","topic":"Convolution for mixing visual patches"},{"id":"vision-transformers/caformer","relation":"comparison","topic":"Convolution for mixing visual patches"},{"id":"reparameterization/replknet","relation":"comparison","topic":"Large kernels and simpler convolutional backbones"}]},{"id":"vision-transformers/caformer","category":"vision-transformers","legacyPath":"vision-transformers/2210-caformer","legacySlug":"2210-caformer","legacyPaths":[],"title":"CAFormer","subtitle":"MetaFormer User Manual","author":"Z. Yuan","paperDate":"2022-10-24","publishedOn":"2024-07-11","paperTitle":"MetaFormer Baselines for Vision","paperUrl":"https://doi.org/10.1109/TPAMI.2023.3329173","bibliography":{"title":"MetaFormer Baselines for Vision","authors":["Weihao Yu","Chenyang Si","Pan Zhou","Mi Luo","Yichen Zhou","Jiashi Feng","Shuicheng Yan","Xinchao Wang"],"url":"https://doi.org/10.1109/TPAMI.2023.3329173","pdfUrl":"https://arxiv.org/pdf/2210.13452v4","codeUrl":"https://github.com/sail-sg/metaformer","preprint":{"id":"2210.13452","submittedOn":"2022-10-24","url":"https://arxiv.org/abs/2210.13452"},"publication":{"venue":"IEEE Transactions on Pattern Analysis and Machine Intelligence","shortVenue":"IEEE TPAMI","year":2024,"kind":"journal","url":"https://doi.org/10.1109/TPAMI.2023.3329173"},"citation":"@misc{visiontransformerscaformer2022,\n  title = {{MetaFormer Baselines for Vision}},\n  author = {Weihao Yu and Chenyang Si and Pan Zhou and Mi Luo and Yichen Zhou and Jiashi Feng and Shuicheng Yan and Xinchao Wang},\n  year = {2022},\n  eprint = {2210.13452},\n  archivePrefix = {arXiv},\n  url = {https://arxiv.org/abs/2210.13452}\n}\n","citationPath":"/content/papers/citations/vision-transformers/caformer.aa84265d674f.bib"},"thumbnail":{"src":"/content/papers/assets/6ccbfbc74d7ee0be5bc2f37dd6cdd936bf9ed5cf9412cdab0f7dcc2c77a6d9ec.jpg","width":1224,"height":1004},"locale":"en","path":"/content/papers/en/vision-transformers/caformer.8024e9840b7d.md","headings":[{"id":"defining-the-problem","text":"Defining the Problem","depth":2},{"id":"solving-the-problem","text":"Solving the Problem","depth":2},{"id":"model-architecture","text":"Model Architecture","depth":3},{"id":"starrelu","text":"StarReLU","depth":3},{"id":"discussion","text":"Discussion","depth":2},{"id":"using-basic-token-mixers","text":"Using Basic Token Mixers","depth":3},{"id":"using-common-token-mixers","text":"Using Common Token Mixers","depth":3},{"id":"ablation-experiments","text":"Ablation Experiments","depth":3},{"id":"conclusion","text":"Conclusion","depth":2}],"anchorAliases":{},"guide":null,"tags":["vision-transformers","image-classification","normalization","nus","sea-ai-lab"],"relatedReading":[{"id":"vision-transformers/poolformer","relation":"background","topic":"Separating the backbone from token mixing"},{"id":"vision-transformers/convmixer","relation":"comparison","topic":"Convolution for mixing visual patches"},{"id":"classic-cnns/convnext","relation":"comparison","topic":"Convolution for mixing visual patches"}]}],"text":"We have seen plenty of titles in the form **“XXX is all you need”** over the past few years.\n\nWhenever one turns up, we cannot help taking a look: what happened this time?\n\n## Problem Definition\n\nSince ViT appeared, everyone has wanted to know why Transformers work so well. Is it self-attention, token mixing, or the design of the whole architecture?\n\nIn this paper, the authors ask whether ViT's strength also comes from patchifying the image. They propose ConvMixer to remove self-attention from this kind of design. If performance holds up, that gives us a reason to think patch representation matters **at least to some extent**; the experiment does not isolate patchification as the only cause.\n\n## Solution\n\n### Model Architecture\n\n![ConvMixer patch embedding, depthwise and pointwise convolutions; original Figure 2 with note annotations](/content/papers/assets/af2cec1d36107f037a52b0aa922b81f89982a4b57a54e1c91f587e04cf030c62.jpg \"Imported original Figure 2 with earlier note annotations; Trockman and Kolter, arXiv:2201.09792v1\")\n\nThe authors keep ViT's idea of taking patches as input and maintaining the same resolution through the later layers, but build a different architecture with convolutions. There are two main changes. The red marks on this imported figure are the note's annotations, rather than part of the original paper figure.\n\n1. **Replace self-attention with convolution.** The image is first divided into patches using a convolution whose kernel and stride both equal the patch size, while retaining their two-dimensional arrangement. For token mixing, the model uses a depthwise convolution instead of self-attention. Each layer mixes nearby patches within the kernel's reach, and stacking layers expands that reach. This lets us examine a patch-based model without self-attention.\n2. **Replace the MLP with pointwise convolution.** A $1\\times1$ convolution mixes channels at each spatial position, much like a per-token linear layer. It is not equivalent to a complete two-layer MLP. The figure then shows GELU and BatchNorm.\n\n### Training Strategy\n\nThe authors train from random initialization on ImageNet-1K without extra pretraining or additional data. Their setup includes RandAugment and MixUp, along with AdamW. They did not tune ImageNet hyperparameters and trained for fewer epochs than some comparison models because compute was limited.\n\n### Model Design Parameters\n\n![ImageNet-1k top-1 accuracy against parameter count; original paper Figure 1](/content/papers/assets/369998c6167fac545d0c6c6a552004ff8ef1c892c6458658a9075b396d966bc4.jpg \"Trockman and Kolter, Figure 1, arXiv:2201.09792v1\")\n\nFour parameters describe a ConvMixer:\n\n1. **Width (hidden dimension, $h$):** The dimension of each patch embedding.\n2. **Depth ($d$):** The number of repeated ConvMixer layers.\n3. **Patch size ($p$):** Sets the model's internal spatial resolution by dividing the input image into patches.\n4. **Kernel size ($k$):** Sets the size of the depthwise convolution kernel and the area mixed in one layer.\n\nModels are named for width and depth, such as ConvMixer-$h$/$d$. ConvMixer supports variable input sizes; with an input side length $n$ divisible by $p$, its internal side length is $n/p$. The figure above plots ImageNet accuracy against parameter count, rather than showing these four operations.\n\n## Discussion\n\n### Performance on ImageNet\n\n![ImageNet-1k comparison of ConvMixer, ResNet, DeiT and ResMLP; original paper Table 1](/content/papers/assets/2b0a4eb0caaa3081c5b133fa9260a6b7b1508a386988bd9e72efb771e036682f.jpg \"Trockman and Kolter, Table 1, arXiv:2201.09792v1\")\n\n\n> [!TIP]\n> \n> The table's throughput was measured on one RTX8000 with FP16 and a batch size of 64. ConvMixer is slower than several comparison models. The authors suggest its smaller patches may be one reason, though the table alone cannot isolate that cause.\n\n\nConvMixer-1536/20 reaches **81.37%** ImageNet top-1 with **51.6M** parameters, ahead of ResNet-152's **79.64%** with **60.2M** parameters. ConvMixer-768/32 also reaches a similar **80.16%** with roughly one-third as many parameters as ResNet-152, though the training epochs differ.\n\nDespite its relatively small parameter count, ConvMixer-1536/20 exceeds ResMLP-B24/8's **81.0%** and approaches DeiT-B's **81.8%** in this main table. DeiT and ResMLP benefited from more hyperparameter tuning; ConvMixer's main result used an untuned setup. The appendix separately reports **82.20%** after changing regularization, so we should keep those training settings distinct.\n\n**The cost of patch size, kernel size and tuning**\n\n![ConvMixer patch and kernel variants and tuned results; original paper Appendix Table 2](/content/papers/assets/8285cbfd0782146934fa48acf57a480e4e1296cc35e4e251077fa165f8a659f6.jpg \"Trockman and Kolter, Appendix A Table 2, arXiv:2201.09792v1\")\n\nThe appendix shows the patch-size trade-off. For ConvMixer-1536/20, changing $p$ from **7 to 14** lowers top-1 from **81.37% to 78.92%**, while throughput rises from **134 to 538 images/s**. The untuned $k=3$ row is also less accurate than the $k=9$ row; the starred **82.20%** result uses different regularization. Looking only at accuracy or speed misses the other side.\n\n## Conclusion\n\nThe authors propose ConvMixer to weaken the role of self-attention and explore what patchification contributes. Performance remains strong without self-attention, leading them to two conclusions:\n\n1. The patch-based design matters.\n2. ConvMixer is simple, performs well, and is worth considering.\n\n\n> [!TIP]\n> \n> We are more persuaded by the conclusion that **self-attention is not required** in this comparison. Patchification itself seems too simple to simplify any further.\n> \n> It may look like one linear embedding step, much as `nn.Embedding` is a familiar starting point in NLP. The image version projects pixel patches rather than looking up word vectors. In NLP, people spend far more energy deciding how to cut text into tokens with BPE or WordPiece than praising `nn.Embedding` alone.\n> \n> Given this paper's title, we expected a magical patchification operation that would greatly improve a model while keeping the same Transformer architecture. Then perhaps I could say, “A good patchify is all you need.”\n> \n> But that leads to another dilemma. We brought in Transformers partly to leave convolutional inductive biases behind, then turned around and added more operations to this supposedly more powerful architecture, as though we did not trust it to solve the problem by itself.\n> \n> Ah, what a maddening question this is!\n","imageSizes":{"/content/papers/assets/af2cec1d36107f037a52b0aa922b81f89982a4b57a54e1c91f587e04cf030c62.jpg":{"width":3992,"height":1567},"/content/papers/assets/369998c6167fac545d0c6c6a552004ff8ef1c892c6458658a9075b396d966bc4.jpg":{"width":1224,"height":376},"/content/papers/assets/2b0a4eb0caaa3081c5b133fa9260a6b7b1508a386988bd9e72efb771e036682f.jpg":{"width":1000,"height":1080},"/content/papers/assets/8285cbfd0782146934fa48acf57a480e4e1296cc35e4e251077fa165f8a659f6.jpg":{"width":852,"height":704}}}
