{"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/diffusion-models-for-counterfactual","title":"Diffusion Models for Counterfactual Explanations","arxiv_id":"2203.15636","date":"2022-03-29","proceeding":null,"authors":["Guillaume Jeanneret","Loïc Simon","Frédéric Jurie"],"abstract":"Counterfactual explanations have shown promising results as a post-hoc framework to make image classifiers more explainable. In this paper, we propose DiME, a method allowing the generation of counterfactual images using the recent diffusion models. By leveraging the guided generative diffusion process, our proposed methodology shows how to use the gradients of the target classifier to generate counterfactual explanations of input instances. Further, we analyze current approaches to evaluate spurious correlations and extend the evaluation measurements by proposing a new metric: Correlation Difference. Our experimental validations show that the proposed algorithm surpasses previous State-of-the-Art results on 5 out of 6 metrics on CelebA.","url_abs":"https://arxiv.org/abs/2203.15636v1","url_pdf":"https://arxiv.org/pdf/2203.15636v1.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":"diffusion-models-for-counterfactual","repo_url":"https://github.com/guillaumejs2403/DiME","is_official":1,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok","spdx":"MIT"}}],"tasks":[{"task_slug":null,"task_name":"counterfactual"}],"methods":[{"method_slug":"diffusion","method_name":"Diffusion"}],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=2203.15636","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2203.15636"}},"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/guillaumejs2403/DiME","reach":{"status":"ok","spdx":"MIT"}}],"summary":{"ran_draft_wrong":3,"ran_honours":3,"ran":5,"unverified":8},"by_repo_kind":{"official":{"samples":19,"ran":11,"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":"cfd76fd0d89574a4","entry":"approx_standard_normal_cdf","repo":"guillaumejs2403/DiME","repo_kind":"official","path":"core/losses.py","file_url":"https://github.com/guillaumejs2403/DiME/blob/HEAD/core/losses.py","link_basis":"harvester_set","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"MISDECLARED","metamorphic_tier":"invariant","behaviour_fingerprint":true,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"cfd76fd0d89574a4"}},{"code_sha256_prefix":"2ab2316ac6fdd869","entry":"betas_for_alpha_bar","repo":"guillaumejs2403/DiME","repo_kind":"official","path":"core/gaussian_diffusion.py","file_url":"https://github.com/guillaumejs2403/DiME/blob/HEAD/core/gaussian_diffusion.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":"2ab2316ac6fdd869"}},{"code_sha256_prefix":"cd33283d615fb3d7","entry":"discretized_gaussian_log_likelihood","repo":"guillaumejs2403/DiME","repo_kind":"official","path":"core/losses.py","file_url":"https://github.com/guillaumejs2403/DiME/blob/HEAD/core/losses.py","link_basis":"harvester_set","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"MISDECLARED","metamorphic_tier":"invariant","behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"cd33283d615fb3d7"}},{"code_sha256_prefix":"a086d6286a40b889","entry":"get_named_beta_schedule","repo":"guillaumejs2403/DiME","repo_kind":"official","path":"core/gaussian_diffusion.py","file_url":"https://github.com/guillaumejs2403/DiME/blob/HEAD/core/gaussian_diffusion.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":"a086d6286a40b889"}},{"code_sha256_prefix":"e41367ad14ff58fd","entry":"get_param_groups_and_shapes","repo":"guillaumejs2403/DiME","repo_kind":"official","path":"core/fp16_util.py","file_url":"https://github.com/guillaumejs2403/DiME/blob/HEAD/core/fp16_util.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":"e41367ad14ff58fd"}},{"code_sha256_prefix":"e20dd5102da3b050","entry":"make_master_params","repo":"guillaumejs2403/DiME","repo_kind":"official","path":"core/fp16_util.py","file_url":"https://github.com/guillaumejs2403/DiME/blob/HEAD/core/fp16_util.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":"e20dd5102da3b050"}},{"code_sha256_prefix":"bcd8b4acab199405","entry":"make_output_format","repo":"guillaumejs2403/DiME","repo_kind":"official","path":"core/logger.py","file_url":"https://github.com/guillaumejs2403/DiME/blob/HEAD/core/logger.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":"bcd8b4acab199405"}},{"code_sha256_prefix":"cf2798b666b231ca","entry":"normal_kl","repo":"guillaumejs2403/DiME","repo_kind":"official","path":"core/losses.py","file_url":"https://github.com/guillaumejs2403/DiME/blob/HEAD/core/losses.py","link_basis":"harvester_set","language":"python","status":"ran_honours","verification_level":1,"contract_check":"HONOURS","metamorphic_tier":"invariant","behaviour_fingerprint":true,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"cf2798b666b231ca"}},{"code_sha256_prefix":"4745538bfc32f1f9","entry":"random_crop_arr","repo":"guillaumejs2403/DiME","repo_kind":"official","path":"core/image_datasets.py","file_url":"https://github.com/guillaumejs2403/DiME/blob/HEAD/core/image_datasets.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":"4745538bfc32f1f9"}},{"code_sha256_prefix":"64fff1e30802b815","entry":"unflatten_master_params","repo":"guillaumejs2403/DiME","repo_kind":"official","path":"core/fp16_util.py","file_url":"https://github.com/guillaumejs2403/DiME/blob/HEAD/core/fp16_util.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":"64fff1e30802b815"}},{"code_sha256_prefix":"129b804760b3115f","entry":"zero_module","repo":"guillaumejs2403/DiME","repo_kind":"official","path":"core/nn.py","file_url":"https://github.com/guillaumejs2403/DiME/blob/HEAD/core/nn.py","link_basis":"harvester_set","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":"129b804760b3115f"}},{"code_sha256_prefix":"ecd0fc28815b65ae","entry":"avg_pool_nd","repo":"guillaumejs2403/DiME","repo_kind":"official","path":"core/nn.py","file_url":"https://github.com/guillaumejs2403/DiME/blob/HEAD/core/nn.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":"ecd0fc28815b65ae"}},{"code_sha256_prefix":"f8b4a29a52612a41","entry":"center_crop_arr","repo":"guillaumejs2403/DiME","repo_kind":"official","path":"core/image_datasets.py","file_url":"https://github.com/guillaumejs2403/DiME/blob/HEAD/core/image_datasets.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":"f8b4a29a52612a41"}},{"code_sha256_prefix":"0dfa1d24815f124b","entry":"compute_FVA","repo":"guillaumejs2403/DiME","repo_kind":"official","path":"compute_FVA.py","file_url":"https://github.com/guillaumejs2403/DiME/blob/HEAD/compute_FVA.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":"0dfa1d24815f124b"}},{"code_sha256_prefix":"c0768ad536c9f142","entry":"compute_LPIPS","repo":"guillaumejs2403/DiME","repo_kind":"official","path":"compute_LPIPS.py","file_url":"https://github.com/guillaumejs2403/DiME/blob/HEAD/compute_LPIPS.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":"c0768ad536c9f142"}},{"code_sha256_prefix":"a357ee5062aa2a9c","entry":"compute_MNAC","repo":"guillaumejs2403/DiME","repo_kind":"official","path":"compute_MNAC.py","file_url":"https://github.com/guillaumejs2403/DiME/blob/HEAD/compute_MNAC.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":"a357ee5062aa2a9c"}},{"code_sha256_prefix":"fe4eb545bbb728e0","entry":"conv_nd","repo":"guillaumejs2403/DiME","repo_kind":"official","path":"core/nn.py","file_url":"https://github.com/guillaumejs2403/DiME/blob/HEAD/core/nn.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":"fe4eb545bbb728e0"}},{"code_sha256_prefix":"e515a67f7f32e76d","entry":"mpi_weighted_mean","repo":"guillaumejs2403/DiME","repo_kind":"official","path":"core/logger.py","file_url":"https://github.com/guillaumejs2403/DiME/blob/HEAD/core/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":"e515a67f7f32e76d"}},{"code_sha256_prefix":"501595e0bcbace60","entry":"profile","repo":"guillaumejs2403/DiME","repo_kind":"official","path":"core/logger.py","file_url":"https://github.com/guillaumejs2403/DiME/blob/HEAD/core/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":"501595e0bcbace60"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}