<<

Scalable Training of Inference Networks for Gaussian-Process Models

Jiaxin Shi 1 Mohammad Emtiyaz Khan 2 Jun Zhu 1

Abstract

Inference in Gaussian process (GP) models is computationally challenging for large data, and often difficult to approximate with a small number of inducing points. We explore an alternative ap- proximation that employs stochastic inference net- works for a flexible inference. Unfortunately, for such networks, minibatch training is difficult to be able to learn meaningful correlations over func- tion outputs for a large dataset. We propose an algorithm that enables such training by tracking a stochastic, functional mirror-descent algorithm. At each iteration, this only requires considering a Figure 1. Inference networks for GPs are an alternative way to finite number of input locations, resulting in a scal- predict output f ∗ given test inputs x∗. able and easy-to-implement algorithm. Empirical 1 results show comparable and, sometimes, supe- points in the input space to reduce the cost of in- rior performance to existing sparse variational GP version (Quinonero-Candela˜ & Rasmussen, 2005; Titsias, methods. 2009). Methods that employ variational inference to es- timate inducing points (Titsias, 2009) can scale well to large data by minibatch stochastic-gradient methods (Hens- 1. Introduction man et al., 2013), but the quality of posterior approxima- tions obtained could be limited since the number of in- Gaussian processes (GP) (Rasmussen & Williams, 2006) ducing points needs to be small, even when the data are and their deep variants (Damianou & Lawrence, 2013) extremely large (Cheng & Boots, 2017). Optimization of are powerful nonparametric distributions for both super- inducing points is another challenging problem when the vised (Williams & Rasmussen, 1996; Bernardo et al., 1998; objective is nonconvex and stochastic-gradient methods can Williams & Barber, 1998) and unsupervised machine- get stuck (Bauer et al., 2016). learning (Lawrence, 2005; Damianou et al., 2016). Such A relatively less-explored approach is to approximate the GP processes can generate smooth functions to model complex posterior distribution by using approximators, such data and provide principled approaches for uncertainty quan- as deep neural networks (Sun et al., 2019). By introducing tification. Despite this, their application has been limited randomness in the parameters of such inference networks, it because for such modeling requires in- is possible to generate functions similar to those generated version of a matrix which is computationally challenging by the posterior distribution, as illustrated in Fig.1. By (typically (N 3) for N data examples). O directly approximating the functions, we can obtain more Many methods have been proposed to tackle this issue, and flexible alternatives to sparse variational approaches. Unfor- they mostly rely on finding a small number of inducing tunately, unlike sparse methods, training with minibatches

1 is challenging in the function space. The difficulty is to Dept. of Comp. Sci. & Tech., Institute for AI, BNRist Center, be able to maintain meaningful correlations over function THBI Lab, Tsinghua University, Beijing, China 2RIKEN Center for Advanced Intelligence project, Tokyo, Japan. Correspondence outputs while only looking at a handful of examples in each to: Jiaxin Shi , Jun Zhu . tremely important for them to be useful for flexible posterior inference in GP models. Proceedings of the 36 th International Conference on , Long Beach, California, PMLR 97, 2019. Copyright 1For supervised learning, these can be features, while for unsu- 2019 by the author(s). pervised learning, these could be latent vectors. Scalable Training of Inference Networks for Gaussian-Process Models

In this paper, we propose an algorithm to scalably train the in sparse GPs, while Balan et al.(2015) track stochastic network by tracking an adaptive Bayesian filter defined in gradient Langevin dynamics (SGLD) (the teacher) to dis- the function space. The filter is obtained by using a stochas- till information into a neural network (the student). Our tic, functional mirror-descent algorithm which is guaranteed method can also be interpreted in a teacher-student frame- to converge to the exact posterior process but is computa- work, where the teacher can be obtain from the student tionally intractable. By bootstrapping from approximations network by taking a stochastic mirror descent step, which given by inference networks, we can use stochastic gra- is much cheaper than simultaneously running another infer- dients to train the network with minibatches of data. We ence algorithm like SGLD. demonstrate training of various types of networks, such as Some of our inference networks are based on random feature those based on random feature expansions and deep neural expansion and are related to existing work on spectrum networks. Our results show that the problem caused by approximations for GPs (Lazaro-Gredilla´ et al., 2010; Gal & incorrectly minibatching in previous works is fixed by our Turner, 2015; Hensman et al., 2018). Among themL azaro-´ method. Unlike exist works that use neural networks to pa- Gredilla et al.(2010) does function-space inference and is rameterize deep kernel in the GP prior (Wilson et al., 2016), similar to our work, but is a full-batch algorithm. our variational treatment prevents overfitting and allows arbitrarily complex networks, which often achieve better performance than inducing-point approaches in regression 2. Bayesian Inference in GP Models tasks. Finally, we show that our method is a more flexible We start by discussing the challenges associated with exist- alternative for GP inference than existing sparse methods, ing methods for inference in GP models, and then discuss which allows us to train deep ConvNets for the inference of the difficulty in scalable training of inference networks. GPs induced from infinite-width Bayesian ConvNets. 2.1. Gaussian Processes 1.1. Related work A Gaussian Process (GP) is a defined us- For a scalable inference in GP models, plenty of work ing a function m(x) and function k(x, x0): has been done on developing sparse methods (Quinonero-˜ Candela & Rasmussen, 2005; Titsias, 2009; Hensman et al., f(x) (m(x), k(x, x0)) . (1) 2013). These works have made GPs a viable choice for ∼ GP practical problems by making minibatch training possible. A remarkable property of GPs is that, for any finite num- > Our work takes a different approach than these methods ber of inputs X = [x1,..., xN ] , the marginal distribution > by using inference networks for posterior approximation. of the function values f = [f(x1), . . . , f(xN )] follow a The computation complexity of our method is similar to multivariate Gaussian distribution: f (mD, KD,D) , sparse methods, but our posterior approximations are much where := [1, 2,...,N] are the indices∼ N of the data ex- D more flexible. Currently, it is challenging to train such infer- amples, mD is a vector with entries m(xi) and KD,D is a ence networks in the function space while achieving a good matrix with (i, j)’th entry as k(xi, xj). This property can performance. Our work fills this gap and shows that it is be utilized to obtain function approximations for the model- indeed possible to scalably train them and get a similar, and ing of complex data. For example, for regression analysis sometimes better, performance than sparse GP methods. given input features X, the function values f can be used to model the output mean: y (f, σ2I) where σ2 is the A few recent approaches have used inference networks for ∼ N posterior approximations in the function space, although noise variance. Correlations in the data vector y can now they have not directly applied it to inference in GP mod- be explained through the correlation defined using the GP els. For example, Neural Processes (NP) (Garnelo et al., prior in the function space. This approach is widely used to 2018a;b) uses inference networks on a model with a learned design nonlinear methods for supervised and unsupervised prior, while Variational Implicit Processes (VIP) (Ma et al., learning. 2018), in a similar setup, uses a GP for approximations. Given such a prior distribution, the goal of Bayesian in- Hafner et al.(2018) design a function-space prior called the ference is to compute the posterior distribution over the noise contrastive prior. The work of Sun et al.(2019) is function f(x) evaluated at arbitrary test inputs x. For Gaus- perhaps the closest to our approach, but they use an heuris- sian likelihoods such as in regression, due to the conjugacy, tic procedure for minibatch training. Our work proposes a the posterior distribution takes a convenient closed-form scalable minibatch training method which is useful for all solution, thus the predictive distribution at a test location x∗ of these existing works. is available in closed-form:

The idea of tracking a learning process to distill informa- ∗ T 2 −1 f(x ) y k (KD,D + σ I) (y mD), tion has been used in many previous approaches, e.g., Bui | ∼ N ∗,D − T 2 −1  k∗∗ k (KD,D + σ I) kD,∗ , (2) et al.(2017) use streaming variational Bayes for inference − ∗D Scalable Training of Inference Networks for Gaussian-Process Models

∗ ∗ ∗ where [k∗D]i = k(x , xi) and k∗∗ = k(x , x ). Equa- resentation of the posterior and variational distributions by tion (2) is difficult to compute in practice when N is large. p(f y) and q(f) respectively, then the variational objective The computational cost of matrix inversion is in (N 3). in the| function space can be written as following: This inversion is only possible when N is of moderateO size, usually only a few thousands. (q(f)) = Eq(f) [log p(y f)] KL [q(f) p(f)] . (4) L | − k 2.2. Sparse Approximations for GPs We recover the sparse variational GP problem in (3) 1/2 Sparse-approximation methods reduce the computation cost when we restrict q(f) p(f∗ u)q(u) Ku K∗ −1 1/2 ∝ | | | | − M M N K∗uKu Ku∗ , where f∗ represents the function out- by choosing a small number of points, where , | to perform the matrix inversion. These points are known as puts not covered by u. The two determinants arise from the the inducing points. A variety of such methods have been change of measure from function f to its outputs:f(x) = f, k(x, ) H. proposed (Quinonero-Candela˜ & Rasmussen, 2005) and h · i they mostly differ in the manner of selection of these points We can improve the flexibility of the approximations by em- and the kind of approximations used for the matrix inverse. ploying better choices of q(f). Function approximators with Among these, methods based on variational inference are random parameters, such as stochastic neural networks, are perhaps one of the most popular (Titsias, 2009). Given M such alternatives, where we can learn to generate functions > inducing points Z := [z1, z2,..., zM ] and their function that mimic the samples from the posterior. This is illustrated > values u := [f(z1), f(z2), . . . , f(zM )] , these methods in Fig.1. Drawing an analogy to the networks used for approximate the posterior distribution p(f, u y, X, Z) with inference in deep generative models (Kingma & Welling, | a variational distribution q(f, u). By restricting the vari- 2013), we call them inference networks. When trained well, ational approximation to be q(f, u) := q(u)p(f u), the such networks can yield much more flexible posterior ap- | variational lower bound is greatly simplified, proximations than sparse variational approximation which is restricted by the choice of inducing points. (q, Z) := Eq(u)p(f|u) [log p(y f)] KL[q(u) p(u)]. (3) L | − k Unfortunately, training inference networks is much more For GP regression, the optimal q(u) is a Gaussian whose challenging than sparse methods. The sparse approach sim- parameters can be obtained in closed-form (Titsias, 2009). plifies the problem to a parametric form where we only need Even though the computation of q(u) scales linearly with to deal with a small number inducing points and data exam- N, its covariance matrix can be inverted in (M 3) which O ples. It is challenging to design a similar procedure without reduces the prediction cost drastically. The linear depen- any sparse assumption on q(f). dence on N can be further reduced by using a minibatch training proposed in Hensman et al.(2013), which makes Existing approaches have mostly relied on heuristic proce- the method scale well to large data. Sparse variational meth- dures to solve this problem. For example, a recent approach ods can scale well, and also perform reasonably with enough of Sun et al.(2019) proposes to match marginal distribu- number of properly chosen inducing-points. tions of q(f) and p(f y) at a finite number of measurement | > points XM := [x1, x2,..., xM ] sampled from a distribu- In practice, however, the number of inducing points is lim- 2 tion c(x), by minimizing KL [q(fM) p(fM y)] where fM ited to make the matrix inversion feasible. This limits the k | are the function values at XM. This is a reasonable criterion flexibility of the posterior distribution whose complexity to match two GPs, since they are completely determined might grow with the complexity of the problem. Finding by their first two moments and the solution is unique when good inducing points is another challenging issue. The M > 2 (Sun et al., 2019). However, this is challenging to landscape of the lower bound with respect to Z presents a optimize due to the dependence of the term p(fM y) on the difficult optimization problem, and, so far, there are no good whole dataset y. Sun et al.(2019) propose to pick| subsets methods for this problem. of data at each iteration but then the minimization prob- lem no longer corresponds to matching q(f) and p(f y) 2.3. Function Space View and Inference Networks faithfully. Many other existing works on function-space| in- ference with neural networks face similar challenges when The sparse variational method discussed above can be de- it comes to minibatch training (Wang et al., 2019; Ma et al., rived by using a function-space view of GPs. As discussed 2018; Hafner et al., 2018). Such scalable training of infer- in several recent works (Cheng & Boots, 2016; 2017; Mal- ence network, while maintaining meaningful correlations in lasto & Feragen, 2017), a GP has a dual representation in function outputs for a large dataset, remains a challenging a separable Banach space, which contains the RKHS problem. induced by the covariance kernel. This view motivatesH to directly apply variational inference in the function space. 2We drop the dependence of p and q on training data X and Following Cheng & Boots(2016), if we denote the dual rep- sampled locations XM. Scalable Training of Inference Networks for Gaussian-Process Models

3. Scalable Training of Inference Networks 3.2. Minibatch Training of Inference Networks We present a new algorithm to scalably train inference net- We propose a tractable approximation to (6) by bootstrap- works by using minibatches. Our main idea is to track a ping from the inference network at each iteration. We stochastic, functional mirror descent algorithm to enable ef- denote the inference network by qγ (f) where γ is the ficient minibatch training. We start with a brief description set of parameters that we wish to estimate. We assume of the mirror descent algorithm. that we can evaluate the network at a finite set of M > points XM := [x1, x2,..., xM ] and that, just like a GP, 3.1. Stochastic Functional Mirror Descent Algorithm the evaluated points follow a Gaussian distribution, i.e., qγ (fM) = (µM, ΣM), where µM and ΣM are the We follow the functional mirror-descent method proposed N in Dai et al.(2016); Cheng & Boots(2016) to optimize (4). mean and covariance that depend on the parameter γ. In sec- The functional mirror descent algorithm is an extension of tion4, we will give many examples of inference networks gradient descent where gradient steps are taken in a function that have this property. space and the length of the steps is measured by using With such a qγ (f), we hope to track (6), so that qγt+1 (f) a Bregman divergence (e.g., KL) instead of a Euclidean moves closer to the true posterior process than qγt (f). For distance. A stochastic version of this algorithm is analogous this purpose, an obvious solution is to replace qt(f) by to stochastic gradient descent where a minibatch of data qγt (f), i.e., we can bootstrap from the current posterior could be used to build a stochastic approximation of the approximation given by the inference network: functional gradient. The method takes the following form: Nβt βt 1−βt qˆt+1(f) p(yn f) p(f) qγ (f) . (7) Z ∝ | t ˆ 1 qt+1 = arg max ∂ (qt)q(f)df KL [q qt] . (5) q L − βt k The idea of bootstrap has long been used in particle filter- ing (Doucet et al., 2001) to obtain better posterior approxi- where t is the iteration, βt > 0 is the learning rate, mations. An attractive property of (7) for GP regression is ˆ qt := qt(f) is the previous approximation, and ∂ (qt) = that, given inputs XM, all the quantities in the right hand L N log p(yn f)+log p(f) log qt(f) is an unbiased stochas- side follow a Gaussian distribution, therefore qˆt+1 has a tic approximation| of the− functional gradient of (q) at Gaussian distribution whose mean and covariance are avail- L q = qt obtained by randomly a data example n. able in closed-form. The last two terms in (7) are Gaussian An attractive property is that there is a closed-form solution and can be multiplied to get the new GP prior: given as follows, βt 1−βt p(fM, fn) qγt (fM, fn) q (f) p(y f)Nβt p(f)βt q (f)1−βt . (6) " #! t+1 n t  m  K K ∝ | := e M , e M,M e M,n , (8) N mn K K This update can be seen as an adaptive Bayesian filter where e e n,M e n,n q (f)    βt the previous posterior approximation t is used to modify 0 KM,M KM,n the prior distribution p(f) and a likelihood of the subsam- , ∝ N 0 Kn,M Kn,n pled data is used to update the posterior approximation. We (1−β )  µ   Σ Σ  t note that the functional mirror descent is equivalent to natu- M , M,M M,n , (9) ral gradient for exponential family densities. In appendixA × N µn Σn,M Σn,n we provide an alternative derivation of (6) by taking natural gradient on the exponential family representation of GP. where me and Ke denotes the new mean and covariance. Using this in (7) and multiplying by the Gaussian likelihood, Each step of this algorithm only requires subsampling a we get the following new GP regression problem, which has single data point, which makes it attractive for our purposes. a closed-form solution similar to (2): The algorithm is also guaranteed to converge to the true posterior p(f y) as discussed in Dai et al.(2016), where a 2 | qˆt+1(fM, fn) (yn fn, σ /(Nβt)) particle-based approach is proposed for the update in (6). ∝ N "| #!  m  K K Khan & Lin(2017) used a parametric version where the e M , e M,M e M,n . (10) update can be performed analytically. Our case is different × N me n Ke n,M Ke n,n from these works because the is a function, thus infinite-dimensional and difficult to be represented in The marginal qˆt+1(fM) can be read from this directly. a compact form. We instead use an inference network to Though we have access to any finite marginal distribution of implement this filter. We will use a version of (6) to com- qˆt+1(f), mapping this to the inference network parameters pute stochastic gradients and update the parameters of the is difficult. We can use the approach of Sun et al.(2019) inference network. This is explained next. to match the marginals of the qγ (f) and qˆt+1(f) at finite Scalable Training of Inference Networks for Gaussian-Process Models

Algorithm 1 GPNet for supervised learning Choice of c(x): Previous works on function-space infer- N ence (Sun et al., 2019; Wang et al., 2019; Hafner et al., Input: (xn, yn) , c(x), M, T , β, η. { }n=1 2018) have studied ways to sample the measurement points. 1: Initialize the inference network qγ . The general approach is to apply uniform sampling in the 2: for t = 1,...,T do input domain for low-dimensional problems; while for high- 3: Randomly sample a training data (xn, yn). dimensional input space, we can sample ”near” the training 4: Sample XM = (x1,..., xM ) from c(x). data by adding noise to them. A useful trick for RBF kernels 5: if Gaussian likelihood then is to set c(x) as the training distribution convolved with the 6: Compute qˆt+1(fM) using (10). kernel. In applications where the input region of test points 7: γt+1 γt η γ KL [qγ (fM) qˆt+1(fM)]. is known, we can set the c(x) to include it. 8: else ← − ∇ k −1 9: γt+1 γt + η γ t(qγ ; qγ , XM). Hyperparameter selection: We set β = β (1+ξ√t) ← ∇ L t t 0 10: end if to ensure that the original stochastic mirror descent con- 11: end for verges. Typical values are 1, 0.1, 0.01 for β0, and 1, 0.1 { } { } 12: return qγt . for ξ. We can update GP hyperparameters when needed in an online fashion using the lower bound of minibatch P P log marginal likelihood: Eqt log p(yi fi) i∈B i∈B | − number of measurement points XM sampled from a distri- KL [qt(fi) p(fi)], which is similar to sparse variational bution c(x), i.e., we update γ using the gradient of the KL methods. Ink our experiments the learning rate for GP hyper- divergence as shown below, where η is the learning rate: parameters is the same as η.

γt+1 = γt η γ KL [qγ (fM) qˆt+1(fM)] . (11) − ∇ k |γ=γt 4. Examples of Inference Networks for GPs When the likelihood is non-Gaussian, qˆt+1(fM) does not have a closed-form expression. We propose to upper bound So far we have used qγ (f) to denote the inference networks, without discussing how to construct them. Below we explore KL [qγ (fM) qˆt+1(fM)] with the KL divergence between k several types of networks that can be used in GPNet. the two joint distributions KL [qγ (fM, fn) qˆt+1(fM, fn)]. Minimizing this is equivalent to maximizing:k 4.1. Bayesian Neural Networks (BNN)

t(qγ ; qγt , XM) = Eqγ (fM,fn) [Nβtlog p(yn fn)+ L | A well-known fact in the community is: The function de- βt log p(fM,fn)+(1 βt) log qγ (fM,fn) log qγ(fM,fn)] . fined by a single-layer fully-connected neural network (NN) − t − with infinitely many hidden units and independent weight Our method is similar in spirit to RL methods such as tempo- randomness is equivalent to a GP (Neal, 1995). Recently, the ral difference learning with function approximators (Sutton result is extended to deep NNs (Lee et al., 2018; Matthews & Barto, 1998), which also employs stochastic gradients to et al., 2018; Garriga-Alonso et al., 2019; Novak et al., 2019). bootstrap from existing value function approximation. Their This equivalence has motivated the use of BNNs as inference success indicates that taking a gradient step with a small networks to model the distribution of functions (Sun et al., step size here might ensure good performance in practice. 2019; Wang et al., 2019). Given a neural network g(x; Ω), where Ω denotes the network weights, a BNN is constructed 3.3. Algorithm by introducing weight randomness: Ω (Ω0, V). Typi- ∼ N We name our algorithm Gaussian Process Inference Net- cally V is a factorized or matrix-variate Gaussian that fac- works (GPNet), which is summarized in Algorithm1. For torizes across layers. In this case the inference network parameters should be γ = Ω0, V . each iteration of our algorithm, the stochastic mirror descent { } update is computed by subsampling a datapoint from the However, this approach has several problems. First, the training set, then the inference network is trained to track the output density of BNN is intractable. In Flam-Shepherd update at a set of measurement locations sampled from c(x). et al.(2017); Wang et al.(2019) this difficulty is addressed Though we have described the algorithm using a single data by approximating the output distribution as a Gaussian and example, it is straightforward to extend it to minibatches. estimating the moments from samples, but drawing sam- The computation cost in case of GP regression is the cost of ples is costly due to many forward passes through the NN. matrix inversion which is (M 3). Note that, unlike sparse The covariance estimate will present large variance for the methods, M does not haveO to be large for a flexible inference. typical sample size we can afford. In Sun et al.(2019) the The inference network can be a complex model containing situation is improved by directly estimating the gradients f log q(fM) instead of the moments, with a low-variance neural networks which can be very flexible. Our procedure ∇ M essentially uses M locations to be able to compute stochastic but biased gradient estimator (Shi et al., 2018). However, the gradients to update the parameters of the network. sample size still needs to be hundreds. Moreover, because Scalable Training of Inference Networks for Gaussian-Process Models the stochastic process defined by finite-width BNNs may Deep Neural Networks It is not always easy to explic- not be a GP, it is unclear whether matching finite marginal itly write the inner-product form of a given kernel except distributions would suffice to match two processes. the stationary case discussed. We may need a black-box approach, e.g., to parameterize φ(x) with a function ap- 4.2. Tractable Variants proximator such as neural networks with general nonlin- earities (e.g., ReLU and tanh) and fit it during inference. Given the problems faced with BNNs, we explore two more In Snoek et al.(2015) a similar architecture called adap- types of inference networks that are equivalent to GPs. Both tive basis regression networks was proposed as priors in approaches naturally arise from the feature-space repre- Bayesian optimization. Similar to their observations, we sentation of GPs. It is known that for a Bayesian linear have found that this type of networks require significant regression with input feature φ(x) and Gaussian weights effort to tune. Inspired by the Fisher kernel (Jaakkola & w (0, Σ), the output distribution is equivalent to a GP Haussler, 1999), we also considered an alternative feature ∼ N 0 > 0 with the covariance k(x, x ) = φ(x) Σφ(x ) (Rasmussen map: the vector of how much information stored in each & Williams, 2006). In general, any positive definite kernel weight parameter, measured by the gradients of network 0 k(x, x ) can be written as the inner product of two feature outputs with respect to weights g(x; Ω). Plugging into 0 Ω maps φ(x) and φ(x ). As long as we know the φ(x) that φ(x), we get a Neural Tangent∇ Kernel (Jacot-Guillarmod corresponds to the kernel, we can interpret our GP latent 0 > et al., 2018): kNTK(x, x ) = Ωg(x; Ω0) V Ωg(x; Ω0). function f (0, k) as a parametric model: ∇ ∇ ∼ GP The performance of an inference network parameterized in f(x) = w>φ(x), w (0, I). (12) this way is similar to a BNN because the NTK can be in- ∼ N terpreted as introducing weight randomness on a first-order We could define the variational process in a similar form: expansion of neural networks: q(f): f(x) = w>φ(x), w (m, V), (13) ∼ N g(x; Ω) = g(x; Ω0) + Ωg(x; Ω0)(Ω Ω0), where m, V are the parameters of the inference network. ∇ − { } where if Ω (Ω0, V) then it is equivalent to the GP: Random Feature Expansion (RFE) For GPs with sta- ∼ N f (g( ; Ω0), kNTK). As seen, the mean function is as tionary kernels (i.e., kernels that only depend on the dif- flexible∼ GP as a· deep NN, while the kernel utilizes the gradients ference between inputs, k(x, x0) = ψ(x x0)), Bochner’s − as features. In some of our experiments we found it faster theorem guarantees that the can be writ- to converge than adaptive-basis ones, but the drawback is ten as a Fourier transform: much higher computational cost due to backpropagation Z > 0 k(x, x0) = eis (x−x )p(s)ds, (14) through Jacobians. where p(s) is a spectral density in one-to-one correspon- 5. Experiments dence with ψ. Random Fourier features (Rahimi & Recht, 2008) is an approximation to kernel methods which gives Throughout all experiments, M denotes both the num- explicit feature maps. The key observation is that eq. (14) ber of inducing points in SVGP and the number of mea- can be approximated by Monte-Carlo: surement points in GPNet and FBNN (Sun et al., 2019). Implementations are based on a customized version of M 0 1 X > 0 GPflow (de G. Matthews et al., 2017; Sun et al., 2018) and k(x, x ) cos(s (x x )), s1:M p(s), ≈ M m − ∼ ZhuSuan (Shi et al., 2017). Code is available at https: m=1 //github.com/thjashin/gp-infer-net. where the imaginary part is zero. Defining φr(x) = √1 [cos(s>x),..., cos(s> x), sin(s>x),..., sin(s> x)]>, M 1 M 1 M 5.1. Synthetic Data we can use it as the approximate feature map: 0 > 0 We consider the inference of a GP with RBF kernel on k(x, x ) φr(x) φr(x ). When using random ≈ > the synthetic dataset introduced in Snelson & Ghahramani Fourier features, the inference network w φr(x) is a neural network with one hidden layer. The activation (2006). We analyze the properties of our method and com- pare with SVGP and FBNN (Sun et al., 2019). We fit these functions for the hidden layer are cos and sin. s1,..., sM and w serve as the input-to-hidden and the hidden-to-output algorithms with minibatch size 20 on 100 data points. We weights, respectively. This architecture is called Random ran for 40K iterations and used learning rate 0.003 for all Feature Expansion in Cutajar et al.(2016), where they methods. For fair comparison, for all three methods we pre- use a multi-layer stack to mimic a deep GP prior, though train the prior hyperparameters for 100 iterations using the inference is still in the weight space. As done in their work, GP marginal likelihood and keep them fixed thereafter. We vary M in 2, 5, 20 for all methods. The networks used in we relax s1,..., sM to be trainable so that the inference GPNet and{ FBNN are} the same RFE with 20 hidden units. network parameters are γ = m, V, s1:M . { } Scalable Training of Inference Networks for Gaussian-Process Models

(a) (b)

Figure 2. Posterior process on the Snelson dataset, where shaded areas correspond to intervals of ±3 standard deviations, and dashed lines denote the ground truths. (a) Top row: SVGP with M ∈ {2, 5, 20} (left to right) inducing points; Bottom row: GPNet with M ∈ {2, 5, 20} measurement points. (b) Top: FBNN, M = 20; Bottom: GPNet, M = 20.

Results are plotted in Fig.2. We can see that the perfor- Table 1. Large-scale regression on the airline dataset. mance of SVGP grows with more inducing points. When M=100 M=500 M = 20, both SVGP and GPNet can recover the exact METRIC SVGPGPNET FBNN SVGPGPNET FBNN GP prediction. GPNet fits the data better when M = 2, 5. RMSE 24.261 24.055 23.801 23.698 23.675 24.114 This is because M does not constrain the capacity of the Test LL -4.618 -4.616 -4.586 -4.594 -4.601 -4.582 inference network, though it does affect the convergence speed, i.e., smaller M causes larger variance in the training. similar computational complexity. The regression results on In Fig. 2b we take a closer look at the predictions by GPNet small datasets including Boston, Concrete and Energy show and FBNN near the training data. We can see that FBNN that overfitting is not observed with our powerful networks. consistently overestimates the uncertainty. This effect can Note that these three datasets only contain 1-2 minibatches be well explained by their heuristic way of doing minibatch, of data, thus the performance of FBNN and GPNet are com- that in each iteration they fit a different objective to match parable because minibatch training is not an issue; while on the local effect of 20 training points in a minibatch, while larger datasets such as Kin8nm, Power and Wine, GPNet our stochastic mirror descent maintains a shared global ob- consistently outperforms FBNN. We find on Protein GPNet jective that takes all observations into consideration. is slower to converge than other methods, and increasing the training iterations will give far better performance. 5.2. Regression Airline Delay To demonstrate the advantage of our mini- Benchmarks We evaluate our method on seven standard batch algorithm on large-scale datasets, we conducted ex- regression benchmark datasets. We use RFE networks with periments on the airline delay dataset, which includes 5.9 1000 hidden units for this task. Following the settings of million flight records in the USA from Jan to Apr in 2018. Salimbeni & Deisenroth(2017), we compare to the strong Following the protocol in Hensman et al.(2013), we ran- baselines: SVGP with 100 and 500 inducing points. We domly take 700K points for training and 100K for testing. also compare to FBNN using the same inference network The results are shown in Table1. Experiment details can be as in GPNet3. To put the comparison into a wider con- found in appendixB. We can see that GPNet achieves best text, we include the results by probabilistic backpropaga- RMSE among three methods and has comparable test log tion (PBP) (Hernandez-Lobato´ & Adams, 2015), which is likelihoods with SVGP. The RMSE gap between M = 100 an effective weight-space inference method for BNNs. De- and M = 500 for SVGP is larger than that of GPNet, which tails of datasets and experiment settings can be found in again demonstrates that the power of our inference network appendixB. Results are summarized in Fig.3. We can see is not limited by M. Interestingly, larger M seems to cause that GPNet has comparable or smaller RMSE than SVGP on underfitting of FBNN and leads to worse RMSE, which may most datasets, and the performance gap is often large when also be due to the minibatch issue. comparing them given M = 100. This demonstrates the ef- fectiveness of inference networks than inducing points given 5.3. Classification

3Though the algorithm of Sun et al.(2019) is designed for Finally, we demonstrate the flexibility of GPNet by fit- BNNs, it also applies to other types of inference networks. ting a deep convolutional inference network for a CNN- Scalable Training of Inference Networks for Gaussian-Process Models

PBP SVGP, M=500 SVGP, M=100 GPNet, M=500 GPNet, M=100 FBNN, M=500

2 4 6 4 5 6 7 0.5 1.0 1.5 0.06 0.08 0.10 3.5 4.0 4.5 3.5 4.0 4.5 0.5 0.6 0.7 boston concrete energy kin8nm power protein wine red

PBP SVGP, M=500 SVGP, M=100 GPNet, M=500 GPNet, M=100 FBNN, M=500

3 2 3.50 3.25 3.00 2.75 2.0 1.5 1.0 0.5 1.0 1.2 2.9 2.8 2.7 3.5 3.0 1.0 0.8 −boston − − −concrete− − − − energy− − kin8nm − power− − − protein− −wine red −

Figure 3. Regression results on benchmark datasets. Top row: Test RMSE; Bottom row: Test log likelihood. All results are drawn as violin plots which shows a kernel density of results on different splits, except for PBP we only have the mean and standard error, so an error bar is drawn instead.

Table 2. Image classification: Test error rates. blocks (details in appendixB). It is natural to use the original ConvNet with trainable weight randomness as the inference METHODS MNIST CIFAR10 network (q(f)) for this CNN-GP. However, as discussed in SVGP, RBF-ARD (Krauth et al., 2016) 1.55% - section4, using a BNN results in intractable output distri- Conv GP (van der Wilk et al., 2017) 1.22% 35.4% butions which require many efforts to address. To avoid SVGP, CNN-GP (Garriga-Alonso et al., 2019) 2.4% - this, we use a deterministic ConvNet with an NTK on top GPNet, CNN-GP 1.12% 24.63% of it defined using the fully-connected layers. This enables NN-GP (Lee et al., 2018) 1.21% 44.34% flexible covariance modeling while still allowing an efficient CNN-GP (Garriga-Alonso et al., 2019) 0.96% - ResNet-GP (Garriga-Alonso et al., 2019) 0.84% - training. With the non-conjugate form of our algorithm, we CNN-GP (Novak et al., 2019) 0.88% 32.86% are free to use a softmax likelihood, which is more suitable to classification tasks.

GP (Garriga-Alonso et al., 2019), whose covariance kernel Results are compared to recent works in table2. The are derived from an infinite-width Bayesian ConvNet (see first half of the table are approximate inference approaches appendix B.3 for detailed derivation of the GP prior). with classification likelihoods, while the second half does exact prediction by GP regression. By comparing to Previously, inference for GPs with such a kernel has only carefully-designed inducing-point approaches such as Conv been investigated through exact prediction (Garriga-Alonso GP (van der Wilk et al., 2017), we can clearly see the ad- et al., 2019; Novak et al., 2019), where the classification vantage of our method, i.e., easily scaling up GP inference problem is treated as regression so that eq. (2) applies. to highly-structured kernels by using flexible inference net- Though this is done for datasets like MNIST and CIFAR10 works that match the structures, while getting superior per- 3 in recent works, O(N ) complexity is impractical for the formance than carefully-designed inducing-point methods. method to be widely adopted. A scalable option would be sparse approximations. We tried SVGP for this prior. However, we found the training is unstable if we update 6. Conclusion the inducing point locations. Initializing them with data or We propose an algorithm to scalably train a stochastic infer- with K- centers both result in numerical errors that ence network to approximate the GP posterior distribution. prevent the method from learning. There are no other results In the algorithm the inference network is trained by tracking reported using SVGP for such kernels except in Garriga- a stochastic functional mirror descent update which is cheap Alonso et al.(2019), where they also fix the inducing point to compute from the current approximation using a mini- locations (1000 training data were used). We believe it is batch of data. Experiments show that our algorithm fixes due to the difficulty of finding good inducing point locations the minibatch issue of previous works on function-space in such a high-dimensional input space of images. inference. Empirical comparisons to sparse variational GP We test GPNet on MNIST and CIFAR10 with a CNN-GP methods show that our method is a more flexible alternative prior. The ConvNet that defines this prior has 6 residual to GP inference. Scalable Training of Inference Networks for Gaussian-Process Models

Acknowledgements de G. Matthews, A. G., van der Wilk, M., Nickson, T., Fujii, K., Boukouvalas, A., Leon-Villagr´ a,´ P., Ghahramani, Z., We thank Ziyu Wang, Shengyang Sun, Ching-An Cheng and Hensman, J. GPflow: A Gaussian process library us- for helpful discussions and Hugh Salimbeni for help with ing TensorFlow. Journal of Machine Learning Research, the experiments. JS was supported by a Microsoft Research 18(40):1–6, 2017. Asia Fellowship. This work was supported by the National Key Research and Development Program of China (No. Doucet, A., De Freitas, N., and Gordon, N. An introduction 2017YFA0700904), NSFC Projects (Nos. 61620106010, to sequential monte carlo methods. In Sequential Monte 61621136008, 61571261), Beijing NSF Project (No. Carlo methods in practice, pp. 3–14. Springer, 2001. L172037), DITD Program JCKY2017204B064, Tiangong Institute for Intelligent Computing, Beijing Academy of Eldredge, N. Analysis and probability on infinite- Artificial Intelligence (BAAI), NVIDIA NVAIL Program, dimensional spaces. arXiv preprint arXiv:1607.03591, and the projects from Siemens and Intel. 2016. Flam-Shepherd, D., Requeima, J., and Duvenaud, D. Map- References ping Gaussian process priors to Bayesian neural networks. NIPS Bayesian Workshop, 2017. Balan, A. K., Rathod, V., Murphy, K. P., and Welling, M. Bayesian dark knowledge. In Advances in Neural Infor- Gal, Y. and Turner, R. Improving the Gaussian process mation Processing Systems, pp. 3438–3446, 2015. sparse spectrum approximation by representing uncer- tainty in frequency inputs. In International Conference Bauer, M., van der Wilk, M., and Rasmussen, C. E. Under- on Machine Learning, pp. 655–664, 2015. standing probabilistic sparse Gaussian process approxi- mations. In Advances in Neural Information Processing Garnelo, M., Rosenbaum, D., Maddison, C., Ramalho, T., Systems, pp. 1533–1541, 2016. Saxton, D., Shanahan, M., Teh, Y. W., Rezende, D., and Eslami, S. A. Conditional neural processes. In Interna- Bernardo, J., Berger, J., Dawid, A., Smith, A., et al. Re- tional Conference on Machine Learning, pp. 1690–1699, gression and classification using Gaussian process priors. 2018a. Bayesian , 6:475, 1998. Garnelo, M., Schwarz, J., Rosenbaum, D., Viola, F., Bui, T. D., Nguyen, C., and Turner, R. E. Streaming sparse Rezende, D. J., Eslami, S., and Teh, Y. W. Neural pro- Gaussian process approximations. In Advances in Neural cesses. arXiv preprint arXiv:1807.01622, 2018b. Information Processing Systems, pp. 3299–3307, 2017. Garriga-Alonso, A., Rasmussen, C. E., and Aitchison, L. Cheng, C.-A. and Boots, B. Incremental variational sparse Deep convolutional networks as shallow Gaussian pro- Gaussian process regression. In Advances in Neural In- cesses. In International Conference on Learning Repre- formation Processing Systems, pp. 4410–4418, 2016. sentations, 2019. Cheng, C.-A. and Boots, B. Variational inference for Gaus- Hafner, D., Tran, D., Irpan, A., Lillicrap, T., and David- sian process models with linear complexity. In Advances son, J. Reliable uncertainty estimates in deep neural in Neural Information Processing Systems, pp. 5184– networks using noise contrastive priors. arXiv preprint 5194, 2017. arXiv:1807.09289, 2018. Cutajar, K., Bonilla, E. V., Michiardi, P., and Filippone, M. Hensman, J., Fusi, N., and Lawrence, N. D. Gaussian Random feature expansions for deep Gaussian processes. processes for big data. arXiv preprint arXiv:1309.6835, arXiv preprint arXiv:1610.04386, 2016. 2013. Dai, B., He, N., Dai, H., and Song, L. Provable Bayesian Hensman, J., Durr, N., e, and Solin, A. Variational fourier inference via particle mirror descent. In Artificial Intelli- features for Gaussian processes. Journal of Machine gence and Statistics, pp. 985–994, 2016. Learning Research, 18(151):1–52, 2018. Damianou, A. and Lawrence, N. Deep Gaussian processes. Hernandez-Lobato,´ J. M. and Adams, R. Probabilistic back- In Artificial Intelligence and Statistics, pp. 207–215, propagation for scalable learning of Bayesian neural net- 2013. works. In International Conference on Machine Learning, pp. 1861–1869, 2015. Damianou, A. C., Titsias, M. K., and Lawrence, N. D. Vari- ational inference for latent variables and uncertain inputs Jaakkola, T. and Haussler, D. Exploiting generative mod- in Gaussian processes. Journal of Machine Learning els in discriminative classifiers. In Advances in Neural Research, 17(42):1–62, 2016. Information Processing Systems, pp. 487–493, 1999. Scalable Training of Inference Networks for Gaussian-Process Models

Jacot-Guillarmod, A., Gabriel, F., and Hongler, C. Neural Novak, R., Xiao, L., Bahri, Y., Lee, J., Yang, G., Abolafia, tangent kernel: Convergence and generalization in neural D. A., Pennington, J., and Sohl-dickstein, J. Bayesian networks. In Advances in Neural Information Processing deep convolutional networks with many channels are Systems, pp. 8580–8589. 2018. Gaussian processes. In International Conference on Learning Representations, 2019. Kanagawa, M., Hennig, P., Sejdinovic, D., and Sriperum- budur, B. K. Gaussian processes and kernel methods: A Quinonero-Candela,˜ J. and Rasmussen, C. E. A unifying review on connections and equivalences. arXiv preprint view of sparse approximate Gaussian process regression. arXiv:1807.02582, 2018. Journal of Machine Learning Research, 6(Dec):1939– 1959, 2005. Khan, M. and Lin, W. Conjugate-computation varia- tional inference: Converting variational inference in non- Rahimi, A. and Recht, B. Random features for large-scale conjugate models to inferences in conjugate models. In kernel machines. In Advances in Neural Information Artificial Intelligence and Statistics, pp. 878–887, 2017. Processing Systems, pp. 1177–1184, 2008. Kingma, D. P. and Welling, M. Auto-encoding variational Raskutti, G. and Mukherjee, S. The information geometry bayes. arXiv preprint arXiv:1312.6114, 2013. of mirror descent. IEEE Transactions on Information Krauth, K., Bonilla, E. V., Cutajar, K., and Filippone, M. Au- Theory, 61(3):1451–1457, 2015. toGP: Exploring the capabilities and limitations of Gaus- sian process models. arXiv preprint arXiv:1610.05392, Rasmussen, C. E. and Williams, C. K. Gaussian processes 2016. for machine learning. MIT Press, 2006.

Lawrence, N. Probabilistic non-linear principal component Salimbeni, H. and Deisenroth, M. Doubly stochastic vari- analysis with Gaussian process latent variable models. ational inference for deep Gaussian processes. In Ad- Journal of Machine Learning Research, 6(Nov):1783– vances in Neural Information Processing Systems, pp. 1816, 2005. 4588–4599, 2017.

Lazaro-Gredilla,´ M., Quinonero-Candela,˜ J., Rasmussen, Shi, J., Chen, J., Zhu, J., Sun, S., Luo, Y., Gu, Y., and Zhou, C. E., and Figueiras-Vidal, A. R. Sparse spectrum Gaus- Y. ZhuSuan: A library for Bayesian deep learning. arXiv sian process regression. Journal of Machine Learning preprint arXiv:1709.05870, 2017. Research, 11:1865–1881, 2010. Shi, J., Sun, S., and Zhu, J. A spectral approach to gradient Lee, J., Sohl-dickstein, J., Pennington, J., Novak, R., estimation for implicit distributions. In International Schoenholz, S., and Bahri, Y. Deep neural networks Conference on Machine Learning, pp. 4651–4660, 2018. as Gaussian processes. In International Conference on Learning Representations, 2018. Snelson, E. and Ghahramani, Z. Sparse Gaussian processes using pseudo-inputs. In Advances in Neural Information Ma, C., Li, Y., and Hernandez-Lobato,´ J. M. Variational Processing Systems, pp. 1257–1264, 2006. implicit processes. arXiv preprint arXiv:1806.02390, 2018. Snoek, J., Rippel, O., Swersky, K., Kiros, R., Satish, N., Sundaram, N., Patwary, M., Prabhat, M., and Adams, MacKay, D. J. Bayesian non-linear modeling for the pre- R. Scalable Bayesian optimization using deep neural net- diction competition. In Maximum Entropy and Bayesian works. In International Conference on Machine Learning, Methods, pp. 221–234. Springer, 1996. pp. 2171–2180, 2015. Mallasto, A. and Feragen, A. Learning from uncertain curves: The 2-wasserstein metric for Gaussian processes. Sun, S., Zhang, G., Wang, C., Zeng, W., Li, J., and Grosse, In Advances in Neural Information Processing Systems, R. Differentiable compositional kernel learning for Gaus- pp. 5660–5670, 2017. sian processes. In International Conference on Machine Learning, pp. 4835–4844, 2018. Matthews, A. G. d. G., Rowland, M., Hron, J., Turner, R. E., and Ghahramani, Z. Gaussian process behaviour in wide Sun, S., Zhang, G., Shi, J., and Grosse, R. Functional deep neural networks. arXiv preprint arXiv:1804.11271, variational Bayesian neural networks. In International 2018. Conference on Learning Representations, 2019.

Neal, R. M. Bayesian Learning for Neural Networks. PhD Sutton, R. S. and Barto, A. G. Reinforcement learning - an thesis, University of Toronto, 1995. introduction. MIT Press, 1998. Scalable Training of Inference Networks for Gaussian-Process Models

Titsias, M. Variational learning of inducing variables in sparse Gaussian processes. In Artificial Intelligence and Statistics, pp. 567–574, 2009. van der Wilk, M., Rasmussen, C. E., and Hensman, J. Con- volutional Gaussian processes. In Advances in Neural Information Processing Systems, pp. 2849–2858, 2017.

Wainwright, M. J., Jordan, M. I., et al. Graphical models, exponential families, and variational inference. Founda- tions and Trends R in Machine Learning, 1(1–2):1–305, 2008. Wang, Z., Ren, T., Zhu, J., and Zhang, B. Function space particle optimization for Bayesian neural networks. In International Conference on Learning Representations, 2019. Williams, C. K. and Barber, D. Bayesian classification with Gaussian processes. IEEE Transactions on Pattern Analysis and Machine Intelligence, 20(12):1342–1351, 1998. Williams, C. K. and Rasmussen, C. E. Gaussian processes for regression. In Advances in Neural Information Pro- cessing Systems, pp. 514–520, 1996.

Wilson, A. G., Hu, Z., Salakhutdinov, R., and Xing, E. P. Deep kernel learning. In Artificial Intelligence and Statis- tics, pp. 370–378, 2016.