{"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/stochastic-gradient-hamiltonian-monte-carlo","title":"Stochastic Gradient Hamiltonian Monte Carlo","arxiv_id":"1402.4102","date":"2014-02-17","proceeding":null,"authors":["Tianqi Chen","Emily B. Fox","Carlos Guestrin"],"abstract":"Hamiltonian Monte Carlo (HMC) sampling methods provide a mechanism for\ndefining distant proposals with high acceptance probabilities in a\nMetropolis-Hastings framework, enabling more efficient exploration of the state\nspace than standard random-walk proposals. The popularity of such methods has\ngrown significantly in recent years. However, a limitation of HMC methods is\nthe required gradient computation for simulation of the Hamiltonian dynamical\nsystem-such computation is infeasible in problems involving a large sample size\nor streaming data. Instead, we must rely on a noisy gradient estimate computed\nfrom a subset of the data. In this paper, we explore the properties of such a\nstochastic gradient HMC approach. Surprisingly, the natural implementation of\nthe stochastic approximation can be arbitrarily bad. To address this problem we\nintroduce a variant that uses second-order Langevin dynamics with a friction\nterm that counteracts the effects of the noisy gradient, maintaining the\ndesired target distribution as the invariant distribution. Results on simulated\ndata validate our theory. We also provide an application of our methods to a\nclassification task using neural networks and to online Bayesian matrix\nfactorization.","url_abs":"http://arxiv.org/abs/1402.4102v2","url_pdf":"http://arxiv.org/pdf/1402.4102v2.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":"stochastic-gradient-hamiltonian-monte-carlo","repo_url":"https://github.com/JavierAntoran/Bayesian-Neural-Networks","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok","spdx":"MIT"}},{"paper_slug":"stochastic-gradient-hamiltonian-monte-carlo","repo_url":"https://github.com/TurboFreeze/sghmc","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"none","reach":{"status":"ok"}},{"paper_slug":"stochastic-gradient-hamiltonian-monte-carlo","repo_url":"https://github.com/hsvgbkhgbv/TACTHMC","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"unanswered"}},{"paper_slug":"stochastic-gradient-hamiltonian-monte-carlo","repo_url":"https://github.com/hsvgbkhgbv/Thermostat-assisted-continuously-tempered-Hamiltonian-Monte-Carlo-for-Bayesian-learning","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok"}},{"paper_slug":"stochastic-gradient-hamiltonian-monte-carlo","repo_url":"https://github.com/mohammeddonia/RSCAM-GradNoise","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"none","reach":{"status":"ok"}},{"paper_slug":"stochastic-gradient-hamiltonian-monte-carlo","repo_url":"https://github.com/MindSpore-scientific-2/code-3/tree/main/stochastic-attention-head-removal-a-simple","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":0,"framework":"mindspore","reach":null},{"paper_slug":"stochastic-gradient-hamiltonian-monte-carlo","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":[{"task_slug":"efficient-exploration","task_name":"Efficient Exploration"},{"task_slug":"friction","task_name":"Friction"}],"methods":[],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"syntology_url":"https://syntology.ai/paper/1402.4102","atlas_url":"https://app.syntology.ai/?focus=1402.4102","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"1402.4102"}},"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/TurboFreeze/sghmc","reach":{"status":"ok"}},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/hsvgbkhgbv/TACTHMC","reach":{"status":"unanswered"}},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/hsvgbkhgbv/Thermostat-assisted-continuously-tempered-Hamiltonian-Monte-Carlo-for-Bayesian-learning","reach":{"status":"ok"}},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/soran-ghaderi/torchebm","reach":{"status":"unanswered"}},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/MindSpore-scientific-2/code-3/tree/main/stochastic-attention-head-removal-a-simple","reach":null},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/JavierAntoran/Bayesian-Neural-Networks","reach":{"status":"ok","spdx":"MIT"}},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/mohammeddonia/RSCAM-GradNoise","reach":{"status":"ok"}}],"summary":{"unverified":6},"by_repo_kind":{"listed":{"samples":6,"ran":0,"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":"f258e196f4cf2a5a","entry":"KLD_cost","repo":"JavierAntoran/Bayesian-Neural-Networks","repo_kind":"listed","path":"src/Bayes_By_Backprop_Local_Reparametrization/model.py","file_url":"https://github.com/JavierAntoran/Bayesian-Neural-Networks/blob/HEAD/src/Bayes_By_Backprop_Local_Reparametrization/model.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":"f258e196f4cf2a5a"}},{"code_sha256_prefix":"053b71fed2950dd4","entry":"get_num_batches","repo":"JavierAntoran/Bayesian-Neural-Networks","repo_kind":"listed","path":"src/utils.py","file_url":"https://github.com/JavierAntoran/Bayesian-Neural-Networks/blob/HEAD/src/utils.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":"053b71fed2950dd4"}},{"code_sha256_prefix":"6e777e925f25d081","entry":"humansize","repo":"JavierAntoran/Bayesian-Neural-Networks","repo_kind":"listed","path":"src/utils.py","file_url":"https://github.com/JavierAntoran/Bayesian-Neural-Networks/blob/HEAD/src/utils.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":"6e777e925f25d081"}},{"code_sha256_prefix":"d34bfdbf711662e1","entry":"isotropic_gauss_loglike","repo":"JavierAntoran/Bayesian-Neural-Networks","repo_kind":"listed","path":"src/priors.py","file_url":"https://github.com/JavierAntoran/Bayesian-Neural-Networks/blob/HEAD/src/priors.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":"d34bfdbf711662e1"}},{"code_sha256_prefix":"8bf151fd95debad7","entry":"load_object","repo":"JavierAntoran/Bayesian-Neural-Networks","repo_kind":"listed","path":"src/utils.py","file_url":"https://github.com/JavierAntoran/Bayesian-Neural-Networks/blob/HEAD/src/utils.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":"8bf151fd95debad7"}},{"code_sha256_prefix":"6abcd469960b413d","entry":"sample_weights","repo":"JavierAntoran/Bayesian-Neural-Networks","repo_kind":"listed","path":"src/Bayes_By_Backprop/model.py","file_url":"https://github.com/JavierAntoran/Bayesian-Neural-Networks/blob/HEAD/src/Bayes_By_Backprop/model.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":"6abcd469960b413d"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}