API Reference#
Routines#
Routines are the main building blocks of the library. They define the framework in which models are trained and evaluated, and make it easy to compute the metrics crucial for uncertainty estimation across the supported tasks: classification, regression, segmentation, and pixelwise regression. See the Evaluating Models page for a full breakdown of the metrics computed by each routine.
Classification#
Routine for training & testing on classification tasks. |
Segmentation#
Routine for training & testing on segmentation tasks. |
Regression#
Routine for training & testing on regression tasks. |
Pixelwise Regression#
Routine for training & testing on pixel regression tasks. |
Layers#
Ensemble layers#
Packed-Ensembles-style Linear layer. |
|
Packed-Ensembles-style Conv2d layer. |
|
Packed-Ensembles-style MultiheadAttention layer. |
|
Packed-Ensembles-style LayerNorm layer. |
|
Packed-Ensembles-style TransformerEncoderLayer (made up of self-attention followed by a feedforward network). |
|
Packed-Ensembles-style TransformerDecoderLayer (made up of self-attention, multi-head attention, and feedforward network). |
|
BatchEnsemble-style Linear layer. |
|
BatchEnsemble-style Conv2d layer. |
|
Masksembles-style Linear layer. |
|
Masksembles-style Conv2d layer. |
Bayesian layers#
Bayesian Linear Layer with Mixture of Normals prior and Normal posterior. |
|
Bayesian Conv1d Layer with Mixture of Normals prior and Normal posterior. |
|
Bayesian Conv2d Layer with Gaussian Mixture prior and Normal posterior. |
|
Bayesian Conv3d Layer with Gaussian mixture prior and Normal posterior. |
|
LPBNN-style linear layer. |
|
LPBNN-style 2D convolutional layer. |
Density layers#
Linear Layers#
Base Linear layer for any distribution with loc and scale parameters. |
|
Base Linear layer for any distribution with loc and scale parameters. |
|
Base Linear layer for any distribution with loc and scale parameters. |
|
Student's T-Distribution Linear Density Layer. |
|
Normal-Inverse-Gamma Distribution Linear Density Layer. |
Convolution Layers#
Base Convolutional layer for any distribution with loc and scale parameters. |
|
Base Convolutional layer for any distribution with loc and scale parameters. |
|
Base Convolutional layer for any distribution with loc and scale parameters. |
|
Student's T-Distribution Convolutional Density Layer. |
|
Normal-Inverse-Gamma Distribution Convolutional Density Layer. |
Model Backbones#
ResNet#
BatchEnsemble of ResNet. |
|
LPBNN version of ResNet. |
|
Masksembles of ResNet. |
|
MIMO ResNet. |
|
Packed-Ensembles of ResNet. |
|
ResNet model. |
WideResNet#
BatchEnsemble of Wide-ResNet-28x10. |
|
Masksembles of Wide-ResNet-28x10. |
|
MIMO of Wide-ResNet-28x10. |
|
Packed-Ensembles of Wide-ResNet-28x10. |
|
Wide-ResNet-28x10 from Wide Residual Networks. |
InceptionTime#
BatchEnsemble of InceptionTime. |
|
Bayesian InceptionTime. |
|
InceptionTime from InceptionTime: Finding AlexNet for Time Series Classification. |
|
MIMO InceptionTime. |
|
Packed-Ensembles of InceptionTime. |
UQ Methods#
UQ Methods encapsulate your models to enable better uncertainty estimation.
Functions#
Some methods can be directly created through functions such as the following:
BatchEnsemble wrapper for a model. |
|
Build a Deep Ensembles out of the original models. |
|
MC Dropout wrapper for a model. |
Classes#
Some methods need to be instantiated as classes such as the following:
Wrap a BatchEnsemble model to ensure correct batch replication. |
|
Ensemble of models at different points in the training trajectory. |
|
Exponential Moving Average (EMA). |
|
Stochastic Weight Averaging. |
|
Stochastic Weight Averaging Gaussian (SWAG). |
|
Zero for test-time adaptation. |
Metrics#
Classification#
Proper Scores#
Compute the Brier score. |
Computes the Negative Log-Likelihood (NLL) metric for classification tasks. |
Out-of-Distribution Detection#
Selective Classification#
Calculate The Area Under the Generalized Risk-Coverage curve (AUGRC). |
|
Calculate Area Under the Risk-Coverage curve. |
|
Provide coverage at x Risk. |
|
Provide coverage at 5% Risk. |
|
Compute the risk at a specified coverage threshold. |
|
Compute the risk at 80% coverage. |
Selective Classification with OOD#
Calculate The Area Under the Generalized Risk-Coverage curve (AUGRC). |
|
Calculate Area Under the Risk-Coverage curve. |
|
Provide coverage at x Risk. |
|
Coverage at 5% SCOD risk. |
|
Compute the risk at a specified coverage threshold. |
|
SCOD risk at 80% coverage. |
Calibration#
Computes the Adaptive Top-label Calibration Error (ACE) for classification tasks. |
|
Computes the Calibration Error for classification tasks. |
|
Smooth Expected Calibration Error (SmECE). |
|
Compute the Classwise Expected Calibration Error (ECE). |
Conformal Predictions#
Empirical coverage rate metric. |
|
Average prediction-set size — the standard efficiency metric for conformal prediction methods. |
Diversity#
Calculate the Disagreement Metric. |
|
The Shannon Entropy Metric to estimate the confidence of a single model or the mean confidence across estimators. |
|
Compute the Mutual Information Metric. |
|
Compute the Variation Ratio. |
Others#
Metric to estimate the Top-label Grouping Loss. |
Regression#
Computes the Negative Log-Likelihood (NLL) metric for classification tasks. |
|
Compute the LOG10 metric. |
|
Mean Absolute Error of the inverse predictions (iMAE). |
|
Compute the Mean Absolute Error relative to the Ground Truth (MAErel or ARErel). |
|
Compute mean squared error relative to the Ground Truth (MSErel or SRE). |
|
Mean Squared Error of the inverse predictions (iMSE). |
|
Compute the Mean Squared Logarithmic Error (MSLE). |
|
Compute The Scale-Invariant Logarithmic Loss metric. |
|
Compute the Threshold Accuracy metric, also referred to as \(\delta_1\), \(\delta_2\), or \(\delta_3\). |
Calibration#
Quantile Calibration Error for regression tasks. |
Segmentation#
Computes the Mean Intersection over Union (mIoU) score. |
|
Image-averaged binary AUROC for dense binary segmentation tasks. |
|
Image-averaged binary Average Precision for dense segmentation tasks. |
|
Image-averaged FPR@95 TPR for dense binary segmentation tasks. |
Others#
The Area Under the Sparsification Error curve (AUSE) metric to evaluate the quality of the uncertainty estimates, i.e., how much they coincide with the true errors. |
Losses#
Binary Cross Entropy with Logits Loss with label smoothing. |
|
The \(\beta\)-Negative Log-Likelihood loss (Seitzer et al., 2022). |
|
The Conflictual Loss. |
|
The Confidence Penalty loss. |
|
The Deep Evidential Classification (DEC) loss. |
|
The Deep Evidential Regression (DER) loss. |
|
Negative Log-Likelihood loss for probabilistic regression. |
|
The (negative) Evidence Lower Bound (ELBO) loss for Bayesian Neural Networks. |
|
Focal Loss for classification tasks. |
|
KL divergence loss for Bayesian Neural Networks. |
Post-Processing Methods#
Laplace approximation for post-hoc Bayesian uncertainty estimation. |
|
Monte Carlo Batch Normalization (MCBN) wrapper for 2D inputs (Teye, Azizpour & Smith, ICML 2018). |
Scaling Methods#
Temperature scaling post-processing for calibrated probabilities. |
|
Vector scaling post-processing for calibrated probabilities. |
|
Matrix scaling post-processing for calibrated probabilities. |
|
Dirichlet scaling post-processing for calibrated probabilities (Kull et al., 2019). |
|
Isotonic Regression post-processing for calibrated probabilities (Zadrozny & Elkan, 2002). |
Conformal Methods#
Abstract base class for split-conformal classification predictors. |
|
Conformal classification with Adaptive Prediction Sets (APS; Romano, Sesia & Candès, NeurIPS 2020). |
|
Conformal classification with Regularised Adaptive Prediction Sets (RAPS; Angelopoulos, Bates, Jordan & Malik, 2021). |
|
Threshold-based conformal classifier (THR; Sadinle et al., 2019). |
OOD Scores#
Abstract base class for Out-of-Distribution (OOD) criteria. |
|
OOD criterion based on the Max-Logit score (Hendrycks et al.). |
|
OOD criterion based on the free-energy score (Liu et al., NeurIPS 2020). |
|
OOD criterion based on the Maximum Softmax Probability (MSP) baseline of Hendrycks & Gimpel (ICLR 2017). |
|
OOD criterion based on entropy. |
|
OOD criterion based on mutual information (BALD). |
|
OOD criterion based on the Maximum Softmax Probability (MSP) baseline of Hendrycks & Gimpel (ICLR 2017). |
|
OOD criterion based on variation ratio. |
Datamodules#
Classification#
DataModule for CIFAR10. |
|
DataModule for CIFAR100. |
|
DataModule for the ImageNet dataset. |
|
DataModule for MNIST. |
|
DataModule for the Tiny-ImageNet dataset. |
Tabular Classification#
Tabular binary classification datamodule. |
|
Tabular binary classification datamodule. |
|
Tabular binary classification datamodule. |
|
Tabular binary classification datamodule. |
|
Tabular binary classification datamodule. |
|
Tabular binary classification datamodule. |
|
Tabular binary classification datamodule. |
|
Tabular binary classification datamodule. |
|
Tabular binary classification datamodule. |
|
Tabular binary classification datamodule. |
|
Tabular binary classification datamodule. |
|
Tabular binary classification datamodule. |
|
Tabular binary classification datamodule. |
|
Tabular binary classification datamodule. |
|
Tabular binary classification datamodule. |
|
Wine Quality datamodule. |
Regression#
UCI regression datamodule. |
Segmentation#
DataModule for the CamVid dataset. |
|
DataModule for the Cityscapes dataset. |
|
Segmentation DataModule for the MUAD dataset. |
Datasets#
Classification#
The corrupted MNIST-C Dataset. |
|
The notMNIST dataset. |
|
The corrupted CIFAR-10-C Dataset. |
|
The corrupted CIFAR-100-C Dataset. |
|
CIFAR-10H Dataset. |
|
CIFAR-10N Dataset. |
|
CIFAR-100N Dataset. |
|
Initializes the ImageNetA dataset class. |
|
Initializes the ImageNetC dataset class. |
|
Initializes the ImageNetO dataset class. |
|
Initializes the ImageNetR dataset class. |
|
Inspired by https://gist.github.com/z-a-f/b862013c0dc2b540cf96a123a6766e54. |
|
The corrupted TinyImageNet-C Dataset. |
|
OpenImage-O dataset. |
Tabular Classification#
Tabular binary classification dataset. |
|
Tabular binary classification dataset. |
|
Tabular binary classification dataset. |
|
Tabular binary classification dataset. |
|
Tabular binary classification dataset. |
|
Tabular binary classification dataset. |
|
Tabular binary classification dataset. |
|
Tabular binary classification dataset. |
|
Tabular binary classification dataset. |
|
Tabular binary classification dataset. |
|
Tabular binary classification dataset. |
|
Tabular binary classification dataset. |
|
Tabular binary classification dataset. |
|
Tabular binary classification dataset. |
|
Tabular binary classification dataset. |
|
Wine Quality classification dataset. |
Regression#
UCI regression dataset. |
Segmentation#
CamVid Dataset. |
|
Cityscapes dataset wrapper with train-ID color mapping. |
Others & Cross-Categories#
Dataset used for PixMix augmentations. |
|
Frost corruption image dataset. |
|
KITTI Depth Estimation dataset. |
|
The MUAD Dataset. |
|
NYUv2 depth dataset. |
Callbacks#
Custom Lightning callbacks for advanced checkpointing and model saving functionalities.
Save the checkpoints maximizing or minimizing a given linear form on the metric values. |
|
Keep multiple checkpoints corresponding to the best model in terms of: Accuracy, Brier-Score and Negative Log-Likelihood. |
|
Keep multiple checkpoints corresponding to the best model in terms of: Mean Squared Error, and eventually the Negative Log-Likelihood and Quantile Calibration Error. |
|
Keep multiple checkpoints corresponding to the best model in terms of: Mean Intersection over Union, Brier-Score and Negative Log-Likelihood. |