lightning-uq-box

Lightning-UQ-Box: Uncertainty Quantification for Neural Networks with PyTorch and Lightning

https://github.com/lightning-uq-box/lightning-uq-box

Science Score: 54.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
    1 of 9 committers (11.1%) from academic institutions
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (16.6%) to scientific vocabulary

Keywords

bayesian-neural-networks conformal-prediction deep-learning earth-observation predictive-uncertainty pytorch pytorch-lightning uncertainty-quantification

Keywords from Contributors

polynomial mesh interpretability sequences projection interactive optim hacking network-simulation
Last synced: 6 months ago · JSON representation ·

Repository

Lightning-UQ-Box: Uncertainty Quantification for Neural Networks with PyTorch and Lightning

Basic Info
Statistics
  • Stars: 195
  • Watchers: 7
  • Forks: 22
  • Open Issues: 23
  • Releases: 2
Topics
bayesian-neural-networks conformal-prediction deep-learning earth-observation predictive-uncertainty pytorch pytorch-lightning uncertainty-quantification
Created about 3 years ago · Last pushed 6 months ago
Metadata Files
Readme License Citation

README.md

Lightning-UQ-Box logo

docs style tests codecov license PyTorch Lightning

lightning-uq-box

The lightning-uq-box is a PyTorch library that provides various Uncertainty Quantification (UQ) techniques for modern neural network architectures.

We hope to provide the starting point for a collaborative open source effort to make it easier for practitioners to include UQ in their workflows and remove possible barriers of entry. Additionally, we hope this can be a pathway to more easily compare methods across UQ frameworks and potentially enhance the development of new UQ methods for neural networks.

The project is currently under active development, but we nevertheless hope for early feedback, feature requests, or contributions. Please check the Contribution Guide for further information.

The goal of this library is threefold:

  1. Provide implementations for a variety of Uncertainty Quantification methods for Modern Deep Neural Networks that work with a range of neural network architectures and have different theoretical underpinnings
  2. Make it easy to compare UQ methods on a given dataset
  3. Focus on reproducibility of experiments with minimum boiler plate code and standardized evaluation protocols

To this end, each UQ-Method is essentially just a Lightning Module which can be used with a Lightning Data Module and a Trainer to execute training, evaluation and inference for your desired task. The library also utilizes the Lightning Command Line Interface (CLI) for better reproducibility of experiments and setting up experiments at scale.

Theory Guide

For a comprehensive document that provides more mathematical details for each method and generally forms the basis of our implementations, please see the Theory Guide. As a living document, we plan to update it as the library encompasses more methods. If you have any questions, or find typos or errors, feel free to open an issue.

Installation

The recommended way to install the latest released version is via pip,

console pip install lightning-uq-box

For the latest development version you can run,

console pip install git+https://github.com/lightning-uq-box/lightning-uq-box.git

The package is also available for installation via conda or spack. You can find instructions in the documention

UQ-Methods

In the tables that follow below, you can see what UQ-Method/Task combination is currently supported by the Lightning-UQ-Box via these indicators:

  • ✅ supported
  • ❌ not designed for this task
  • ⏳ in progress

The implemented methods are of course not exhaustive, as the number of new methods keeps increasing. For an overview of methods that we are tracking or are planning to support, take a look at this issue.

Classification of UQ-Methods

The following sections aims to give an overview of different UQ-Methods by grouping them according to some commonalities. We agree that there could be other groupings as well and welcome suggestions to improve this overview. We also follow this grouping for the API documentation in the hopes to make navigation easier.

Single Forward Pass Methods

| UQ-Method | Regression | Classification | Segmentation | Pixel Wise Regression | |-----------------------------------------------|:----------:|:--------------:|:------------:|:---------------------:| | Quantile Regression (QR) | ✅ | ❌ | ❌ | ✅ | | Deep Evidential (DE) | ✅ | ⏳ | ⏳ | ✅ | | Mean Variance Estimation (MVE) | ✅ | ❌ | ❌ | ✅ | | ZigZag | ✅ | ✅ | ❌ | ❌ | | Mixture Density Networks | ✅ | ❌ | ❌ | ⏳ |

Approximate Bayesian Methods

| UQ-Method | Regression | Classification | Segmentation | Pixel Wise Regression | |-----------------------------------------------|:----------:|:--------------:|:------------:|:---------------------:| | Bayesian Neural Network VI ELBO (BNNVIELBO) | ✅ | ✅ | ✅ | ⏳ | | Bayesian Neural Network VI (BNN_VI) | ✅ | ⏳ | ⏳ | ⏳ | | Deep Kernel Learning (DKL) | ✅ | ✅ | ❌ | ❌ | | Deterministic Uncertainty Estimation (DUE) | ✅ | ✅ | ❌ | ❌ | | Laplace Approximation (Laplace) | ✅ | ✅ | ❌ | ❌ | | Monte Carlo Dropout (MC-Dropout) | ✅ | ✅ | ✅ | ✅ | | Stochastic Gradient Langevin Dynamics (SGLD) | ✅ | ✅ | ⏳ | ⏳ | | Spectral Normalized Gaussian Process (SNGP) | ✅ | ✅ | ❌ | ❌ | | Stochastic Weight Averaging Gaussian (SWAG) | ✅ | ✅ | ✅ | ✅ | | Variational Bayesian Last Layer (VBLL) | ✅ | ✅ | ❌ | ❌ | | Deep Ensemble | ✅ | ✅ | ✅ | ✅ | | Masked Ensemble | ✅ | ✅ | ⏳ | ⏳ | | Density Uncertainty Layer | ✅ | ✅ | ❌ | ❌ |

Generative Models

| UQ-Method | Regression | Classification | Segmentation | Pixel Wise Regression | |-----------------------------------------------|:----------:|:--------------:|:------------:|:---------------------:| | Classification And Regression Diffusion (CARD)| ✅ | ✅ | ❌ | ❌ | | Probabilistic UNet | ❌ | ❌ | ✅ | ❌ | | Hierarchical Probabilistic UNet | ❌ | ❌ | ✅ | ❌ | | Variational Auto-Encoder (VAE) | ❌ | ❌ | ❌ | ✅ |

Post-Hoc methods

| UQ-Method | Regression | Classification | Segmentation | Pixel Wise Regression | |-----------------------------------------------|:----------:|:--------------:|:------------:|:---------------------:| | Test Time Augmentation (TTA) | ✅ | ✅ | ⏳ | ⏳ | | Temperature Scaling | ❌ | ✅ | ⏳ | ❌ | | Conformal Quantile Regression (Conformal QR) | ✅ | ❌ | ❌ | ⏳ | | Regularized Adaptive Prediction Sets (RAPS) | ❌ | ✅ | ❌ | ❌ | | Image to Image Conformal | ❌ | ❌ | ❌ | ✅ |

Tutorials

We try to provide many different tutorials so that users can get a better understanding of implemented methods and get a feel for how they apply to different problems. Head over to the tutorials page to get started. These tutorials can also be launched in google colab if you navigate to the rocket icon at the top of a tutorial page.

Documentation

We aim to provide an extensive documentation on all included UQ-methods that provide some theoretical background, as well as tutorials that illustrate these methods on toy datasets.

Citation

If you use this software in your work, please cite our paper:

bibtex @article{JMLR:v26:24-2110, author = {Nils Lehmann and Nina Maria Gottschling and Jakob Gawlikowski and Adam J. Stewart and Stefan Depeweg and Eric Nalisnick}, title = {Lightning UQ Box: Uncertainty Quantification for Neural Networks}, journal = {Journal of Machine Learning Research}, year = {2025}, volume = {26}, number = {54}, pages = {1--7}, url = {http://jmlr.org/papers/v26/24-2110.html} }

Citation (CITATION.cff)

# https://github.com/citation-file-format/citation-file-format/blob/main/schema-guide.md
# Can be validated using `cffconvert --validate`
authors:
  - family-names: 'Lehmann'
    given-names: 'Nils'
  - family-names: 'Gottschling'
    given-names: 'Nina M.'
  - family-names: 'Gawlikowski'
    given-names: 'Jakob'
  - family-names: 'Stewart'
    given-names: 'Adam J.'
  - family-names: 'Depeweg'
    given-names: 'Stefan'
  - family-names: 'Nalisnick'
    given-names: 'Eric'
cff-version: '1.2.0'
message: 'If you use this software, please cite it using the metadata from this file.'
preferred-citation:
  authors:
    - family-names: 'Lehmann'
      given-names: 'Nils'
    - family-names: 'Gottschling'
      given-names: 'Nina M.'
    - family-names: 'Gawlikowski'
      given-names: 'Jakob'
    - family-names: 'Stewart'
      given-names: 'Adam J.'
    - family-names: 'Depeweg'
      given-names: 'Stefan'
    - family-names: 'Nalisnick'
      given-names: 'Eric'
  journal: 'Journal of Machine Learning Research'
  volume: '26'
  number: '24'
  pages: '1-11'
  url: 'https://jmlr.org/papers/v26/24-2110.html'
  title: 'Lightning UQ Box: Uncertainty Quantification for Neural Networks'
  type: 'article'
  year: 2024
title: 'Lightning UQ Box: Uncertainty Quantification for Neural Networks'

GitHub Events

Total
  • Create event: 145
  • Release event: 1
  • Issues event: 11
  • Watch event: 58
  • Delete event: 145
  • Issue comment event: 56
  • Push event: 174
  • Pull request review comment event: 17
  • Pull request review event: 110
  • Pull request event: 329
  • Fork event: 7
Last Year
  • Create event: 145
  • Release event: 1
  • Issues event: 11
  • Watch event: 58
  • Delete event: 145
  • Issue comment event: 56
  • Push event: 174
  • Pull request review comment event: 17
  • Pull request review event: 110
  • Pull request event: 329
  • Fork event: 7

Committers

Last synced: 9 months ago

All Time
  • Total Commits: 359
  • Total Committers: 9
  • Avg Commits per committer: 39.889
  • Development Distribution Score (DDS): 0.448
Past Year
  • Commits: 190
  • Committers: 5
  • Avg Commits per committer: 38.0
  • Development Distribution Score (DDS): 0.311
Top Committers
Name Email Commits
Nils Lehmann 3****h 198
dependabot[bot] 4****] 131
Adam J. Stewart a****6@g****m 15
nm19000 1****0 8
Steve Schmerler g****t@e****m 2
Gawlikowski, Jakob j****i@d****e 2
Vytautas Jancauskas u****o@g****m 1
Sebastian Starke 3****b 1
Brian Wu 7****4 1
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 6 months ago

All Time
  • Total issues: 20
  • Total pull requests: 415
  • Average time to close issues: 27 days
  • Average time to close pull requests: 8 days
  • Total issue authors: 6
  • Total pull request authors: 9
  • Average comments per issue: 2.5
  • Average comments per pull request: 0.55
  • Merged pull requests: 340
  • Bot issues: 0
  • Bot pull requests: 257
Past Year
  • Issues: 8
  • Pull requests: 293
  • Average time to close issues: 18 days
  • Average time to close pull requests: 2 days
  • Issue authors: 3
  • Pull request authors: 3
  • Average comments per issue: 1.5
  • Average comments per pull request: 0.24
  • Merged pull requests: 246
  • Bot issues: 0
  • Bot pull requests: 257
Top Authors
Issue Authors
  • dependabot[bot] (8)
  • elcorto (6)
  • nilsleh (6)
  • wrkhard (3)
  • adamjstewart (3)
  • codingS3b (2)
  • qqaazz800624 (1)
  • wccai (1)
Pull Request Authors
  • dependabot[bot] (310)
  • nilsleh (195)
  • adamjstewart (32)
  • codingS3b (4)
  • elcorto (4)
  • orbitfold (3)
  • nm19000 (2)
  • qqaazz800624 (2)
  • stde (1)
Top Labels
Issue Labels
dependencies (8) python (7) github_actions (1) documentation (1)
Pull Request Labels
dependencies (309) python (284) github_actions (23)

Packages

  • Total packages: 2
  • Total downloads:
    • pypi 511 last-month
  • Total dependent packages: 0
    (may contain duplicates)
  • Total dependent repositories: 0
    (may contain duplicates)
  • Total versions: 2
  • Total maintainers: 2
spack.io: py-lightning-uq-box

Lighning-UQ-Box: A toolbox for uncertainty quantification in deep learning.

  • Versions: 0
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Dependent repos count: 0.0%
Average: 28.3%
Dependent packages count: 56.6%
Maintainers (2)
Last synced: 6 months ago
pypi.org: lightning-uq-box

Lightning-UQ-Box: A toolbox for uncertainty quantification in deep learning

  • Documentation: https://lightning-uq-box.readthedocs.io/
  • License: Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright 2024 lightning-uq-box Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
  • Latest release: 0.2.0
    published about 1 year ago
  • Versions: 2
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 511 Last month
Rankings
Dependent packages count: 9.7%
Average: 36.9%
Dependent repos count: 64.1%
Maintainers (2)
Last synced: 7 months ago

Dependencies

.github/workflows/style.yaml actions
  • actions/cache v3.2.6 composite
  • actions/checkout v3.3.0 composite
  • actions/setup-python v4.5.0 composite
.github/workflows/tests.yaml actions
  • actions/checkout v2 composite
  • actions/setup-python v2 composite
  • codecov/codecov-action v3.1.1 composite
pyproject.toml pypi
  • einops >=0.3
  • gpytorch >=1.11
  • laplace-torch >=0.1a2
  • lightning >=2.1.1
  • matplotlib >=3.3.3
  • numpy >=1.19.3
  • pandas >=1.1.3
  • scikit-learn >=1.3
  • torch >=2.0
  • torchmetrics >=1.2
  • torchvision >=0.16.1
  • uncertainty-toolbox >=0.1.1
requirements/docs.txt pypi
  • ipywidgets ==8.0.6
  • myst-parser ==2.0
  • nbsphinx ==0.9.1
  • sphinx-togglebutton ==0.3.2
  • sphinx_book_theme ==1.0.1
requirements/requirements.txt pypi
  • gpytorch ==1.11
  • laplace-torch ==0.1a2
  • lightning ==2.1.2
  • pandas ==1.5.3
  • scikit-learn ==1.3.2
  • setuptools ==67.6.0
  • torch ==2.1.1
  • torchmetrics ==1.2
  • torchvision ==0.16.1
  • uncertainty-toolbox ==0.1.1
requirements/style.txt pypi
  • black ==23.1.0
  • flake8 ==6.0.0
  • isort ==5.11.4
  • pydocstyle ==6.1.1
  • pyupgrade ==3.3.1
requirements/tests.txt pypi
  • hydra-core ==1.3.2 test
  • jsonargparse ==4.27.1 test
  • mypy ==1.0.1 test
  • nbmake ==1.4.1 test
  • omegaconf ==2.3.0 test
  • pytest ==7.2.1 test
  • pytest-cov ==4.0.0 test
  • segmentation-models-pytorch ==0.3.3 test
  • timm ==0.9.2 test