{"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/demystifying-local-vision-transformer-sparse","title":"On the Connection between Local Attention and Dynamic Depth-wise Convolution","arxiv_id":"2106.04263","date":"2021-06-08","proceeding":"ICLR 2022 4","authors":["Qi Han","Zejia Fan","Qi Dai","Lei Sun","Ming-Ming Cheng","Jiaying Liu","Jingdong Wang"],"abstract":"Vision Transformer (ViT) attains state-of-the-art performance in visual recognition, and the variant, Local Vision Transformer, makes further improvements. The major component in Local Vision Transformer, local attention, performs the attention separately over small local windows. We rephrase local attention as a channel-wise locally-connected layer and analyze it from two network regularization manners, sparse connectivity and weight sharing, as well as weight computation. Sparse connectivity: there is no connection across channels, and each position is connected to the positions within a small local window. Weight sharing: the connection weights for one position are shared across channels or within each group of channels. Dynamic weight: the connection weights are dynamically predicted according to each image instance. We point out that local attention resembles depth-wise convolution and its dynamic version in sparse connectivity. The main difference lies in weight sharing - depth-wise convolution shares connection weights (kernel weights) across spatial positions. We empirically observe that the models based on depth-wise convolution and the dynamic variant with lower computation complexity perform on-par with or sometimes slightly better than Swin Transformer, an instance of Local Vision Transformer, for ImageNet classification, COCO object detection and ADE semantic segmentation. These observations suggest that Local Vision Transformer takes advantage of two regularization forms and dynamic weight to increase the network capacity. Code is available at https://github.com/Atten4Vis/DemystifyLocalViT.","url_abs":"https://arxiv.org/abs/2106.04263v5","url_pdf":"https://arxiv.org/pdf/2106.04263v5.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":"demystifying-local-vision-transformer-sparse","repo_url":"https://github.com/atten4vis/demystifylocalvit","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok","spdx":"MIT"}}],"tasks":[{"task_slug":"object-detection","task_name":"Object Detection"},{"task_slug":null,"task_name":"Position"},{"task_slug":"semantic-segmentation","task_name":"Semantic Segmentation"},{"task_slug":"object-detection-1","task_name":"object-detection"}],"methods":[{"method_slug":"absolute-position-encodings","method_name":"Absolute Position Encodings"},{"method_slug":"adam","method_name":"Adam"},{"method_slug":"attention","method_name":"Attention"},{"method_slug":"bpe","method_name":"BPE"},{"method_slug":"convolution","method_name":"Convolution"},{"method_slug":"dense-connections","method_name":"Dense Connections"},{"method_slug":"dropout","method_name":"Dropout"},{"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":"multi-head-attention","method_name":"Multi-Head Attention"},{"method_slug":"position-wise-feed-forward-layer","method_name":"Position-Wise Feed-Forward Layer"},{"method_slug":"residual-connection","method_name":"Residual Connection"},{"method_slug":"softmax","method_name":"Softmax"},{"method_slug":"stochastic-depth","method_name":"Stochastic Depth"},{"method_slug":"swin-transformer","method_name":"Swin Transformer"},{"method_slug":"transformer","method_name":"Transformer"},{"method_slug":"vision-transformer","method_name":"Vision Transformer"}],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=2106.04263","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2106.04263"}},"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":"deterministic:regex_extraction","url":"https://github.com/Atten4Vis/DemystifyLocalViT","reach":{"status":"ok","spdx":"MIT"}},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/atten4vis/demystifylocalvit","reach":{"status":"ok","spdx":"MIT"}}],"summary":{"ran_violates":1,"ran":5,"ran_honours":1,"unverified":9},"by_repo_kind":{"official":{"samples":16,"ran":7,"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":"c5acf386fe00c470","entry":"GET_BLOCKS","repo":"Atten4Vis/DemystifyLocalViT","repo_kind":"official","path":"models/idynamic.py","file_url":"https://github.com/Atten4Vis/DemystifyLocalViT/blob/HEAD/models/idynamic.py","link_basis":"harvester_set","language":"python","status":"ran_violates","verification_level":1,"contract_check":"VIOLATES","metamorphic_tier":"well_formed","behaviour_fingerprint":true,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"c5acf386fe00c470"}},{"code_sha256_prefix":"e35a4b2e4114b1a5","entry":"build_optimizer","repo":"Atten4Vis/DemystifyLocalViT","repo_kind":"official","path":"optimizer.py","file_url":"https://github.com/Atten4Vis/DemystifyLocalViT/blob/HEAD/optimizer.py","link_basis":"harvester_set","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"e35a4b2e4114b1a5"}},{"code_sha256_prefix":"88d68650d669bb11","entry":"get_final_iter","repo":"Atten4Vis/DemystifyLocalViT","repo_kind":"official","path":"downstreams/segmentation/.dev/gather_models.py","file_url":"https://github.com/Atten4Vis/DemystifyLocalViT/blob/HEAD/downstreams/segmentation/.dev/gather_models.py","link_basis":"harvester_set","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"88d68650d669bb11"}},{"code_sha256_prefix":"2268355e37eebb82","entry":"get_final_results","repo":"Atten4Vis/DemystifyLocalViT","repo_kind":"official","path":"downstreams/detection/.dev_scripts/gather_models.py","file_url":"https://github.com/Atten4Vis/DemystifyLocalViT/blob/HEAD/downstreams/detection/.dev_scripts/gather_models.py","link_basis":"harvester_set","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"2268355e37eebb82"}},{"code_sha256_prefix":"eec1e7cba51d5e8e","entry":"get_grad_norm","repo":"Atten4Vis/DemystifyLocalViT","repo_kind":"official","path":"utils.py","file_url":"https://github.com/Atten4Vis/DemystifyLocalViT/blob/HEAD/utils.py","link_basis":"harvester_set","language":"python","status":"ran_honours","verification_level":1,"contract_check":"HONOURS","metamorphic_tier":"well_formed","behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"eec1e7cba51d5e8e"}},{"code_sha256_prefix":"e76a491553cf9fcf","entry":"process_checkpoint","repo":"Atten4Vis/DemystifyLocalViT","repo_kind":"official","path":"downstreams/detection/.dev_scripts/gather_models.py","file_url":"https://github.com/Atten4Vis/DemystifyLocalViT/blob/HEAD/downstreams/detection/.dev_scripts/gather_models.py","link_basis":"harvester_set","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"e76a491553cf9fcf"}},{"code_sha256_prefix":"b33222a09fc93bec","entry":"set_weight_decay","repo":"Atten4Vis/DemystifyLocalViT","repo_kind":"official","path":"optimizer.py","file_url":"https://github.com/Atten4Vis/DemystifyLocalViT/blob/HEAD/optimizer.py","link_basis":"harvester_set","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"b33222a09fc93bec"}},{"code_sha256_prefix":"1e624f979ea53ae4","entry":"Dtype","repo":"Atten4Vis/DemystifyLocalViT","repo_kind":"official","path":"models/idynamic.py","file_url":"https://github.com/Atten4Vis/DemystifyLocalViT/blob/HEAD/models/idynamic.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"1e624f979ea53ae4"}},{"code_sha256_prefix":"0c32459bef92ff8c","entry":"auto_resume_helper","repo":"Atten4Vis/DemystifyLocalViT","repo_kind":"official","path":"utils.py","file_url":"https://github.com/Atten4Vis/DemystifyLocalViT/blob/HEAD/utils.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"0c32459bef92ff8c"}},{"code_sha256_prefix":"dd74736c6244d64b","entry":"build_model","repo":"Atten4Vis/DemystifyLocalViT","repo_kind":"official","path":"models/build.py","file_url":"https://github.com/Atten4Vis/DemystifyLocalViT/blob/HEAD/models/build.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"dd74736c6244d64b"}},{"code_sha256_prefix":"c02cc4e0b5720211","entry":"build_scheduler","repo":"Atten4Vis/DemystifyLocalViT","repo_kind":"official","path":"lr_scheduler.py","file_url":"https://github.com/Atten4Vis/DemystifyLocalViT/blob/HEAD/lr_scheduler.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"c02cc4e0b5720211"}},{"code_sha256_prefix":"b0a5beb34716d5a6","entry":"check_keywords_in_name","repo":"Atten4Vis/DemystifyLocalViT","repo_kind":"official","path":"optimizer.py","file_url":"https://github.com/Atten4Vis/DemystifyLocalViT/blob/HEAD/optimizer.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"b0a5beb34716d5a6"}},{"code_sha256_prefix":"80450600f7f09b0a","entry":"create_logger","repo":"Atten4Vis/DemystifyLocalViT","repo_kind":"official","path":"logger.py","file_url":"https://github.com/Atten4Vis/DemystifyLocalViT/blob/HEAD/logger.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"80450600f7f09b0a"}},{"code_sha256_prefix":"c32302734842a753","entry":"get_config","repo":"Atten4Vis/DemystifyLocalViT","repo_kind":"official","path":"config.py","file_url":"https://github.com/Atten4Vis/DemystifyLocalViT/blob/HEAD/config.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"c32302734842a753"}},{"code_sha256_prefix":"6c10c287d59a984c","entry":"get_final_results","repo":"Atten4Vis/DemystifyLocalViT","repo_kind":"official","path":"downstreams/segmentation/.dev/gather_models.py","file_url":"https://github.com/Atten4Vis/DemystifyLocalViT/blob/HEAD/downstreams/segmentation/.dev/gather_models.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"6c10c287d59a984c"}},{"code_sha256_prefix":"d690bbafcc136a37","entry":"load_checkpoint","repo":"Atten4Vis/DemystifyLocalViT","repo_kind":"official","path":"utils.py","file_url":"https://github.com/Atten4Vis/DemystifyLocalViT/blob/HEAD/utils.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"d690bbafcc136a37"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}