Generalized Variational Inference in Function Spaces: Gaussian Measures meet Bayesian Deep Learning
Abstract
We develop a framework for generalized variational inference in infinitedimensional function spaces and use it to construct a method termed Gaussian
Wasserstein inference (GWI).
GWI leverages the Wasserstein distance between
Gaussian measures on the Hilbert space of square-integrable functions in order to determine a variational posterior using a tractable optimization criterion. It avoids pathologies arising in standard variational function space inference.
An exciting application of GWI is the ability to use deep neural networks in the variational parametrization of GWI, combining their superior predictive performance with the principled uncertainty quantification analogous to that of Gaussian processes.
The proposed method obtains state-of-the-art performance on several benchmark datasets.
Introduction
In the past decade, considerable effort has been invested in developing Bayesian deep learning approaches [Welling and Teh, 2011, Chen et al., 2014, Blundell et al., 2015, Gal and Ghahramani, 2016, Kendall and Gal, 2017, Ritter et al., 2018, Khan et al., 2018, Maddox et al., 2019].
There are at least two key advantages to Bayesian models.
Firstly, Bayesian model averaging is known to improve predictive performance [Komaki, 1996] even in misspecified situations [Fushiki, 2005, Ramamoorthi et al., 2015].
The empirical success of methods such as deep ensembles [Lakshminarayanan et al., 2017] may be interpreted as compelling evidence for this claim [Wilson and Izmailov, 2020].
Secondly, Bayesian models provide the user with a predictive distribution for an unseen data point.
This can be naturally leveraged to quantify posterior uncertainty.
Even though impressive progress has been made, there are problems that remain unresolved.
The prior distribution for the unknown function is typically induced by a prior distribution over deep neural network weights (and biases).
It is hard to interpret the inductive bias in a function space that is induced by such priors for weights and unclear how one might incorporate prior knowledge about the unknown function.
Additionally, the resulting inference problem is extremely high-dimensional and requires approximation techniques that are either computationally expensive [Neal, 2012] or so crude that the approximate posterior may suffer from pathological behavior [Foong et al., 2020].
The difficulties of performing Bayesian inference for weights have led to the emergence of methods that approach the problem in function space directly [Ma et al., 2019, Sun et al., 2019, Rudner et al., 2020,
Ma and Hernández-Lobato, 2021].
The theory of constructing prior distributions in function spaces is well developed and the most famous class of prior distributions are Gaussian processes .
They have been commonly used for decades in the machine learning community to elicit interpretable functional priors and are known to have well-calibrated predictive uncertainties [Rasmussen, 2003].
In a separate thread of research, a new powerful inference framework called Generalized Variational
Inference (GVI) has been recently developed [Knoblauch et al., 2019].
The authors argue that standard assumptions of Bayesian inference such as well-specified priors, well-specified likelihoods and infinite computing power are often violated in practice.
They therefore propose a generalized view on Bayesian inference that takes these points into consideration.
We extend the work of Knoblauch et al.
[2019] to situations where no probability density functions for the prior exist and are thus able to use generalized variational inference in infinite-dimensional function spaces directly.
We then specify both the prior and variational measures as Gaussian measures and measure their dissimilarity using the Wasserstein distance.
This results in the method which we call Gaussian Wasserstein Inference in Function Spaces (GWI-FS).
An exciting application of our method is the ability to equip deep neural networks with uncertainty quantification using the framework analogous to that of Gaussian processes, resulting in a state-of-the-art method termed GWI-net .
Our main contributions are:
• We create a general framework for inference in function space based on Gaussian measures on the space of square-integrable functions, • We derive an objective function that can be expressed in terms of the parameters of the Gaussian measures , • We derive a tractable approximation to our objective function that is valid for (almost) arbitrary kernels and mean functions, • We demonstrate the utility of our method by obtaining state-of-the-art results on the UCI regression datasets and on Fashion MNIST and CIFAR 10 3 .
Related Work
GWI-FS draws on the work developed in the Gaussian process literature, but can be used to equip traditional neural network architectures with uncertainty.
We therefore give a brief overview of the relevant related methods in both the Bayesian neural network (BNNs) and Gaussian process community.
Bayesian neural networks
Traditionally Bayesian neural networks have been assigned priors in weight space.
The effects of various priors on inference and uncertainty quantification are still not well understood [Fortuin et al., 2021].
As the posterior (over weights) is intractable, sampling algorithms such as Hamiltonian Monte Carlo (HMC) were initially proposed Neal [2012].
Due to the unfavorable scaling properties of standard HMC which requires the full gradient, batch-size approximations of HMC evolved [Chen et al., 2014].
Another line of research exploits Langevin dynamics to generate posterior samples [Welling and Teh, 2011] in weight space.
Variational methods for BNNs in weight space
In variational inference, the true posterior is approximated by a more tractable so-called variational distribution.
The user specifies a class of approximate posterior measures and selects the best posterior approximation by maximizing the so-called evidence lower bound (ELBO).
The Bayes by Backprop [Blundell et al., 2015] method is one such variational mean-field approximation of the weight-space posterior.
In variational dropout [Gal and Ghahramani, 2016], a specific approximation is chosen to reinterpret dropout [Srivastava et al., 2014] at test time as a variational procedure.
Variational methods for BNNs in function spaces Inference in weight space is challenging, as the problem is typically high-dimensional and the posterior distribution over weights multi-modal.
This led to a line of research in which inference algorithms are formulated in function spaces.
Variational implicit processes [Ma et al., 2019] approximate the BNN posterior as a linear combination of draws from the prior.
Functional-BNN [Sun et al., 2019] matches a BNN to a functional prior (for example a GP) and performs inference by optimising a functional Kullback-Leibler (KL) divergence exploiting score function estimators [Li and Turner, 2017, Shi et al., 2018].
Rudner et al.
[2020] use a local approximation to the prior and variational posterior processes to obtain a tractable functional Kullback-Leibler divergence.
Ma and Hernández-Lobato [2021] generalise the variational family in Ma et al.
[2019] and obtain a more scalable procedure by using a different approximation to the functional KL-divergence.
Recent work has also proposed to adapt BNN priors to interpretable functional priors by minimizing the Wasserstein distance between a BNN prior and a Gaussian process [Tran et al., 2020].
Another line of research exploits the Wasserstein gradient flow and tries to encourage diversity in the function space [D’Angelo et al., 2021, D’Angelo and Fortuin, 2021].
Gaussian processes
Standard Gaussian process regression [Rasmussen, 2003] allows interpretable prior specification but scales poorly with respect to the number of data points.
As a result, a plethora of approximation techniques are introduced.
On one hand, there are variational approximations to the true posterior [Titsias, 2009, Hensman et al., 2013] and several extensions [Hensman et al., 2017,
Salimbeni et al., 2018, Dutordoir et al., 2020].
On the other hand, GPU utilization is combined with
Krylov subspace methods to obtain scalability [Gardner et al., 2018, Wang et al., 2019].
Background
In this section we give some background on generalized variational inference in infinite dimensions and introduce Gaussian measures in Hilbert spaces.
We further discuss their relation to the more familiar Gaussian processes at the end.
3.1 Generalized Variational Inference in Function Spaces
In functional variational inference, we assign a prior p ( f ) to the unknown function f ∈ E , where E is a function space 4 .
The prior is combined with the likelihood p ( y | f ) to give the posterior p ( f | y ) .
The posterior is often intractable which is why in variational inference we specify a tractable variational approximation q ( f ) to p ( f | y ) and train our model by maximising the evidence lower bound (ELBO)
[Equation]
where D KL denotes the KL divergence.
Note that in the case where E is infinite dimensional p ( f ) and q ( f ) cannot be probability density functions with respect to the Lebesgue measure [see e.g.
Hunt et al., 1992, for a discussion], which is why the above notation, although commonly used, is imprecise.
What we in fact mean are the probability measures over E associated with the prior and variational approximation.
We will denote these measures as P F and Q F from now on to make this difference explicit.
The ELBO in this notation reads as
[Equation]
Note that the KL divergence (for measures) is defined as
[Equation]
where we assume that Q F is dominated by the measure P F which guarantees the existence of the
Radon-Nikodym derivative d Q F /d P F .
A number of papers focus on obtaining tractable approximations of (3)
[Sun et al., 2019, Rudner et al., 2020, Ma and Hernández-Lobato, 2021].
However, the use of KL-divergence in infinite-dimensional function spaces can be a delicate task, since benign constructions of priors and variational approximations may not satisfy that Q F is dominated by P F which leads to D KL (cid:0) Q F , P F (cid:1)
= ∞
[Burt et al., 2020].
This often renders the objective (2) useless or at least problematic.
A true Bayesian is committed to the use of the KL divergence in (2) as maximizing L is equivalent to minimizing the KL divergence between the true posterior measure and the variational measure.
This equivalence is typically demonstrated using pdfs but the argument generalizes to infinite dimensions as is shown for GPs in Matthews et al.
[2016] or in a more measure theoretic formulation in Theorem 4 of Wild and Wynne [2021].
However, Knoblauch et al.
[2019] argue that given the problems of prior and likelihood specification as well as available compute, an axiomatically justified way of moving from prior to posterior beliefs is by solving a more general optimization problem [Knoblauch et al., 2019, Theorem 15].
Crucially it is valid to replace the KL-divergence by an arbitrary measure of dissimilarity D satisfying D ( Q F , P F ) ≥ 0 and D ( Q F , P F ) =
⇒ Q F = P F .
The arguments in Knoblauch et al.
[2019] are made assuming the existence of a pdf for the prior, but they rely solely on a reformulation of Bayesian inference as optimization problem [Knoblauch et al., 2019, Chapter 2].
We show in Appendix A.1 that this reformulation can also be made for infinite-dimensional prior measures and therefore consider the generalized loss
[Equation]
a valid optimization objective for an arbitrary dissimilarity measure D .
This is merely an infinitedimensional version of equation (10) in Knoblauch et al.
We refer to inference targeting the objective (4) as Generalized variational inference in function space (GVI-FS).
Generalised variational inference can be interpreted as regularised loss minimisation lifted into the space of probability measures.
The first term in (4) is understood as a loss which we want to minimise on average, while the second term punishes strong deviations from the prior.
The particular instance of GVI-FS that we explore is where both P F and Q F are Gaussian measures (on an infinite-dimensional Hilbert space) and D is chosen to be the Wasserstein metric [Kantorovich, 1960].
We will refer to this setting as Gaussian Wasserstein Inference in Function Space (GWI-FS) or more consciously as Gaussian Wasserstein Inference (GWI)
3.2 Gaussian Random Elements and Gaussian Measures in Hilbert spaces
In this section we introduce Gaussian random elements (GRE) and Gaussian measures in Hilbert spaces – these concepts are somewhat technical but crucial in the construction of our method.
We then describe their close relationship to the more familiar Gaussian process notions in the next section.
Let (cid:0) Ω , A , P (cid:1) be the underlying (physical) probability space and (cid:0) H, ⟨· , ·⟩ (cid:1) be a Hilbert space.
Gaussian random elements
A measurable function F : Ω → H is called GRE (in H ) if and only if ⟨ F, h ⟩ : Ω → R has a scalar Gaussian distribution for all h ∈ H .
Every GRE F has a mean element m ∈ H defined by
[Equation]
and a (linear) covariance operator C : H → H defined by
[Equation]
6) for h ∈ H .
Both integrals are to be understood as Bochner integrals [Kukush, 2020, Chapter 3].
The
Bochner integral has the property that (cid:10) (cid:82) F ( ω ) d P ( ω ) , h ⟩ = (cid:82) ⟨ F ( ω ) , h ⟩ d P ( ω ) for all h ∈ H .
This combined with Fubini’s theorem and the definition of a GRE implies that
[Equation]
for any h ∈ H with N ( µ, σ 2 ) denoting the normal distribution with mean µ ∈ R and variance σ 2 > 0 .
Similarly we denote F ∼ N ( m, C ) for a GRE in H with mean element m and covariance operator C .
It can be shown that the covariance operator C of a GRE is a positive self-adjoint trace-class operator.
Conversely, for every positive self-adjoint trace class operator and every m ∈ H , there exists a GRE with F ∼ N ( m, C )
[Bogachev, 1998, Theorem 2.3.1].
Gaussian measures
The push-forward measure of P through F is defined as P F ( A ) :=
P (cid:0) F − 1 ( A ) (cid:1) for all Borel-measurable A ⊂ H .
If F ∼ N ( m, C ) is a GRE, we call P := P F a GM and write P = N ( m, C ) .
Note that GMs or equivalently GREs allow us to specify probability distributions over (infinite-dimensional)
Hilbert spaces by using a given mean element and a given covariance operator.
Details about Gaussian Measures in Hilbert spaces can be found in Chapter 2 of Da Prato and Zabczyk [2014] or in Kukush [2020].
In fact, Gaussian measures can be defined on even more general linear spaces such as Banach or Fréchet spaces [Bogachev, 1998].
3.3 Gaussian Processes and Their Corresponding Measures
In this section we describe how Gaussian processes – a standard tool to assign functional priors in
Bayesian machine learning – are related to Gaussian measures.
Let (cid:0) Ω , A , P (cid:1) be the underlying (physical) probability space and X ⊂ R D be measurable.
The (product-) measurable mapping G : Ω × X
→ R is called a Gaussian process (GP) if and only if for all N ∈ N and all X = { x n } Nn =1 ⊂
X the random vector G ( X ) :
= (cid:0) G ( · , x 1 ) , . . .
, G ( · , x N ) (cid:1) T is multivariate Gaussian.
For a GP G we define a mean function m ( x ) :
= E (cid:2) G ( x ) (cid:3) , x ∈ X , and a covariance function by k ( x, x ′ ) :
=
C [ G ( x ) , G ( x ′ ) (cid:3) for x, x ′ ∈ X .
Here E denotes the expected value and C [ · , · ] the covariance.
It follows from the definition that G ( X ) ∼ N (cid:0) m ( X ) , k
( X, X ) (cid:1) for any { x n } Nn =1 ⊂ X , where we define m ( X ) :
= (cid:0) m ( x n ) (cid:1) N n =1 and k ( X, X ) :
= (cid:0) k
( x n , x n ′ )
(cid:1) N n,n ′ =1 .
We write G ∼ GP ( m, k ) for a GP with mean function m and covariance function k .
Note that by the properties of the covariance we know that k ( X, X ) is a (symmetric) positive semi-definite matrix for all { x n } Nn =1 ⊂ X and N ∈ N .
A function with this property is called kernel , a terminology that we adopt henceforth.
Kolmogorov’s existence theorem [Billingsley, 2008, Section 36] guarantees the existence of a Gaussian process for any kernel k and any mean function m .
The standard reference for Gaussian processes in machine learning is Rasmussen [2003].
The main advantage of Gaussian processes in specifying priors over a function space is that the kernel k allows us to incorporate readily interpretable prior assumptions, such as smoothness or periodicity.
For example, choosing the squared exponential kernel
[Rasmussen, 2003] implies that the unknown function is infinitely differentiable and that the correlation of the functional output is higher the closer the inputs are.
In order to insert the Gaussian process prior into our generalized loss in (4) we need to know the probability measure that is associated to the Gaussian process.
In general, we can associate more than one Gaussian measure with a given Gaussian process.
For example:
• If the GP has continuous sample paths we can associate a Gaussian measure on the space E of continuous functions with it [Lifshits, 2012, Example 2.4].
• If the GP has square-integrable sample paths we can associate a Gaussian measure on the Hilbert space of square-integrable functions with it (cf.
Theorem 1).
These sample path properties can be guaranteed under additional assumptions on the kernel.
The next theorem discusses one such kernel condition which guarantees the GP to have sample paths in the Hilbert space of square integrable functions, denoted L 2 ( X , ρ, R ) , with inner product ⟨ g, h ⟩ 2 :=
(cid:82)
X g ( x ) h ( x ) dρ ( x ) .
Theorem 1.
Let F ∼ GP ( m, k ) be a GP with mean m ∈ L 2 ( X , ρ, R ) and kernel k such that
[Equation]
We call a kernel satisfying (8) trace-class kernel.
Then the mapping (cid:101) F : Ω → L 2 ( X , ρ, R ) defined as (cid:101) F ( ω ) :
= F ( ω, · ) is a Gaussian random element with mean m and covariance operator C given as
[Equation]
(9) for any g ∈ L 2 ( X , ρ, R ) .
Consequently P :=
P F ∼ N ( m, C ) is a Gaussian measure.
Proof.
The fact that (cid:101) F as defined above is a GRE follows immediately from Example 2.3.16 in
Bogachev [1998].
The fact that m is its mean and C as defined in (9) is its covariance operator follows from Fubini’s theorem.
It shall be noted that there is no need to appeal to GPs in order to justify the use of GMs.
In fact, it has recently been demonstrated that variational inference for GPs can be formulated purely in terms of
GMs [Wild and Wynne, 2021].
In the following sections we will therefore deploy GMs without any reference to GPs, but it is of course always possible to think of them as the measures that correspond to GPs where the kernel satisfies an additional assumption such as (8).
Gaussian Wasserstein Inference in Function Spaces
This section describes how the Wasserstein distance between Gaussian measures can be used to obtain a tractable optimization target for inference in function spaces.
In the end, we discuss several parametrizations of GWI and introduce our main inference method - the GWI-net.
4.1 Model description
Let { ( x n , y n ) } Nn =1 ⊂ X
× Y be N ∈ N paired observations.
We assume that X ⊂ R D , D ∈ N and further that
Y = R for regression and Y = { 1 , . . .
, J } for classification with J ∈ N classes.
We focus in our exposition here on the regression case but have given the relevant derivations for classification in Appendix A.6.
As pointed out in section 3.1, GVI in function space minimises the generalized loss L = − E Q (cid:2) log p ( y | F ) (cid:3)
+ D (cid:0) Q F , P F (cid:1) .
We make the mild assumption that the unknown function f is square integrable with respect to the data distribution ρ on X which means f ∈ E =
L 2 ( X , ρ, R ) .
The prior P := P F is described by a Gaussian measure with mean m
P ∈ L 2 ( X , ρ, R ) and covariance operator C P described by a trace-class kernel k :
X × X
→ R which means it is given as ( C P f )( x ) := (cid:82) X
k
( x, x ′ )
f ( x ′ ) dρ
( x ′ ) for all f ∈ L 2 ( X , ρ, R ) .
We assume a Gaussian likelihood for y :=
( y 1 , . . .
, y N )
given as p ( y | f )
:= (cid:81)
Nn =1 p ( y n | f ) 6 with
[Equation]
(10) where N ( · | µ, σ 2 ) denotes the pdf of a normal distribution with mean µ ∈ R and variance σ 2 > 0 .
This prior and likelihood are natural choices as they mimic the standard formulation of Gaussian process regression.
The variational approximation of the posterior is chosen to be another Gaussian measure Q :=
Q F with arbitrary mean m Q ∈ L 2 ( X , ρ, R ) and arbitrary covariance operator C Q induced by a trace-class kernel r : ( C Q f )( x ) :
= (cid:82)
X r ( x, x ′ )
f ( x ′ ) dρ
( x ′ ) for all f ∈ L 2 ( X , ρ, R ) .
It remains for us to select a dissimilarity measure D .
As already pointed out in the introduction we decide to use the Wasserstein distance W 2 (a formal definition is given in Appendix A.3).
This choice was guided by two considerations:
The Wasserstein metric was proven to be a useful metric for probability distributions in machine learning applications
[Arjovsky et al., 2017, Tran et al., 2020].
Furthermore the Wasserstein metric is known to have desirable statistical properties [Panaretos and Zemel, 2019].
The Wasserstein distance is tractable for arbitrary Gaussian measures on (separable)
Hilbert spaces [Gelbrich, 1990] and given as
[Equation]
where tr denotes the trace of an operator and C 1 / 2 P is the square root of the positive, selfadjoint operator C P .
This is in stark contrast to the KL-divergence that is infinite whenever Q F is not dominated by P F and even in the case where it is finite there exists no explicit formula for the KL-divergence in infinite dimensions.
The generalized loss for our model is therefore given as
[Equation]
Note that the expected log-likelihood in (12) can be calculated analytically as
[Equation]
It remains to produce an approximation of (11) in order to obtain a tractable inference procedure.
To this end, note that by definition ∥
m P − m Q |
= (cid:82) (cid:0) m P ( x ) − m Q ( x ) (cid:1) 2 dρ ( x ) and further tr ( C P ) = (cid:82) k
( x, x ) dρ ( x ) [Brislawn, 1991].
We now replace the true input distribution ρ with the empirical data distribution (cid:98) ρ :
= 1 N (cid:80) Nn
=
δ x n , where δ x denotes the Dirac measure in x ∈ X .
This gives ∥ m P − m Q ∥ 22 ≈ 1 N (cid:80) Nn =1 (cid:0) m P ( x n ) − m Q ( x n ) (cid:1) 2 , tr ( C P )
≈ 1 N (cid:80)
Nn =1 k ( x n , x n ) and tr ( C Q )
≈ 1 N (cid:80)
Nn =1 r ( x n , x n ) .
It remains to provide an approximation of tr (cid:104)(cid:0) C 1 / 2 P C Q C 1 / [Equation] P (cid:1) 1 / 2 (cid:105) .
The key idea is to approximate the spectrum of C 1 / 2 P C Q C 1 / 2 P by that of an appropriate kernel matrix.
Details are discussed in Appendix A.4.
This leads to the following final approximation for the
Wasserstein metric
[Equation]
where X S :
=
( x S, 1 , . . .
, x S,N S ) with x S, 1 , . . .
x S,N S ∈ R D being subsampled from the input data X .
Further r
( X S , X ) :
= (cid:0) r ( x S,s , x n ) (cid:1) s,n and k
( X, X S ) :
= (cid:0) k
( x n , x S,s ) (cid:1) n,s for n = 1 , . .
, N , s = 1 , . .
. , N S and λ s (cid:0) r ( X S , X ) k
( X, X S ) (cid:1) denotes the s -th eigenvalue of the matrix r ( X S , X ) k
( X, X S ) ∈ R N S × N S .
The approximation quality of (cid:99) W is related to the spectral decay of the operator C P C Q , which in turn is determined by the kernels k and r .
For the choices made in Section 4.2 we empirically observe rapid spectral decay (cp.
Appendix A.13)
and therefore are confident that the 2-Wasserstein distance is estimated reliably for our method.
The combination of (13), (14) and (15) gives a generalized loss that is tractable in terms of m P , m Q , k , and r .
If we disregard computation time of m P , m Q , k and r , the generalized loss can be evaluated in O ( N + N 2 S N + N 3 S ) , where typically N S ≪ N , e.g. N S = 100 .
We provide a batch version of our loss in Appendix A.5 which reduces the computations to O ( N 2 S N B + N 3 S ) where N B ≪ N is the batch-size.
Note, however, that the final computation time for our method will be determined by the complexity hidden in the evaluation of m Q , m P , k , and r as we need N B evaluations of m Q and m P and N S · N B evaluations of r and k per iteration.
4.2 Parameterisations of Prior and Variational Measure
The prior for our model is given as P = N ( m P , C P ) with C P induced by a trace-class kernel k .
One of the advantages of the proposed approach is that any trace-class kernel is allowed and this is where one can incorporate specific assumptions and domain expertise.
This is a thoroughly studied topic: the prior kernel can encode periodicity [Durrande et al., 2016], geometric intuition [van der
Wilk et al., 2018], and even model linear constraints for the unknown function [Jidling et al., 2017].
In order to keep the exposition simple and maintain focus on the inference, however, and in line with using simple priors on network weights in standard Bayesian deep learning, we opt for a simple zero mean prior m P = 0 and a standard ARD kernel k given as
[Equation]
for x, x ′ ∈ X
⊂ R D .
We refer to σ f > 0 as kernel scaling factor and to α d > 0 as length-scale for dimension d .
The parameters σ f and α :=
( α 1 , . . .
, α D ) are called prior hyperparameters .
The rest of the section explores various choices for the variational mean m Q and the variational kernel r .
The parameters appearing in the specification of m Q and r are referred to as variational parameters .
GWI: Stochastic variational Gaussian process
Let z 1 , . .
z M ∈
X be a subsample of the data X with M ≪ N .
We define the posterior mean
[Equation] [Equation]
with β m ∈ R and k m ( x ) :
= k ( x, z m ) , m = 1 , . . .
, M where k is the prior kernel k and β := ( β 1 , . .
β M ) ∈
R M are variational parameters.
Define further the variational kernel
[Equation]
We query the above functions at N = 1000 equidistant points and add white noise with ϵ ∼
N (0 , 0 .
We use M = 30 inducing points and train our method as described in Appendix A.7.
The plot shows m Q ( x ) ± 1 .
96 (cid:112) V
[ Y ∗ ( x ) | Y ] where V [ Y ∗ ( x ) | Y ] is the posterior predictive variance given as r ( x, x ) + σ 2 .
where Σ ∈ R M × M is the symmetric and positive definite variational covariance matrix that parameterises r .
This choice of m Q and r essentially recovers the stochastic variational Gaussian processes (SVGP) model of Titsias [2009].
Note that in our framework it is straightforward to use all (or just more) basis functions for the mean m Q ( x ) :
= m P ( x ) + (cid:80) Nn =1 β n k n ( x ) where k n ( x ) :
= k ( x, x n ) , β n ∈ R , n = 1 , . . .
, N .
This mirrors the construction in Cheng and Boots [2017] where we allow more parameters to learn the mean than in SVGP.
However, both Titsias [2009] and Cheng and Boots [2017] use a different objective function than GWI to learn the unknown parameters.
GWI: deep neural network with SVGP
An interesting approach is to parameterise the posterior mean as a deep neural network (DNN).
We assume the DNN has L ∈ N hidden layers and the width of layer ℓ = 1 , . . .
, L is denoted D ℓ with D 0 :
=
D and D L +1 = 1 .
This means we define g 1 ( x ) :
=
W 1 x + b 1 and further h ℓ ( x ) :
= ϕ (cid:0) g ℓ ( x ) (cid:1) , g ℓ +1 ( x ) :
= W ℓ +1 h ℓ ( x )+ b ℓ +1 for ℓ = 1 , . . .
, L .
Here W l +1 is D ℓ +
× D ℓ matrix, b ℓ +1 ∈ R D ℓ +1 is a bias vector for layer l and ϕ an activation function.
We can then define the variational mean as m Q ( x ) :
= m P ( x ) + g L +1 ( x ) .
If we choose the
SVGP kernel r in (18), we essentially predict with a neural network and quantify uncertainty with a (sparse) Gaussian process, capturing the beneficial properties of both.
Neural networks have been combined in several ways with GPs [Wilson et al., 2016, Tran et al., 2020].
However, to the best of our knowledge they were not used to directly parametrize the posterior in the context of generalized variational inference in function space.
The spirit of our approach is fundamentally different: rather than thinking of a neural network as a model which needs to be made
Bayesian, we use it as a parametrisation of a variational posterior.
We note that we do not here provide an exhaustive study on how to best parameterize the variational measure.
This paper is focused on demonstrating the ability of the proposed method to obtain valid uncertainty quantification.
An exploratory study on how properties and quality of uncertainty quantification relate to different choices of m Q and r is reserved for future work.
We mention potential problems that can occur from misspecification in Appendix A.10.
Experiments
We show results for GWI with the SVGP mean (17) and the SVGP kernel (18).
We use the shorthand
GWI: SVGP for this approach.
Additionally we implement the DNN mean with the SVGP kernel (18).
This combination achieves impressive results on various regression and classification tasks.
We call this method GWI: DNN-SVGP or simply GWI-net.
Illustrative Examples
In Figure 1 we illustrate GWI-net on a few toy examples.
One can clearly see that the posterior predictive variance expands for regions lacking observations which demonstrates the ability of our method to quantify uncertainty.
We provide an additional graphic comparison with SVGP in Appendix A.12 and an example for two-dimensional inputs in Appendix A.
There we show that the pathologies regarding the quantification of in-between uncertainty discussed in Foong et al.
[2020] are not present for our method.
UCI Regression
In Table 1 we report the average test negative log-likelihood (NLL) (cf.
Appendix
A.7 for details) of GWI: SVGP and GWI-net (GWI: DNN-SVGP) and the results of several weightspace approaches for BNNs: Bayes-by-Backprop (BBB)
[Blundell et al., 2015], variational dropout (VDO)
[Gal and Ghahramani, 2016], and variational alpha dropout ( α = 0 . 5 )
[Li and Gal, 2017].
We also compare with four function-space BNN inference methods: functional variational inference with BNN prior (FVI)
[Ma and Hernández-Lobato, 2021], variationally implicit processes (VIP) with BNNs, VIP-Neural processes [Ma et al., 2019], and functional BNNs (FBNNs)
[Sun et al., 2019].
In order to ensure a fair comparison we matched neural network architectures and training procedures for the different methods. Detailed explanations are given in Appendix A.7.
[Figure] [Table] [Figure]
[Table]
[Figure]
[Table]
[Figure]
[Table] [Figure] [Table] [Figure]
[Table]
[Figure]
[Table]
[Figure] [Table] [Figure] [Table]
[Figure]
[Table]
[Figure]
[Table]
[Figure]
[Table]
[Figure]
[Table]
[Figure]
[Table]
[Figure]
[Table]
[Figure]
[Table]
[Figure]
[Table]
[Figure]
[Table]
[Figure]
[Table]
[Figure]
[Table]
[Figure]
[Table]
[Figure]
[Table]
[Figure]
[Table]
[Figure]
[Table]
[Figure]
[Table]
[Figure]
[Table]
[Figure]
[Table]
[Figure]
[Table]
Classification and OOD Detection
We demonstrate the ability of GWI to perform image classifications on Fashion MNIST [Xiao et al., 2017] and CIFAR-10 [Krizhevsky et al., 2009].
We compare to FVI, mean-field variational inference (MVFI)
[Blundell et al., 2015], maximum a posteriori approximation (MAP), K-FAC Laplace-GNN [Martens and Grosse, 2015] and its dampened version [Ritter et al., 2018].
Implementation details are discussed in A.8.
We also assess the ability of our model to perform out-of-distribution detection using in-distribution (ID) / out of-distribution (OOD) pairs given as FashionMNIST/MNIST and CIFAR10/SVNH.
Following the setting of Osawa et al.
[2019], Immer et al.
[2021] we calculate the area under the curve (AUC) of a binary out-of-distribution classifier based on predictive entropies.
Results are shown in
Table 2.
[Table]
Our method performs best in all categories on the Fashion MNIST dataset achieving state-of-the-art results.
On CIFAR10 we obtain the highest accuracy and best NLL by a significant margin and perform competitively in the OOD detection task.
Limitations
In this section we discuss some of the shortcomings and difficulties which are related to our method.
The GVI-FS framework allows the specification of function space inference via infinite dimensional parameters such as mean and kernel functions.
This great flexibility essentially allows the specification of mismatched prior and posterior parameters.
We illustrate such a case in Appendix A.10.
GWI-net relies on the SVGP kernel defined in 18 for its posterior approximation.
It therefore inherits numerical instabilities associated with the inversion of the kernel matrix.
For the data sets discussed in this paper it was possible to overcome these issues by smart initialisation of the optimiser (cf.
Appendix A.7), but it may be an interesting research avenue to come up with a kernel that avoids these instabilities.
Our method approximates the Wasserstein distance in function space via the spectrum of kernel matrices (cf.
Appendix A.4).
These approximations require quick spectral decay of the composition of prior and variational covariance operator to be accurate and computationally tractable.
The prior
SE kernel combined with the variational SVGP kernel did have this property (cf.
A.13) which allowed for cheap and accurate approximations.
However, other parameterisations may result in less accurate estimation.
A theoretical investigation of how the approximation quality relates to kernel properties is an interesting topic for further research.
The proposed framework models prior and variational distribution with a Gaussian measure on the space of square integrable functions.
As a consequence the posterior distribution for the functional output is Gaussian as well.
This means it is unimodal and concentrated around the posterior mean.
Although this constrains the form of functional posterior significantly the authors would argue that the empirical success of GWI-net demonstrates that the approach is flexible to meaningfully quantify uncertainty.
Conclusion
In this paper, we developed a framework for generalized variational inference in infinite-dimensional function spaces.
We leveraged the function space perspective to develop a new inference approach combining Gaussian measures and Wasserstein distance with predictive performance of deep neural networks, yielding principled uncertainty quantification.
The value of our method was demonstrated on several benchmark datasets.
Checklist
The checklist follows the references.
Please read the checklist guidelines carefully for information on how to answer these questions.
For each question, change the default [TODO] to [Yes] , [No] , or [N/A] .
You are strongly encouraged to include a justification to your answer , either by referencing the appropriate section of your paper or providing a brief inline description.
For example:
• Did you include the license to the code and datasets?
[Yes] See Section ?? .
• Did you include the license to the code and datasets?
[No] The code and the data are proprietary.
• Did you include the license to the code and datasets?
[N/A]
Please do not modify the questions and only use the provided macros for your answers.
Note that the
Checklist section does not count towards the page limit.
In your paper, please delete this instructions block and only keep the Checklist section heading above along with the questions/answers below.
For all authors... (a) Do the main claims made in the abstract and introduction accurately reflect the paper’s contributions and scope?
[Yes] (b) Did you describe the limitations of your work?
[Yes] See Appendix A. (c) Did you discuss any potential negative societal impacts of your work?
[N/A] Nothing to discuss (d) Have you read the ethics review guidelines and ensured that your paper conforms to them?
[Yes] 2.
If you are including theoretical results... (a) Did you state the full set of assumptions of all theoretical results?
[Yes] (b) Did you include complete proofs of all theoretical results?
[Yes] See Appendix A.1-A. 3.
If you ran experiments... (a) Did you include the code, data, and instructions needed to reproduce the main experimental results (either in the supplemental material or as a URL)?
[Yes] See footnote in introduction (b) Did you specify all the training details (e.g., data splits, hyperparameters, how they were chosen)?
[Yes] See Appendix A.7 and A. (c) Did you report error bars (e.g., with respect to the random seed after running experiments multiple times)?
[Yes] (d) Did you include the total amount of compute and the type of resources used (e.g., type of GPUs, internal cluster, or cloud provider)?
[Yes] See Appendix A. 4.
If you are using existing assets (e.g., code, data, models) or curating/releasing new assets... (a) If your work uses existing assets, did you cite the creators?
[N/A] (b) Did you mention the license of the assets?
[N/A] (c) Did you include any new assets either in the supplemental material or as a URL?
[N/A] (d) Did you discuss whether and how consent was obtained from people whose data you’re using/curating?
[N/A] (e) Did you discuss whether the data you are using/curating contains personally identifiable information or offensive content?
[N/A] 5.
If you used crowdsourcing or conducted research with human subjects... (a) Did you include the full text of instructions given to participants and screenshots, if applicable?
[N/A] (b) Did you describe any potential participant risks, with links to Institutional Review Board (IRB) approvals, if applicable? [N/A] (c) Did you include the estimated hourly wage paid to participants and the total amount spent on participant compensation?
[N/A]
A Appendix A.1 Bayesian Inference as an Optimization Problem for an Infinite-Dimensional Prior Measure
Let E be a (infinite dimensional) Polish space and B ( E ) the Borel σ -algebra on E .
We denote the set of Borel probability measures on B ( E ) as P ( E ) and choose a fixed prior measure P ∈ P ( E ) .
The likelihood is described by a Markov kernel function p :
[Equation]
where Y ⊂ R N is Borel measurable.
The prior and the likelihood induce for any fixed y ∈ Y a posterior measure denoted as (cid:98) P ∈ P ( E ) [Ghosal and Van der Vaart, 2017, Chapter 1.3].
The next theorem shows that this posterior measure is the solution to a certain optimization problem.
Theorem 2 (Bayes Posterior as optimization) .
The Bayesian posterior measure (cid:98) P is given as
[Equation]
20) for any fixed prior measure P ∈ P ( E ) and fixed y ∈ Y such that f ∈ E
(cid:55)→ p ( y | f ) > 0 .
Proof.
According to Bayes rule in infinite dimensions [Ghosal and Van der Vaart, 2017, Chapter 1.3] we know that (cid:98) P is dominated by P with Radon-Nikodym derivative given as
[Equation]
(21) for f ∈ E where p ( y ) :
= (cid:82) p ( y | F = f ) dP ( f ) is the marginal likelihood for y .
The reverse is also true and P is dominated by (cid:98) P .
We prove this by contraposition and therefore assume that P ( A ) >for some A ∈ B ( E ) .
From Bayes rule we know that
[Equation] [Equation]
as the integrand is positive by assumption and P ( A ) > 0 .
This gives (cid:98) P ( A ) > 0 and therefore that P is dominated by (cid:98) P .
In this case standard rules for Radon-Nikodym derivatives give that
[Equation]
for f ∈ E .
Note that without loss of generality we can assume that the optimal Q ∈ P ( E ) is dominated by P (and therefore also dominated by (cid:98) P ) since otherwise (20) is infinite by definition of the KL divergence.
For such a Q dominated by P it holds that
[Equation] [Equation]
where the last line follows from the chain rule for Radon-Nikodym derivatives.
We further have
[Equation]
[Equation] [Equation] since D KL ( Q, P ) ≥ 0 , with equality if and only if Q = (cid:98) P .
This proves the claim.
A.2 Pointwise Evaluation as Weak Limit
To outline the problem briefly: If F ∼ N ( m, C ) is a GRE with mean m ∈ L 2 ( X , ρ, R ) and covariance operator C as defined in (9) then it is in general unclear what the distribution of F ( x ) would be for a fixed x ∈ X .
The technical reason is that the pointwise evaluation π x : L 2 ( X , ρ, R ) → R , i.e. π x ( [Equation]
[Equation] f
[Equation]
(30) is not well-defined.
An element g of the space L 2 ( X , ρ, R ) is an equivalence class and only identifiable up to a ρ -nullset.
This means that the definition of π x in (30) makes no sense whenever ρ ( { x } ) =
which is the case whenever ρ has a pdf w.r.t.
the Lebesgue measure.
However, we will remedy this situation by defining for a fixed x ∈ X
[Equation]
31) where h n,x ∈ L 2 ( X , ρ, R ) is an appropriately chosen sequence and the limit is to be understood as convergence in distribution of the sequence of scalar random variables ⟨ F, h n,x ⟩ 2 .
Theorem 3.
Let F ∼ N ( m, C ) be a GRE in L 2 ( X , ρ, R ) with mean m ∈ L 2 ( X , ρ, R ) and covari- ance operator C as defined in (9) .
Assume that ρ is a probability measure on X ⊂ R D and that ρ is absolutely continuous with respect to the Lebesgue measure λ on R D with pdf ρ ′ .
Denote the support of the measure ρ by supp ( ρ ) and assume that x is an arbitrary point in the interior of supp ( ρ ) such that m , k and ρ ′ are continuous at x .
Let
[Equation]
be the so called standard molifier and note that η is smooth with (cid:82) η ( t ) dt = 1 .
We further define the sequence h n,x ( t ) :
= η (cid:0) n ( t − x ) (cid:1) /ρ ′ ( t ) for n ∈ N , t ∈ supp ( ρ ) and h n,x = 0 for t / ∈ supp ( ρ ) .
Then
[Equation]
33) for n → ∞ where D −→ denotes convergence in distribution.
Proof.
Note that supp ( h n,x ) =
B 1 /n ( x ) := { t ∈ R D : | t − x | ≤ 1 n } and B 1 /n ( x ) ⊂ supp ( ρ ) for large enough n ∈ N since x is from the interior of supp ( ρ ) .
This means that h n,x
∈ L 2 ( X , ρ, R ) for large enough n as
[Equation]
The last expression is finite for large enough n because the integrand is continuous at x .
According to the definition of of GREs we therefore conclude that
[Equation]
for large enough n ∈ N .
The next statement we show is that m n ( x ) := ⟨ m, h n,x ⟩ 2 → m ( x ) for n → ∞ .
To this end notice that
[Equation] [Equation]
Let now ϵ > 0 be arbitrary.
For n large enough we | m ( x ) − m ( t ) | ≤ ϵ for all t ∈ B 1 /n ( x ) due to the continuity of m in x .
This immediately implies
[Equation]
x
[Equation]
for large enough n which shows the convergence of m n ( x ) to m ( x ) .
A similar argument shows that k n ( x, x ) := ⟨ Ch n,x , h n,x ⟩ 2 → k ( x, x ) for n → ∞ .
We therefore conclude that
[Equation]
for n → ∞ due to Slutsky’s theorem.
According to Theorem 3 we can simply define F ( x ) ∼ N ( m ( x ) , k
( x, x )) for all x in the interior of the support of ρ if m , k and ρ ′ are continuous at x .
These are mild assumptions and we can typically assume that they are satisfied in practice.
A.3 The Wasserstein Metric for Probability Measures
Let E be a Polish space.
For p ≥ 1 , let P p ( E ) denote the collection of all probability measures µ on
E with finite p th moment, that is, there exists some x 0 in M such that:
[Equation]
The p th Wasserstein distance between two probability measures µ and ν in P p ( E ) is defined as
[Equation]
where Γ( µ, ν ) denotes the collection of all measures on E × E with marginals µ and ν on the first and second arguments respectively.
More details about the Wasserstein distance can be found in Chapter 7 of Ambrosio et al.
A.4 A Tractable Approximation of the Wasserstein Metric
Recall that the Wasserstein metric for the two Gaussian measures P = N ( m P , C P ) and Q =
N ( m Q , C Q ) on the Hilbert space H =
L 2 ( X , ρ, R ) is given as
[Equation]
[Equation]
Further the operators C P and C Q are defined through trace-class kernels k and r as described in
Section 3.1.
We will now discuss how to approximate each term in (46).
First, note that
[Equation]
which follows by replacing the true input distribution with the empirical data distribution.
Second, note that under very general conditions on k and ρ it holds that [Brislawn, 1991]
[Equation]
and similarly for C Q .
Again by replacing ρ with the empirical data distribution we obtain natural estimators:
[Equation]
Denote by λ n ( C ) the n -th eigenvalue of a positive, self-adjoint operator C .
By definition of the trace and the square root of an operator we have
[Equation]
where the second line follows from the fact that the operator C Q C P has the same eigenvalues as
C 1 / 2 P C Q C 1 / 2 P [Hladnik and Omladiˇc, 1988, Proposition 1].
The operator C Q C P is given as
[Equation]
where we define
[Equation]
for all x, t ∈ X .
This means that C Q C P is also an integral operator with (non-symmetric) kernel r ∗ k .
We again replace ρ with (cid:98) ρ to obtain
[Equation]
[Equation] The spectrum of C Q C P can now be approximated by the spectrum of the matrix 1 N (cid:92) ( r ∗ k )
( X, X )
[Rasmussen, 2003, cf.
Chapter 4.3.2] or 1 N S (cid:92) ( r ∗ k )( X S , X S ) where X S is a subsample of the data points X of size N S < N .
If we plug this approximation into (52) we obtain
[Equation]
[Equation]
[Equation]
which is the last expression that we had to approximate.
Note that since C Q C P has the same spectrum as the self-adjoint, positive, trace-class operator C 1 / 2 P C Q C 1 / 2 P we know that its eigenvalues are real, positive and converge to zero.
A.5 Generalized Loss for Regression in Batch Mode
The batch version of the generalized loss is given as:
[Equation]
N B ∈ N is the batch-size.
The indices n 1 , . . .
[Equation] n N B are the batch-indices and X B is the batch matrix.
A.6 GWI for (Multiclass) Classification
Let { ( x n , y n ) } Nn =1 ⊂ X
× Y be data with X ⊂ R D and Y = { 1 , . . .
, J } , where J ∈ N represents J ≥ 2 distinct classes.
Model
We use the same likelihood for y :
= ( y 1 , . .
, y N ) as described in Chapter 4 of Matthews [2017] which is:
[Equation]
63) with
[Equation]
64) for y n ∈ { 1 , . .
. , J } .
The function h ϵℓ is defined as
[Equation]
for ℓ = 1 , . . .
, J for ϵ > 0 .
We chose ϵ = 1% in our implementation.
We assume that F 1 , . . .
F J are independent GREs on L 2 ( X , ρ, R ) with prior means m P,j and prior covariance operators C P,j , j = 1 , . . .
, J .
The variational measures for F 1 , . .
. , F J are assumed to be independent and given as Q j =
N (cid:0) m Q,j , C Q,j (cid:1) for j = 1 , . . .
, J .
We further write Q (cid:16)(cid:0) F 1 ( x ) , . .
, F J ( x ) (cid:1) ∈
A (cid:17) , A ⊂ R J for the variational (posterior) approximation of the probability of the event { (cid:0) F 1 ( x ) , . .
, F J ( x ) (cid:1) ∈ A } .
This leads to the following expected log-likelihood
[Equation]
≈
[Equation]
with
[Equation]
for any x ∈ X , j = 1 , . . .
, J where ( w i , ξ i ) Ii =1 are the weights and roots of the Hermite polynomial of order I ∈ N .
This is the same Gauss-Hermite approximation as described in Chapter 4 of Matthews [2017].
The final objective for multiclass classification is given as
[Equation]
[Equation] where the expected log-likelihood is approximated by (69) and each Wasserstein distance W 22 ( P j , Q j ) can be estimated as in (14)-(15).
Prediction
The probability that an unseen point x ∗ ∈ X belongs to class j ∈ { 1 , . .
, J } is given as
[Equation]
for any x ∗ ∈ X .
We predict the class label as maximiser of this probability.
If we apply tempering, we simply replace every r j ( x, x ) with T · r j ( x, x ) for j = 1 , . . .
, J in the definition of S ( x, j ) .
Negative Log Likelihood
The variational approximation to the negative log-likelihood is
[Equation]
for any point x ∗ ∈ X for which we know that the class label is y ∗
[Equation]
A.7 Implementation Details: Regression
The Regression model is given as F ∼ N (0 , C ) and
[Equation] (74) with ϵ n ∼ N (0 , σ 2 ) , n = 1 , . . .
, N .
The covariance operator C P depends on the choice of a kernel k , i.e. C P = C P,k for which we use the ARD kernel k given as
[Equation]
(75) for x, x ′ ∈ R D .
We refer to σ f > 0 as kernel scaling factor , to α d > 0 as length-scale for dimension d and to σ > 0 as observation noise .
The data is first randomly split into three categories: training set 80% , validation set 10% and test set 10% .
The observations Y are then standardised by subtracting the empirical mean (of the training data) and dividing by the empirical standard deviation (of the training data).
The inputs data X is left unaltered.
The number of inducing points
The number of inducing points M is treated as a hyperparameter, this means we train the model for each M ∈ { 0 . 5 √ N, √ N, 1 . 5 √ N, 2 √ N } and choose the best model.
For GWI: SVGP we use M ∈ { 1 √ N, 2 √ N, . . .
5 √ N } .
The choice of inducing points
The input points Z 1 , . . .
, Z M in (18) are sampled independently from the training data X and then fixed for GWI-net.
For GWI: SVGP they are only initialised this way and then learned by maximising the generalized loss.
Prior hyperparameters
The prior hyperparameters σ f , α :=
( α 1 , . . .
, α D ) and σ are chosen by maximising the marginal log-likelihood for the data X =
Z and the corresponding observations, which we denote Y Z .
Note that the marginal log-likelihood is tractable and given as
[Equation]
) and can therefore be evaluated in O ( M 3 )
=
O ( N √ N ) .
Variational mean
For GWI-net we use a neural network with L = 2 hidden layers, width D 1 = D 2 = 10 and tanh as activation function.
This follows the set-up of Ma and Hernández-Lobato [2021].
Variational kernel
The kernel r which is chosen as described in (18) and therefore depends on the covariance matrix Σ ∈ R M × M and the M ∈ N inducing points
Z =
( Z 1 , . . .
, Z M ) ∈ R D × M .
We parametrise Σ as Σ = LL T with initialisation
[Equation]
where k ( Z, X )
k
( X, Z ) is approximated by batch-sizing as NN B k ( Z, X B ) k
( X B , Z ) .
This corresponds to an approximation of the optimal choice for Σ in SVGP [Titsias, 2009].
Parameters in the generalized loss
The generalized loss in Appendix A.5 depends further on
N S , N B and X S .
The batch-size N B is chosen to be N B = 1000 for N > 1000 .
For N < 1000 we use the full training data.
The comparison points X S are sampled independently from the training data X in each iteration.
We train here for 1000 epochs on the regression task and 100 epochs on the classification task following Ma and Hernández-Lobato [2021].
Tempering the predictive posterior
Wenzel et al.
[2020] observe that the performance of many Bayesian neural networks can be improved by tempering the predictive posterior.
Tempering refers to a shrinking of the predictive posterior variance by a factor of α T ∈ [0 , 1] .
This effect has also been observed for Gaussian processes in Adlam et al.
[2020] where it can be interpreted as elevating problems that occur from prior misspecification.
The prior hyperparameters for the ARD kernel k in (16) are selected by maximising the marginal log-likelihood on a subset of the training data.
This procedure may lead to prior misspecification, which is why we decided to temper the predictive posterior, which means that we use the predictive distribution
[Equation]
for an unseen data point x ∗ ∈ X .
The (tempered) NLL for each data point is given as
[Equation]
The tempering factor α T is chosen as minimiser of the average NLL on the validation set.
The final predictions on the test set are made using this optimal α T and (78).
Note however that for the
NLL numbers reported in Table 1 we add log( (cid:98) σ train ) to (80) where (cid:98) σ train is the empirical standard deviation of the training data.
This is done for fair comparison as it is how the NLL is calculated in
Ma and Hernández-Lobato [2021].
A.8 Implementation Details: Classification
As described in section (A.6) we use the prior mean functions m P,j and kernels k j for j = 1 , . . .
, J .
For our experiments we chose m P,j = 0 for j = 1 , . .
J and k :
= k 1 = . . .
, k J where k is the
ARD kernel in (16).
We use a multi-output neural network for the variational means m Q,j and an SVGP kernel for each r j , j = 1 , . . .
, J .
The number of inducing points
The number of inducing points M is treated as a hyperparameter, this means we train the model for each M ∈ { 0 . 5 √ N, 0 .
75 √ N, √ N } and choose the best model.
The choice of inducing points
The input points Z 1 , . . .
, Z M in (18) are sampled independently from the training data X and then fixed for GWI-net.
Prior hyperparameters
The prior hyperparameters are initialised as described in A.7, thus maximising the marginal likelihood of a regression model, since the marginal likelihood of our classification model is intractable.
Variational mean
We use the same CNN architecture as described in Immer et al.
[2021], Schneider et al.
[2019] for all models.
Variational kernel
Each variational kernel r j uses the same inducing points Z but gets an individual matrix Σ j ∈ R M × M for j = 1 , . .
, J .
They are all initialised as described in A.7.
Parameters in the generalized loss
The generalized loss in Appendix A.5 depends on N S , N B and X S .
The batch-size N B is chosen to be N B = 1000 for N > 1000 .
For N < 1000 we use the full training data.
The comparison points X S are sampled independently from the training data X in each iteration.
We train 100 epochs on the classification task following Ma and Hernández-Lobato [2021].
Tempering the predictive posterior
For the same reasons as outlined in Appendix A.7 we temper the predictive posterior.
Recall that the NLL for classification is given as
[Equation] [Equation]
for any point x ∗ ∈ X for which we know that the class label is y ∗ ∈ { 1 , . . .
, J } .
We use a tempering factor α j > 0 for each variational measure Q j ∼ N ( m Q,j , α j r j ) , j = 1 , . . .
, J .
We train the model with α j = 1 for all j = 1 , . . .
, J and select the tempering factors afterwards as minimiser of the average NLL on the validation set.
A.9 Illustrative Example for Two Dimensional Inputs
In Foong et al.
[2020] it is observed that several BNN posterior approximation techniques struggle with the quantification of in-between uncertainty.
The red points mark where observations were made and it is clear that mean-field variational inference (MVFI)
[Hinton and Van Camp, 1993] and Monte
Carlo Dropout (MCDO)
[Gal and Ghahramani, 2016] exhibit unjustifiably high posterior certainty in the area where no observations are made.
This is a pathology of the approximation technique as the true Bayesian posterior which is approximated to very high precision by Hamiltonian Monte
Carlo (HMC)
[Neal, 2012] or the infinite-width GP limit [Matthews et al., 2018] do not display such behaviour.
In Figure 2 our method GWI-net is displayed next to the methods described in Foong et al.
As one can observe our model is keenly aware of its limited ability to predict points in-between the two clusters of observed data points.
− 2 −  2 x 1 − 2 . 0 − 1 .− 1 . 0 − 0 .0 .
5 2 .xσ
[ f ( x {+)] − 2 − 
+}
[Table]
[Figure]
A.10 Model Misspecification in Gaussian Wasserstein Inference
The generalized loss in Appendix A.5 is a valid optimization target for any m P , m
Q ∈
L 2 ( X , ρ, R ) and any trace-class kernels k and r .
This gives the user a lot of abilities to specify different models, by experimenting with various choices, specifically for m Q and r .
However with great power comes great responsibility: it is quite easy to misspecify GWI.
To illustrate the issue let us use a periodic kernel k [Duvenaud, 2014] given as
[Equation]
(82) and the SVGP kernel r in (18).
By the definition of r the uncertainty will be low for points similiar to the inducing points Z , i.e. for points x ∈ X k ( x, z m )
≈ σ 2 f for all m = 1 , . . .
, M .
A problem now occurs, if the posterior mean m Q does not respect the knowledge embedded in k and r .
Lets for example use a simple fully connected deep neural network m Q and choose the point x ∗ :
= z 1 + 10 p .
Assume further that z 1 , . .
z M < x ∗ .
Then we get k ( x ∗ , z m )
=
k ( z 1 , z m ) for all m = 1 , . . .
, M due to the periodicity of sin( x ) and therefore r ( x ∗ , x ∗ ) =
r ( z 1 , z 1 ) .
It is however very unlikely that the neural network will predict m Q ( z 1 ) as well as m Q ( x ∗ ) since it is unaware of this periodicity.
This small example should illustrate that it is crucial that m Q is compatible with the prior knowledge reflected in k and r .
However, note that this problem is not present for our model, GWI-net.
The
ARD kernel encodes the inductive bias that the underlying function is infinitely differentiable and that points close to each other have highly correlated functional outputs.
A simple fully connected DNN with tanh activation function is indeed smooth and further it is reasonable to assume that predictions are more unreliable the further they are from the data (as measured by the squared euclidean distance).
The ARD kernel is in this sense compatible with a fully connected DNN.
It shall be noted that the DNN used for the classification examples in (5) used convolutional layers as explained in Appendix A.8.
This can be understood as embedding prior knowledge about translation equivariance into the DNN [Goodfellow et al., 2016, Chapter 9.4].
It might therefore be desirable to use a prior kernel k that embeds similar properties such as the kernel suggested by Van der Wilk et al.
We considered this to be beyond the scope of this paper but the interaction of DNN architecture and the choice of prior kernels is an interesting avenue for future research.
A.11 Details on computational resources used
For all our experiments, we distributed our jobs across 8 Nvidia V100 cards.
A.12 Additional plots for 1D experiments
In Figure 3 we compare GWI-net, GWI-SVGP and SVGP on one-dimensional toy data.
Note that all three methods use the same posterior kernel, but GWI-net differs from GWI-SVGP in terms of the posterior mean function. GWI-SVGP and SVGP have the same posterior mean but differ in terms of the objective function used for training.
A.13 Empirical estimation error of 2-Wasserstein distance
The approximation quality of the 2-Wasserstein distance is determined by the approximation quality of the spectrum of the appearing covariance operators.
For most kernels in practice like SE or
Matern kernel, the spectrum decays very quickly, which is why using the first 100 eigenvalues often empirically seems to be sufficient to approximate the spectrum and therefore the 2-Wasserstein distance.
We plot the magnitude of the first 100 positive eigenvalues (sorted on magnitude) for datasets BOSTON, CONCRETE, ENERGY, WINE and YACHT in Figure 4.
We see in Figure 4 that eigenvalues indeed decay fast.
We query the above functions at N = 1000 equidistant points and add white noise with ϵ ∼
N (0 , 0 .
We use M = 30 inducing points and train our method as described in Appendix A.7.
The plot shows m Q ( x ) ± 1 .
96 (cid:112) V
[ Y ∗ ( x ) | Y ] where V [ Y ∗ ( x ) | Y ] is the posterior predictive variance given as r ( x, x ) + σ 2 .
Here the fitted models from top to bottom are GWI-net, GWI-SVGP and SVGP.
[Figure]