{"about":{"site":"https://codewithpapers.app","non_affiliation":"Code with Papers and Syntology are not affiliated with, endorsed by, or sponsored by Papers with Code, Meta, or the pwc-archive mirror.","licence":"CC BY-SA 4.0","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","attribution":"https://codewithpapers.app/attribution","modified":"archive material modified by Syntology; see the attribution page"},"url":"/paper/patches-are-all-you-need-1","title":"Patches Are All You Need?","arxiv_id":"2201.09792","date":"2022-01-24","proceeding":null,"authors":["Asher Trockman","J. Zico Kolter"],"abstract":"Although convolutional networks have been the dominant architecture for vision tasks for many years, recent experiments have shown that Transformer-based models, most notably the Vision Transformer (ViT), may exceed their performance in some settings. However, due to the quadratic runtime of the self-attention layers in Transformers, ViTs require the use of patch embeddings, which group together small regions of the image into single input features, in order to be applied to larger image sizes. This raises a question: Is the performance of ViTs due to the inherently-more-powerful Transformer architecture, or is it at least partly due to using patches as the input representation? In this paper, we present some evidence for the latter: specifically, we propose the ConvMixer, an extremely simple model that is similar in spirit to the ViT and the even-more-basic MLP-Mixer in that it operates directly on patches as input, separates the mixing of spatial and channel dimensions, and maintains equal size and resolution throughout the network. In contrast, however, the ConvMixer uses only standard convolutions to achieve the mixing steps. Despite its simplicity, we show that the ConvMixer outperforms the ViT, MLP-Mixer, and some of their variants for similar parameter counts and data set sizes, in addition to outperforming classical vision models such as the ResNet. Our code is available at https://github.com/locuslab/convmixer.","url_abs":"https://arxiv.org/abs/2201.09792v1","url_pdf":"https://arxiv.org/pdf/2201.09792v1.pdf","source":{"archive":"pwc-archive (Hugging Face), CC BY-SA 4.0","snapshot":"2025-07-28","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","row_kind":"abstracts"},"code_links":[{"paper_slug":"patches-are-all-you-need-1","repo_url":"https://github.com/locuslab/convmixer","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":0,"framework":"pytorch","reach":null},{"paper_slug":"patches-are-all-you-need-1","repo_url":"https://github.com/tmp-iclr/convmixer","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":0,"framework":"pytorch","reach":{"status":"ok","spdx":"MIT"}},{"paper_slug":"patches-are-all-you-need-1","repo_url":"https://github.com/Westlake-AI/openmixup","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":null},{"paper_slug":"patches-are-all-you-need-1","repo_url":"https://github.com/brohrer/sharpened-cosine-similarity","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"jax","reach":{"status":"ok","spdx":"MIT"}},{"paper_slug":"patches-are-all-you-need-1","repo_url":"https://github.com/osiriszjq/impulse_init","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":null},{"paper_slug":"patches-are-all-you-need-1","repo_url":"https://github.com/BR-IDL/PaddleViT/tree/develop/image_classification","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":0,"framework":"paddle","reach":null},{"paper_slug":"patches-are-all-you-need-1","repo_url":"https://github.com/DarshanDeshpande/jax-models","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":0,"framework":"jax","reach":null},{"paper_slug":"patches-are-all-you-need-1","repo_url":"https://github.com/Rishit-dagli/ConvMixer-torch2tf","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":0,"framework":"pytorch","reach":{"status":"ok","spdx":"Apache-2.0"}},{"paper_slug":"patches-are-all-you-need-1","repo_url":"https://github.com/labmlai/annotated_deep_learning_paper_implementations","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":0,"framework":"pytorch","reach":null},{"paper_slug":"patches-are-all-you-need-1","repo_url":"https://github.com/martinsbruveris/tensorflow-image-models","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":0,"framework":"tf","reach":null},{"paper_slug":"patches-are-all-you-need-1","repo_url":"https://github.com/mindspore-courses/External-Attention-MindSpore/blob/main/model/backbone/ConvMixer.py","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":0,"framework":"mindspore","reach":null},{"paper_slug":"patches-are-all-you-need-1","repo_url":"https://gitlab.com/birder/birder","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":0,"framework":"pytorch","reach":null}],"tasks":[{"task_slug":"all","task_name":"All"},{"task_slug":"image-classification","task_name":"Image Classification"}],"methods":[{"method_slug":"1x1-convolution","method_name":"1x1 Convolution"},{"method_slug":"absolute-position-encodings","method_name":"Absolute Position Encodings"},{"method_slug":"adam","method_name":"Adam"},{"method_slug":"attention","method_name":"Attention"},{"method_slug":"average-pooling","method_name":"Average Pooling"},{"method_slug":"bpe","method_name":"BPE"},{"method_slug":"batch-normalization","method_name":"Batch Normalization"},{"method_slug":"bottleneck-residual-block","method_name":"Bottleneck Residual Block"},{"method_slug":"convolution","method_name":"Convolution"},{"method_slug":"dense-connections","method_name":"Dense Connections"},{"method_slug":"dropout","method_name":"Dropout"},{"method_slug":"global-average-pooling","method_name":"Global Average Pooling"},{"method_slug":"kaiming-initialization","method_name":"Kaiming Initialization"},{"method_slug":"label-smoothing","method_name":"Label Smoothing"},{"method_slug":"layer-normalization","method_name":"Layer Normalization"},{"method_slug":"linear-layer","method_name":"Linear Layer"},{"method_slug":"mlp-mixer","method_name":"MLP-Mixer"},{"method_slug":"max-pooling","method_name":"Max Pooling"},{"method_slug":"multi-head-attention","method_name":"Multi-Head Attention"},{"method_slug":"position-wise-feed-forward-layer","method_name":"Position-Wise Feed-Forward Layer"},{"method_slug":"relu","method_name":"ReLU"},{"method_slug":"residual-block","method_name":"Residual Block"},{"method_slug":"residual-connection","method_name":"Residual Connection"},{"method_slug":"softmax","method_name":"Softmax"},{"method_slug":"transformer","method_name":"Transformer"},{"method_slug":"vision-transformer","method_name":"Vision Transformer"}],"datasets_introduced":[],"methods_introduced":[],"results":[{"leaderboard":"/sota/image-classification-on-cifar-10","task":"Image Classification","dataset":"CIFAR-10","model":"ConvMixer-256/16","rank_in_archive_order":101,"of":265,"metrics":{"Percentage correct":"96.74"},"uses_additional_data":false},{"leaderboard":"/sota/image-classification-on-cifar-10","task":"Image Classification","dataset":"CIFAR-10","model":"ConvMixer-256/8","rank_in_archive_order":123,"of":265,"metrics":{"Percentage correct":"96.03"},"uses_additional_data":false},{"leaderboard":"/sota/image-classification-on-imagenet","task":"Image Classification","dataset":"ImageNet","model":"ConvMixer-1536/20","rank_in_archive_order":566,"of":1060,"metrics":{"Number of params":"51.6M","Top 1 Accuracy":"82.20"},"uses_additional_data":false}],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=2201.09792","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2201.09792"}},"developers":"https://syntology.ai/developers","read_at":"2026-09-24T18:15:14+00:00","read_at_is":"when the build read Syntology's graph, not when any sample ran","claim":"Per-sample execution status on synthesized fixtures; not a correctness claim about the paper. Samples come from repositories linked to the paper, official or community; repo_kind says which.","repos":[{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/Westlake-AI/openmixup","reach":null},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/Rishit-dagli/ConvMixer-torch2tf","reach":{"status":"ok","spdx":"Apache-2.0"}},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/martinsbruveris/tensorflow-image-models","reach":null},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://gitlab.com/birder/birder","reach":null},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/mindspore-courses/External-Attention-MindSpore/blob/main/model/backbone/ConvMixer.py","reach":null},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/tmp-iclr/convmixer","reach":{"status":"ok","spdx":"MIT"}},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/osiriszjq/impulse_init","reach":null},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/DarshanDeshpande/jax-models","reach":null},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/labmlai/annotated_deep_learning_paper_implementations","reach":null},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/BR-IDL/PaddleViT/tree/develop/image_classification","reach":null},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/brohrer/sharpened-cosine-similarity","reach":{"status":"ok","spdx":"MIT"}},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/locuslab/convmixer","reach":null}],"summary":{"ran_honours":5,"ran_draft_wrong":1,"ran":2},"by_repo_kind":{"official":{"samples":6,"ran":6,"repositories":2},"listed":{"samples":2,"ran":2,"repositories":1}},"repo_kind_vocabulary":{"official":"The archive marks this repository official for the paper","named_in_paper":"The archive records that the paper mentions this repository; it is not marked official","listed":"In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper","found_in_text":"Syntology found this repository in the paper's own text; whether it is the authors' implementation is not asserted","community":"Not in the archive's code links for this paper; a community repository Syntology harvested"},"n_pointer_only_for_licence":0,"samples":[{"code_sha256_prefix":"410bffb8a07b52e3","entry":"count_params","repo":"tmp-iclr/convmixer","repo_kind":"official","path":"pytorch-image-models/benchmark.py","file_url":"https://github.com/tmp-iclr/convmixer/blob/HEAD/pytorch-image-models/benchmark.py","link_basis":"harvester_set","language":"python","status":"ran_honours","verification_level":2,"contract_check":"HONOURS","metamorphic_tier":"well_formed","behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"410bffb8a07b52e3"}},{"code_sha256_prefix":"a7690d61376264fc","entry":"ConvMixer","repo":"locuslab/convmixer","repo_kind":"official","path":"convmixer.py","file_url":"https://github.com/locuslab/convmixer/blob/HEAD/convmixer.py","link_basis":"first_harvest_node","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"OUTPUT_MISDECLARED","metamorphic_tier":"deterministic","behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"a7690d61376264fc"}},{"code_sha256_prefix":"0440e95034d883bd","entry":"SpatialConv2d_Linear_init","repo":"osiriszjq/impulse_init","repo_kind":"listed","path":"convmixer.py","file_url":"https://github.com/osiriszjq/impulse_init/blob/HEAD/convmixer.py","link_basis":"first_harvest_node","language":"python","status":"ran_honours","verification_level":1,"contract_check":"HONOURS","metamorphic_tier":"well_formed","behaviour_fingerprint":true,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"0440e95034d883bd"}},{"code_sha256_prefix":"b04417d600247aaa","entry":"SpatialConv2d_init","repo":"osiriszjq/impulse_init","repo_kind":"listed","path":"convmixer.py","file_url":"https://github.com/osiriszjq/impulse_init/blob/HEAD/convmixer.py","link_basis":"first_harvest_node","language":"python","status":"ran_honours","verification_level":1,"contract_check":"HONOURS","metamorphic_tier":"well_formed","behaviour_fingerprint":true,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"b04417d600247aaa"}},{"code_sha256_prefix":"33bca8cbc866bf64","entry":"checkpoint_metric","repo":"tmp-iclr/convmixer","repo_kind":"official","path":"pytorch-image-models/avg_checkpoints.py","file_url":"https://github.com/tmp-iclr/convmixer/blob/HEAD/pytorch-image-models/avg_checkpoints.py","link_basis":"harvester_set","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"33bca8cbc866bf64"}},{"code_sha256_prefix":"50d653ee6a59955c","entry":"cuda_timestamp","repo":"tmp-iclr/convmixer","repo_kind":"official","path":"pytorch-image-models/benchmark.py","file_url":"https://github.com/tmp-iclr/convmixer/blob/HEAD/pytorch-image-models/benchmark.py","link_basis":"harvester_set","language":"python","status":"ran_honours","verification_level":1,"contract_check":"HONOURS","metamorphic_tier":"well_formed","behaviour_fingerprint":true,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"50d653ee6a59955c"}},{"code_sha256_prefix":"5bed58ca17652913","entry":"map_mx_to_torch_model","repo":"tmp-iclr/convmixer","repo_kind":"official","path":"pytorch-image-models/convert/convert_from_mxnet.py","file_url":"https://github.com/tmp-iclr/convmixer/blob/HEAD/pytorch-image-models/convert/convert_from_mxnet.py","link_basis":"harvester_set","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"5bed58ca17652913"}},{"code_sha256_prefix":"475160c5a1a1225a","entry":"timestamp","repo":"tmp-iclr/convmixer","repo_kind":"official","path":"pytorch-image-models/benchmark.py","file_url":"https://github.com/tmp-iclr/convmixer/blob/HEAD/pytorch-image-models/benchmark.py","link_basis":"harvester_set","language":"python","status":"ran_honours","verification_level":1,"contract_check":"HONOURS","metamorphic_tier":"well_formed","behaviour_fingerprint":true,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"475160c5a1a1225a"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}