{"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/learning-a-sparse-transformer-network-for","title":"Learning A Sparse Transformer Network for Effective Image Deraining","arxiv_id":"2303.11950","date":"2023-03-21","proceeding":"CVPR 2023 1","authors":["Xiang Chen","Hao Li","Mingqiang Li","Jinshan Pan"],"abstract":"Transformers-based methods have achieved significant performance in image deraining as they can model the non-local information which is vital for high-quality image reconstruction. In this paper, we find that most existing Transformers usually use all similarities of the tokens from the query-key pairs for the feature aggregation. However, if the tokens from the query are different from those of the key, the self-attention values estimated from these tokens also involve in feature aggregation, which accordingly interferes with the clear image restoration. To overcome this problem, we propose an effective DeRaining network, Sparse Transformer (DRSformer) that can adaptively keep the most useful self-attention values for feature aggregation so that the aggregated features better facilitate high-quality image reconstruction. Specifically, we develop a learnable top-k selection operator to adaptively retain the most crucial attention scores from the keys for each query for better feature aggregation. Simultaneously, as the naive feed-forward network in Transformers does not model the multi-scale information that is important for latent clear image restoration, we develop an effective mixed-scale feed-forward network to generate better features for image deraining. To learn an enriched set of hybrid features, which combines local context from CNN operators, we equip our model with mixture of experts feature compensator to present a cooperation refinement deraining scheme. Extensive experimental results on the commonly used benchmarks demonstrate that the proposed method achieves favorable performance against state-of-the-art approaches. The source code and trained models are available at https://github.com/cschenxiang/DRSformer.","url_abs":"https://arxiv.org/abs/2303.11950v1","url_pdf":"https://arxiv.org/pdf/2303.11950v1.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":"learning-a-sparse-transformer-network-for","repo_url":"https://github.com/cschenxiang/drsformer","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":1,"framework":"pytorch","reach":null}],"tasks":[{"task_slug":"image-reconstruction","task_name":"Image Reconstruction"},{"task_slug":"image-restoration","task_name":"Image Restoration"},{"task_slug":"mixture-of-experts","task_name":"Mixture-of-Experts"},{"task_slug":"rain-removal","task_name":"Rain Removal"}],"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":"attention-dropout","method_name":"Attention Dropout"},{"method_slug":"bpe","method_name":"BPE"},{"method_slug":"cosine-annealing","method_name":"Cosine Annealing"},{"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":"linear-warmup-with-cosine-annealing","method_name":"Linear Warmup With Cosine Annealing"},{"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":"sparse-transformer","method_name":"Sparse Transformer"},{"method_slug":"transformer","method_name":"Transformer"},{"method_slug":"weight-decay","method_name":"Weight Decay"}],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"syntology_url":"https://syntology.ai/paper/2303.11950","atlas_url":"https://app.syntology.ai/?focus=2303.11950","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2303.11950"}},"developers":"https://syntology.ai/developers","read_at":"2026-09-25T09:33:49+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/cschenxiang/drsformer","reach":null}],"summary":{"ran":8,"unverified":3},"by_repo_kind":{"official":{"samples":11,"ran":8,"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":11,"samples":[{"code_sha256_prefix":"50006ae54761f527","entry":"Attention","repo":"cschenxiang/drsformer","repo_kind":"official","path":"basicsr/models/archs/DRSformer_arch.py","file_url":"https://github.com/cschenxiang/drsformer/blob/HEAD/basicsr/models/archs/DRSformer_arch.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":"deterministic","behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"50006ae54761f527"}},{"code_sha256_prefix":"e2ef9c678fe3aa44","entry":"DilConv","repo":"cschenxiang/drsformer","repo_kind":"official","path":"basicsr/models/archs/DRSformer_arch.py","file_url":"https://github.com/cschenxiang/drsformer/blob/HEAD/basicsr/models/archs/DRSformer_arch.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":"deterministic","behaviour_fingerprint":true,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"e2ef9c678fe3aa44"}},{"code_sha256_prefix":"5cfc302c76ee3b91","entry":"FeedForward","repo":"cschenxiang/drsformer","repo_kind":"official","path":"basicsr/models/archs/DRSformer_arch.py","file_url":"https://github.com/cschenxiang/drsformer/blob/HEAD/basicsr/models/archs/DRSformer_arch.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":"deterministic","behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"5cfc302c76ee3b91"}},{"code_sha256_prefix":"9ead1340d2ad5517","entry":"OALayer","repo":"cschenxiang/drsformer","repo_kind":"official","path":"basicsr/models/archs/DRSformer_arch.py","file_url":"https://github.com/cschenxiang/drsformer/blob/HEAD/basicsr/models/archs/DRSformer_arch.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":"deterministic","behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"9ead1340d2ad5517"}},{"code_sha256_prefix":"fffe92151028a264","entry":"OperationLayer","repo":"cschenxiang/drsformer","repo_kind":"official","path":"basicsr/models/archs/DRSformer_arch.py","file_url":"https://github.com/cschenxiang/drsformer/blob/HEAD/basicsr/models/archs/DRSformer_arch.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":"deterministic","behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"fffe92151028a264"}},{"code_sha256_prefix":"b7c2f09ec69779da","entry":"ReLUConv","repo":"cschenxiang/drsformer","repo_kind":"official","path":"basicsr/models/archs/DRSformer_arch.py","file_url":"https://github.com/cschenxiang/drsformer/blob/HEAD/basicsr/models/archs/DRSformer_arch.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"b7c2f09ec69779da"}},{"code_sha256_prefix":"7a5365697cfc3402","entry":"SepConv","repo":"cschenxiang/drsformer","repo_kind":"official","path":"basicsr/models/archs/DRSformer_arch.py","file_url":"https://github.com/cschenxiang/drsformer/blob/HEAD/basicsr/models/archs/DRSformer_arch.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":"deterministic","behaviour_fingerprint":true,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"7a5365697cfc3402"}},{"code_sha256_prefix":"1b2bc200cd85b70e","entry":"subnet","repo":"cschenxiang/drsformer","repo_kind":"official","path":"basicsr/models/archs/DRSformer_arch.py","file_url":"https://github.com/cschenxiang/drsformer/blob/HEAD/basicsr/models/archs/DRSformer_arch.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":"deterministic","behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"1b2bc200cd85b70e"}},{"code_sha256_prefix":"ae686cb3b8b5b1f9","entry":"DRSformer","repo":"cschenxiang/drsformer","repo_kind":"official","path":"basicsr/models/archs/DRSformer_arch.py","file_url":"https://github.com/cschenxiang/drsformer/blob/HEAD/basicsr/models/archs/DRSformer_arch.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"ae686cb3b8b5b1f9"}},{"code_sha256_prefix":"7b56e8b085b9944e","entry":"GroupOLs","repo":"cschenxiang/drsformer","repo_kind":"official","path":"basicsr/models/archs/DRSformer_arch.py","file_url":"https://github.com/cschenxiang/drsformer/blob/HEAD/basicsr/models/archs/DRSformer_arch.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"7b56e8b085b9944e"}},{"code_sha256_prefix":"724b7c5be1319bc9","entry":"TransformerBlock","repo":"cschenxiang/drsformer","repo_kind":"official","path":"basicsr/models/archs/DRSformer_arch.py","file_url":"https://github.com/cschenxiang/drsformer/blob/HEAD/basicsr/models/archs/DRSformer_arch.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"724b7c5be1319bc9"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}