





























































































\section{Introduction} \label{sec:introduction}

\input{sections/1_introduction} 

\section{Related Work} \label{sec:related_work}

\input{sections/2_related_work} 

\vspace{4mm}
\section{Taxonomy for Deterministic Uncertainty Quantification} \label{sec:taxonomy}

\input{sections/3_taxonomy} 

\section{Evaluation of Deterministic Epistemic Uncertainty}\label{sec:experiments} 

\input{sections/4_experiments}

\section{Conclusion} \label{sec:conclusion}

\input{sections/5_conclusion}
\vspace{-2mm}
\section{Broader Impact} \label{sec:broader_impact}

\input{sections/6_broader_impact}

\iffalse
\clearpage

\bibliographystyle{unsrt}




\subsection{Regularization of Hidden Representations} \label{ssec:taxonomy_strategy}
We group \acp{dum} according to how feature collapse is tackled, enabling \ac{ood} detection based on latent representations.
In particular, we identify two main paradigms - distance awareness and informative representations - which we discuss in \autoref{sssec:distance_awareness} and \autoref{sssec:informative_representations}.

\subsubsection{Distance Awareness} \label{sssec:distance_awareness}

The fundamental idea of distance-aware hidden representations is to avoid feature collapse by enforcing distances between latent representations to mirror distances in the input space. 
This can be achieved by constraining the Lipschitz constant, as it enforces a lower and an upper bound to expansion and contraction performed by an underlying neural network. 
A lower bound is associated with \textit{sensitivity}, since it enforces that different inputs are mapped to distinct latent representations and, thus, provides a solution to feature collapse. 
Moreover, an upper bound enforces \textit{smoothness} of the hidden representations, \textit{i.e.}{} small changes in the input do not result in large changes in the latent space.
More formally, given any pair of inputs $x_1$ and $x_2$ the following lower and upper bounds must hold for the resulting activation of a feature extractor $f_\theta$ with parameters $\theta$: $c_1||x_1-x_2||_I \leq ||f_\theta(x_1)-f_\theta(x_2)||_F \leq c_2||x_1-x_2||_I$.
$c_1$ and $c_2$ denote respectively the lower and upper bound for the Lipschitz constant, and $||\cdot||_I$ and $||\cdot||_F$ are the chosen metrics in the input and feature space respectively.
While there exist other approaches, \textit{e.g.}{}~\cite{obukhov2021spectral}, recent proposals have primarily adopted two methods to impose the bi-Lipschitz constraint. 

\textbf{Gradient Penalty.} 
First introduced to regularize the Lipschitz constant in GAN training~\cite{gulrajani2017improved}, a two-sided gradient penalty is used as an additional loss term to enforce detectability in the feature space of changes in the input by DUQ~\cite{van2020uncertainty}.
The gradient penalty is formulated as an additional loss term that regularises the Frobenius norm $||J||_F$ of the Jacobian $J$ of a \ac{nn} to enforce a bi-Lipschitz
constraint. Therefore, the training loss of a \ac{nn} is typically enhanced with the absolute difference between $||J||_F$ and some chosen positive constant (see supplement or \cite{van2020uncertainty} for more details).

\textbf{Spectral Normalization.} The two-sided gradient penalty described above requires backpropagating through the Jacobian of a \ac{nn} and is, thus, computationally demanding. A more efficient technique is \ac{sn}~\cite{miyato2018spectral}. For each layer, \ac{sn} normalizes the weights $W$ of each layer using their spectral norm $sn(W)$ to constrain the bi-Lipschitz constant. Thus, weight matrices are normalized according to: $W_{sn}=\frac{W}{c\cdot sn(W)}$.
Note, that this soft constraint becomes hard for $c=1$. We refer to the supplement or \cite{liu2020simple} for further details.
Various \acp{dum} - SNGP~\cite{liu2020simple}, DUE~\cite{van2021improving} and DDU~\cite{mukhoti2021deterministic} - rely on \ac{sn} of the weight matrices to enforce distance-awareness of hidden representations.

Note that the Lipschitz constraint is defined with respect to a predefined distance measure, which can be difficult to choose for many high-dimensional data distributions of practical interest.
A popular choice, also adopted by~\cite{van2020uncertainty,liu2020simple,van2021improving}, is the $L_2$ distance.
Moreover, principled approaches to provide exact singular values in convolutional layers~\cite{sedghi2018singular} result in prohibitive computational complexity; the spectral normalization approximations typically adopted by the methods previously described have been found to be sub-optimal~\textit{et al.}~\cite{singla2019bounding}, and its interaction with losses, architecture and optimization is yet to be fully understood~\cite{rosca2020case}.
Consequently, Lipschitz regularization with respect to a potentially meaningless distance measure may result in overly sensitive models.
\autoref{ssec:classification_results} analyses the impact of regularization strength on \ac{ood} detection.

\subsubsection{Informative Representations} \label{sssec:informative_representations}
While methods enforcing distance-awareness achieve remarkable performance in OOD detection, they do not explicitly preserve sample-specific information.
Consequently, depending on the underlying distance metric they may discard useful information about the input or act overly sensitive.
An alternative line of work proposes to avoid feature collapse by learning informative representations~\cite{alemi2018uncertainty,wu2020simple,postels2020hidden,nalisnick2019hybrid,ardizzone2018analyzing,ardizzone2020training}, thus forcing discriminative models to preserve information beyond what required by its target task in its hidden representations independent of the choice of an underlying distance metric.
Notably, while representations that are aware of distances in the input space are arguably also informative, both categories remain fundamentally different in their approach to feature collapse.
While distance-awareness is based on the choice of a specific distance metric tying together input and latent space, informative representations incentivize the network to store more information about the input using an auxiliary task \cite{postels2020hidden, wu2020simple} or forbid information loss by construction \cite{ardizzone2018analyzing,nalisnick2019hybrid,ardizzone2020training}.
We identify three distinct families of approaches to enforce informative representations.

\textbf{Contrastive learning}~\cite{oord2018representation,wu2020simple} has emerged as an approach for learning representations that are both informative and discriminative.
This is utilized by Wu \textit{et al.}~\cite{wu2020simple}, who build on top of SimCLR~\cite{chen2020simple} to regularize hidden representations for a discriminative task by using an auxiliary contrastive loss to force representations to further discriminate between individual instances. 

\textbf{Reconstruction regularization}~\cite{postels2020hidden} instead forces the intermediate activations to embody a complete representation of the input space. 
This is achieved by adding a decoder branch fed with the activations of a given layer to reconstruct the input.
Since this method aims at producing Maximally Informative Representations, we term it MIR.

\textbf{\acp{inn}}~\cite{jacobsen2018revnet,ardizzone2018analyzing,nalisnick2019hybrid,ardizzone2020training}, built via a cascade of homeomorphic layers, cannot discard information except at the final classification stage.
Consequently, the mutual information between input and hidden representation is retained by construction.
Interestingly, Behrmann \textit{et al.}~\cite{behrmann2018invertible} showed that a ResNet is invertible if its Lipschitz constant is lower than $1$, meaning that invertible ResNets both possess highly-informative representations and satisfy distance-awareness. However, note that this is not a necessary condition for invertibility, and thus information preservation, in general.
\subsection{Uncertainty Estimation} \label{ssec:taxonomy_density_models}
We now describe the different approaches to quantifying uncertainty based on such regularized representations. 
We distinguish two directions - generative and discriminative approaches. 
While generative approaches use the likelihood produced by an explicit generative model of the distribution of hidden representations as a proxy for uncertainty, discriminative methods directly use the predictions based on regularized representations to quantify uncertainty.

\textbf{Generative approaches} estimate the distribution of hidden representations post-training and use the likelihood as uncertainty metric to detect \ac{ood} samples.
Wu \textit{et al.}~\cite{wu2020simple} propose a Deep Contrastive Uncertainty (DCU) method to train an additional deep network from the representation space to a distribution space, where the variance of the distribution is used as a confidence measure.
MIR~\cite{postels2020hidden} and DDU~\cite{mukhoti2021deterministic} fit a class-conditional GMM to their regularized hidden representations and use the log-likelihood as an epistemic uncertainty proxy.
A special instance of the generative approaches are \acp{inn} as they directly estimate the training data distribution. This allows using the likelihood of the input data as a proxy of uncertainty. While this idea is appealing, it can lead to training difficulties, imposes strong constraints on the underlying feature extractor and in some instances even remains susceptible to \ac{ood} data~\cite{nalisnick2018deep}.

\textbf{Discriminative approaches} use the predictions based on regularized representations to directly assess confidence.
Mandelbaum \textit{et al.}~\cite{mandelbaum2017distance} propose to use a Distance-based Confidence Score (DCS) to estimate local density at a point as the Euclidean distance in the embedded space between the point and its k nearest neighbors in the training set.
Similarly, DUQ~\cite{van2020uncertainty} builds on Radial Basis Function (RBF) networks~\cite{lecun1998gradient} and propose a novel centroid updating scheme. 
Uncertainty is estimated as the distance between the model output and the closest centroid.
DUMs adopting \ac{sn}~\cite{liu2020simple,van2021improving}, and thus preserving $L_2$ distances, typically fit \acp{gp} with RBF kernels on top of the learned feature space, extending distance awareness to the output layer.
In particular, SNGP~\cite{liu2020simple} relies on a Laplace approximation of the \ac{gp} based on the random Fourier feature (RFF) expansion of the \ac{gp} posterior~\cite{rasmussen2003gaussian}.
DUE~\cite{van2021improving} leverages instead the inducing point approximation~\cite{titsias2009variational,hensman2015scalable}, allowing to pick an arbitrarily large number of inducing points without overfitting~\cite{burt2019rates}.
The uncertainty is then derived respectively as the Dempster-Shafer metric~\cite{liu2020simple} or the softmax entropy~\cite{van2021improving}.







\subsubsection{Results} \label{ssec:classification_results}

\textbf{Calibration under continuous distributional shift.} \autoref{tab:classification_cal} shows accuracy on the test set and calibration performance in terms of \ac{raulc}. With the exception of DUQ, which we find to be prone to training instabilities, all \acp{dum} achieve similar predictive performance as \ac{mc} dropout, deep ensembles and standard softmax models. In terms of uncertainty calibration, we observe that in particular DUE, SNGP and MIR compete with established uncertainty estimation methods (\textit{e.g.}{} \ac{mc} dropout) across most datasets and both types of distributional shifts. Consequently, these approaches do not only fare well at detecting \ac{ood} data but also deliver well calibrated uncertainties under synthetic distributional shifts.
However, this is not sufficient to justify their use for real-world safety-critical applications.
Refer to \autoref{ssec:segmentation_results} for an analysis of calibration under realistic distributional shift.

\begin{figure*}[t]
\begin{tabular}{ccc}

\multicolumn{3}{c}{\input{figures/image_classification/acc_aulc_auroc_vs_perturbation/custom_legend}}
\\

\input{figures/image_classification/acc_aulc_auroc_vs_perturbation/mnist_ACC_vs_perturbation} &
\input{figures/image_classification/acc_aulc_auroc_vs_perturbation/mnist_AUROC_vs_perturbation} &
\input{figures/image_classification/acc_aulc_auroc_vs_perturbation/mnist_AULC_vs_perturbation}
\\

\input{figures/image_classification/acc_aulc_auroc_vs_perturbation/svhn_ACC_vs_perturbation} &
\input{figures/image_classification/acc_aulc_auroc_vs_perturbation/svhn_AUROC_vs_perturbation} &
\input{figures/image_classification/acc_aulc_auroc_vs_perturbation/svhn_AULC_vs_perturbation}

\end{tabular}
\vspace{-1em}
\caption{We compare \acp{dum} and the baselines (\ac{mc} dropout (MCD), ensembles (Ens)) under continuous distributional shifts. Therefore, we plot accuracy (LEFT), \ac{auroc} (CENTER) and \ac{raulc} (RIGHT) against the perturbation magnitude for a MLP trained on MNIST (TOP) and a ResNet-18 on SVHN (BOTTOM). We perturbe MNIST using rotations and SVHN using additive Gaussian noise. The \ac{auroc} is computed against unperturbed test data. Most \acp{dum} demonstrate similar behaviour as the baselines, except DDU. While MIR shows strong performance on MNIST, its performance drops on CIFAR10.}\label{fig:acc_aulc_auroc_vs_perturbation}
\end{figure*}


\begin{table}[t]
\small
    \centering
    \setlength{\tabcolsep}{2.8pt}
    \input{tables/classification_cal}
    \caption{We evaluate the in-domain test accuracy (Acc, \%) and calibration performance (\ac{raulc}, \%) on MNIST, FashionMNIST, CIFAR10 and SVHN datasets. The backbones for all methods are MLP for MNIST/FashionMNIST and ResNet-18 for CIFAR10/SVHN. We observe that - in particular - DUE, SNGP and MIR are well calibrated across several scenarios.}
    \label{tab:classification_cal}
\end{table}

\begin{table}[t]
\small
    \centering
    \setlength{\tabcolsep}{3pt}
    \input{tables/classification_ood}
    \caption{Experiments for OOD detection (AUROC and AUPR, \%). The baseline method and all \acp{dum} use a MLP trained on MNIST/FashionMNIST and predict on another dataset. MIR demonstrates strong performance. (F-MNIST $=$ FashionMNIST).}
    \label{tab:classification_ood1}
\end{table}

\textbf{\ac{ood} Detection.} \autoref{tab:classification_ood1} shows quantitative results on detecting \ac{ood} data for \acp{dum}, \ac{mc} dropout, softmax entropy and deep ensembles trained on MNIST/FashionMNIST (similarly in the supplement for ResNet-18 trained on CIFAR10/SVHN). Among \acp{dum}, SNGP and MIR demonstrate the best performance across a variety of scenarios. While \acp{dum} confirm to be naturally suited for \ac{ood} detection, other established approaches (\textit{e.g.}{} \ac{mc} dropout) remain competitive. We note a particular drop in performance for \acp{dum} estimating uncertainty based on the distribution of hidden representations (\textit{i.e.} MIR and DDU) in the case of CIFAR10 vs. SVHN (see supplement). We hypothesize that this results from difficulties of generative models at distinguishing CIFAR10 and SVHN \cite{nalisnick2018deep}.


\textbf{Sensitivity to Regularization Strength.} The hyperparameter associated with each \ac{dum} constitutes an important element in each method. It is important to know whether their performance in terms of \ac{ood} detection and calibration is sensitive to its choice. Intuitively, we expect the regularization technique to be positively correlated with \ac{ood} detection performance, since this is what most \acp{dum} were designed for. For each regularization paradigm - distance-awareness (SNGP) and informative representations (MIR) -, \autoref{fig:sensitivity_to_regularization_strength} visualizes the calibration (\ac{raulc}) and \ac{ood} detection (\ac{auroc}) performance depending on the strength of the regularization (similarly for other datasets and methods in the supplement). Most interestingly, we find that \acp{dum} regularizing the Lipschitz constant of the underlying feature extractor do not show evidence for a correlation between the regularization strength and the performance on \ac{ood} detection. One possible reason for this result is that Lipschitz-regularization is defined in the context of a particular predefined norm (\textit{e.g.}{} $L_2$) (see \autoref{sec:taxonomy}). However, this norm does not necessarily represent meaningful distances on a particular dataset (\textit{e.g.}{} images). On the contrary, in the case of enforcing informative representations using reconstruction regularization (MIR), we find evidence for a correlation between regularization strength and performance in terms of both \ac{ood} detection and calibration.


\begin{figure}[t]
\begin{tabular}{ccc}
\vspace{-4mm}
\input{figures/image_classification/regularization_strength_error_bars/mir_mnist_AULC_vs_ACC} & 
\input{figures/image_classification/regularization_strength_error_bars/mir_mnist_fashion_mnist_AUROC_vs_ACC} &
\input{figures/image_classification/regularization_strength_error_bars/mir_mnist_omniglot_AUROC_vs_ACC} 
\\ \vspace{-1mm}
\input{figures/image_classification/regularization_strength_error_bars/sngp_mnist_AULC_vs_ACC} & 
\input{figures/image_classification/regularization_strength_error_bars/sngp_mnist_fashion_mnist_AUROC_vs_ACC} & \hspace{-3mm}
\input{figures/image_classification/regularization_strength_error_bars/sngp_mnist_omniglot_AUROC_vs_ACC}
\end{tabular}
\vspace{-0.5em}
\caption{Trained on MNIST. Vertical axis: Test accuracy. Horizontal axis: \ac{raulc} (left), \ac{auroc} against FashionMNIST (center) and Omniglot (right) for MIR (top) and SNGP (bottom) using different regularization strength. For SNGP a larger hyperparameter corresponds to less regularization. For MIR we observe a correlation between regularization strength and performance.}\label{fig:sensitivity_to_regularization_strength}
\vspace{-1em}
\end{figure}
\subsubsection{Dataset} \label{ssec:segmentation_dataset}
To benchmark our model in a realistically and continuously changing environment, we collect a synthetic dataset for semantic segmentation. 
We use the CARLA Simulator~\cite{Dosovitskiy17} for rendering the images and segmentation masks. The classes definition is aligned with the CityScape dataset~\cite{Cordts2016Cityscapes}. 

\textbf{Training data.} Data is collected from four towns in CARLA. We produce 32 sequences from each town. Vehicles and pedestrians are randomly generated for each sequence. Every sequence has 500 frames with a sampling rate of $10$ FPS. We uniformly sample a validation set.

\textbf{Continuous Distributional Shifts.} We use the time-of-the-day (weather conditions in the supplement) as the parameter for continuously changing the distribution. Visual examples and details on data collection are in the appendix. The time-of-the-day is parametrized by the Sun's altitude angle, where $90^\circ$ means the mid-day (training data) and the $0^\circ$ means the dust/dawn. We produce samples with altitude angles from $90^\circ$ to $15^\circ$ by steps of $5^\circ$, and $15^\circ$ to $-5^\circ$, where the environment changes sharply, in $1^\circ$ steps.
\subsubsection{Method Details} \label{ssec:segmentation_method_details}
\textbf{Backbone.} 
We adopt \ac{drn}~\cite{Yu2016, Yu2017} as semantic segmentation backbone. 
\ac{drn} introduces dilated convolutions to ResNet, effectively increasing the receptive field without increasing the number of layers or parameters. This improves the spatial accuracy of \ac{drn}, achieving satisfactory results on CityScapes~\cite{Cordts2016Cityscapes}. 
We adopt the variant DRN-A-50.
All experiments were run $3$ times.

\textbf{SNGP.} 
\ac{drn} uses $1 \times 1$ convolutions at the last layer to map the latest feature map to the predicted segmentation mask.
This works under the assumption that all pixels in the output mask are i.i.d. random variables.
Following this intuition, we extend SNGP to semantic segmentation by fitting a $GP: \mathbb{R}^Z \rightarrow \mathbb{R}^C$  at pixel level that maps from the deep feature dimension $z$ to the number of classes $c$. By keeping the \ac{gp} kernel parameters shared across all pixels, we simulate a  $1 \times 1$ convolutional \acp{gp}, \textit{i.e.}{} $\sigma: (H_l \times W_l \times Z) \rightarrow (H_l \times W_l \times C)$, where $\sigma$ convolves the \ac{gp}, $H_l$ and $W_l$ are respectively feature map height and width at layer $l$, $Z$ is the number of latent features and $C$ is the number of output classes. For details about the \ac{gp} we refer to \cite{liu2020simple} or the supplement.

\textbf{MIR.} To estimate image-level uncertainty MIR requires fitting the distribution of hidden representations. We fit a \ac{gmm} with $20$ components (\textit{i.e.}{} number of classes) to each spatial location of the hidden representations using features extracted from the training data independently. This assumes that the distribution is translation invariant and factorizes along the spatial dimensions of the latent space which is similar to the procedure used in \cite{blum2019fishyscapes}. We refer to the supplement for more details and computation of pixel-level uncertainties in this framework.

\subsubsection{Results} \label{ssec:segmentation_results}
\textbf{Continuous Distribution Shift.} 
We compare \acp{dum} with \ac{mc} dropout and the softmax baseline.
in terms of their calibration under realistic distributional shifts.
\autoref{table:calibration_segmentation} shows quantitative results. Encouragingly, all methods yield similar performance in terms of \ac{miou} and pixel accuracy. However, we observe that while \acp{dum} yield a considerable improvement over the softmax entropy - both in \ac{ood} detection and calibration - using a similar computational budget, these methods still fall short of established approaches, such as \ac{mc} dropout, in terms of calibration under challenging realistic distributional shifts. 
This finding is further supported by the results of \autoref{fig:miou_auroc_lc}, which shows 
that \acp{dum} behave poorly in terms of calibration (see Lift curves) under realistic distributional shift.
We believe that these shortcomings must be addressed before practical deployment.


\begin{table}[t]
    \centering
    \scalebox{0.9}{
    \input{tables/segmentation}
    }
    \caption{We compare predictive performance on unperturbed test data - pixel accuracy (Acc.) and \ac{miou} - and calibration (rAULC) on realistic continuous distributional shifts of softmax, \ac{mc} dropout (MCD), SNGP and MIR on semantic segmentation. While SNGP and MIR perform better than the simple softmax baseline, they remain outclassed by \ac{mc} dropout in terms of calibration.}
    \label{table:calibration_segmentation}
    \vspace{-1em}
\end{table}

\begin{figure}

\begin{tabular}{ccc}

\multicolumn{3}{c}{\input{figures/semantic_segmentation/custom_legend}}
\\

\input{figures/semantic_segmentation/segmentation_mIoU_vs_perturbation} &
\input{figures/semantic_segmentation/segmentation_AUROC_vs_perturbation} &
\input{figures/semantic_segmentation/segmentation_LC_summary}

\end{tabular}
\caption{We compare the \ac{miou} (left), \ac{auroc} (center) and \ac{raulc} (right) of softmax (SM), \ac{mc} dropout (MCD), SNGP and MIR under realistic continuous distributional shifts. The \ac{auroc} is computed against unperturbed test data. While the softmax entropy as a measure of uncertainty clearly fails in this scenario, \acp{dum} (SNGP/MIR) yield reasonable uncertainty using a similar computational budget at identical predictive performance (\ac{miou}). However, \ac{mc} dropout, with its larger computational footprint, provides better calibrated uncertainty estimates (Lift).}\label{fig:miou_auroc_lc}
\vspace{-4mm}
\end{figure}

\subsection{Image Classification}\label{ssec:classification}
\input{sections/4_1_image_classification}


\subsection{Semantic Segmentation}\label{ssec:segmentation}
\input{sections/4_2_large_scale_visual_task}



\subsection{Official Implementation} \label{ssec:code}
An official implementation of this work can be found, completely anonymized, at the following link:
\url{https://1drv.ms/u/s!AmvoAvndzeKvarxW2fCTi_4W9-o?e=KjaQNE}


\subsection{Additional Results} \label{ssec:suppl_additional_results}
\subsubsection{Image Classification} \label{sssec:suppl_classification_results}
\textbf{OOD Detection.}
\autoref{table:classification_ood2} show quantitative results on detecting \ac{ood} data for \acp{dum}, \ac{mc} dropout, softmax entropy and deep ensembles trained on CIFAR/SVHN.
Similarly to the results shown in \autoref{ssec:classification_results}, among \acp{dum} SNGP and MIR demonstrate strong performance across a variety of scenarios. Note that in this case DUE also shows good performance. While \acp{dum} confirm to be naturally suited for \ac{ood} detection, other established approaches (\textit{e.g.}{} \ac{mc} dropout) remain competitive.

\begin{table}[htbp]
\small
    \centering
    \setlength{\tabcolsep}{3pt}
    \input{tables/classification_ood_2}
    \caption{Experiments for OOD detection performance (AUROC and AUPR, \%). The baselines and all \acp{dum} use a ResNet-18 trained on CIFAR10/SVHN. In particular, SNGP, MIR and DUE demonstrate strong performance. However, computationally more expensive baselines remain competitive.} \label{table:classification_ood2}
\end{table}

\textbf{Sensitivity to regularization strength.}
\input{figures/image_classification/supplementary_regularization_strength/mnist_regularization_strength}
\input{figures/image_classification/supplementary_regularization_strength/fashion_mnist_regularization_strength}
\input{figures/image_classification/supplementary_regularization_strength/cifar10_regularization_strength}
\input{figures/image_classification/supplementary_regularization_strength/svhn_regularization_strength}
We provide additional ablation studies on the sensitivity to regularization strength for different methods on datasets, \textit{i.e.}{} MNIST (\autoref{fig:suppl_mnist_sensitivity_to_regularization_strength}), FashionMNIST (\autoref{fig:suppl_fashion_mnist_sensitivity_to_regularization_strength}), CIFAR10 (\autoref{fig:suppl_cifar_sensitivity_to_regularization_strength}), and SVHN (\autoref{fig:suppl_svhn_sensitivity_to_regularization_strength}).
These results confirm the findings of the main manuscript, \textit{i.e.}{} that only MIR and Dropout are sensible to regularization strength, while \acp{dum} based on Lipschitz regularization are not influenced by the regularization strength. Note that for MIR we observe that regularization strength and calibration/ood detection are anti-correlated. We hypothesize that this originates from generative models inability to distinguish these datasets \cite{nalisnick2018deep}. Thus, storing more information in the latent representations about the input leads to worse \ac{ood} detection performance.

\subsubsection{Semantic Segmentation}  \label{sssec:suppl_segmentation_results}
\textbf{Weather conditions.} Additionally, we evaluate the calibration performance of DUMs under changing weather conditions. Fig.~\ref{fig:carla_weather} of Sec.~\ref{ssec:suppl_segmentation_dataset} demonstrates examples of this distributional shift. The quantitative evaluation results are summarized in Table~\ref{table:calibration_segmentation_weather}. Similar to the trend in the Table~\ref{table:calibration_segmentation}, all methods yield decent performance on pixel accuracy and mIoU, and the DUMs obtain significant improvements over the Softmax baseline. However, we again observe that \ac{mc} dropout outperforms \acp{dum} on continuous distributional shifts. 
\begin{table}[!h]
    \centering
    \scalebox{0.9}{
    \input{tables/segmentation2}
    }
    \caption{Calibration results on semantic segmentation for weather conditions.}
    \label{table:calibration_segmentation_weather}
\end{table}
 
\textbf{Examples of segmentation and uncertainty masks.}
\input{figures/supplementary_segmentation_uncertainty/minimal_shift_uncertainty}
\input{figures/supplementary_segmentation_uncertainty/maximal_shift_uncertainty}
We show qualitative examples of predicted masks, error masks and uncertainty masks for Softmax, \ac{mc} dropout, SNGP and MIR on semantic segmentation. 
\autoref{fig:suppl_segmentation_minimal} illustrates examples under \textit{minimal} distributional shift (\textit{i.e.}{} Azimuth angle of the sun $=85\degree$ and \autoref{fig:suppl_segmentation_maximal} under \textit{maximal} distributional shift (\textit{i.e.}{} Azimuth angle of the sun $=-5\degree$.
We show the input image (Input), the segmentation ground truth (GT), the predicted segmentation mask (Prediction), the error mask (Error) and the uncertainty mask (Uncertainty).
The error mask is computed as a boolean mask with True values when a pixel is predicted wrongly (yellow) and False (blue) when the prediction is instead correct. 
The uncertainty mask is preprocessed to facilitate visualization. In particular, we first compute mean $\mu$ and standard deviation $\sigma$ of per-pixel uncertainties over each uncertainty mask. Then, the uncertainty mask is clipped between $[\mu-2\sigma, \mu+2\sigma]$. Finally, the uncertainty mask is normalized between $0$ and $1$ before being visualized.

While the softmax entropy provides decent uncertainty estimates under minimal distributional shift, it tends to be overconfident under severe distributional shift.
In particular, Softmax models are only uncertain close to object borders, but they are confident about large portions of the image that are instead predicted wrongly.
This can be observed in \autoref{fig:suppl_segmentation_maximal}, where all models tend to predict the entire sky wrongly (assigned to `building' class), but the Softmax model is the most confident about its predictions of the sky being correct.
\acp{dum} and \ac{mc} dropout do a better job at recognizing wrong predictions under sever domain shift by outputting higher uncertainty values.

\subsection{Lipschitz Regularization} \label{ssec:suppl_regularization}

\textbf{Gradient Penalty.} 
Given a model $g$ and an input $x$, regularising the Frobenius norm $||J||_F$ of its Jacobian $J$ constraints its Lipschitz constant.
Therefore, the following two-sided gradient penalty is used:
$\lambda \left[ ||\nabla_x g(x)||_F-1\right]^2$,
where $\lambda$ is the regularization strength, $||\cdot||_2$ is the $L_2$ norm, the target bi-Lipschitz constant is 1. 

\textbf{Spectral Normalization.} A more efficient technique to constrain the Lipschitz constant is \ac{sn}~\cite{miyato2018spectral}. For each layer $g: \mathbf{h}_{in} \rightarrow \mathbf{h}_{out}$, \ac{sn} effectively constrain its Lipschitz norm $||g||_{Lip}=sup_{\mathbf{h}}sn(\nabla g(\mathbf{h}))$, where $sn(A)$ is the spectral norm - the $L_2$ matrix norm - of the matrix A, equivalent to its largest singular value.
When applied, \ac{sn} normalizes the spectral norm of the weights $W$ of each layer to satisfy the soft-Lipschitz constraint $sn(W)=c$ (hard- if the Lipschitz constant $c=1$): $W_{sn}=W/sn(W)$.
A number of \acp{dum} - SNGP~\cite{liu2020simple}, DUE~\cite{van2021improving} and DDU~\cite{mukhoti2021deterministic} - rely on \ac{sn} of the weight matrices to make the feature extractor distance preserving.


\subsection{Training Details}
\label{ssec:suppl_training_details}
We provide training and optimization details for all evaluated methods.
All methods using spectral normalization use $1$ power iteration.
Hyperparameters were chosen to minimize the validation loss.

\subsubsection{Image Classification - MNIST/FashionMNIST}
All methods trained on MNIST/FashionMNIST used a MLP as backbone with $3$ hidden layers of $100$ dimensions each and ReLU activation functions.
We used a batch size of $128$ samples and trained for $200$ epochs.
No data augmentation is performed.

\textbf{Softmax and Deep ensembles.}
We used for the single softmax model the Adam optimizer with learning rate $0.003$, and $L_2$ weight regularization $0.0001$. When using ensembles, $10$ models are trained from different random initializations.

\textbf{\ac{mc} dropout.}
We used for all baselines the Adam optimizer with learning rate $0.003$, dropout rate $0.4$ and $L_2$ weight regularization $0.0001$.

\textbf{DUE}
We trained DUE with the SGD optimizer with learning rate $0.01$, $L_2$ weight regularization $0.0005$, and a multi-step learning rate decay policy with decay rate $0.2$ and decay steps at the epochs $60$, $120$, $160$.
We found the optimal \ac{sn} coefficient to be $7$, with the GP approximation using $10$ (number of classes) inducing points initialized using k-means over $10000$ samples.

\textbf{DUQ}
We trained DUQ with the SGD optimizer with learning rate $0.01$, $L_2$ weight regularization $0.0001$, and a multi-step learning rate decay policy with decay rate $0.3$ and decay steps at the epochs $10$, $20$.
Lengthscale for the RBF kernel is $0.1$ and optimal gradient penalty loss weight is $0$.

\textbf{DDU.}
We trained DDU with the Adam optimizer with learning rate $0.001$, $L_2$ weight regularization $0.0001$, and a multi-step learning rate decay policy with decay rate $0.2$ and decay steps at the epochs $100$, $200$, $300$.
We found the optimal \ac{sn} coefficient to be $6$. The GMM fit on top of the pretrained feature extractor is trained for $100$ epochs and is fit with $64$ batches.

\textbf{SNGP.}
We trained SNGP with the SGD optimizer with learning rate $0.05$, $L_2$ weight regularization $0.0003$, and a multi-step learning rate decay policy with decay rate $0.2$ and decay steps at the epochs $60$, $120$, $160$.
We found the optimal \ac{sn} coefficient to be $6$, with the GP approximation using $10$ hidden dimensions, lengthscale $2$ and mean field factor $30$.

\textbf{MIR.} 
We trained MIR with the Adam optimizer with learning rate $0.001$, and $L_2$ weight regularization $0.0001$.
We found the optimal reconstruction loss weight to be $1$.


\subsubsection{Image Classification - CIFAR10/SVHN}
When training on CIFAR-10/SVHN, we use a ResNet-18~\cite{he2016deep} as backbone. 
The dimensionality of the last feature space encoded with the ResNet backbone is $100$ for all methods.
We used a batch size of $128$ samples and trained for $400$ epochs.
The training set is augmented with common data augmentation techniques. We apply random horizontal flips, random brightness augmentation with maximum delta $0.2$ and random contrast adjustment with multiplier lower bound $0.8$ and upper bound $1.2$.

\textbf{Softmax and Deep ensembles.}
We used for the single softmax model the Adam optimizer with learning rate $0.003$, $L_2$ weight regularization $0.0001$, and a multi-step learning rate decay policy with decay rate $0.2$ and decay steps at the epochs $250$, $300$, $400$. When using ensembles, $10$ models are trained from different random initializations.

\textbf{\ac{mc} dropout.}
We used for all baselines the Adam optimizer with learning rate $0.003$, dropout rate $0.3$, $L_2$ weight regularization $0.0001$, and a multi-step learning rate decay policy with decay rate $0.2$ and decay steps at the epochs $250$, $300$, $400$.

\textbf{DUE}
We trained DUE with the SGD optimizer with learning rate $0.01$, $L_2$ weight regularization $0.0005$, dropout rate $0.1$, and a multi-step learning rate decay policy with decay rate $0.2$ and decay steps at the epochs $100$, $200$, $300$.
We found the optimal \ac{sn} coefficient to be $7$ for SVHN and $9$ for CIFAR-10, with the GP approximation using $10$ (number of classes) inducing points initialized using k-means over $10000$ samples.

\textbf{DUQ}
We trained DUE with the SGD optimizer with learning rate $0.01$, $L_2$ weight regularization $0.0001$, dropout rate $0.1$, and a multi-step learning rate decay policy with decay rate $0.3$ and decay steps at the epochs $200$, $250$. $300$.
Lengthscale for the RBF kernel is $0.1$ and optimal gradient penalty loss weight is $0$

\textbf{DDU.}
We trained DDU with the Adam optimizer with learning rate $0.001$, $L_2$ weight regularization $0.0001$, dropout rate $0.3$, and a multi-step learning rate decay policy with decay rate $0.2$ and decay steps at the epochs $80$, $120$, $180$.
We found the optimal \ac{sn} coefficient to be $7$. The GMM fit on top of the pretrained feature extractor is trained for $100$ epochs and is fit with $64$ batches.

\textbf{SNGP.}
We trained SNGP with the SGD optimizer with learning rate $0.05$, $L_2$ weight regularization $0.0004$, dropout rate $0.1$, and a multi-step learning rate decay policy with decay rate $0.2$ and decay steps at the epochs $100$, $200$, $300$.
We found the optimal \ac{sn} coefficient to be $7$, with the GP approximation using $10$ hidden dimensions, lengthscale $2$ and mean field factor $30$.

\textbf{MIR.} 
We trained MIR with the Adam optimizer with learning rate $0.003$, $L_2$ weight regularization $0.0001$, dropout rate $0.1$, and a multi-step learning rate decay policy with decay rate $0.2$ and decay steps at the epochs $150$, $200$, $250$, $300$.
We found the optimal reconstruction loss weight to be $1$.


\subsubsection{Semantic Segmentation.}
When training on semantic segmentation, we use a \ac{drn}~\cite{Yu2016, Yu2017} (DRN-A-50) as backbone.
We used a batch size of $8$ samples and trained for $200$ epochs.
Images are rescaled to size $200 \times 320$
The training set is augmented with common data augmentation techniques.
All training samples are augmented with random cropping with factor $0.8$. We apply random horizontal flips, random brightness augmentation with maximum delta $0.2$ and random contrast adjustment with multiplier lower bound $0.8$ and upper bound $1.2$.


\textbf{Softmax.}
We used for the single softmax model the Adam optimizer with learning rate $0.0004$, $L_2$ weight regularization $0.0001$, and a multi-step learning rate decay policy with decay rate $0.3$ and decay steps at the epochs $30$, $60$, $90$, $120$. 

\textbf{\ac{mc} dropout.}
We used for all baselines the Adam optimizer with learning rate $0.0004$, dropout rate $0.4$, $L_2$ weight regularization $0.0001$, and a multi-step learning rate decay policy with decay rate $0.3$ and decay steps at the epochs $30$, $60$, $90$, $120$.

\textbf{SNGP.}
We trained SNGP with the SGD optimizer with learning rate $0.0002$, $L_2$ weight regularization $0.0003$, dropout rate $0.1$, and a multi-step learning rate decay policy with decay rate $0.2$ and decay steps at the epochs $20$, $40$, $60$, $80$, $100$.
We found the optimal \ac{sn} coefficient to be $6$, with the GP approximation using $128$ hidden dimensions, lengthscale $2$ and mean field factor $25$.

\textbf{MIR.}
We trained MIR with the Adam optimizer with learning rate $0.0002$, $L_2$ weight regularization $0.0001$, dropout rate $0.1$, and a multi-step learning rate decay policy with decay rate $0.3$ and decay steps at the epochs $30$, $60$, $90$, $120$.
We found the optimal reconstruction loss weight to be $1$.

\subsection{Implementation Details.} \label{ssec:suppl_implementation_details}
All methods were re-implemented in Tensorflow 2.0.
We payed attention to all the details reported in each paper and we run all experiments for each method multiple times to account for stochasticity, \textit{i.e.}{} $5$ times for classification and $3$ times for segmentation.
When an implementation was publicly available, we relied on it. 
This is the case for DUQ (\url{https://github.com/y0ast/deterministic-uncertainty-quantification}), SNGP (\url{https://github.com/google/uncertainty-baselines/blob/master/baselines/imagenet/sngp.py}) and DUE (\url{https://github.com/y0ast/DUE}).

\textbf{SNGP.} We follow the publicly available implementation of SNGP, which, compared to the implementation described in the original paper, proposes to further reduce the computational overhead of the GP approximation by replacing the Monte-Carlo averaging with the mean-field approximation~\cite{daunizeau2017semi}.
This is especially relevant in large-scale tasks like semantic segmentation, were it is important to reduce the computational overload.

\subsubsection{Image Classification}
\textbf{DUE.} Note that only DUE uses a \ac{sn} approximation also for the batch normalization layer. 
All other methods only restrict the Lipschitz constant of convolutional and fully connected layers.

\textbf{MIR} only differs from regular softmax models in its decoder module used for the reconstruction regularization loss \cite{postels2020hidden}. When training MLP architectures the decoder is comprised of two fully-connected layer. The first has a ReLU activation function and 200 output neruons. The second has a linear activation function and its output dimensionality equals that of the models' input data. When training convolutional neural networks the decoder is comprised of four blocks of transpose convolutions, batch normalization layers and ReLU activation functions that gradually upscale the hidden representations to the dimensionality of the input data. These four blocks are followed by a 1x1 convolution with linear activation function.

\subsubsection{Semantic Segmentation}

\textbf{MIR.} Similar to image classification, MIR only differs from regular segmentation models in its decoder module used for the reconstruction regularization loss \cite{postels2020hidden}. The decoder module is comprised of a single point-wise feed forward layer that maps the hidden representations $\textbf{z}\in \mathbb{R}^{W_z\times H_z \times C_z}$ to $\textbf{z}\in \mathbb{R}^{W_z\times H_z \times 3}$. Subsequently, the result is bilinearly upsampled to the image resolution on which we compute the reconstruction loss.

\subsubsection{Uncertainty Derivation.} \label{ssec:suppl_uncertainty_derivation_classification} 
We provide details on the estimation of uncertainty for the baseline methods.
For details on the uncertainty derivation in DUMs, please refer to \autoref{sec:taxonomy} of the main paper or to the original paper of each amalysed method.

\textbf{Softmax.} In case of the softmax baseline we estimate uncertainty using the entropy of the predictive distribution parameterized by the neural network. Given an input $\textbf{x}$ the entropy $H$ is given by $H(\textbf{y}|\textbf{x}) = \sum -p(\textbf{y}|\textbf{x}) \log (p(\textbf{y}|\textbf{x}))$ where $p(\textbf{y}|\textbf{x})$ are the softmax probabilities.

\textbf{\ac{mc} dropout and deep ensembles.} We following \cite{gal2017deep} and compute epistemic uncertainty as the conditional mutual information between the weights $\textbf{w}$ and the predictions $\hat{y}$ given the input $\textbf{x}$. Given an input $\textbf{x}$ and a set of weights $\textbf{w}$ we observe the predictive distribution $p(\hat{y}|x, w)$. Then epistemic uncertainty $u_{ep}$ is calculated by approximating the mutual information conditioned on the input $\textbf{x}$:
\begin{align*}
    u_{ep} &= I\left( \hat{y}, w | x \right) \\ 
    &= H(\hat{y}| x) -  H(\hat{y}| w, x) \\
    &= E_{y\sim p(\hat{y}|x)} \left[ -\log(p(\hat{y}|x)) \right] - u_{al}
\end{align*}
where $u_{al}$ denotes the aleatoric uncertainty. Here, $p(\hat{y}|x) = \int \mathrm{d}w p(w) p(\hat{y}|x, w)$ is evaluated using a finite set of samples/ensemble members.


\subsubsection{Uncertainty Derivation for Semantic Segmentation.} \label{ssec:suppl_uncertainty_derivation_segmentation}
We derive uncertainty estimates for each method for semantic segmentation.
We average pixel-level uncertainties under the assumption that all pixels are represented by i.i.d. variables.

\textbf{Uncertainty Averaging.}
In our experiments on continuous distributional shifts we want to estimate a global uncertainty for the output map and are not interested in pixel-level confidence. Therefore, we propose to approximate the uncertainty of the predicted segmentation masks as the average of all pixel-level uncertainties, i.e.,
\begin{equation}
\begin{aligned}
    H(\mathbf{y} \mid \mathbf{x}) & = \mathbb{E}_{\mathbf{x}} \left[ -\int_{\mathbf{y}} p(\mathbf{y} \mid \mathbf{x}) \log p(\mathbf{y} \mid \mathbf{x}) \mathrm{d} \mathbf{y} \right] \\
    & = \mathbb{E}_{\mathbf{x}} \left[ -\int_{\mathbf{y}} p(\mathbf{y} \mid \mathbf{x}) \log p(y_1 \mid \mathbf{x}) \mathrm{d} \mathbf{y} \right] + \cdots + \mathbb{E}_{\mathbf{x}} \left[ -\int_{\mathbf{y}} p(\mathbf{y} \mid \mathbf{x}) \log p(y_n \mid \mathbf{x}) \mathrm{d} \mathbf{y} \right] \\
    & \approx \frac{1}{n} \sum_{i=1}^n H(y_i \mid \mathbf{x})
\end{aligned}
\end{equation}

\textbf{MIR} estimates epistemic uncertainty using the likelihood of hidden representations $\textbf{z}\in \mathbb{R}^{W_z\times H_z \times C_z}$. Since $\textbf{z}$ is high-dimensional in our experiments, we assume that it factorizes along $W_z$ and $H_z$ and is translation invariant. Formally, $p(\textbf{z}) = \prod_i^{W_z}\prod_{j}^{H_z}p_{\theta}(\textbf{z}_{ij})$ where $\textbf{z}_{ij} \in \mathbb{R}^{W_z\times H_z}$ and $\theta$ is shared across $W_z$ and $H_z$. 

We parameterize $p_{\theta}$ with a GMM with $n=10$ components where each component has a full covariance matrix. We fit the GMM on $100000$ hidden representations ($\textbf{z}_{ij} \in \mathbb{R}^{C_z}$) randomly picked from the training dataset post-training. Since $C_z = 1024$ is still high-dimensional, we first apply PCA to reduce its dimensionality to $32$. 

In the dilated resnet architecture used for semantic segmentation the latent representation $\textbf{z}$ is passed through a point-wise feedforward layer $f: \mathbb{R}^{W_z\times H_z \times C_z} \mapsto \mathbb{R}^{W_z\times H_z \times 3}$ and, subsequently, bilinearly upsampled to image resolution ($\mathbb{R}^{W\times H \times K}$) where K is the number of classes. We could estimate the global, \textit{i.e.} image-level, uncertainty of an input, by providing the negative log-likelihood of the factorizing distribution. However, in order to also obtain pixel-wise uncertainties using MIR, we first compute the negative log-likelihood (\textit{i.e.} epistemic uncertainty) associated with each latent representation $\textbf{z}_{ij}$. Then, we bilinearly upsample the negative log-likelihoods and use the result as proxy for pixel-wise epistemic uncertainty. To obtain a global, \textit{i.e.} image-level, uncertainty we apply the same averaging scheme used for SNGP, softmax and \ac{mc} dropout.


\subsection{Dataset} \label{ssec:suppl_segmentation_dataset}
To benchmark our model on data with realistically and continuously changing environment, we collect a synthetic dataset for semantic segmentation. 
We use the CARLA Simulator~\cite{Dosovitskiy17} for rendering the images and segmentation masks. The classes definition is aligned with the CityScape dataset~\cite{Cordts2016Cityscapes}. In order to obtain a fair comparison, all the OOD data are sampled with the same trajectory and the environmental objects, except for the time-of-the-day or weather parameters. 

\paragraph{In-domain data} The data is collected from 4 towns in CARLA. We produce 32 sequences from each town. The distribution of the vehicles and pedestrians are randomly generated for each sequence. Every sequence has has 500 frames with a sampling rate of $10$ FPS. From them we randomly sample the training and validation set.

\paragraph{Out-of-domain data} Here, we consider the time-of-the-day and the rain strength as the  parameters for the continuous changing environment. In practice, these two parameters have major influence for autonomous driving tasks. 

 The change of the time-of-the-day is illustrated in Fig.~\ref{fig:carla_time}. The time-of-the-day is parametrized by the Sun's altitude angle, where $90^\circ$ means the mid-day and the $0^\circ$ means the dust or dawn. Here, we produce samples with the altitude angle changes from $90^\circ$ to $15^\circ$ by step of $5^\circ$, and $15^\circ$ to $-5^\circ$ by step of $1^\circ$ where the environment changes shapely. From these examples, we can confirm that the change of time-of-the-day leads to the major change in the lightness, color and visibility of the sky, roads and the buildings nearby.  
The effect of rain strength is demonstrated in Fig.~\ref{fig:carla_weather}. Here the cloudiness and, ground wetness and ground reflection are the main changing parameters. 
\begin{figure}[htbp]
    \def3.4cm{3.4cm}
    \centering
    \subfloat[Mid-day ($90^\circ$)]{\includegraphics[width=3.4cm]{figures/continue/90.resize.png}} \ %
    \subfloat[Afternoon ($45^\circ$)]{\includegraphics[width=3.4cm]{figures/continue/45.resize.png}} \ %
    \subfloat[Afternoon ($15^\circ$)]{\includegraphics[width=3.4cm]{figures/continue/15.resize.png}} \ %
    \subfloat[Evening ($10^\circ$)]{\includegraphics[width=3.4cm]{figures/continue/10.resize.png}} \\%
    \subfloat[Dust ($2^\circ$)]{\includegraphics[width=3.4cm]{figures/continue/3.resize.png}} \ %
    \subfloat[Sunset ($0^\circ$)]{\includegraphics[width=3.4cm]{figures/continue/0.resize.png}} \ %
    \subfloat[Sunset ($-2^\circ$)]{\includegraphics[width=3.4cm]{figures/continue/_2.resize.png}} \ %
    \subfloat[Night ($\leq -5 ^\circ$)]{\includegraphics[width=3.4cm]{figures/continue/_5.resize.png}}%
    \caption{Changing of the time-of-the-day}
    \label{fig:carla_time}
\end{figure}
\begin{figure}[htbp]
    \def3.4cm{3.4cm}
    \centering
    \subfloat[Clear]{\includegraphics[width=3.4cm]{figures/weather/clear.resize.png}} \ %
    \subfloat[Cloudy]{\includegraphics[width=3.4cm]{figures/weather/cloudy.resize.png}} \ %
    \subfloat[Small rain]{\includegraphics[width=3.4cm]{figures/weather/small_rain.resize.png}} \ %
    \subfloat[Heavy rain]{\includegraphics[width=3.4cm]{figures/weather/heavy_rain.resize.png}}
    \caption{Changing of the weather}
    \label{fig:carla_weather}
\end{figure}










