{"id":13738500,"url":"https://github.com/AlexImmer/Laplace","last_synced_at":"2025-05-08T16:34:20.322Z","repository":{"id":37807635,"uuid":"347129505","full_name":"aleximmer/Laplace","owner":"aleximmer","description":"Laplace approximations for Deep Learning.","archived":false,"fork":false,"pushed_at":"2025-04-22T09:13:07.000Z","size":48560,"stargazers_count":503,"open_issues_count":64,"forks_count":78,"subscribers_count":8,"default_branch":"main","last_synced_at":"2025-05-02T23:05:49.442Z","etag":null,"topics":["approximate-bayesian-inference","deep-learning","laplace-approximation","neural-network"],"latest_commit_sha":null,"homepage":"https://aleximmer.github.io/Laplace","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/aleximmer.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-03-12T16:31:04.000Z","updated_at":"2025-04-29T10:47:18.000Z","dependencies_parsed_at":"2024-04-02T23:28:36.101Z","dependency_job_id":"23cb44d7-bd70-404c-8c0b-c1cc9945f2b2","html_url":"https://github.com/aleximmer/Laplace","commit_stats":{"total_commits":318,"total_committers":9,"mean_commits":"35.333333333333336","dds":0.7421383647798743,"last_synced_commit":"ada1c6f9a4aa879939de52c8fa454ff27cbfe5a4"},"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aleximmer%2FLaplace","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aleximmer%2FLaplace/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aleximmer%2FLaplace/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aleximmer%2FLaplace/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aleximmer","download_url":"https://codeload.github.com/aleximmer/Laplace/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253105624,"owners_count":21855067,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["approximate-bayesian-inference","deep-learning","laplace-approximation","neural-network"],"created_at":"2024-08-03T03:02:24.171Z","updated_at":"2025-05-08T16:34:19.909Z","avatar_url":"https://github.com/aleximmer.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n \u003cimg src=\"https://raw.githubusercontent.com/AlexImmer/Laplace/main/logo/laplace_logo.png\" alt=\"Laplace\" width=\"300\"/\u003e\n\n![pytest](https://github.com/aleximmer/laplace/actions/workflows/pytest-default.yml/badge.svg)\n![lint](https://github.com/aleximmer/laplace/actions/workflows/lint-ruff.yml/badge.svg)\n![format](https://github.com/aleximmer/laplace/actions/workflows/format-ruff.yml/badge.svg)\n\n\u003cbr /\u003e\n\n[📖 Documentation \\\u0026 API reference](https://aleximmer.github.io/Laplace)\n\n\u003cbr /\u003e\n\u003c/div\u003e\n\nThe laplace package facilitates the application of Laplace approximations for entire neural networks, subnetworks of neural networks, or just their last layer.\nThe package enables posterior approximations, marginal-likelihood estimation, and various posterior predictive computations.\n\nThere is also a corresponding paper, [_Laplace Redux — Effortless Bayesian Deep Learning_](https://arxiv.org/abs/2106.14806), which introduces the library, provides an introduction to the Laplace approximation, reviews its use in deep learning, and empirically demonstrates its versatility and competitiveness. Please consider referring to the paper when using our library:\n\n```bibtex\n@inproceedings{laplace2021,\n  title={Laplace Redux--Effortless {B}ayesian Deep Learning},\n  author={Erik Daxberger and Agustinus Kristiadi and Alexander Immer\n          and Runa Eschenhagen and Matthias Bauer and Philipp Hennig},\n  booktitle={{N}eur{IPS}},\n  year={2021}\n}\n```\n\nThe [code](https://github.com/runame/laplace-redux) to reproduce the experiments in the paper is also publicly available; it provides examples of how to use our library for predictive uncertainty quantification, model selection, and continual learning.\n\n\u003e [!IMPORTANT]\n\u003e As a user, one should not expect Laplace to work automatically.\n\u003e That is, one should experiment with different Laplace's options\n\u003e (hessian_factorization, prior precision tuning method, predictive method, backend,\n\u003e etc!). Try looking at various papers that use Laplace for references on how to\n\u003e set all those options depending on the applications/problems at hand.\n\n## Installation\n\n\u003e [!IMPORTANT]\n\u003e We assume Python \u003e= 3.9 since lower versions are [(soon to be) deprecated](https://devguide.python.org/versions/).\n\u003e PyTorch version 2.0 and up is also required for full compatibility.\n\nTo install laplace with `pip`, run the following:\n\n```bash\npip install laplace-torch\n```\n\nAdditionally, if you want to use the `asdfghjkl` backend, please install it via:\n\n```bash\npip install git+https://git@github.com/wiseodd/asdl@asdfghjkl\n```\n\n## Simple usage\n\n\u003e [!TIP]\n\u003e Check out \u003chttps://aleximmer.github.io/Laplace\u003e for more usage examples\n\u003e and API reference.\n\nIn the following example, a pre-trained model is loaded,\nthen the Laplace approximation is fit to the training data\n(using a diagonal Hessian approximation over all parameters),\nand the prior precision is optimized with cross-validation `\"gridsearch\"`.\nAfter that, the resulting LA is used for prediction with\nthe `\"probit\"` predictive for classification.\n\n```python\nfrom laplace import Laplace\n\n# Pre-trained model\nmodel = load_map_model()\n\n# User-specified LA flavor\nla = Laplace(model, \"classification\",\n             subset_of_weights=\"all\",\n             hessian_structure=\"diag\")\nla.fit(train_loader)\nla.optimize_prior_precision(\n    method=\"gridsearch\",\n    pred_type=\"glm\",\n    link_approx=\"probit\",\n    val_loader=val_loader\n)\n\n# User-specified predictive approx.\npred = la(x, pred_type=\"glm\", link_approx=\"probit\")\n```\n\n## Contributing\n\nPull requests are very welcome.\nPlease follow the guidelines in \u003chttps://aleximmer.github.io/Laplace/devs_guide\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FAlexImmer%2FLaplace","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FAlexImmer%2FLaplace","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FAlexImmer%2FLaplace/lists"}