API Reference¶
Routines¶
The routine are the main building blocks of the library. They define the framework in which the models are trained and evaluated. They allow for easy computation of different metrics crucial for uncertainty estimation in different contexts, namely classification, regression and segmentation.
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. |
Baselines¶
TorchUncertainty provide lightning-based models that can be easily trained and evaluated. These models inherit from the routines and are specifically designed to benchmark different methods in similar settings, here with constant architectures.
Classification¶
ResNet backbone baseline for classification providing support for various versions and architectures. |
|
VGG backbone baseline for classification providing support for various versions and architectures. |
|
Wide-ResNet28x10 backbone baseline for classification providing support for various versions. |
Regression¶
MLP baseline for regression providing support for various versions. |
Segmentation¶
SegFormer backbone baseline for segmentation providing support for various versions and architectures. |
Monocular Depth Estimation¶
Layers¶
Ensemble layers¶
Packed-Ensembles-style Linear layer. |
|
Packed-Ensembles-style Conv2d layer. |
|
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. |
Models¶
Wrappers¶
Functions¶
Build a Deep Ensembles out of the original models. |
|
MC Dropout wrapper for a model. |
Classes¶
Ensemble of models at different points in the training trajectory. |
|
Exponential Moving Average. |
|
MC Dropout wrapper for a model containing nn.Dropout modules. |
|
Stochastic Weight Averaging. |
|
Stochastic Weight Averaging Gaussian (SWAG). |
Metrics¶
Classification¶
Proper Scores¶
The Brier Score Metric. |
|
The Negative Log Likelihood Metric. |
Out-of-Distribution Detection¶
Area Under the Risk-Coverage curve. |
|
The False Positive Rate at x% Recall metric. |
|
The False Positive Rate at 95% Recall metric. |
Selective Classification¶
Area Under the Generalized Risk-Coverage curve. |
|
Risk at given Coverage. |
|
Risk at 80% Coverage. |
|
Coverage at x Risk. |
|
Coverage at 5% Risk. |
Calibration¶
Adaptive Top-label Calibration Error. |
|
Top-label Calibration Error. |
Diversity¶
The Disagreement Metric to estimate the confidence of an ensemble of estimators. |
|
The Shannon Entropy Metric to estimate the confidence of a single model or the mean confidence across estimators. |
|
The Mutual Information Metric to estimate the epistemic uncertainty of an ensemble of estimators. |
|
Others¶
Metric to estimate the Top-label Grouping Loss. |
Regression¶
The Negative Log Likelihood Metric. |
|
The Log10 metric. |
|
Mean Absolute Error of the inverse predictions (iMAE). |
|
Compute Mean Absolute Error relative to the Ground Truth (MAErel |
|
Compute mean squared error relative to the Ground Truth (MSErel or SRE). |
|
Mean Squared Error of the inverse predictions (iMSE). |
|
MeanSquaredLogError (MSELog) regression metric. |
|
The Scale-Invariant Logarithmic Loss metric. |
|
The Threshold Accuracy metric, a.k.a. |
Segmentation¶
Compute the MeanIntersection over Union (IoU) score. |
Others¶
The Area Under the Sparsification Error curve (AUSE) metric to estimate the quality of the uncertainty estimates, i.e., how much they coincide with the true errors. |
Losses¶
Negative Log-Likelihood loss using given distributions as inputs. |
|
KL divergence loss for Bayesian Neural Networks. |
|
The Evidence Lower Bound (ELBO) loss for Bayesian Neural Networks. |
|
The Beta Negative Log-likelihood loss. |
|
The deep evidential classification loss. |
|
The Deep Evidential Regression loss. |
|
Focal-Loss for classification tasks. |
|
The Conflictual Loss. |
|
The Confidence Penalty Loss. |
|
KL divergence loss for Bayesian Neural Networks. |
|
The Evidence Lower Bound (ELBO) loss for Bayesian Neural Networks. |
|
Binary Cross Entropy with Logits Loss with label smoothing. |
Post-Processing Methods¶
Monte Carlo Batch Normalization wrapper. |
|
Laplace approximation for uncertainty estimation. |
Scaling Methods¶
Temperature scaling post-processing for calibrated probabilities. |
|
Vector scaling post-processing for calibrated probabilities. |
|
Matrix scaling post-processing for calibrated probabilities. |
Datamodules¶
Classification¶
DataModule for CIFAR10. |
|
DataModule for CIFAR100. |
|
DataModule for MNIST. |
|
DataModule for ImageNet. |
UCI Tabular Classification¶
The Bank Marketing UCI classification datamodule. |
|
The Dota2 Games UCI classification datamodule. |
|
The HTRU2 UCI classification datamodule. |
|
The online shoppers intention UCI classification datamodule. |
|
The Bank Marketing UCI classification datamodule. |
Regression¶
The UCI regression datasets. |
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. |
|
CIFAR-10H Dataset. |
|
CIFAR-10N Dataset. |
|
The corrupted ImageNet-C dataset. |
|
Inspired by https://gist.github.com/z-a-f/b862013c0dc2b540cf96a123a6766e54. |
|
The corrupted TinyImageNet-C Dataset. |
|
OpenImage-O dataset. |
UCI Tabular Classification¶
The bank Marketing UCI classification dataset. |
|
The DOTA 2 Games UCI classification dataset. |
|
The HTRU2 UCI classification dataset. |
|
The Online Shoppers Intention UCI classification dataset. |
|
The SpamBase UCI classification dataset. |
Regression¶
The UCI regression datasets. |
Segmentation¶
CamVid Dataset. |
|
Others & Cross-Categories¶
Dataset used for PixMix augmentations. |
|
The MUAD Dataset. |
|
NYUv2 depth dataset. |