{"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/causaldiff-causality-inspired-disentanglement","title":"CausalDiff: Causality-Inspired Disentanglement via Diffusion Model for Adversarial Defense","arxiv_id":"2410.23091","date":"2024-10-30","proceeding":null,"authors":["Mingkun Zhang","Keping Bi","Wei Chen","Quanrun Chen","Jiafeng Guo","Xueqi Cheng"],"abstract":"Despite ongoing efforts to defend neural classifiers from adversarial attacks, they remain vulnerable, especially to unseen attacks. In contrast, humans are difficult to be cheated by subtle manipulations, since we make judgments only based on essential factors. Inspired by this observation, we attempt to model label generation with essential label-causative factors and incorporate label-non-causative factors to assist data generation. For an adversarial example, we aim to discriminate the perturbations as non-causative factors and make predictions only based on the label-causative factors. Concretely, we propose a casual diffusion model (CausalDiff) that adapts diffusion models for conditional data generation and disentangles the two types of casual factors by learning towards a novel casual information bottleneck objective. Empirically, CausalDiff has significantly outperformed state-of-the-art defense methods on various unseen attacks, achieving an average robustness of 86.39% (+4.01%) on CIFAR-10, 56.25% (+3.13%) on CIFAR-100, and 82.62% (+4.93%) on GTSRB (German Traffic Sign Recognition Benchmark). The code is available at https://github.com/CAS-AISafetyBasicResearchGroup/CausalDiff.","url_abs":"https://arxiv.org/abs/2410.23091v6","url_pdf":"https://arxiv.org/pdf/2410.23091v6.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":"causaldiff-causality-inspired-disentanglement","repo_url":"https://github.com/cas-aisafetybasicresearchgroup/causaldiff","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":1,"framework":"pytorch","reach":null}],"tasks":[{"task_slug":"adversarial-defense","task_name":"Adversarial Defense"},{"task_slug":"disentanglement","task_name":"Disentanglement"},{"task_slug":"traffic-sign-recognition","task_name":"Traffic Sign Recognition"}],"methods":[{"method_slug":"diffusion","method_name":"Diffusion"}],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=2410.23091","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2410.23091"}},"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/TMLResearchGroup-CAS/CausalDiff","reach":{"status":"ok","spdx":"MIT"}},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/cas-aisafetybasicresearchgroup/causaldiff","reach":null}],"summary":{"ran":2,"ran_fixture":1,"unverified":14},"by_repo_kind":{"official":{"samples":4,"ran":2,"repositories":1},"found_in_text":{"samples":13,"ran":1,"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":"f847a1b1c3b13042","entry":"BasicBlock","repo":"cas-aisafetybasicresearchgroup/causaldiff","repo_kind":"official","path":"model/unet_autoenc.py","file_url":"https://github.com/cas-aisafetybasicresearchgroup/causaldiff/blob/HEAD/model/unet_autoenc.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":"invariant","behaviour_fingerprint":true,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"f847a1b1c3b13042"}},{"code_sha256_prefix":"8990ccc3a7ed53f8","entry":"Flatten","repo":"cas-aisafetybasicresearchgroup/causaldiff","repo_kind":"official","path":"model/unet_autoenc.py","file_url":"https://github.com/cas-aisafetybasicresearchgroup/causaldiff/blob/HEAD/model/unet_autoenc.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":"invariant","behaviour_fingerprint":true,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"8990ccc3a7ed53f8"}},{"code_sha256_prefix":"39352f70cb57396e","entry":"space_timesteps","repo":"tmlresearchgroup-cas/causaldiff","repo_kind":"found_in_text","path":"diffusion/diffusion.py","file_url":"https://github.com/tmlresearchgroup-cas/causaldiff/blob/HEAD/diffusion/diffusion.py","link_basis":"first_harvest_node","language":"python","status":"ran_fixture","verification_level":1,"contract_check":"RAISES","metamorphic_tier":"deterministic","behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"39352f70cb57396e"}},{"code_sha256_prefix":"7e8b3a3ffd864e29","entry":"NetworkBlock","repo":"cas-aisafetybasicresearchgroup/causaldiff","repo_kind":"official","path":"model/unet_autoenc.py","file_url":"https://github.com/cas-aisafetybasicresearchgroup/causaldiff/blob/HEAD/model/unet_autoenc.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":"7e8b3a3ffd864e29"}},{"code_sha256_prefix":"a14e237c2789b10d","entry":"apply_conditions","repo":"TMLResearchGroup-CAS/CausalDiff","repo_kind":"found_in_text","path":"model/blocks.py","file_url":"https://github.com/TMLResearchGroup-CAS/CausalDiff/blob/HEAD/model/blocks.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":"a14e237c2789b10d"}},{"code_sha256_prefix":"235265a7a3a652fb","entry":"chunk_size","repo":"TMLResearchGroup-CAS/CausalDiff","repo_kind":"found_in_text","path":"dist_utils.py","file_url":"https://github.com/TMLResearchGroup-CAS/CausalDiff/blob/HEAD/dist_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":"235265a7a3a652fb"}},{"code_sha256_prefix":"3f55f85544860186","entry":"compute_acc","repo":"tmlresearchgroup-cas/causaldiff","repo_kind":"found_in_text","path":"run_eval.py","file_url":"https://github.com/tmlresearchgroup-cas/causaldiff/blob/HEAD/run_eval.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":"3f55f85544860186"}},{"code_sha256_prefix":"dd8d3dcf271eb1a8","entry":"compute_acc","repo":"TMLResearchGroup-CAS/CausalDiff","repo_kind":"found_in_text","path":"experiment.py","file_url":"https://github.com/TMLResearchGroup-CAS/CausalDiff/blob/HEAD/experiment.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":"dd8d3dcf271eb1a8"}},{"code_sha256_prefix":"6b0fadb6db123712","entry":"convert","repo":"TMLResearchGroup-CAS/CausalDiff","repo_kind":"found_in_text","path":"lmdb_writer.py","file_url":"https://github.com/TMLResearchGroup-CAS/CausalDiff/blob/HEAD/lmdb_writer.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":"6b0fadb6db123712"}},{"code_sha256_prefix":"2b8bea10ddab8540","entry":"d_LaCIM","repo":"cas-aisafetybasicresearchgroup/causaldiff","repo_kind":"official","path":"model/unet_autoenc.py","file_url":"https://github.com/cas-aisafetybasicresearchgroup/causaldiff/blob/HEAD/model/unet_autoenc.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":"2b8bea10ddab8540"}},{"code_sha256_prefix":"4f9b67ed1294c6a0","entry":"is_time","repo":"TMLResearchGroup-CAS/CausalDiff","repo_kind":"found_in_text","path":"experiment.py","file_url":"https://github.com/TMLResearchGroup-CAS/CausalDiff/blob/HEAD/experiment.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":"4f9b67ed1294c6a0"}},{"code_sha256_prefix":"3436fefeb3a4b49a","entry":"jsonable","repo":"TMLResearchGroup-CAS/CausalDiff","repo_kind":"found_in_text","path":"config_base.py","file_url":"https://github.com/TMLResearchGroup-CAS/CausalDiff/blob/HEAD/config_base.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":"3436fefeb3a4b49a"}},{"code_sha256_prefix":"7b0f30c49d628c72","entry":"make_transform","repo":"TMLResearchGroup-CAS/CausalDiff","repo_kind":"found_in_text","path":"dataset.py","file_url":"https://github.com/TMLResearchGroup-CAS/CausalDiff/blob/HEAD/dataset.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":"7b0f30c49d628c72"}},{"code_sha256_prefix":"9f4bd412a84d05e0","entry":"mean_nll","repo":"tmlresearchgroup-cas/causaldiff","repo_kind":"found_in_text","path":"run_eval.py","file_url":"https://github.com/tmlresearchgroup-cas/causaldiff/blob/HEAD/run_eval.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":"9f4bd412a84d05e0"}},{"code_sha256_prefix":"79dd7b45925d286c","entry":"psnr","repo":"TMLResearchGroup-CAS/CausalDiff","repo_kind":"found_in_text","path":"metrics.py","file_url":"https://github.com/TMLResearchGroup-CAS/CausalDiff/blob/HEAD/metrics.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":"79dd7b45925d286c"}},{"code_sha256_prefix":"c921df1a998cbb0f","entry":"t_sample","repo":"tmlresearchgroup-cas/causaldiff","repo_kind":"found_in_text","path":"run_eval.py","file_url":"https://github.com/tmlresearchgroup-cas/causaldiff/blob/HEAD/run_eval.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":"c921df1a998cbb0f"}},{"code_sha256_prefix":"96226a66ab62eb91","entry":"use_cached_dataset_path","repo":"TMLResearchGroup-CAS/CausalDiff","repo_kind":"found_in_text","path":"dataset_util.py","file_url":"https://github.com/TMLResearchGroup-CAS/CausalDiff/blob/HEAD/dataset_util.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":"96226a66ab62eb91"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}