DEV Community

Ethan Davis
Ethan Davis

Posted on

Sparse Gaussian Process Approximations

Adapted from an appendix of my MS thesis.

Sparse Approximation

The best way to perform GP inference and training is to compute a Cholesky decomposition of the N×NN \times N Gram matrix. Unfortunately, this take O(N3)\mathcal{O}(N^ 3) time. Instead, we can use an approximation method based on inducing points, also called pseudoinputs, which are like a learned summary of the training data that we can condition on, rather than conditioning on all of it [1].

Let X\boldsymbol{X} be the observed inputs, and fX=f(X)\boldsymbol{f}_ X=f(\boldsymbol{X}) be the unknown vector of function values for which we have observations y\boldsymbol{y} . Let f\boldsymbol{f}_ \ast be the unknown function values at one or more test points X\boldsymbol{X}_ \ast . Finally, let us assume we have MM additional inputs Z\boldsymbol{Z} with unknown function values fZ\boldsymbol{f}_ Z also denoted by u\boldsymbol{u} . The exact joint prior has the following form [1].

p(fX,f)=p(f,fX,fZ)dfZ=p(f,fXfZ)p(fZ)dfZ=N(0,(KX,XKX,K,XK,)). p(\boldsymbol{f}_ X,\boldsymbol{f}_ \ast) = \int p(\boldsymbol{f}_ \ast,\boldsymbol{f}_ X,\boldsymbol{f}_ Z)\mathrm{d}\boldsymbol{f}_ Z = \int p(\boldsymbol{f}_ \ast,\boldsymbol{f}_ X|\boldsymbol{f}_ Z)p(\boldsymbol{f}_ Z)\mathrm{d}\boldsymbol{f}_ Z = \mathcal{N}\left(\boldsymbol{0}, \begin{pmatrix} \boldsymbol{K}_ {X,X} & \boldsymbol{K}_ {X,\ast} \\ \boldsymbol{K}_ {\ast,X} & \boldsymbol{K}_ {\ast,\ast} \\ \end{pmatrix} \right).

We can choose fZ\boldsymbol{f}_ Z in such a way that it acts as a sufficient statistic for the data, so that we can predict f\boldsymbol{f}_ \ast just using fZ\boldsymbol{f}_ Z instead of fX\boldsymbol{f}_ X , and thus we approximate the prior as follows [1].

p(f,fX,fZ)=p(ffX,fZ)p(fXfZ)p(fZ)p(ffZ)p(fXfZ)p(fZ). p(\boldsymbol{f}_ \ast,\boldsymbol{f}_ X,\boldsymbol{f}_ Z) = p(\boldsymbol{f}_ \ast|\boldsymbol{f}_ X,\boldsymbol{f}_ Z)p(\boldsymbol{f}_ X|\boldsymbol{f}_ Z)p(\boldsymbol{f}_ Z) \approx p(\boldsymbol{f}_ \ast|\boldsymbol{f}_ Z)p(\boldsymbol{f}_ X|\boldsymbol{f}_ Z)p(\boldsymbol{f}_ Z).

From this we derive the following train and test conditionals [1].

p(fXfZ)=N(fXKX,ZKZ,Z1fZ,KX,XQX,X)p(ffZ)=N(fK,ZKZ,Z1fZ,K,Q,). \begin{aligned} p(\boldsymbol{f}_ X|\boldsymbol{f}_ Z) &= \mathcal{N}(\boldsymbol{f}_ X|\boldsymbol{K}_ {X,Z}\boldsymbol{K}_ {Z,Z}^ {-1}\boldsymbol{f}_ Z,\boldsymbol{K}_ {X,X}-\boldsymbol{Q}_ {X,X}) \\ p(\boldsymbol{f}_ \ast|\boldsymbol{f}_ Z) &= \mathcal{N}(\boldsymbol{f}_ \ast|\boldsymbol{K}_ {\ast,Z}\boldsymbol{K}_ {Z,Z}^ {-1}\boldsymbol{f}_ Z,\boldsymbol{K}_ {\ast,\ast}-\boldsymbol{Q}_ {\ast,\ast}).\end{aligned}

The above equations can be seen as exact inference on noise-free observations fZ\boldsymbol{f}_ Z . To gain computational speedups, we can make further approximations to the terms Q~X,X=KX,XQX,X\tilde{\boldsymbol{Q}}_ {X,X}=\boldsymbol{K}_ {X,X}-\boldsymbol{Q}_ {X,X} and Q~,=K,Q,\tilde{\boldsymbol{Q}}_ {\ast,\ast}=\boldsymbol{K}_ {\ast,\ast}-\boldsymbol{Q}_ {\ast,\ast} . We can then derive the approximate prior q(fX,f)=q(fXfZ)q(ffZ)p(fZ)dfZq(\boldsymbol{f}_ X,\boldsymbol{f}_ \ast)=\int q(\boldsymbol{f}_ X|\boldsymbol{f}_ Z)q(\boldsymbol{f}_ \ast|\boldsymbol{f}_ Z)p(\boldsymbol{f}_ Z)\mathrm{d}\boldsymbol{f}_ Z , which we then condition on the observations in the usual way. All of these approximations result in a training cost of O(M3+NM2)\mathcal{O}(M^ 3+NM^ 2) , and then take O(M)\mathcal{O}(M) time for the predictive mean for each test case, and O(M2)\mathcal{O}(M^ 2) time for the predictive variance. Compare this to O(N3)\mathcal{O}(N^ 3) training time and O(N)\mathcal{O}(N) and O(N2)\mathcal{O}(N^ 2) testing time for exact inference [1].

The deterministic inducing conditional (DIC) approximation, or the subset of regressors (SOR) approximation, results from assuming Q~X,X=0\tilde{\boldsymbol{Q}}_ {X,X}=\boldsymbol{0} and Q~,=0\tilde{\boldsymbol{Q}}_ {\ast,\ast}=\boldsymbol{0} , so the conditionals are deterministic. This can result in an underestimate of the predictive variance. One way to overcome the overconfidence of DIC is to only assume Q~X,X=0\tilde{\boldsymbol{Q}}_ {X,X}=\boldsymbol{0} but let Q~,=K,Q,\tilde{\boldsymbol{Q}}_ {\ast,\ast}=\boldsymbol{K}_ {\ast,\ast}-\boldsymbol{Q}_ {\ast,\ast} be exact. This is called the deterministic training conditional (DTC). Lastly, the fully independent training conditional (FITC) approximation assumes q(fXfZ)q(\boldsymbol{f}_ X|\boldsymbol{f}_ Z) is fully factorized. This throws away less uncertainty than the SOR and DTC methods, since it does not make any deterministic assumptions about the relationship between fX\boldsymbol{f}_ X and fZ\boldsymbol{f}_ Z [1].

qSOR(fX,f)=N(0,(QX,XQX,Q,XQ,))qDTC(fX,f)=N(0,(QX,XQX,Q,XK,))qFITC(fX,f)=N(0,(QX,Xdiag(QX,XKX,X)QX,Q,XK,)). \begin{aligned} q_ {\mathrm{SOR}}(\boldsymbol{f}_ X,\boldsymbol{f}_ \ast) &= \mathcal{N}\left(\boldsymbol{0}, \begin{pmatrix} \boldsymbol{Q}_ {X,X} & \boldsymbol{Q}_ {X,\ast} \\ \boldsymbol{Q}_ {\ast,X} & \boldsymbol{Q}_ {\ast,\ast} \\ \end{pmatrix} \right) \\ q_ {\mathrm{DTC}}(\boldsymbol{f}_ X,\boldsymbol{f}_ \ast) &= \mathcal{N}\left(\boldsymbol{0}, \begin{pmatrix} \boldsymbol{Q}_ {X,X} & \boldsymbol{Q}_ {X,\ast} \\ \boldsymbol{Q}_ {\ast,X} & \boldsymbol{K}_ {\ast,\ast} \\ \end{pmatrix} \right) \\ q_ {\mathrm{FITC}}(\boldsymbol{f}_ X,\boldsymbol{f}_ \ast) &= \mathcal{N}\left(\boldsymbol{0}, \begin{pmatrix} \boldsymbol{Q}_ {X,X}-\operatorname{diag}(\boldsymbol{Q}_ {X,X}-\boldsymbol{K}_ {X,X}) & \boldsymbol{Q}_ {X,\ast} \\ \boldsymbol{Q}_ {\ast,X} & \boldsymbol{K}_ {\ast,\ast} \\ \end{pmatrix} \right).\end{aligned}

Sparse GP comparison.

Sparse GP comparison.

The simplest approach to selecting the inducing points from the training set is to throw away some of the data. In this case, we could pick random examples. However, intuitively it makes more sense to try to pick a subset that in some sense covers the original data, so it contains approximately the same information without redundancy. Clustering algorithms such as kk -means are a popular heuristic approach. We can also use coreset methods which can provably find such an information preserving subset. Furthermore, we can approach learning the inducing points by treating them like kernel hyperparameters, and choosing them so as to maximize the log marginal likelihood [1].

References

  1. Kevin P. Murphy (2023) Probabilistic Machine Learning: Advanced Topics. MIT Press.

Top comments (0)