{"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/enhance-the-visual-representation-via","title":"Enhance the Visual Representation via Discrete Adversarial Training","arxiv_id":"2209.07735","date":"2022-09-16","proceeding":null,"authors":["Xiaofeng Mao","Yuefeng Chen","Ranjie Duan","Yao Zhu","Gege Qi","Shaokai Ye","Xiaodan Li","Rong Zhang","Hui Xue"],"abstract":"Adversarial Training (AT), which is commonly accepted as one of the most effective approaches defending against adversarial examples, can largely harm the standard performance, thus has limited usefulness on industrial-scale production and applications. Surprisingly, this phenomenon is totally opposite in Natural Language Processing (NLP) task, where AT can even benefit for generalization. We notice the merit of AT in NLP tasks could derive from the discrete and symbolic input space. For borrowing the advantage from NLP-style AT, we propose Discrete Adversarial Training (DAT). DAT leverages VQGAN to reform the image data to discrete text-like inputs, i.e. visual words. Then it minimizes the maximal risk on such discrete images with symbolic adversarial perturbations. We further give an explanation from the perspective of distribution to demonstrate the effectiveness of DAT. As a plug-and-play technique for enhancing the visual representation, DAT achieves significant improvement on multiple tasks including image classification, object detection and self-supervised learning. Especially, the model pre-trained with Masked Auto-Encoding (MAE) and fine-tuned by our DAT without extra data can get 31.40 mCE on ImageNet-C and 32.77% top-1 accuracy on Stylized-ImageNet, building the new state-of-the-art. The code will be available at https://github.com/alibaba/easyrobust.","url_abs":"https://arxiv.org/abs/2209.07735v1","url_pdf":"https://arxiv.org/pdf/2209.07735v1.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":"enhance-the-visual-representation-via","repo_url":"https://github.com/alibaba/easyrobust/tree/main/examples/imageclassification/imagenet/dat","is_official":1,"mentioned_in_paper":0,"mentioned_in_github":0,"framework":"pytorch","reach":null}],"tasks":[{"task_slug":"domain-generalization","task_name":"Domain Generalization"},{"task_slug":"image-classification","task_name":"Image Classification"},{"task_slug":"object-detection","task_name":"Object Detection"},{"task_slug":"self-supervised-learning","task_name":"Self-Supervised Learning"},{"task_slug":"image-classification","task_name":"image-classification"}],"methods":[],"datasets_introduced":[],"methods_introduced":[],"results":[{"leaderboard":"/sota/domain-generalization-on-imagenet-a","task":"Domain Generalization","dataset":"ImageNet-A","model":"MAE+DAT (ViT-H)","rank_in_archive_order":11,"of":39,"metrics":{"Top-1 accuracy %":"68.92"},"uses_additional_data":false},{"leaderboard":"/sota/domain-generalization-on-imagenet-c","task":"Domain Generalization","dataset":"ImageNet-C","model":"MAE+DAT (ViT-H)","rank_in_archive_order":3,"of":47,"metrics":{"Number of params":"632M","mean Corruption Error (mCE)":"31.4"},"uses_additional_data":false},{"leaderboard":"/sota/domain-generalization-on-imagenet-r","task":"Domain Generalization","dataset":"ImageNet-R","model":"MAE+DAT (ViT-H)","rank_in_archive_order":12,"of":39,"metrics":{"Top-1 Error Rate":"34.39"},"uses_additional_data":false},{"leaderboard":"/sota/domain-generalization-on-imagenet-sketch","task":"Domain Generalization","dataset":"ImageNet-Sketch","model":"MAE+DAT (ViT-H)","rank_in_archive_order":11,"of":20,"metrics":{"Top-1 accuracy":"50.03"},"uses_additional_data":false},{"leaderboard":"/sota/domain-generalization-on-stylized-imagenet","task":"Domain Generalization","dataset":"Stylized-ImageNet","model":"MAE+DAT (ViT-H)","rank_in_archive_order":1,"of":3,"metrics":{"Top 1 Accuracy":"32.77"},"uses_additional_data":false},{"leaderboard":"/sota/image-classification-on-imagenet","task":"Image Classification","dataset":"ImageNet","model":"MAE+DAT (ViT-H)","rank_in_archive_order":110,"of":1060,"metrics":{"Top 1 Accuracy":"87.02%"},"uses_additional_data":false}],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=2209.07735","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2209.07735"}},"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/alibaba/easyrobust","reach":null},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/alibaba/easyrobust/tree/main/examples/imageclassification/imagenet/dat","reach":null}],"summary":{"ran":5,"ran_draft_wrong":3,"ran_honours":2,"unverified":1},"by_repo_kind":{"official":{"samples":10,"ran":9,"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":1,"samples":[{"code_sha256_prefix":"5f368427f2d48e50","entry":"Diffeo","repo":"alibaba/easyrobust","repo_kind":"official","path":"easyrobust/modules/prime.py","file_url":"https://github.com/alibaba/easyrobust/blob/HEAD/easyrobust/modules/prime.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"5f368427f2d48e50"}},{"code_sha256_prefix":"5b26e951879d385b","entry":"PRIMEAugModule","repo":"alibaba/easyrobust","repo_kind":"official","path":"easyrobust/modules/prime.py","file_url":"https://github.com/alibaba/easyrobust/blob/HEAD/easyrobust/modules/prime.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"5b26e951879d385b"}},{"code_sha256_prefix":"03f527454201d6e7","entry":"RandomFilter","repo":"alibaba/easyrobust","repo_kind":"official","path":"easyrobust/modules/prime.py","file_url":"https://github.com/alibaba/easyrobust/blob/HEAD/easyrobust/modules/prime.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"03f527454201d6e7"}},{"code_sha256_prefix":"b79407df1fc77419","entry":"RandomSmoothColor","repo":"alibaba/easyrobust","repo_kind":"official","path":"easyrobust/modules/prime.py","file_url":"https://github.com/alibaba/easyrobust/blob/HEAD/easyrobust/modules/prime.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"b79407df1fc77419"}},{"code_sha256_prefix":"4e905fbdfa4e05cc","entry":"TransformLayer","repo":"alibaba/easyrobust","repo_kind":"official","path":"easyrobust/modules/prime.py","file_url":"https://github.com/alibaba/easyrobust/blob/HEAD/easyrobust/modules/prime.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"4e905fbdfa4e05cc"}},{"code_sha256_prefix":"49c4bfde12e638af","entry":"deform","repo":"alibaba/easyrobust","repo_kind":"official","path":"easyrobust/modules/prime.py","file_url":"https://github.com/alibaba/easyrobust/blob/HEAD/easyrobust/modules/prime.py","link_basis":"first_harvest_node","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"MISDECLARED","metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"49c4bfde12e638af"}},{"code_sha256_prefix":"f9efe607667fba03","entry":"remap","repo":"alibaba/easyrobust","repo_kind":"official","path":"easyrobust/modules/prime.py","file_url":"https://github.com/alibaba/easyrobust/blob/HEAD/easyrobust/modules/prime.py","link_basis":"first_harvest_node","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"MISDECLARED","metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"f9efe607667fba03"}},{"code_sha256_prefix":"21e1843fa11d415e","entry":"scalar_field","repo":"alibaba/easyrobust","repo_kind":"official","path":"easyrobust/modules/prime.py","file_url":"https://github.com/alibaba/easyrobust/blob/HEAD/easyrobust/modules/prime.py","link_basis":"first_harvest_node","language":"python","status":"ran_honours","verification_level":1,"contract_check":"HONOURS","metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"21e1843fa11d415e"}},{"code_sha256_prefix":"e57e011fe9cb8615","entry":"scalar_field_modes","repo":null,"repo_kind":null,"path":null,"file_url":null,"link_basis":"identical_code_first_harvested_elsewhere","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"OUTPUT_MISDECLARED","metamorphic_tier":"deterministic","behaviour_fingerprint":false,"licence":null,"inline_ok":false,"mcp_get_code":{"code_sha256":"e57e011fe9cb8615"}},{"code_sha256_prefix":"f8159fb1492781a3","entry":"temperature_range","repo":"alibaba/easyrobust","repo_kind":"official","path":"easyrobust/modules/prime.py","file_url":"https://github.com/alibaba/easyrobust/blob/HEAD/easyrobust/modules/prime.py","link_basis":"first_harvest_node","language":"python","status":"ran_honours","verification_level":1,"contract_check":"HONOURS","metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"f8159fb1492781a3"}},{"code_sha256_prefix":"7796b07f8bd25227","entry":"PRIMEAugmentation32","repo":"alibaba/easyrobust","repo_kind":"official","path":"easyrobust/modules/prime.py","file_url":"https://github.com/alibaba/easyrobust/blob/HEAD/easyrobust/modules/prime.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"7796b07f8bd25227"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}