{"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-classifier-is-secretly-an-energy-based-1","title":"Your Classifier is Secretly an Energy Based Model and You Should Treat it Like One","arxiv_id":"1912.03263","date":"2019-12-06","proceeding":"ICLR 2020 1","authors":["Will Grathwohl","Kuan-Chieh Wang","Jörn-Henrik Jacobsen","David Duvenaud","Mohammad Norouzi","Kevin Swersky"],"abstract":"We propose to reinterpret a standard discriminative classifier of p(y|x) as an energy based model for the joint distribution p(x,y). In this setting, the standard class probabilities can be easily computed as well as unnormalized values of p(x) and p(x|y). Within this framework, standard discriminative architectures may beused and the model can also be trained on unlabeled data. We demonstrate that energy based training of the joint distribution improves calibration, robustness, andout-of-distribution detection while also enabling our models to generate samplesrivaling the quality of recent GAN approaches. We improve upon recently proposed techniques for scaling up the training of energy based models and presentan approach which adds little overhead compared to standard classification training. Our approach is the first to achieve performance rivaling the state-of-the-artin both generative and discriminative learning within one hybrid model.","url_abs":"https://arxiv.org/abs/1912.03263v3","url_pdf":"https://arxiv.org/pdf/1912.03263v3.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-classifier-is-secretly-an-energy-based-1","repo_url":"https://github.com/wgrathwohl/JEM","is_official":1,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":null},{"paper_slug":"your-classifier-is-secretly-an-energy-based-1","repo_url":"https://github.com/dfalbel/JEM","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok","spdx":"NOASSERTION"}},{"paper_slug":"your-classifier-is-secretly-an-energy-based-1","repo_url":"https://github.com/divymurli/ML_Reprod_HybridEnergyModels","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":null},{"paper_slug":"your-classifier-is-secretly-an-energy-based-1","repo_url":"https://github.com/tohmae/pytorch-jem","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":null},{"paper_slug":"your-classifier-is-secretly-an-energy-based-1","repo_url":"https://github.com/soran-ghaderi/torchebm","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":0,"framework":"pytorch","reach":{"status":"unanswered"}}],"tasks":[],"methods":[{"method_slug":"convolution","method_name":"Convolution"}],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"syntology_url":null,"atlas_url":"https://app.syntology.ai/?focus=1912.03263","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"1912.03263"}},"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/wgrathwohl/JEM","reach":null},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/dfalbel/JEM","reach":{"status":"ok","spdx":"NOASSERTION"}},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/divymurli/ML_Reprod_HybridEnergyModels","reach":null},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/tohmae/pytorch-jem","reach":null},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/soran-ghaderi/torchebm","reach":{"status":"unanswered"}}],"summary":{"ran_honours":6,"ran_draft_wrong":4,"ran_violates":1,"unverified":2},"by_repo_kind":{"official":{"samples":7,"ran":6,"repositories":1},"listed":{"samples":6,"ran":5,"repositories":2}},"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":6,"samples":[{"code_sha256_prefix":"a28fb1100053feb0","entry":"grad_norm","repo":"wgrathwohl/JEM","repo_kind":"official","path":"train_wrn_ebm.py","file_url":"https://github.com/wgrathwohl/JEM/blob/HEAD/train_wrn_ebm.py","link_basis":"first_harvest_node","language":"python","status":"ran_honours","verification_level":2,"contract_check":"HONOURS","metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"a28fb1100053feb0"}},{"code_sha256_prefix":"474dd5d796ad2a88","entry":"LogSumExp","repo":"tohmae/pytorch-jem","repo_kind":"listed","path":"jem.py","file_url":"https://github.com/tohmae/pytorch-jem/blob/HEAD/jem.py","link_basis":"first_harvest_node","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":"474dd5d796ad2a88"}},{"code_sha256_prefix":"c5699286991b3f6a","entry":"calibration_buckets","repo":"divymurli/ML_Reprod_HybridEnergyModels","repo_kind":"listed","path":"calibration.py","file_url":"https://github.com/divymurli/ML_Reprod_HybridEnergyModels/blob/HEAD/calibration.py","link_basis":"first_harvest_node","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":"c5699286991b3f6a"}},{"code_sha256_prefix":"3a340a600f735188","entry":"correct_and_confidence","repo":"divymurli/ML_Reprod_HybridEnergyModels","repo_kind":"listed","path":"calibration.py","file_url":"https://github.com/divymurli/ML_Reprod_HybridEnergyModels/blob/HEAD/calibration.py","link_basis":"first_harvest_node","language":"python","status":"ran_honours","verification_level":1,"contract_check":"HONOURS","metamorphic_tier":"well_formed","behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"3a340a600f735188"}},{"code_sha256_prefix":"f58aff46d12bb096","entry":"expected_calibration_error","repo":"divymurli/ML_Reprod_HybridEnergyModels","repo_kind":"listed","path":"calibration.py","file_url":"https://github.com/divymurli/ML_Reprod_HybridEnergyModels/blob/HEAD/calibration.py","link_basis":"first_harvest_node","language":"python","status":"ran_violates","verification_level":1,"contract_check":"VIOLATES","metamorphic_tier":"well_formed","behaviour_fingerprint":true,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"f58aff46d12bb096"}},{"code_sha256_prefix":"8ee251be6654f2cb","entry":"grad_vals","repo":"wgrathwohl/JEM","repo_kind":"official","path":"train_wrn_ebm.py","file_url":"https://github.com/wgrathwohl/JEM/blob/HEAD/train_wrn_ebm.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":"8ee251be6654f2cb"}},{"code_sha256_prefix":"77d3d7b7c1ab83ce","entry":"init_random","repo":"wgrathwohl/JEM","repo_kind":"official","path":"train_wrn_ebm.py","file_url":"https://github.com/wgrathwohl/JEM/blob/HEAD/train_wrn_ebm.py","link_basis":"first_harvest_node","language":"python","status":"ran_honours","verification_level":1,"contract_check":"HONOURS","metamorphic_tier":"well_formed","behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"77d3d7b7c1ab83ce"}},{"code_sha256_prefix":"d9a9c0f7abb58719","entry":"init_random","repo":"wgrathwohl/JEM","repo_kind":"official","path":"eval_wrn_ebm.py","file_url":"https://github.com/wgrathwohl/JEM/blob/HEAD/eval_wrn_ebm.py","link_basis":"first_harvest_node","language":"python","status":"ran_honours","verification_level":1,"contract_check":"HONOURS","metamorphic_tier":"well_formed","behaviour_fingerprint":true,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"d9a9c0f7abb58719"}},{"code_sha256_prefix":"b689087804867dc7","entry":"jacobian","repo":"tohmae/pytorch-jem","repo_kind":"listed","path":"jem.py","file_url":"https://github.com/tohmae/pytorch-jem/blob/HEAD/jem.py","link_basis":"first_harvest_node","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"MISDECLARED","metamorphic_tier":"invariant","behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"b689087804867dc7"}},{"code_sha256_prefix":"cd015a30f1e9cb2f","entry":"remove_module_state_dict","repo":"wgrathwohl/JEM","repo_kind":"official","path":"attack_model.py","file_url":"https://github.com/wgrathwohl/JEM/blob/HEAD/attack_model.py","link_basis":"first_harvest_node","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"OUTPUT_MISDECLARED","metamorphic_tier":"deterministic","behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"cd015a30f1e9cb2f"}},{"code_sha256_prefix":"3152c073d34050ea","entry":"sample_q","repo":"wgrathwohl/JEM","repo_kind":"official","path":"eval_wrn_ebm.py","file_url":"https://github.com/wgrathwohl/JEM/blob/HEAD/eval_wrn_ebm.py","link_basis":"first_harvest_node","language":"python","status":"ran_honours","verification_level":1,"contract_check":"HONOURS","metamorphic_tier":"well_formed","behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"3152c073d34050ea"}},{"code_sha256_prefix":"302a4bc5f78a346c","entry":"sample_p_0","repo":"wgrathwohl/JEM","repo_kind":"official","path":"eval_wrn_ebm.py","file_url":"https://github.com/wgrathwohl/JEM/blob/HEAD/eval_wrn_ebm.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":"302a4bc5f78a346c"}},{"code_sha256_prefix":"d9c152564c59b4f6","entry":"sampler","repo":"tohmae/pytorch-jem","repo_kind":"listed","path":"jem.py","file_url":"https://github.com/tohmae/pytorch-jem/blob/HEAD/jem.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":"d9c152564c59b4f6"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}