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 lightningbased 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. 

WideResNet28x10 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¶
PackedEnsemblesstyle Linear layer. 

PackedEnsemblesstyle Conv2d layer. 

BatchEnsemblestyle Linear layer. 

BatchEnsemblestyle Conv2d layer. 

Masksemblesstyle Linear layer. 

Masksemblesstyle 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. 

LPBNNstyle linear layer. 

LPBNNstyle 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. 
OutofDistribution Detection¶
Area Under the RiskCoverage curve. 

The False Positive Rate at x% Recall metric. 

The False Positive Rate at 95% Recall metric. 
Selective Classification¶
Area Under the Generalized RiskCoverage curve. 

Risk at given Coverage. 

Risk at 80% Coverage. 

Coverage at x Risk. 

Coverage at 5% Risk. 
Calibration¶
Adaptive Toplabel Calibration Error. 

Toplabel 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 Toplabel 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 ScaleInvariant 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 LogLikelihood 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 Loglikelihood loss. 

The deep evidential classification loss. 

The Deep Evidential Regression loss. 

FocalLoss 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. 
PostProcessing Methods¶
Monte Carlo Batch Normalization wrapper. 

Laplace approximation for uncertainty estimation. 
Scaling Methods¶
Temperature scaling postprocessing for calibrated probabilities. 

Vector scaling postprocessing for calibrated probabilities. 

Matrix scaling postprocessing for calibrated probabilities. 
Datamodules¶
Classification¶
DataModule for CIFAR10. 

DataModule for CIFAR100. 

DataModule for MNIST. 

DataModule for ImageNet. 
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 MNISTC Dataset. 

The notMNIST dataset. 

The corrupted CIFAR10C Dataset. 

CIFAR10H Dataset. 

CIFAR10N Dataset. 

The corrupted ImageNetC dataset. 

Inspired by https://gist.github.com/zaf/b862013c0dc2b540cf96a123a6766e54. 

The corrupted TinyImageNetC Dataset. 

OpenImageO dataset. 
Regression¶
The UCI regression datasets. 
Segmentation¶
CamVid Dataset. 

Others & CrossCategories¶
Dataset used for PixMix augmentations. 

The MUAD Dataset. 

NYUv2 depth dataset. 