Uncertainty, structured prediction, and causal learning · Uncertainty, structured prediction, and causal learning · UNC008 · Model
Deep Gaussian process (DGP)
Compose Gaussian-process mappings to represent nonlinear hierarchical uncertainty. Intermediate representations are random variables, distinguishing a DGP from a GP attached to a point-estimated neural feature…
In CodeSplash
Documented in the Academy only. There's no Set up button.
- Availability
- Explained here
- Code example
- Component demo, not a trained model
- Who ran it
- CodeSplash's run and the reference's record
- CodeSplash's run
- The reference's example ran in Python and R here, and they agree.
- The reference's record
- Python: Ran in the reference's review. The report doesn't record which version of the code ran. R: Reviewed but not run: R wasn't available to the reference's authors.
Purpose
Compose Gaussian-process mappings to represent nonlinear hierarchical uncertainty. Intermediate representations are random variables, distinguishing a DGP from a GP attached to a point-estimated neural feature extractor. Both supervised regression and unsupervised latent hierarchies exist; the likelihood and inference formulation determine the task.
Question / hypotheses
Can a hierarchy of stochastic functions explain data better than one GP while retaining useful predictive uncertainty? Compare predictive scores and calibration at fixed computational budgets, not depth alone.
Architecture / computational structure
Layer one maps observed or latent inputs to random hidden outputs; each later GP maps the preceding random outputs to another layer. Sparse variational implementations maintain inducing variables for every layer and propagate stochastic samples through the composition. Nonlinear composition makes exact Gaussian inference unavailable.
Assumptions
Each layer assumes a kernel/prior and an output conditional independence structure. The approximate posterior and inducing budget restrict what uncertainty can be represented. A deeper hierarchy is not automatically better; information can collapse or become difficult to optimize.
Formula / computational definition
and . A common sparse variational objective is , with layer samples retaining their conditional dependencies.
Parameters and notation
Learned: kernel/noise parameters, inducing locations and variational means/covariances. Hyperparameters: layer count, widths, kernel families, inducing counts, Monte Carlo paths, minibatch size and optimizer controls. The original latent-variable variational construction and modern doubly stochastic formulations need not use identical parameterizations.
Fitting, fine-tuning, and adaptation
Warm-start kernel and inducing parameters for new data, or freeze earlier layers and adapt the top layer as an explicitly restricted model. For sequential variational updates, specify how prior information is carried forward. Recheck numerical conditioning and uncertainty after unfreezing or changing inducing locations.
How to use and calibrate
Begin with a single GP and add depth only when validation benefits. Track ELBO components, predictive NLL, empirical interval coverage and Monte Carlo error. Plot whole sampled functions when a joint-sampling approximation permits it; independent pointwise samples can misrepresent trajectory uncertainty.
Example application
Model a smooth measured process whose response changes nonlinearly across regimes. Compare a GP, DKL model and DGP on predictive scores and uncertainty in deliberately held-out regions.
Interpretation / pitfalls
Watch out
Averaging hidden-layer means before passing them onward generally loses uncertainty and changes the model. A small variational family can be overconfident. Sampling from a prior demonstrates architecture, but it does not reproduce posterior fitting or validate practical coverage.
Python and R code examples
Scope: Two-layer GP prior-forward component on a shared input grid, with fixed standard-normal draws. The second kernel is evaluated at the sampled first-layer values; this is not a posterior or a trained DGP.
Dependencies / validation: use the shared NumPy/SciPy or base-R setup above. Python executed successfully with assertions; R reviewed but not executed.
Python and R
The reference's own programs, shown as written. A component demo shows one central piece of the method; it doesn't train a full model.
Component demo, not a trained model — Two-layer GP prior-forward component on a shared input grid, with fixed standard-normal draws. The second kernel is evaluated at the sampled first-layer values; this is not a posterior or a trained DGP.
Shared setup for this chapter
import numpy as np
from scipy.special import logsumexp, gammaln
from scipy.linalg import expm
from itertools import product
def rbf(a, b, ell=1.0):
a, b = np.atleast_2d(a), np.atleast_2d(b)
return np.exp(-np.sum((a[:, None, :] - b[None, :, :])**2, axis=2)/(2*ell**2))
x = np.linspace(-1,1,5)[:,None]
K1 = rbf(x,x,.7)+1e-8*np.eye(5)
h = np.linalg.cholesky(K1) @ np.array([.2,-.5,.8,-.1,.4])
K2 = rbf(h[:,None],h[:,None],.5)+1e-8*np.eye(5)
f = np.linalg.cholesky(K2) @ np.array([-.3,.6,.2,-.7,.1])
assert np.linalg.eigvalsh(K2).min()>0 and np.isfinite(f).all()
print({'hidden_sample':h.tolist(),'output_sample':f.tolist()})
Component demo, not a trained model — Two-layer GP prior-forward component on a shared input grid, with fixed standard-normal draws. The second kernel is evaluated at the sampled first-layer values; this is not a posterior or a trained DGP.
Shared setup for this chapter
lse <- function(z) { m <- max(z); m + log(sum(exp(z-m))) }
rbf <- function(a,b,ell=1) {
a <- as.matrix(a); b <- as.matrix(b)
D <- outer(rowSums(a*a),rowSums(b*b),"+")-2*a%*%t(b)
exp(-pmax(D,0)/(2*ell^2))
}
x <- matrix(seq(-1,1,length.out=5),ncol=1)
K1 <- rbf(x,x,.7)+1e-8*diag(5)
h <- as.vector(t(chol(K1))%*%c(.2,-.5,.8,-.1,.4))
K2 <- rbf(matrix(h,ncol=1),matrix(h,ncol=1),.5)+1e-8*diag(5)
f <- as.vector(t(chol(K2))%*%c(-.3,.6,.2,-.7,.1))
stopifnot(min(eigen(K2,symmetric=TRUE)$values)>0,all(is.finite(f)))
print(list(hidden_sample=h,output_sample=f))
Sources
- Damianou–Lawrence DGP introductionproceedings.mlr.press
- Doubly stochastic variational inferencearxiv.org
From the CodeSplash reference, entry UNC008.