EVIDENTIAL TURING PROCESSES
Year: 2022

Abstract:
A probabilistic classifier with reliable predictive uncertainties i) fits successfully to the target domain data, ii) provides calibrated class probabilities in difficult regions of the target domain (e.g. class overlap), and iii) accurately identifies queries coming out of the target domain and rejects them. We introduce an original combination of Evidential Deep Learning, Neural Processes, and Neural Turing Machines capable of providing all three essential properties mentioned above for total uncertainty quantification. We observe our method on five classification tasks to be the only one that can excel all three aspects of total calibration with a single standalone predictor. Our unified solution delivers an implementation-friendly and compute efficient recipe for safety clearance and provides intellectual economy to an investigation of algorithmic roots of epistemic awareness in deep neural nets.

heading: 1 INTRODUCTION
text: The applicability of deep neural nets to safety-critical use cases such as autonomous driving or medical diagnostics is an active matter of fundamental research (Schwalbe & Schels, 2020). Key challenges in the development of total safety in deep learning are at least three-fold: i) evaluation of model fit, ii) risk assessment in difficult regions of the target domain (e.g. class overlap) based on which safety-preserving fallback functions can be deployed, and iii) rejection of inputs that do not belong to the target domain, such as an image of a cat presented to a character recognition system. The attention of the machine learning community to each of these critical safety elements is in steady increase (Naeini et al., 2015; Guo et al., 2017; Kuleshov et al., 2018). However, the developments often follow isolated directions and the proposed solutions are largely fragmented. Calibration of neural net probabilities focuses primarily on post-hoc adjustment algorithms trained on validation sets from in-domain data (Guo et al., 2017), ignoring the out-of-domain detection and model fit evaluation aspects. On the other hand, recent advances in out-of-domain detection build on strong penalization of divergence from the probability mass observed in the target domain (Sensoy et al., 2018; Malinin & Gales, 2018), distorting the quality of class probability scores. Such fragmentation of best practices not only hinders their accessibility by real-world applications but also complicates the scientific inquiry of the underlying reasons behind the sub-optimality of neural net uncertainties.
We aim to identify the guiding principles for Bayesian modeling that could deliver the most complete set of uncertainty quantification capabilities in one single model. We first characterize Bayesian models with respect to the relationship of their global and local variables: (a) Parametric Bayesian Models comprise a likelihood function that maps inputs to outputs via probabilistic global parameters, (b) Evidential Bayesian Models apply an uninformative prior distribution on the parameters of the likelihood function and infer the prior hyperparameters by amortizing on an input observation. Investigating the decomposition of the predictive distribution variance, we find out that the ∗Work done while at Heidelberg University, Germany.
uncertainty characteristics of these two approaches exhibit complementary strengths. We introduce a third approach that employs a prior on the likelihood parameters that both conditions on the input observations on the true model and amortizes on them during inference. The mapping from the input observations to the prior hyperparameters is governed by a random set of global parameters. We refer to the resulting approach as a (c) Complete Bayesian Model, since its predictive distribution variance combines the favorable properties of Parametric and Evidential Bayesian Models. Figure 1 gives an overview of the relationship between these three Bayesian modeling approaches.
The advantages of the Complete Bayesian Models come with the challenge of choosing an inputdependent prior. We introduce a new stochastic process construction that addresses this problem by accumulating observations from a context set during training time into the parameters of a global hyperprior variable by an explicitly designed update rule. We design the input-specific prior on the likelihood parameters by conditioning it on both the hyperprior and the input observation. As conditioning via explicit parameter updates amounts to maintaining an external memory that can be queried by the prior distribution, we refer to the eventual stochastic process as a Turing Process with inspiration from the earlier work on Neural Turing Machines (Graves et al., 2014) and Neural Processes (Garnelo et al., 2018b). We arrive at our target Bayesian design that is equipped with the complete set of uncertainty quantification capabilities by incorporating the Turing Process design into a Complete Bayesian Model. We refer to the resulting approach as an Evidential Turing Process. We observe on five real-world classification tasks that the Evidential Turing Process is the only model that excels simultaneously at model fit, class overlap quantification, and out-of-domain detection.

heading: 2 PROBLEM STATEMENT: TOTAL CALIBRATION
text: Consider the following data generating process with K modes
y|π ∼ Cat(y|π), x|y ∼ K∑ k=1 Iy=kp(x|y = k), (1)
where Cat(y|·) is a categorical distribution, Iu is the indicator function for predicate u, and p(x|y) is the class-conditional density function on input observation x. For any prior class distribution π, the classification problem can be cast as identifying the class probabilities for observed patterns Pr[y|x, π] = Cat(y|fπtrue(x)) where fπtrue(x) is a K−dimensional vector with the k-th element
fπ,ktrue(x) = πkp(x|y = k) / K∑ κ=1 πκp(x|y = κ). (2)
In many real-world cases fπtrue is not known and should be identified from a hypothesis space hπ ∈ Hπ via inference given a set of samples D = {(xn, yn)|n = 1, . . . , N} obtained from the true distribution. The risk of the Bayes classifier arg maxy Cat(y|hπ(x)) for a given input x is
R(hπ(x)) = K∑ κ=1 Iκ6=argmaxhπ(x)f π,κ true(x). (3)
For the whole data distribution, we have R(hπ) = Ex|π[R(hπ(x))]. The optimal case is when hπ(x) = f π true(x), which brings about the irreducible Bayes risk resulting from class overlap:
R∗ (f π true(x)) = min { 1−max fπtrue(x),max fπtrue(x) } . (4)
Total Calibration. Given a set of test samples Dts coming from the true data generating process in Eq. 1, we define Total Calibration as the capability of a discriminative predictor hπ(x) to quantify the following three types of uncertainty simultaneously:
i) Model misfit evaluated by the similarity of hπ(x) and fπtrue(x) measurable directly via
KL ( Cat(y|fπtrue(x))p(x) || Cat(y|hπ(x))p(x) ) =
Ep(x) [log Cat(y|fπtrue(x)] + Ep(x) [− log Cat(y|hπ(x))]
where KL(·||·) denotes the Kullback-Leibler divergence. Since Ep(x) [log Cat(y|fπtrue(x))] is a constant with respect to hπ(x), an unbiased estimator of the relative goodness of an inferred model is the negative test log-likelihood NLL(hπ(x)) = −1/|Dts| ∑ (x,y)∈Dts log Cat(y|hπ(x)).
ii) Class overlap evaluated by R∗(fπtrue(x)). As there is no way to measure this quantity from Dts, it is approximated indirectly via Expected Calibration Error (ECE)
ECE[hπ] = M∑ m=1 |Bm| N ∣∣∣acc(Bm)− conf(Bm)∣∣∣ where Bm = {(n|hπ(xn) ∈ [(m − 1)/M,m/M ]} are M bins that partition the test set Dts into Dts = B1 ∪ · · · ∪BM and are characterized by their accuracy and confidence scores
acc(Bm) = 1 |Bm| ∑ n∈Bm Iyn=argmaxhπ(xn), conf(Bm) = 1 |Bm| ∑ n∈Bm hπ(xn). (5)
iii) Domain mismatch defines the rarity of an input pattern x∗ for the target task, that is Pr[p(x = x∗) < ] for small . This quantity cannot be measured since p(x) is unknown. It is approximated indirectly as the success of discriminating between samples x∗ coming from a different data distribution and those in Dts by calculating the Area Under ROC (AUROC) curve w.r.t. hπ(x).

heading: 3 UNCERTAINTY QUANTIFICATION WITH PARAMETRIC AND EVIDENTIAL BAYESIAN MODELS
text: Parametric Bayesian Models. A commonplace design choice is to build the hypothesis space by equipping the hypothesis function with a global parameter θ that takes values from a feasible set Θ, that is Hπ = {hθπ(x)|θ ∈ Θ}. Parametric Bayesian Models (PBMs) employ a prior belief θ ∼ p(θ), which is updated via Bayesian inference on a training set Dtr as p(θ|Dtr) = ∏ (x,y)∈Dtr Cat(y|h θ π(x))p(θ)/p(Dtr). Consider the update on the posterior belief
p(θ|Dtr ∪ (x∗, y∗)) = Cat(y∗|hθπ(x∗))p(θ|Dtr)/Z, (6) after a new observation (x∗, y∗) where the normalizer can be expressed as
Z = 1
p(Dtr)
∫ Cat(y∗|hθπ(x∗))L(θ)p(θ)dθ. (7)
with L(θ) = ∏
(x,y)∈Dtr Cat(y|h θ π(x)). This can be seen as an inner product between the functions
Cat(y∗|hθπ(x∗)) and L(θ) on an embedding space modulated by p(θ). As the sample size grows, the high-density regions of Cat(y∗|hθπ(x∗)) and L(θ) will superpose with higher probability, causing Z to increase, making p(θ|Dtr ∪ (x∗, y∗)) increasingly more peaked, and consequently we will have
lim |Dtr|→+∞
V ar[θ|Dtr] = 0. (8)
This conjecture depends on the assumption that a single random variable θ modulates all samples. The variance of a prediction in favor of a class k decomposes according to the law of total variance
V ar[y∗ = k|x∗,D] = V arθ∼p(θ|Dtr)[h θ π,k(x∗)]︸ ︷︷ ︸
Reducible model uncertainty
+Eθ∼p(θ|Dtr) [ (1− hθπ,k(x∗))hθπ,k(x∗) ] ︸ ︷︷ ︸
Data uncertainty
. (9)
Due to the Eq. 8, the first term on the r.h.s. vanishes in the large sample regime and the second one coincides with the asymptotic solution of the maximum likelihood estimator θMLE . In cases when Hπ contains fπtrue(x), an ideal inference scheme has the potential to recover it and we get
lim N→+∞ Eθ∼p(θ|Dtr)
[ (1− hθπ,k(x∗))hθπ,k(x∗) ] = (1− hθMLEπ,k (x∗))h θMLE π,k (x∗)
= (1− fπtrue(x∗))fπtrue(x∗). The simple proposition below sheds light on the meaning of this result. It points to the fact that the Bayes risk of a classifier (Eq. 4) and the second component of its predictive variance (Eq 9) are proportional. This gives a mechanistic explanation for why the second term on the r.h.s. of Eq. 9 quantifies class overlap. Despite the commonplace allocation of the wording data uncertainty for this term, we are not aware of prior work that derives it formally from basic learning-theoretic concepts.
Proposition. The following inequality holds for any π, π′ ∈ [0.5, 1] pair min(1− π, π) ≥ min(1− π′, π′)⇒ (1− π)π ≥ (1− π′)π′.
Proof. Define π = 0.5+ and π′ = 0.5+ ′ for , ′ > 0. As min(1−π, π) ≥ min(1−π′, π′)⇒ ≤ ′, we get (1−π)π = (1−0.5− )(0.5+ ) = 0.25−0.25 − 2 ≥ 0.25−0.25 ′− ′2 = (1−π′)π′ The conclusion is that (1− fπtrue(x))fπtrue(x) ∝ R∗(fπtrue(x)). Hence, the second term on the r.h.s. of Eq. 9 is caused by the class overlap and it can be used to approximate the Bayes risk. Put together, the first term of the decomposition reflects the missing knowledge on the optimal value of θ that can be reduced by increasing the training set size, while the second reflects the uncertainty stemming from the properties of the true data distribution. Hence we refer to the first term as the reducible model uncertainty and the second the data uncertainty.
Evidential Bayesian Models. In all the analysis above, we assumed a fixed and unknown π that modulates the whole process and cannot be identified by the learning scheme. When we characterize the uncertainty on the class distribution by a prior belief π ∼ p(π), we attain the joint p(y, π|x) = Pr[y|x, π]p(π|x). The variance of the Bayes optimal classifier that averages over this uncertainty Pr[y|x] = ∫ Pr[y|x, π]p(π|x)dπ decomposes as
V ar[y = k|x] = V arπ∼p(π|x)[fπ,ktrue(x)]︸ ︷︷ ︸ Irreducible model uncertainty
+Eπ∼p(π|x) [ (1− fπ,ktrue(x))f π,k true(x) ] ︸ ︷︷ ︸
Data uncertainty
.
The main source of uncertainty p(π|x) is not a posterior this time but an empirical prior on a single observation x, hence its variance will not shrink as |Dtr| → +∞. Therefore, the first term on the r.h.s. reflects the irreducible model uncertainty caused by the missing knowledge about π. The second term indicates data uncertainty as in PBMs, but accounts for the local uncertainty at x caused by π. Evidential Bayesian Models (EBMs) (Sensoy et al., 2018; Malinin & Gales, 2018) suggest
p(y, π|x) = Pr[y|x, π]p(π|x) ≈ Pr[y|π]qψ(π|x) where qψ(π|x) is a density function parameterized by ψ and the dependency of the class-conditional on the input is dropped. Note that the resultant model employs uncertainty on individual data points via π, but it does not have any global random variables. The standard evidential model training is performed by maximizing the expected likelihood subject to a regularizer that penalizes the divergence of qψ(π|x) from the prior belief
arg min ψ
− ∫ logPr[y|π]qψ(π|x)dπ + βKL(qψ(π|x)||p(π)).
Although presented in the original work as as-hoc design choices, such a training objective can alternatively be viewed as β-regularized (Higgins et al., 2017) variational inference of Pr[y|π]p(π|x) with the approximate posterior qψ(π|x) (Chen et al., 2019).

heading: 4 COMPLETE BAYESIAN MODELS: BEST OF BOTH WORLDS
text: The uncertainty decomposition characteristics of PBMs and EBMs provide complementary strengths towards quantification of the three uncertainty types that constitute total calibration.
i) Model misfit: The PBM is favorable since it provides shrinking posterior variance with growing training set size (Eq. 8) and the recovery of θMLE which inherits the consistency guarantees the frequentist approach. Since the uncertainty on the local variable π does not shrink for large samples, NLL would measure how well ψ can capture the regularities of heteroscedastic noise across individual samples, which is a more difficult task than quantifying the fit of a parametric model.
ii) Class overlap: The EBM is favorable since its data uncertainty term Eπ∼p(π|x∗)[(1 − hθπ,k(x∗))h θ π,k(x∗)] is likely to have less estimator variance than Eθ∼p(θ|Dtr)[(1−hθπ,k(x∗))hθπ,k(x∗)] and calculating p(π|x∗) does not require approximate inference as for p(θ|Dtr).
iii) Domain mismatch: The PBM is favorable since the effect of the modulation of a global θ on the variance of Z applies also to the posterior predictive distribution with the only difference that x∗ is a test sample. When the test sample is away from the training set, i.e. minx∈Dtr ||x∗ − x|| is large, then p(y∗|x∗, θ) is less likely to superpose with those regions of θ where L(θ) is pronounced, hence will be flattened out leading to a higher variance posterior predictive for samples coming from another domain. Since EBM has only local random variables, the variance of its posterior is less likely to build a similar discriminative property for domain detection.
Main Hypothesis. A model that inherits the model uncertainty of PBM and data uncertainty of EBM can simultaneously quantify: i) model misfit, ii) class overlap, and iii) domain mismatch.
Guided by our main hypothesis, we combine the PBM and EBM designs within a unified framework that inherits the desirable uncertainty quantification properties of each individual approach
Pr[y|π]p(π|θ, x)p(θ), (10)
which we refer to as a Complete Bayesian Model (CBM) hinting to its capability to solve the total calibration problem. The model simply introduces a global random variable θ into the empirical prior p(π|θ, x) of the EBM. The variance of the posterior predictive of the resultant model decomposes as
V ar[y|x] = V arp(θ|D) [ Ep(π|x,θ)[E[y|π, x]] ] ︸ ︷︷ ︸
Reducible Model Uncertainty
+Ep(θ|D) [ V arp(π|θ,x)[E[y|π]] ] ︸ ︷︷ ︸
Irreducible Model Uncertainty + Ep(θ|D) [ Ep(π|x,θ)[V ar[y|π]] ] ︸ ︷︷ ︸
Data Uncertainty
(11)
where the r.h.s. of the decomposition has the following desirable properties: i) The first term recovers the form of the reducible model uncertainty term of PBM when π is marginalized V arp(θ|D)[Ep(π|x,θ)[E[y|π, x]]] = V arp(θ|D)[E[y|θ, x]]; ii) The second term is the irreducible model uncertainty term of EBM averaged over the uncertainty on the newly introduced global variable θ. It quantifies the portion of uncertainty stemming from heteroscedastic noise, which is not explicit in the decomposition of PBM; iii) The third term recovers the data uncertainty term of EBM when θ is marginalized: Ep(θ|D)[Ep(π|x,θ)[V ar[y|π]] = Ep(π|x)[V ar[y|π]].

heading: 5 THE EVIDENTIAL TURING PROCESS: AN EFFECTIVE CBM REALIZATION
text: Equipping the empirical prior p(π|θ, x) of CBM with the capability of learning to generate accurate prior beliefs on individual samples is the key for total calibration. We adopt the following two guiding principles to obtain highly expressive empirical priors: i) The existence of a global random variable θ can be exploited to express complex reducible model uncertainties using the Neural Processes (Garnelo et al., 2018b) framework, ii) The conditioning of p(π|θ, x) on a global variable θ and an individual observation x can be exploited with an attention mechanism where θ is a memory and x is a query. Dependency on a context set during test time can be lifted using the Neural Turing Machine
(Graves et al., 2014) design, which maintains an external memory that is updated by a rule detached from the optimization scheme of the main loss function. We extend the stochastic process derivation of the Neural Processes by marginalizing out a local variable from a PBM with an external memory that follows the Neural Turing Machine design and arrive at a new family of stochastic processes called a Turing Process, formally defined as below.
Definition 1. A Turing Process is a collection of random variables Y = {yi|i ∈ I} for an index set I = {1, . . . ,K} with arbitrary K ∈ N+ that satisfy the two properties
(i) pM (Y ) = ∫ ∏
yi∈Y p(yi|θ)pM (θ)dθ, (ii) pM ′(Y |Y ′) = ∫ ∏ yi∈Y p(yi|θ)pM ′(θ|Y ′)dθ,
for another random variable collection Y ′ of arbitrary size that lives in the same probability space as Y , a probability measure pM (θ) with free parameters M , and some function M ′ = r(M,Y ′).
The Turing Process can express all stochastic processes since property (i) is sufficient to satisfy Kolmogorov’s Extension Theorem (Øksendal, 1992) and choosing r simply to be an identity mapping would revert us back to the generic definition of a stochastic process. The Turing Process goes further by permitting to explicitly specify how information accumulates within the prior. This is a different approach from the Neural Process that performs conditioning p(Y |Y ′) by applying an amortized posterior q(θ|Y ′) on a plain stochastic process that satisfies only Property (i), hence maintains a data-agnostic prior p(θ) and depends on a context set also at the prediction time.
Given a disjoint partitioning of the data D = DC ∪ DT into a context set (x′, y′) ∈ DC and a target set (x, y) ∈ DT , we propose the data generating process on the target set below
p(y,DT , π, θ) = p(w) pM (Z)︸ ︷︷ ︸ External memory
∏ (x,y)∈DT [ p(y|π) p(π|Z,w, x)︸ ︷︷ ︸
Input-specific prior
] . (12)
We decouple the global parameters θ = {w,Z} into a w that parameterizes a map from the input to the hyperparameter space and an external memory Z = {z1, . . . , zR} governed by the distribution pM (Z) parameterized by M that embeds the context data during training. The memory variable Z updates its belief conditioned on the context set DC by updating its parameters with an explicit rule pM (Z|DC)← pEZ∼pM (Z)[r(Z,DC)](Z). The hyperpriors of p(π|Z,w, x) are then determined by querying the memory Z for each input observation x using an attention mechanism, for instance a transformer network (Vaswani et al., 2017). Choosing the variational distribution as qλ(θ, π|x) = qλ(w)pM (Z)q(π|Z,w, x), we attain the variational free energy formula for our target model FETP (λ) = (13)
Eqλ(w) −∑ (x,y)∈D Eqλ(π|Z,w,x) [ EpM (Z) [ log p(y|π) + log qλ(π|Z,w, x) p(π|Z,w, x) ]] + log qλ(w) p(w)  . The learning procedure will then alternate between updating the variational parameters λ via gradientdescent on FETP (λ) and updating the parameters of the memory variable Z via an external update rule as summarized in Figure 2b. ETP can predict a test sample (x∗, y∗) by only querying the input x∗ on the memory Z and evaluating the prior p(π∗|Z,w, x∗) without need for any context set as
p(y∗|Dtr, x∗) ≈ ∫∫ p(y∗|π∗)q(π∗|Z,w, x∗)pM (Z)qλ(w)dZdw. (14)

heading: 6 MOST IMPORTANT SPECIAL CASES OF THE EVIDENTIAL TURING PROCESS
text: As we build the design of the Evidential Turing Process (ETP) on the CBM framework that overarches the prevalent parametric and evidential approaches, its ablation amounts to recovering many state-of-the-art modeling approaches as listed in Table 1 and detailed below.
Bayesian Neural Net (BNN) (Neal, 1995; MacKay, 1992; 1995) is the most characteristic PBM example that parameterize a likelihood p(y|θ, x) with a neural network fθ(·) whose weights follow a distribution θ ∼ p(θ). In the experiments we assume as a prior θ ∼ N (θ|0, β−1I) and infer its posterior by mean-field variational posterior qλ(θ) applying the reparameterization trick (Kingma et al., 2015; Molchanov et al., 2017).
Evidential Deep Learning (EDL) (Sensoy et al., 2018) introduces the characteristic example of EBMs. EDL employs an uninformative Dirichlet prior on the class probabilities, which then set the mean of a normal distribution on the one-hot-coded class labels y, π ∼ Dir(π|1, . . . , 1)N (y|π, 0.5IK). EDL links the input observations to the distribution of class probabilities by performing amortized variational inference with the approximate distribution qλ(π;x) = Dir(π|αλ(x)).
Neural Processes (NP) (Garnelo et al., 2018a;b) is a PBM used to generate stochastic processes from neural networks by integrating out the global parameters θ as in Property (i) of Definition 1. NPs differ from PBMs by amortizing an arbitrary sized context set DC on the global parameters q(θ|DC) via an aggregator network during inference. NPs can be viewed as Turing Processes with an identity map r. Follow-up work equipped NPs with attention (Kim et al., 2019), translation equivariance (Gordon et al., 2020; Foong et al., 2020), and sequential prediction (Singh et al., 2019; Yoon et al., 2020). All of these NP variants assume prediction-time access to context, making them suitable for interpolation tasks such as image in-painting but not for generic prediction problems.
Evidential Neural Process (ENP) is the EBM variant of a neural process we introduce to bring together best practices of EDL and NPs and make the strongest possible baseline for ETP, defined as
p(y, π, Z|DC) = Cat(y|π)Dir ( π|αθ(Z) ) N ( Z|(µ, σ2) = r({hθ(xj , yj) | (xj , yj) ∈ DC}) ) , (15)
with an aggregation rule r(·), an encoder net hθ(·, ·), and a neural net αθ(·) mapping the global variable Z to the class probability simplex. We further improve upon ENP with an attentive NP approach (Kim et al., 2019) by replacing the fixed aggregation rule r with an attention mechanism, thereby allowing the model to switch focus depending on the target. At the prediction time, we use Z ∼ N (Z|1, κ2I) for small κ to induce an uninformative prior on π in the absence of a context set.

heading: 7 CASE STUDY: CLASSIFICATION WITH EVIDENTIAL TURING PROCESSES
text: We demonstrate a realization of an Evidential Turing Process to a classification problem below
y, π, w, Z|M ∼ Cat(y|π)Dir ( π| exp(a(vw(x);Z)) ) N (v|0, β−1I) R∏ r=1 N (zr|mr, κ2I). (16)
The global variable Z is parameterized by the memory M = (m1, . . . ,mR) consisting of R cells mr ∈ RK .1 The input data x is mapped to the same space via an encoding neural net vw(·) parameterizing a Dirichlet distribution over the class probabilities π via an attention mechanism a(vw, z) = ∑ z′∈Z φ(vw(x), z ′)z, where φ(vw(x), z) = softmax({kψ(z)>vw(x)/ √ K|z ∈ Z}). The function kψ(·) is the key generator network operating on the embedding space. We update the memory cells as a weighted average between remembering and updating
m← EZ∼p(Z|M) tanh(γm+ (1− γ) ∑ (x,y)∈DC φ(vw(x), z)[onehot(y) + soft(vw(x))] ) (17)
where γ ∈ (0, 1) is a fixed scaling factor controlling the relative importance. The second term adds new information to the cell as a weighted sum over all pairs (x, y), taking both the true label (via onehot(y)) as well as the uncertainty in the prediction (via soft(vθ(x))) into account. The final tanh(·) transformation ensures that the memory content remains in a fixed range across updates, as practised in LSTMs (Hochreiter & Schmidhuber, 1997).

heading: 8 EXPERIMENTS
text: We benchmark ETP against the state of the art as addressed in the ablation plan in Table 1 according to the total calibration criteria developed in Sec. 2 on five real-world data sets. See the Appendix B for full details on the experimental setup in each case and for the hyperparameters used throughout. We provide a reference implementation of the proposed model and the experimental pipeline.2
Total calibration. Table 2 reports the prediction error and the three performance scores introduced in Sec. 2 that constitute total calibration. We perform the out-of-domain detection task as in Malinin & Gales (2018) and classify the test split of the target domain and a data set from another domain based on the predictive entropy. ETP is the only method that consistently ranks among top performers in all data sets with respect to all performance scores, which supports our main hypothesis that CBM should outperform PBM and EBM in total calibration.
Response to gradual domain shift. In order to assess how well models can cope with a gradual transition from their native domain, we evaluate their ECE performance on data perturbed by 19 types of corruption (Hendrycks & Diet-
terich, 2019) at five different severity levels. Figure 3 depicts the performance of models averaged across all corruptions. ETP gives the best performance nearly in all data sets and distortion severity levels (see Appendix B.3 Table 4 for a tabular version of these results).
Computational cost. We measured the average wall-clock time per epoch in CIFAR10 to be 10.8± 0.1 seconds for ETP, 8.2± 0.1 seconds for BNN, 8.6± 0.1 seconds for EDL, and 9.5± 0.2 seconds for ENP. The relative standings of the models remain unchanged in all the other data sets.
1In the experiments we fix κ2 = 0.1. Preliminary results showed stability as well for larger/smaller values. 2https://github.com/ituvisionlab/EvidentialCalibration

heading: 9 CONCLUSION
text: Summary. We initially develop the first formal definition of total calibration. Then we analyze how the design of two mainstream Bayesian modeling approaches affect their uncertainty characteristics. Next we introduce Complete Bayesian Models as a unifying framework that inherits the complementary strengths existing ones. We develop the Evidential Turing Process as an optimal realization of Complete Bayesian Models. We derive an experiment setup from our formal definition of total calibration and a systematic ablation of our target model into the strongest representatives of the state of the art. We observe in five real-world tasks that the Evidential Turing Process is the only model that can excel all three aspects of total calibration simulatenously.
Broad impact. Our work delivers evidence for the claim that epistemic awareness of a Bayesian model is indeed a capability learnable only from in-domain data, as appears in biological intelligence via closed-loop interactions of neuronal systems with stimuli. The implications of our work could follow up in interdisciplinary venues, with focus on the relation of associative memory and attention to the neuroscientific roots of epistemic awareness (Lorenz, 1978).
Limitations and ethical concerns. While we observed ETP to outperform BNN variants in our experiments, whether BNNs could bridge the gap after further improvements in the approximate inference remains an open question. The attention mechanism of ETP could also be improved, for instance to transformer nets (Vaswani et al., 2017). The explainability of the memory content of ETP deserves further investigation. The generalizeability of our results to very deep architectures, such as ResNet 152 or DenseNet 161 could be a topic of a separate large-scale empirical study. ETP does not improve the explainability and fairness of the decisions made by the underlying design choices, such as the architecture of the used neural nets in the pipeline. Potential negative societal impacts of deep neural net classifiers stemming from these two factors need to be circumvented separately before the real-world deployment of our work.

heading: APPENDIX

heading: A FURTHER ANALYTICAL RESULTS AND DERIVATIONS

heading: A.1 KULLBACK LEIBLER BETWEEN TWO DIRICHLET DISTRIBUTIONS
text: As both our ETP and and the EDL baseline use the Kullback-Leibler divergence between two Dirichlet distributions, we give the full details of its calculation here. For two distributions over a K-dimensional probability π, Dir(π|α) and Dir(π|β), parameterized by α, β ∈ RK+ , the following identity holds KL ( Dir(π|α) ‖ Dir(π|β) ) = log ( Γ( ∑ k αk) ∏ k Γ(βk)
Γ( ∑ k βk) ∏ k Γ(αk) ) + ∑ k (αk − βk) ( ψ(αk)− ψ( ∑ k αk) ) ,
where Γ(·) and ψ(a) := dda log Γ(a) are the gamma and digamma functions (Abramowitz & Stegun, 1965).

heading: A.2 THE EVIDENTIAL DEEP LEARNING OBJECTIVE
text: The analytical expression of the Evidential Deep Learning (Sensoy et al., 2018) loss as defined in the main paper can be computed as follows. For a single K-dimensional observation y, dropping the n from the notation and instead using the index for the dimensionality throughout the following equations, we have
Ep(π|x) [ ||y − π||2 ] = Ep(π|x) [ (y − π)>(y − π) ] =
K∑ k=1 Ep(π|x) [ (yk − πk)2 ] =
K∑ k=1 Ep(π|x) [ (yk − Ep(π|x) [πk] + Ep(π|x) [πk]− πk)2 ] =
K∑ k=1 (yk − Ep(π|x) [πk])2 + varp(π|x) [πk] ,
with the tractable expectation and variance of a Dirichlet distributed π. The Kullback-Leibler term is between two Dirichlet distributions and given (see the general form in A.1) as
KL (Dir(π|αθ(x)) ‖ Dir(π|1, . . . , 1))
= log
( Γ (∑ k αθ(x)k )
Γ(K) ∏ k Γ(αθ(x)k)
) +
K∑ k=1 (αθ(x)k − 1) ( ψ(αθ(x)k)− ψ (∑ k αθ(x)k )) .

heading: A.3 EVIDENTIAL DEEP LEARNING AS A LATENT VARIABLE MODEL
text: As discussed in the main paper for a set of N observations D = {(x1, y1), . . . , (xN , yN )}, the EDL objective minimizes is given as
LEDL = N∑ n=1 Ep(πn|xn) [ ||yn − πn||22 ] + λKL ( p(πn|xn) ‖ Dir(πn|1, . . . , 1) ) ,
where p(πn|xn) = Dir(π|αθ(xn)). We can instead assume the following generative model
πn ∼ Dir(πn|1, . . . , 1) ∀n yn ∼ N (yn|πn, 0.5IK) ∀n,
i.e. latent variables πn and K-dimensional observations yn following a multivariate normal prior. Approximating the intractable posterior p(π|y), where π = (π1, . . . , πn), y = (y1, ..., yn), with an
amortized variational posterior q(πn;xn) = Dir(πn|αθ(xn)), where αθ(·) is the same architecture as in the EDL model, we have as the evidence lower bound (ELBO) to be maximized
N∑ n=1 Eq(πn;xn) [log p(yn|πn)]− KL ( q(πn;xn) ‖ p(πn) ) =
N∑ n=1 Eq(πn;xn) [ −1 2 log(2π) + K 2 log(2)− (yn − πn)>(yn − πn) ] − KL ( q(πn;xn) ‖ p(πn) ) = const−
N∑ n=1 Eq(πn;xn) [ (yn − πn)>(yn − πn) ] − KL ( q(πn;xn) ‖ p(πn) ) = const− LEDL,
that is the negative ELBO is equal to the EDL loss up to an additive constant.

heading: A.4 POSTERIOR PREDICTIVE
text: For a new input observation x∗, the corresponding posterior predictive distribution on the output y∗ can be computed as
p(y∗ = k|x∗,D) ≈ Ep(Z|M) [ Eqλ(π|x∗,Z) [p(y ∗ = k|π)] ] = Ep(Z|M) [ hkθ /∑ k′ h k′ θ ] ,
where hkθ = hθ (vθ(x ∗), a(vθ(x ∗);Z))k. That is, we can compute it analytically up to a samplingbased evaluation of the expectation over p(Z|M).

heading: B EXPERIMENTAL DETAILS

heading: B.1 SYNTHETIC 1D TWO-CLASS CLASSIFICATION
text: We illustrate the qualitative behaviour of ETP on a synthetic 1d two-class classification task. The data consist of observations (20 per class) from two highly overlapping Gaussian distributions. The neural net, a simple one hidden layer architecture, can learn the task with high accuracy. Figure 4 shows the raw data and underlying distributions as well as the learned memory evidence. The model learns to place more evidence on the correct class further away from the decision boundary while also becoming more varied with increasing distance. Within the high-density region, the asymmetry in how the specific observations are spread out leads to an asymmetry in the memory evidence. Below zero, the blue points are clearly separated, leading to a quick emphasis on that class as we move towards the left. Above zero, however, some blue observations in the orange region prevent the model from rapidly developing over-confidence.
This synthetic data set consisting of two classes with 20 observations each sampled from standard normal distributions centered at±1 respectively. The encoding function vφ(·) consists of a multi-layer perceptron with a single hidden layer consisting of 32 neurons and a ReLU activation function. It is optimized for 400 epochs with the Adam optimizer (Kingma & Ba, 2015) using the PyTorch (Paszke et al., 2019) default parameters and a learning rate of 0.001. In order to keep the model as simple
as possible, the key generator function kλ(·) is constrained to being the identity function, while hξ ( v(x), a(v(x);Z) ) = v(x) + tanh(a(v(x);Z). The memory update is simplified to dropping the tanh(·) rescaling.
B.2 IRIS 2D THREE-CLASS CLASSIFICATION
The data set used in this experiment is the classical Iris data set3 consisting of 150 samples of three iris species (50 per class), with four features measured per sample. We first map the data to the first two principal components for visualization and also use this modified version as the training data. This gives an interpretable toy learning setup where one class is clearly separated from the other two overlapping classes. The encoding function vφ(·) consists of an MLP with two hidden layers of 32 neurons each and ReLU activation functions. We train it for 400 epochs with the Adam optimizer using the PyTorch default parameters and a learning rate of 0.001. In order to keep the model as simple as possible, we constrain the key generator function kλ(·) to the identity function while setting hξ ( v(x), a(v(x);Z) ) = v(x) + tanh(a(v(x);Z). We simplify the memory update by dropping the tanh(·) rescaling. Figure 5 shows the varying importance the model assigns to different parts of the input space depending on the class under consideration. For the separate blue class, the model is significantly more confident in relative terms and absolute values.

heading: B.3 EXPERIMENTS ON REAL DATA
text: All experiments are implemented in PyTorch (Paszke et al., 2019) version 1.7.1 and trained on a TITAN RTX. They have been replicated ten times over random initial seeds.
Fashion MNIST (FMNIST). We use a LeNet5-sized architecture (see Table 3). The out-ofdistribution data is the MNIST (LeCun et al., 2010) data set. We z-score normalize all data sets with the in-domain mean and standard deviations. We train each model for 50 epochs with the Adam optimizer (Kingma & Ba, 2015) using a learning rate of 0.001.
3Originally due to Fisher (1936) and Anderson (1935). We rely on the version provided by the scikit learn library, see https://scikit-learn.org/stable/modules/classes.html# module-sklearn.datasets.
CIFAR10 (C10). We use a LeNet5-sized architecture (see Table 3). The out-of-distribution data is the SVHN (Netzer et al., 2011). We z-score normalize all data sets with the in-domain mean and standard deviations. We further rely on data augmentation for the in domain data using random crops with 32 pixels and four pixel padding as well as horizontal flips. We train each model for 100 epochs using the Adam optimizer (Kingma & Ba, 2015) with a learning rate of 0.0001.
SVHN. We use a LeNet5-sized architecture (see Table 3). The out-of-distribution data is the CIFAR10 data set. We z-score normalize all data sets with the in-domain mean and standard deviations. We train each model for 100 epochs using the Adam optimizer (Kingma & Ba, 2015) with a learning rate of 0.0001.
IMDB Sentiment Classification. We use a LSTM architecture with 64 embedding dimensions and 2 layers with 256 hidden dimensions. We generate the out-of-distribution data by sampling values from the [1, 1000]interval uniformly at random. We train each model for 20 epochs using the SGD optimizer (Robbins & Monro, 1951) with a learning rate of 0.05 and 0.9 momentum. For data preparation, we follow the source code of the original work 4.
Shared Details and Observations. In all experiments, we train the BNN models with a crossentropy loss using softmax as the squashing function to calculate class probabilities. The EDL model is trained with the original loss (Sensoy et al., 2018). We make our predictions with the mean of the Dirichlet distribution as in the original work. For all models, we use entropy as the criterion for detecting out-of-distribution instances.
4https://www.kaggle.com/arunmohan003/sentiment-analysis-using-lstm-pytorch
Robustness against perturbations. We use the CIFAR10-C dataset in the same setup as in original work tHendrycks & Dietterich (2019). As FMNIST-C and SVHN-C are not available, we create them following the same procedure as in the original work. For FMNIST we adapt the procedure to gray-scale images by replicating the image three times for each channel. After applying the distortions, we map it back to the gray scale. Table 4 gives the numerical results used to create Figure 3 in the main paper.

Review summaries:
The paper presents a complete Bayesian model that combines strengths of parametric and evidential Bayesian models.  An instance of this model is an Evidential Turing Process (ETP) -- a model in which the prior on the global variable that governs the likelihood function is input-dependent, and this dependence is established in a way similar to the Neural Turing Machines. Unlike Neural Processes (NPs), it doesn't need a context set during test time as the context is extracted from the training set and stored in a memory variable. Experiments show that  ETPs are somewhat better than BNNs and evidential NPs.

The paper introduces a “Complete Bayesian Model” that combines the benefits of Parametric Bayesian Models and Evidential Bayesian Models. To this end, the authors propose a technique to learn an input-dependent prior. The experiments showcase the efficacy of the method compared to the baselines.

This paper introduces the category of complete Bayesian models, with the goal of providing both in-domain uncertainty quantification (that is, calibration) and and out-of-domain detection. Concretely, the authors develop the evidential Turing process as an implementation of complete Bayesian model. The approach is experimentally validated by experiments on FMNIST, CIFAR10 and SVHN, showing that the evidential Turing process is competitive on all criteria.