{"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/your-diffusion-model-is-secretly-a-noise","title":"Your Diffusion Model is Secretly a Noise Classifier and Benefits from Contrastive Training","arxiv_id":"2407.08946","date":"2024-07-12","proceeding":null,"authors":["Yunshu Wu","Yingtao Luo","Xianghao Kong","Evangelos E. Papalexakis","Greg Ver Steeg"],"abstract":"Diffusion models learn to denoise data and the trained denoiser is then used to generate new samples from the data distribution. In this paper, we revisit the diffusion sampling process and identify a fundamental cause of sample quality degradation: the denoiser is poorly estimated in regions that are far Outside Of the training Distribution (OOD), and the sampling process inevitably evaluates in these OOD regions. This can become problematic for all sampling methods, especially when we move to parallel sampling which requires us to initialize and update the entire sample trajectory of dynamics in parallel, leading to many OOD evaluations. To address this problem, we introduce a new self-supervised training objective that differentiates the levels of noise added to a sample, leading to improved OOD denoising performance. The approach is based on our observation that diffusion models implicitly define a log-likelihood ratio that distinguishes distributions with different amounts of noise, and this expression depends on denoiser performance outside the standard training distribution. We show by diverse experiments that the proposed contrastive diffusion training is effective for both sequential and parallel settings, and it improves the performance and speed of parallel samplers significantly.","url_abs":"https://arxiv.org/abs/2407.08946v2","url_pdf":"https://arxiv.org/pdf/2407.08946v2.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":"your-diffusion-model-is-secretly-a-noise","repo_url":"https://github.com/yunshuwu/ContrastiveDiffusionLoss","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":0,"framework":"pytorch","reach":{"status":"ok"}}],"tasks":[{"task_slug":"denoising","task_name":"Denoising"}],"methods":[{"method_slug":"diffusion","method_name":"Diffusion"},{"method_slug":"speed","method_name":"SPEED"}],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"syntology_url":"https://syntology.ai/paper/2407.08946","atlas_url":"https://app.syntology.ai/?focus=2407.08946","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2407.08946"}},"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/yunshuwu/ContrastiveDiffusionLoss","reach":{"status":"ok"}}],"summary":{"ran_draft_wrong":5,"ran":6,"ran_fixture":1,"unverified":7},"by_repo_kind":{"official":{"samples":19,"ran":12,"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":19,"samples":[{"code_sha256_prefix":"c3a6b977022957cb","entry":"Normalize","repo":"yunshuwu/ContrastiveDiffusionLoss","repo_kind":"official","path":"network_arch/ema_ddpm_unet.py","file_url":"https://github.com/yunshuwu/ContrastiveDiffusionLoss/blob/HEAD/network_arch/ema_ddpm_unet.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":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"c3a6b977022957cb"}},{"code_sha256_prefix":"674eca7b9e1b6439","entry":"format_time","repo":"yunshuwu/ContrastiveDiffusionLoss","repo_kind":"official","path":"dnnlib/util.py","file_url":"https://github.com/yunshuwu/ContrastiveDiffusionLoss/blob/HEAD/dnnlib/util.py","link_basis":"harvester_set","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"OUTPUT_MISDECLARED","metamorphic_tier":"deterministic","behaviour_fingerprint":true,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"674eca7b9e1b6439"}},{"code_sha256_prefix":"32af001972a0699f","entry":"format_time_brief","repo":"yunshuwu/ContrastiveDiffusionLoss","repo_kind":"official","path":"dnnlib/util.py","file_url":"https://github.com/yunshuwu/ContrastiveDiffusionLoss/blob/HEAD/dnnlib/util.py","link_basis":"harvester_set","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"OUTPUT_MISDECLARED","metamorphic_tier":"deterministic","behaviour_fingerprint":true,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"32af001972a0699f"}},{"code_sha256_prefix":"d3d30f649b83beae","entry":"get_ckpt_path","repo":"yunshuwu/ContrastiveDiffusionLoss","repo_kind":"official","path":"ckpt_util.py","file_url":"https://github.com/yunshuwu/ContrastiveDiffusionLoss/blob/HEAD/ckpt_util.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"d3d30f649b83beae"}},{"code_sha256_prefix":"4a8b7eda64bac8b1","entry":"get_ddpm_schedule","repo":"yunshuwu/ContrastiveDiffusionLoss","repo_kind":"official","path":"utils.py","file_url":"https://github.com/yunshuwu/ContrastiveDiffusionLoss/blob/HEAD/utils.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"4a8b7eda64bac8b1"}},{"code_sha256_prefix":"cb49209c125de1b4","entry":"get_timestep_embedding","repo":"yunshuwu/ContrastiveDiffusionLoss","repo_kind":"official","path":"network_arch/ema_ddpm_unet.py","file_url":"https://github.com/yunshuwu/ContrastiveDiffusionLoss/blob/HEAD/network_arch/ema_ddpm_unet.py","link_basis":"harvester_set","language":"python","status":"ran_fixture","verification_level":1,"contract_check":"RAISES","metamorphic_tier":"invariant","behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"cb49209c125de1b4"}},{"code_sha256_prefix":"4e2ebe7dd3aa1d85","entry":"logistic_integrate","repo":"yunshuwu/ContrastiveDiffusionLoss","repo_kind":"official","path":"utils.py","file_url":"https://github.com/yunshuwu/ContrastiveDiffusionLoss/blob/HEAD/utils.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"4e2ebe7dd3aa1d85"}},{"code_sha256_prefix":"3dfb3d007332417e","entry":"logsnr_uniform_selector","repo":"yunshuwu/ContrastiveDiffusionLoss","repo_kind":"official","path":"utils.py","file_url":"https://github.com/yunshuwu/ContrastiveDiffusionLoss/blob/HEAD/utils.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"3dfb3d007332417e"}},{"code_sha256_prefix":"07d90bd6ae1be7db","entry":"md5_hash","repo":"yunshuwu/ContrastiveDiffusionLoss","repo_kind":"official","path":"ckpt_util.py","file_url":"https://github.com/yunshuwu/ContrastiveDiffusionLoss/blob/HEAD/ckpt_util.py","link_basis":"harvester_set","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"OUTPUT_MISDECLARED","metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"07d90bd6ae1be7db"}},{"code_sha256_prefix":"3137073275f8c21a","entry":"nonlinearity","repo":"yunshuwu/ContrastiveDiffusionLoss","repo_kind":"official","path":"network_arch/ema_ddpm_unet.py","file_url":"https://github.com/yunshuwu/ContrastiveDiffusionLoss/blob/HEAD/network_arch/ema_ddpm_unet.py","link_basis":"harvester_set","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"MISDECLARED","metamorphic_tier":"invariant","behaviour_fingerprint":true,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"3137073275f8c21a"}},{"code_sha256_prefix":"54a1664f139dc5e9","entry":"prepreation_karras","repo":"yunshuwu/ContrastiveDiffusionLoss","repo_kind":"official","path":"diffusion_models/seq_samplers.py","file_url":"https://github.com/yunshuwu/ContrastiveDiffusionLoss/blob/HEAD/diffusion_models/seq_samplers.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"54a1664f139dc5e9"}},{"code_sha256_prefix":"26e89fe4f7a4342f","entry":"sample_fn_ddpm","repo":"yunshuwu/ContrastiveDiffusionLoss","repo_kind":"official","path":"diffusion_models/seq_samplers.py","file_url":"https://github.com/yunshuwu/ContrastiveDiffusionLoss/blob/HEAD/diffusion_models/seq_samplers.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"26e89fe4f7a4342f"}},{"code_sha256_prefix":"9d31d2c4cd16bb2d","entry":"ask_yes_no","repo":"yunshuwu/ContrastiveDiffusionLoss","repo_kind":"official","path":"dnnlib/util.py","file_url":"https://github.com/yunshuwu/ContrastiveDiffusionLoss/blob/HEAD/dnnlib/util.py","link_basis":"harvester_set","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":"9d31d2c4cd16bb2d"}},{"code_sha256_prefix":"a09285676a1aca60","entry":"parasam_forward","repo":"yunshuwu/ContrastiveDiffusionLoss","repo_kind":"official","path":"diffusion_models/_para_samplers.py","file_url":"https://github.com/yunshuwu/ContrastiveDiffusionLoss/blob/HEAD/diffusion_models/_para_samplers.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":"a09285676a1aca60"}},{"code_sha256_prefix":"52b472cd0e155aa1","entry":"parasam_forward","repo":"yunshuwu/ContrastiveDiffusionLoss","repo_kind":"official","path":"diffusion_models/para_samplers.py","file_url":"https://github.com/yunshuwu/ContrastiveDiffusionLoss/blob/HEAD/diffusion_models/para_samplers.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":"52b472cd0e155aa1"}},{"code_sha256_prefix":"bb3944742c2d662a","entry":"parasam_forward","repo":"yunshuwu/ContrastiveDiffusionLoss","repo_kind":"official","path":"diffusion_models/para_samplers_visualization.py","file_url":"https://github.com/yunshuwu/ContrastiveDiffusionLoss/blob/HEAD/diffusion_models/para_samplers_visualization.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":"bb3944742c2d662a"}},{"code_sha256_prefix":"709391ce90e2c2c5","entry":"parasam_forward_mmd","repo":"yunshuwu/ContrastiveDiffusionLoss","repo_kind":"official","path":"diffusion_models/para_samplers.py","file_url":"https://github.com/yunshuwu/ContrastiveDiffusionLoss/blob/HEAD/diffusion_models/para_samplers.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":"709391ce90e2c2c5"}},{"code_sha256_prefix":"b9df12d4cc178f7b","entry":"parasam_forward_mmd","repo":"yunshuwu/ContrastiveDiffusionLoss","repo_kind":"official","path":"diffusion_models/para_samplers_visualization.py","file_url":"https://github.com/yunshuwu/ContrastiveDiffusionLoss/blob/HEAD/diffusion_models/para_samplers_visualization.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":"b9df12d4cc178f7b"}},{"code_sha256_prefix":"501d3dd1ed3f35a2","entry":"sample_fn_karras","repo":"yunshuwu/ContrastiveDiffusionLoss","repo_kind":"official","path":"diffusion_models/seq_samplers.py","file_url":"https://github.com/yunshuwu/ContrastiveDiffusionLoss/blob/HEAD/diffusion_models/seq_samplers.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":"501d3dd1ed3f35a2"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}