{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Deep Gaussian Processes\n", "### [Neil D. Lawrence](http://inverseprobability.com), Amazon Cambridge and University of Sheffield\n", "### 2019-01-11\n", "\n", "**Abstract**: Classical machine learning and statistical approaches to learning, such\n", "as neural networks and linear regression, assume a parametric form for\n", "functions. Gaussian process models are an alternative approach that\n", "assumes a probabilistic prior over functions. This brings benefits, in\n", "that uncertainty of function estimation is sustained throughout\n", "inference, and some challenges: algorithms for fitting Gaussian\n", "processes tend to be more complex than parametric models. In these\n", "sessions I will introduce Gaussian processes and explain why sustaining\n", "uncertainty is important. We’ll then look at some extensions of Gaussian\n", "process models, in particular composition of Gaussian processes, or deep\n", "Gaussian processes.\n", "\n", "$$\n", "\\newcommand{\\Amatrix}{\\mathbf{A}}\n", "\\newcommand{\\KL}{\\text{KL}\\left( #1\\,\\|\\,#2 \\right)}\n", "\\newcommand{\\Kaast}{\\kernelMatrix_{\\mathbf{ \\ast}\\mathbf{ \\ast}}}\n", "\\newcommand{\\Kastu}{\\kernelMatrix_{\\mathbf{ \\ast} \\inducingVector}}\n", "\\newcommand{\\Kff}{\\kernelMatrix_{\\mappingFunctionVector \\mappingFunctionVector}}\n", "\\newcommand{\\Kfu}{\\kernelMatrix_{\\mappingFunctionVector \\inducingVector}}\n", "\\newcommand{\\Kuast}{\\kernelMatrix_{\\inducingVector \\bf\\ast}}\n", "\\newcommand{\\Kuf}{\\kernelMatrix_{\\inducingVector \\mappingFunctionVector}}\n", "\\newcommand{\\Kuu}{\\kernelMatrix_{\\inducingVector \\inducingVector}}\n", "\\newcommand{\\Kuui}{\\Kuu^{-1}}\n", "\\newcommand{\\Qaast}{\\mathbf{Q}_{\\bf \\ast \\ast}}\n", "\\newcommand{\\Qastf}{\\mathbf{Q}_{\\ast \\mappingFunction}}\n", "\\newcommand{\\Qfast}{\\mathbf{Q}_{\\mappingFunctionVector \\bf \\ast}}\n", "\\newcommand{\\Qff}{\\mathbf{Q}_{\\mappingFunctionVector \\mappingFunctionVector}}\n", "\\newcommand{\\aMatrix}{\\mathbf{A}}\n", "\\newcommand{\\aScalar}{a}\n", "\\newcommand{\\aVector}{\\mathbf{a}}\n", "\\newcommand{\\acceleration}{a}\n", "\\newcommand{\\bMatrix}{\\mathbf{B}}\n", "\\newcommand{\\bScalar}{b}\n", "\\newcommand{\\bVector}{\\mathbf{b}}\n", "\\newcommand{\\basisFunc}{\\phi}\n", "\\newcommand{\\basisFuncVector}{\\boldsymbol{ \\basisFunc}}\n", "\\newcommand{\\basisFunction}{\\phi}\n", "\\newcommand{\\basisLocation}{\\mu}\n", "\\newcommand{\\basisMatrix}{\\boldsymbol{ \\Phi}}\n", "\\newcommand{\\basisScalar}{\\basisFunction}\n", "\\newcommand{\\basisVector}{\\boldsymbol{ \\basisFunction}}\n", "\\newcommand{\\activationFunction}{\\phi}\n", "\\newcommand{\\activationMatrix}{\\boldsymbol{ \\Phi}}\n", "\\newcommand{\\activationScalar}{\\basisFunction}\n", "\\newcommand{\\activationVector}{\\boldsymbol{ \\basisFunction}}\n", "\\newcommand{\\bigO}{\\mathcal{O}}\n", "\\newcommand{\\binomProb}{\\pi}\n", "\\newcommand{\\cMatrix}{\\mathbf{C}}\n", "\\newcommand{\\cbasisMatrix}{\\hat{\\boldsymbol{ \\Phi}}}\n", "\\newcommand{\\cdataMatrix}{\\hat{\\dataMatrix}}\n", "\\newcommand{\\cdataScalar}{\\hat{\\dataScalar}}\n", "\\newcommand{\\cdataVector}{\\hat{\\dataVector}}\n", "\\newcommand{\\centeredKernelMatrix}{\\mathbf{ \\MakeUppercase{\\centeredKernelScalar}}}\n", "\\newcommand{\\centeredKernelScalar}{b}\n", "\\newcommand{\\centeredKernelVector}{\\centeredKernelScalar}\n", "\\newcommand{\\centeringMatrix}{\\mathbf{H}}\n", "\\newcommand{\\chiSquaredDist}{\\chi_{#1}^{2}\\left(#2\\right)}\n", "\\newcommand{\\chiSquaredSamp}{\\chi_{#1}^{2}}\n", "\\newcommand{\\conditionalCovariance}{\\boldsymbol{ \\Sigma}}\n", "\\newcommand{\\coregionalizationMatrix}{\\mathbf{B}}\n", "\\newcommand{\\coregionalizationScalar}{b}\n", "\\newcommand{\\coregionalizationVector}{\\mathbf{ \\coregionalizationScalar}}\n", "\\newcommand{\\covDist}{\\text{cov}_{#2}\\left(#1\\right)}\n", "\\newcommand{\\covSamp}{\\text{cov}\\left(#1\\right)}\n", "\\newcommand{\\covarianceScalar}{c}\n", "\\newcommand{\\covarianceVector}{\\mathbf{ \\covarianceScalar}}\n", "\\newcommand{\\covarianceMatrix}{\\mathbf{C}}\n", "\\newcommand{\\covarianceMatrixTwo}{\\boldsymbol{ \\Sigma}}\n", "\\newcommand{\\croupierScalar}{s}\n", "\\newcommand{\\croupierVector}{\\mathbf{ \\croupierScalar}}\n", "\\newcommand{\\croupierMatrix}{\\mathbf{ \\MakeUppercase{\\croupierScalar}}}\n", "\\newcommand{\\dataDim}{p}\n", "\\newcommand{\\dataIndex}{i}\n", "\\newcommand{\\dataIndexTwo}{j}\n", "\\newcommand{\\dataMatrix}{\\mathbf{Y}}\n", "\\newcommand{\\dataScalar}{y}\n", "\\newcommand{\\dataSet}{\\mathcal{D}}\n", "\\newcommand{\\dataStd}{\\sigma}\n", "\\newcommand{\\dataVector}{\\mathbf{ \\dataScalar}}\n", "\\newcommand{\\decayRate}{d}\n", "\\newcommand{\\degreeMatrix}{\\mathbf{ \\MakeUppercase{\\degreeScalar}}}\n", "\\newcommand{\\degreeScalar}{d}\n", "\\newcommand{\\degreeVector}{\\mathbf{ \\degreeScalar}}\n", "% Already defined by latex\n", "%\\newcommand{\\det}{\\left|#1\\right|}\n", "\\newcommand{\\diag}{\\text{diag}\\left(#1\\right)}\n", "\\newcommand{\\diagonalMatrix}{\\mathbf{D}}\n", "\\newcommand{\\diff}{\\frac{\\text{d}#1}{\\text{d}#2}}\n", "\\newcommand{\\diffTwo}{\\frac{\\text{d}^2#1}{\\text{d}#2^2}}\n", "\\newcommand{\\displacement}{x}\n", "\\newcommand{\\displacementVector}{\\textbf{\\displacement}}\n", "\\newcommand{\\distanceMatrix}{\\mathbf{ \\MakeUppercase{\\distanceScalar}}}\n", "\\newcommand{\\distanceScalar}{d}\n", "\\newcommand{\\distanceVector}{\\mathbf{ \\distanceScalar}}\n", "\\newcommand{\\eigenvaltwo}{\\ell}\n", "\\newcommand{\\eigenvaltwoMatrix}{\\mathbf{L}}\n", "\\newcommand{\\eigenvaltwoVector}{\\mathbf{l}}\n", "\\newcommand{\\eigenvalue}{\\lambda}\n", "\\newcommand{\\eigenvalueMatrix}{\\boldsymbol{ \\Lambda}}\n", "\\newcommand{\\eigenvalueVector}{\\boldsymbol{ \\lambda}}\n", "\\newcommand{\\eigenvector}{\\mathbf{ \\eigenvectorScalar}}\n", "\\newcommand{\\eigenvectorMatrix}{\\mathbf{U}}\n", "\\newcommand{\\eigenvectorScalar}{u}\n", "\\newcommand{\\eigenvectwo}{\\mathbf{v}}\n", "\\newcommand{\\eigenvectwoMatrix}{\\mathbf{V}}\n", "\\newcommand{\\eigenvectwoScalar}{v}\n", "\\newcommand{\\entropy}{\\mathcal{H}\\left(#1\\right)}\n", "\\newcommand{\\errorFunction}{E}\n", "\\newcommand{\\expDist}{\\left<#1\\right>_{#2}}\n", "\\newcommand{\\expSamp}{\\left<#1\\right>}\n", "\\newcommand{\\expectation}{\\left\\langle #1 \\right\\rangle }\n", "\\newcommand{\\expectationDist}{\\left\\langle #1 \\right\\rangle _{#2}}\n", "\\newcommand{\\expectedDistanceMatrix}{\\mathcal{D}}\n", "\\newcommand{\\eye}{\\mathbf{I}}\n", "\\newcommand{\\fantasyDim}{r}\n", "\\newcommand{\\fantasyMatrix}{\\mathbf{ \\MakeUppercase{\\fantasyScalar}}}\n", "\\newcommand{\\fantasyScalar}{z}\n", "\\newcommand{\\fantasyVector}{\\mathbf{ \\fantasyScalar}}\n", "\\newcommand{\\featureStd}{\\varsigma}\n", "\\newcommand{\\gammaCdf}{\\mathcal{GAMMA CDF}\\left(#1|#2,#3\\right)}\n", "\\newcommand{\\gammaDist}{\\mathcal{G}\\left(#1|#2,#3\\right)}\n", "\\newcommand{\\gammaSamp}{\\mathcal{G}\\left(#1,#2\\right)}\n", "\\newcommand{\\gaussianDist}{\\mathcal{N}\\left(#1|#2,#3\\right)}\n", "\\newcommand{\\gaussianSamp}{\\mathcal{N}\\left(#1,#2\\right)}\n", "\\newcommand{\\given}{|}\n", "\\newcommand{\\half}{\\frac{1}{2}}\n", "\\newcommand{\\heaviside}{H}\n", "\\newcommand{\\hiddenMatrix}{\\mathbf{ \\MakeUppercase{\\hiddenScalar}}}\n", "\\newcommand{\\hiddenScalar}{h}\n", "\\newcommand{\\hiddenVector}{\\mathbf{ \\hiddenScalar}}\n", "\\newcommand{\\identityMatrix}{\\eye}\n", "\\newcommand{\\inducingInputScalar}{z}\n", "\\newcommand{\\inducingInputVector}{\\mathbf{ \\inducingInputScalar}}\n", "\\newcommand{\\inducingInputMatrix}{\\mathbf{Z}}\n", "\\newcommand{\\inducingScalar}{u}\n", "\\newcommand{\\inducingVector}{\\mathbf{ \\inducingScalar}}\n", "\\newcommand{\\inducingMatrix}{\\mathbf{U}}\n", "\\newcommand{\\inlineDiff}{\\text{d}#1/\\text{d}#2}\n", "\\newcommand{\\inputDim}{q}\n", "\\newcommand{\\inputMatrix}{\\mathbf{X}}\n", "\\newcommand{\\inputScalar}{x}\n", "\\newcommand{\\inputSpace}{\\mathcal{X}}\n", "\\newcommand{\\inputVals}{\\inputVector}\n", "\\newcommand{\\inputVector}{\\mathbf{ \\inputScalar}}\n", "\\newcommand{\\iterNum}{k}\n", "\\newcommand{\\kernel}{\\kernelScalar}\n", "\\newcommand{\\kernelMatrix}{\\mathbf{K}}\n", "\\newcommand{\\kernelScalar}{k}\n", "\\newcommand{\\kernelVector}{\\mathbf{ \\kernelScalar}}\n", "\\newcommand{\\kff}{\\kernelScalar_{\\mappingFunction \\mappingFunction}}\n", "\\newcommand{\\kfu}{\\kernelVector_{\\mappingFunction \\inducingScalar}}\n", "\\newcommand{\\kuf}{\\kernelVector_{\\inducingScalar \\mappingFunction}}\n", "\\newcommand{\\kuu}{\\kernelVector_{\\inducingScalar \\inducingScalar}}\n", "\\newcommand{\\lagrangeMultiplier}{\\lambda}\n", "\\newcommand{\\lagrangeMultiplierMatrix}{\\boldsymbol{ \\Lambda}}\n", "\\newcommand{\\lagrangian}{L}\n", "\\newcommand{\\laplacianFactor}{\\mathbf{ \\MakeUppercase{\\laplacianFactorScalar}}}\n", "\\newcommand{\\laplacianFactorScalar}{m}\n", "\\newcommand{\\laplacianFactorVector}{\\mathbf{ \\laplacianFactorScalar}}\n", "\\newcommand{\\laplacianMatrix}{\\mathbf{L}}\n", "\\newcommand{\\laplacianScalar}{\\ell}\n", "\\newcommand{\\laplacianVector}{\\mathbf{ \\ell}}\n", "\\newcommand{\\latentDim}{q}\n", "\\newcommand{\\latentDistanceMatrix}{\\boldsymbol{ \\Delta}}\n", "\\newcommand{\\latentDistanceScalar}{\\delta}\n", "\\newcommand{\\latentDistanceVector}{\\boldsymbol{ \\delta}}\n", "\\newcommand{\\latentForce}{f}\n", "\\newcommand{\\latentFunction}{u}\n", "\\newcommand{\\latentFunctionVector}{\\mathbf{ \\latentFunction}}\n", "\\newcommand{\\latentFunctionMatrix}{\\mathbf{ \\MakeUppercase{\\latentFunction}}}\n", "\\newcommand{\\latentIndex}{j}\n", "\\newcommand{\\latentScalar}{z}\n", "\\newcommand{\\latentVector}{\\mathbf{ \\latentScalar}}\n", "\\newcommand{\\latentMatrix}{\\mathbf{Z}}\n", "\\newcommand{\\learnRate}{\\eta}\n", "\\newcommand{\\lengthScale}{\\ell}\n", "\\newcommand{\\rbfWidth}{\\ell}\n", "\\newcommand{\\likelihoodBound}{\\mathcal{L}}\n", "\\newcommand{\\likelihoodFunction}{L}\n", "\\newcommand{\\locationScalar}{\\mu}\n", "\\newcommand{\\locationVector}{\\boldsymbol{ \\locationScalar}}\n", "\\newcommand{\\locationMatrix}{\\mathbf{M}}\n", "\\newcommand{\\variance}{\\text{var}\\left( #1 \\right)}\n", "\\newcommand{\\mappingFunction}{f}\n", "\\newcommand{\\mappingFunctionMatrix}{\\mathbf{F}}\n", "\\newcommand{\\mappingFunctionTwo}{g}\n", "\\newcommand{\\mappingFunctionTwoMatrix}{\\mathbf{G}}\n", "\\newcommand{\\mappingFunctionTwoVector}{\\mathbf{ \\mappingFunctionTwo}}\n", "\\newcommand{\\mappingFunctionVector}{\\mathbf{ \\mappingFunction}}\n", "\\newcommand{\\scaleScalar}{s}\n", "\\newcommand{\\mappingScalar}{w}\n", "\\newcommand{\\mappingVector}{\\mathbf{ \\mappingScalar}}\n", "\\newcommand{\\mappingMatrix}{\\mathbf{W}}\n", "\\newcommand{\\mappingScalarTwo}{v}\n", "\\newcommand{\\mappingVectorTwo}{\\mathbf{ \\mappingScalarTwo}}\n", "\\newcommand{\\mappingMatrixTwo}{\\mathbf{V}}\n", "\\newcommand{\\maxIters}{K}\n", "\\newcommand{\\meanMatrix}{\\mathbf{M}}\n", "\\newcommand{\\meanScalar}{\\mu}\n", "\\newcommand{\\meanTwoMatrix}{\\mathbf{M}}\n", "\\newcommand{\\meanTwoScalar}{m}\n", "\\newcommand{\\meanTwoVector}{\\mathbf{ \\meanTwoScalar}}\n", "\\newcommand{\\meanVector}{\\boldsymbol{ \\meanScalar}}\n", "\\newcommand{\\mrnaConcentration}{m}\n", "\\newcommand{\\naturalFrequency}{\\omega}\n", "\\newcommand{\\neighborhood}{\\mathcal{N}\\left( #1 \\right)}\n", "\\newcommand{\\neilurl}{http://inverseprobability.com/}\n", "\\newcommand{\\noiseMatrix}{\\boldsymbol{ E}}\n", "\\newcommand{\\noiseScalar}{\\epsilon}\n", "\\newcommand{\\noiseVector}{\\boldsymbol{ \\epsilon}}\n", "\\newcommand{\\norm}{\\left\\Vert #1 \\right\\Vert}\n", "\\newcommand{\\normalizedLaplacianMatrix}{\\hat{\\mathbf{L}}}\n", "\\newcommand{\\normalizedLaplacianScalar}{\\hat{\\ell}}\n", "\\newcommand{\\normalizedLaplacianVector}{\\hat{\\mathbf{ \\ell}}}\n", "\\newcommand{\\numActive}{m}\n", "\\newcommand{\\numBasisFunc}{m}\n", "\\newcommand{\\numComponents}{m}\n", "\\newcommand{\\numComps}{K}\n", "\\newcommand{\\numData}{n}\n", "\\newcommand{\\numFeatures}{K}\n", "\\newcommand{\\numHidden}{h}\n", "\\newcommand{\\numInducing}{m}\n", "\\newcommand{\\numLayers}{\\ell}\n", "\\newcommand{\\numNeighbors}{K}\n", "\\newcommand{\\numSequences}{s}\n", "\\newcommand{\\numSuccess}{s}\n", "\\newcommand{\\numTasks}{m}\n", "\\newcommand{\\numTime}{T}\n", "\\newcommand{\\numTrials}{S}\n", "\\newcommand{\\outputIndex}{j}\n", "\\newcommand{\\paramVector}{\\boldsymbol{ \\theta}}\n", "\\newcommand{\\parameterMatrix}{\\boldsymbol{ \\Theta}}\n", "\\newcommand{\\parameterScalar}{\\theta}\n", "\\newcommand{\\parameterVector}{\\boldsymbol{ \\parameterScalar}}\n", "\\newcommand{\\partDiff}{\\frac{\\partial#1}{\\partial#2}}\n", "\\newcommand{\\precisionScalar}{j}\n", "\\newcommand{\\precisionVector}{\\mathbf{ \\precisionScalar}}\n", "\\newcommand{\\precisionMatrix}{\\mathbf{J}}\n", "\\newcommand{\\pseudotargetScalar}{\\widetilde{y}}\n", "\\newcommand{\\pseudotargetVector}{\\mathbf{ \\pseudotargetScalar}}\n", "\\newcommand{\\pseudotargetMatrix}{\\mathbf{ \\widetilde{Y}}}\n", "\\newcommand{\\rank}{\\text{rank}\\left(#1\\right)}\n", "\\newcommand{\\rayleighDist}{\\mathcal{R}\\left(#1|#2\\right)}\n", "\\newcommand{\\rayleighSamp}{\\mathcal{R}\\left(#1\\right)}\n", "\\newcommand{\\responsibility}{r}\n", "\\newcommand{\\rotationScalar}{r}\n", "\\newcommand{\\rotationVector}{\\mathbf{ \\rotationScalar}}\n", "\\newcommand{\\rotationMatrix}{\\mathbf{R}}\n", "\\newcommand{\\sampleCovScalar}{s}\n", "\\newcommand{\\sampleCovVector}{\\mathbf{ \\sampleCovScalar}}\n", "\\newcommand{\\sampleCovMatrix}{\\mathbf{s}}\n", "\\newcommand{\\scalarProduct}{\\left\\langle{#1},{#2}\\right\\rangle}\n", "\\newcommand{\\sign}{\\text{sign}\\left(#1\\right)}\n", "\\newcommand{\\sigmoid}{\\sigma\\left(#1\\right)}\n", "\\newcommand{\\singularvalue}{\\ell}\n", "\\newcommand{\\singularvalueMatrix}{\\mathbf{L}}\n", "\\newcommand{\\singularvalueVector}{\\mathbf{l}}\n", "\\newcommand{\\sorth}{\\mathbf{u}}\n", "\\newcommand{\\spar}{\\lambda}\n", "\\newcommand{\\trace}{\\text{tr}\\left(#1\\right)}\n", "\\newcommand{\\BasalRate}{B}\n", "\\newcommand{\\DampingCoefficient}{C}\n", "\\newcommand{\\DecayRate}{D}\n", "\\newcommand{\\Displacement}{X}\n", "\\newcommand{\\LatentForce}{F}\n", "\\newcommand{\\Mass}{M}\n", "\\newcommand{\\Sensitivity}{S}\n", "\\newcommand{\\basalRate}{b}\n", "\\newcommand{\\dampingCoefficient}{c}\n", "\\newcommand{\\mass}{m}\n", "\\newcommand{\\sensitivity}{s}\n", "\\newcommand{\\springScalar}{\\kappa}\n", "\\newcommand{\\springVector}{\\boldsymbol{ \\kappa}}\n", "\\newcommand{\\springMatrix}{\\boldsymbol{ \\mathcal{K}}}\n", "\\newcommand{\\tfConcentration}{p}\n", "\\newcommand{\\tfDecayRate}{\\delta}\n", "\\newcommand{\\tfMrnaConcentration}{f}\n", "\\newcommand{\\tfVector}{\\mathbf{ \\tfConcentration}}\n", "\\newcommand{\\velocity}{v}\n", "\\newcommand{\\sufficientStatsScalar}{g}\n", "\\newcommand{\\sufficientStatsVector}{\\mathbf{ \\sufficientStatsScalar}}\n", "\\newcommand{\\sufficientStatsMatrix}{\\mathbf{G}}\n", "\\newcommand{\\switchScalar}{s}\n", "\\newcommand{\\switchVector}{\\mathbf{ \\switchScalar}}\n", "\\newcommand{\\switchMatrix}{\\mathbf{S}}\n", "\\newcommand{\\tr}{\\text{tr}\\left(#1\\right)}\n", "\\newcommand{\\loneNorm}{\\left\\Vert #1 \\right\\Vert_1}\n", "\\newcommand{\\ltwoNorm}{\\left\\Vert #1 \\right\\Vert_2}\n", "\\newcommand{\\onenorm}{\\left\\vert#1\\right\\vert_1}\n", "\\newcommand{\\twonorm}{\\left\\Vert #1 \\right\\Vert}\n", "\\newcommand{\\vScalar}{v}\n", "\\newcommand{\\vVector}{\\mathbf{v}}\n", "\\newcommand{\\vMatrix}{\\mathbf{V}}\n", "\\newcommand{\\varianceDist}{\\text{var}_{#2}\\left( #1 \\right)}\n", "% Already defined by latex\n", "%\\newcommand{\\vec}{#1:}\n", "\\newcommand{\\vecb}{\\left(#1\\right):}\n", "\\newcommand{\\weightScalar}{w}\n", "\\newcommand{\\weightVector}{\\mathbf{ \\weightScalar}}\n", "\\newcommand{\\weightMatrix}{\\mathbf{W}}\n", "\\newcommand{\\weightedAdjacencyMatrix}{\\mathbf{A}}\n", "\\newcommand{\\weightedAdjacencyScalar}{a}\n", "\\newcommand{\\weightedAdjacencyVector}{\\mathbf{ \\weightedAdjacencyScalar}}\n", "\\newcommand{\\onesVector}{\\mathbf{1}}\n", "\\newcommand{\\zerosVector}{\\mathbf{0}}\n", "$$\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "
\n", "\n", " \n", "\n", "
\n", "\n", "
\n", "The cosmic microwave background is, to a very high degree of\n", "precision, a Gaussian process. The parameters of its covariance function\n", "are given by fundamental parameters of the universe, such as the amount\n", "of dark matter and mass.\n", "
\n", "
\n", "\n", " $=f\\Bigg($ $\\Bigg)$\n", "\n", "
\n", "\n", "
\n", "What we observe today is some non-linear function of the cosmic\n", "microwave background.\n", "
\n", "
\n", "Image credit: Kai Arulkumaran\n", "
\n", "Inference in a Gaussian process has computational complexity of\n", "$\\bigO(\\numData^3)$ and storage demands of $\\bigO(\\numData^2)$. This is\n", "too large for many modern data sets.\n", "\n", "Low rank approximations allow us to work with Gaussian processes with\n", "computational complexity of $\\bigO(\\numData\\numInducing^2)$ and storage\n", "demands of $\\bigO(\\numData\\numInducing)$, where $\\numInducing$ is a user\n", "chosen parameter.\n", "\n", "In machine learning, low rank approximations date back to\n", "@Smola:sparsegp00, @Williams:nystrom00, who considered the Nystr\"om\n", "approximation and @Csato:sparse02;@Csato:thesis02 who considered low\n", "rank approximations in the context of on-line learning. Selection of\n", "active points for the approximation was considered by @Seeger:fast03 and\n", "@Snelson:pseudo05 first proposed that the active set could be optimized\n", "directly. Those approaches were reviewed by @Quinonero:unifying05 under\n", "a unifying likelihood approximation perspective. General rules for\n", "deriving the maximum likelihood for these sparse approximations were\n", "given in @Lawrence:larger07.\n", "\n", "Modern variational interpretations of these low rank approaches were\n", "first explored in @Titsias:variational09. A more modern summary which\n", "considers each of these approximations as an $\\alpha$-divergence is\n", "given by @Thang:unifying17.\n", "\n", "### Variational Compression\n", "\n", "Inducing variables are a compression of the real observations. The basic\n", "idea is can I create a new data set that summarizes all the information\n", "in the original data set. If this data set is smaller, I've compressed\n", "the information in the original data set.\n", "\n", "Inducing variables can be thought of as pseudo-data, indeed in\n", "@Snelson:pseudo05 they were referred to as *pseudo-points*.\n", "\n", "The only requirement for inducing variables is that they are jointly\n", "distributed as a Gaussian process with the original data. This means\n", "that they can be from the space $\\mappingFunctionVector$ or a space that\n", "is related through a linear operator (see e.g. @Alvarez:efficient10).\n", "For example we could choose to store the gradient of the function at\n", "particular points or a value from the frequency spectrum of the function\n", "[@Lazaro:spectrum10].\n", "\n", "### Variational Compression II\n", "\n", "Inducing variables don't only allow for the compression of the\n", "non-parameteric information into a reduced data aset but they also allow\n", "for computational scaling of the algorithms through, for example\n", "stochastic variational approaches @Hensman:bigdata13 or parallelization\n", "@Gal:Distributed14,@Dai:gpu14, @Seeger:auto17.\n", "\n", "\n", "We’ve seen how we go from parametric to non-parametric. The limit\n", "implies infinite dimensional $\\mappingVector$. Gaussian processes are\n", "generally non-parametric: combine data with covariance function to get\n", "model. This representation *cannot* be summarized by a parameter vector\n", "of a fixed size.\n", "\n", "Parametric models have a representation that does not respond to\n", "increasing training set size. Bayesian posterior distributions over\n", "parameters contain the information about the training data, for example\n", "if we use use Bayes’ rule from training data, $$\n", "p\\left(\\mappingVector|\\dataVector, \\inputMatrix\\right),\n", "$$ to make predictions on test data $$\n", "p\\left(\\dataScalar_*|\\inputMatrix_*, \\dataVector, \\inputMatrix\\right) = \\int\n", " p\\left(\\dataScalar_*|\\mappingVector,\\inputMatrix_*\\right)p\\left(\\mappingVector|\\dataVector,\n", " \\inputMatrix)\\text{d}\\mappingVector\\right)\n", "$$ then $\\mappingVector$ becomes a bottleneck for information about the\n", "training set to pass to the test set. The solution is to increase\n", "$\\numBasisFunc$ so that the bottleneck is so large that it no longer\n", "presents a problem. How big is big enough for $\\numBasisFunc$?\n", "Non-parametrics says $\\numBasisFunc \\rightarrow \\infty$.\n", "\n", "Now no longer possible to manipulate the model through the standard\n", "parametric form. However, it *is* possible to express *parametric* as\n", "GPs: $$\n", "\\kernelScalar\\left(\\inputVector_i,\\inputVector_j\\right)=\\basisFunction_:\\left(\\inputVector_i\\right)^\\top\\basisFunction_:\\left(\\inputVector_j\\right).\n", "$$ These are known as degenerate covariance matrices. Their rank is at\n", "most $\\numBasisFunc$, non-parametric models have full rank covariance\n", "matrices. Most well known is the “linear kernel”, $$\n", "\\kernelScalar(\\inputVector_i, \\inputVector_j) = \\inputVector_i^\\top\\inputVector_j.\n", "$$ For non-parametrics prediction at a new point,\n", "$\\mappingFunctionVector_*$, is made by conditioning on\n", "$\\mappingFunctionVector$ in the joint distribution. In GPs this involves\n", "combining the training data with the covariance function and the mean\n", "function. Parametric is a special case when conditional prediction can\n", "be summarized in a *fixed* number of parameters. Complexity of\n", "parametric model remains fixed regardless of the size of our training\n", "data set. For a non-parametric model the required number of parameters\n", "grows with the size of the training data.\n", "\n", "### Augment Variable Space\n", "\n", "In inducing variable approximations, we augment the variable space with\n", "a set of inducing points, $\\inducingVector$. These inducing points are\n", "jointly Gaussian distributed with the points from our function,\n", "$\\mappingFunctionVector$. So we have a joint Gaussian process with\n", "covariance, $$\n", "\\begin{bmatrix}\n", "\\mappingFunctionVector\\\\\n", "\\inducingVector\n", "\\end{bmatrix} \\sim \\gaussianSamp{\\zerosVector}{\\kernelMatrix}\n", "$$ where the kernel matrix itself can be decomposed into $$\n", "\\kernelMatrix =\n", "\\begin{bmatrix}\n", "\\Kff & \\Kfu \\\\\n", "\\Kuf & \\Kuu\n", "\\end{bmatrix}\n", "$$\n", "\n", "This defines a joint density between the original function points,\n", "$\\mappingFunctionVector$ and our inducing points, $\\inducingVector$.\n", "This can be decomposed through the product rule to give. $$\n", "p(\\mappingFunctionVector, \\inducingVector) = p(\\mappingFunctionVector| \\inducingVector) p(\\inducingVector)\n", "$$ The Gaussian process is (typically) given by a noise corrupted form\n", "of $\\mappingFunctionVector$, i.e., $$\n", "\\dataScalar(\\inputVector) = \\mappingFunction(\\inputVector) + \\noiseScalar,\n", "$$ which can be written probabilisticlly as, $$\n", "p(\\dataVector) = \\int p(\\dataVector|\\mappingFunctionVector) p(\\mappingFunctionVector) \\text{d}\\mappingFunctionVector,\n", "$$ where for the independent case we have\n", "$p(\\dataVector | \\mappingFunctionVector) = \\prod_{i=1}^\\numData p(\\dataScalar_i|\\mappingFunction_i)$.\n", "\n", "Inducing variables are like auxilliary variables in Monte Carlo\n", "algorithms. We introduce the inducing variables by augmenting this\n", "integral with an additional integral over $\\inducingVector$, $$\n", "p(\\dataVector) = \\int p(\\dataVector|\\mappingFunctionVector) p(\\mappingFunctionVector|\\inducingVector) p(\\inducingVector) \\text{d}\\inducingVector \\text{d}\\mappingFunctionVector.\n", "$$ Now, conceptually speaking we are going to integrate out\n", "\\$\\mappingFunctionVector\\#, initially leaving \\$\\inducingVector in\n", "place. This gives, $$\n", "p(\\dataVector) = \\int p(\\dataVector|\\inducingVector) p(\\inducingVector) \\text{d}\\inducingVector.\n", "$$\n", "\n", "Note the similarity between this form and our standard *parametric*\n", "form. If we had defined our model through standard basis functions we\n", "would have, $$\n", "\\dataScalar(\\inputVector) = \\weightVector^\\top\\basisVector(\\inputVector) + \\noiseScalar\n", "$$ and the resulting probabilistic representation would be $$\n", "p(\\dataVector) = \\int p(\\dataVector|\\weightVector) p(\\weightVector) \\text{d} \\weightVector\n", "$$ allowing us to predict $$\n", "p(\\dataVector^*|\\dataVector) = \\int p(\\dataVector^*|\\weightVector) p(\\weightVector|\\dataVector) \\text{d} \\weightVector\n", "$$\n", "\n", "The new prediction algorithm involves $$\n", "p(\\dataVector^*|\\dataVector) = \\int p(\\dataVector^*|\\inducingVector) p(\\inducingVector|\\dataVector) \\text{d} \\inducingVector\n", "$$ but *importantly* the length of $\\inducingVector$ is not fixed at\n", "*design* time like the number of parameters were. We can vary the number\n", "of inducing variables we use to give us the model capacity we require.\n", "\n", "Unfortunately, computation of $p(\\dataVector|\\inducingVector)$ turns out\n", "to be intractable. As a result, we need to turn to approximations to\n", "make progress.\n", "\n", "### Variational Bound on $p(\\dataVector |\\inducingVector)$\n", "\n", "The conditional density of the data given the inducing points can be\n", "*lower* bounded variationally \n", "\\begin{aligned}\n", " \\log p(\\dataVector|\\inducingVector) & = \\log \\int p(\\dataVector|\\mappingFunctionVector) p(\\mappingFunctionVector|\\inducingVector) \\text{d}\\mappingFunctionVector\\\\ & = \\int q(\\mappingFunctionVector) \\log \\frac{p(\\dataVector|\\mappingFunctionVector) p(\\mappingFunctionVector|\\inducingVector)}{q(\\mappingFunctionVector)}\\text{d}\\mappingFunctionVector + \\KL{q(\\mappingFunctionVector)}{p(\\mappingFunctionVector|\\dataVector, \\inducingVector)}.\n", "\\end{aligned}\n", "\n", "\n", "The key innovation from @Titsias:variational09 was to then make a\n", "particular choice for $q(\\mappingFunctionVector)$. If we set\n", "$q(\\mappingFunctionVector)=p(\\mappingFunctionVector|\\inducingVector)$,\n", "$$\n", " \\log p(\\dataVector|\\inducingVector) \\geq \\log \\int p(\\mappingFunctionVector|\\inducingVector) \\log p(\\dataVector|\\mappingFunctionVector)\\text{d}\\mappingFunctionVector.\n", "$$ $$\n", " p(\\dataVector|\\inducingVector) \\geq \\exp \\int p(\\mappingFunctionVector|\\inducingVector) \\log p(\\dataVector|\\mappingFunctionVector)\\text{d}\\mappingFunctionVector.\n", "$$\n", "\n", "### Optimal Compression in Inducing Variables\n", "\n", "Maximizing the lower bound minimizes the Kullback-Leibler divergence (or\n", "*information gain*) between our approximating density,\n", "$p(\\mappingFunctionVector|\\inducingVector)$ and the true posterior\n", "density, $p(\\mappingFunctionVector|\\dataVector, \\inducingVector)$.\n", "\n", "$$\n", " \\KL{p(\\mappingFunctionVector|\\inducingVector)}{p(\\mappingFunctionVector|\\dataVector, \\inducingVector)} = \\int p(\\mappingFunctionVector|\\inducingVector) \\log \\frac{p(\\mappingFunctionVector|\\inducingVector)}{p(\\mappingFunctionVector|\\dataVector, \\inducingVector)}\\text{d}\\inducingVector\n", "$$\n", "\n", "This bound is minimized when the information stored about $\\dataVector$\n", "is already stored in $\\inducingVector$. In other words, maximizing the\n", "bound seeks an *optimal compression* from the *information gain*\n", "perspective.\n", "\n", "For the case where $\\inducingVector = \\mappingFunctionVector$ the bound\n", "is exact ($\\mappingFunctionVector$ $d$-separates $\\dataVector$ from\n", "$\\inducingVector$).\n", "\n", "### Choice of Inducing Variables\n", "\n", "The quality of the resulting bound is determined by the choice of the\n", "inducing variables. You are free to choose whichever heuristics you like\n", "for the inducing variables, as long as they are drawn jointly from a\n", "valid Gaussian process, i.e. such that $$\n", "\\begin{bmatrix}\n", "\\mappingFunctionVector\\\\\n", "\\inducingVector\n", "\\end{bmatrix} \\sim \\gaussianSamp{\\zerosVector}{\\kernelMatrix}\n", "$$ where the kernel matrix itself can be decomposed into $$\n", "\\kernelMatrix =\n", "\\begin{bmatrix}\n", "\\Kff & \\Kfu \\\\\n", "\\Kuf & \\Kuu\n", "\\end{bmatrix}\n", "$$ Choosing the inducing variables amounts to specifying $\\Kfu$ and\n", "$\\Kuu$ such that $\\kernelMatrix$ remains positive definite. The typical\n", "choice is to choose $\\inducingVector$ in the same domain as\n", "$\\mappingFunctionVector$, associating each inducing output,\n", "$\\inducingScalar_i$ with a corresponding input location\n", "$\\inducingInputVector$. However, more imaginative choices are absolutely\n", "possible. In particular, if $\\inducingVector$ is related to\n", "$\\mappingFunctionVector$ through a linear operator (see e.g.\n", "@Alvarez:efficient10), then valid $\\Kuu$ and $\\Kuf$ can be constructed.\n", "For example we could choose to store the gradient of the function at\n", "particular points or a value from the frequency spectrum of the function\n", "[@Lazaro:spectrum10].\n", "\n", "### Variational Compression II\n", "\n", "Inducing variables don't only allow for the compression of the\n", "non-parameteric information into a reduced data set but they also allow\n", "for computational scaling of the algorithms through, for example\n", "stochastic variational\n", "approaches[@Hoffman:stochastic12; @Hensman:bigdata13] or parallelization\n", "@Gal:Distributed14,@Dai:gpu14, @Seeger:auto17.\n", "\n", "\n", "### A Simple Regression Problem\n", "\n", "Here we set up a simple one dimensional regression problem. The input\n", "locations, $\\inputMatrix$, are in two separate clusters. The response\n", "variable, $\\dataVector$, is sampled from a Gaussian process with an\n", "exponentiated quadratic covariance." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import numpy as np\n", "import GPy" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "np.random.seed(101)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "N = 50\n", "noise_var = 0.01\n", "X = np.zeros((50, 1))\n", "X[:25, :] = np.linspace(0,3,25)[:,None] # First cluster of inputs/covariates\n", "X[25:, :] = np.linspace(7,10,25)[:,None] # Second cluster of inputs/covariates\n", "\n", "# Sample response variables from a Gaussian process with exponentiated quadratic covariance.\n", "k = GPy.kern.RBF(1)\n", "y = np.random.multivariate_normal(np.zeros(N),k.K(X)+np.eye(N)*np.sqrt(noise_var)).reshape(-1,1)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "First we perform a full Gaussian process regression on the data. We\n", "create a GP model, m_full, and fit it to the data, plotting the\n", "resulting fit." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "m_full = GPy.models.GPRegression(X,y)\n", "_ = m_full.optimize(messages=True) # Optimize parameters of covariance function" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import matplotlib.pyplot as plt\n", "import mlai\n", "import teaching_plots as plot \n", "from gp_tutorial import gpplot" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "fig, ax = plt.subplots(figsize=plot.big_wide_figsize)\n", "plot.model_output(m_full, ax=ax, xlabel='$x$', ylabel='$y$', fontsize=20, portion=0.2)\n", "xlim = ax.get_xlim()\n", "ylim = ax.get_ylim()\n", "mlai.write_figure(figure=fig,\n", " filename='../slides/diagrams/gp/sparse-demo-full-gp.svg', \n", " transparent=True, frameon=True)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ " \n", "
\n", "Full Gaussian process fitted to the data set.\n", "
\n", "Now we set up the inducing variables, $\\mathbf{u}$. Each inducing\n", "variable has its own associated input index, $\\mathbf{Z}$, which lives\n", "in the same space as $\\inputMatrix$. Here we are using the true\n", "covariance function parameters to generate the fit." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "kern = GPy.kern.RBF(1)\n", "Z = np.hstack(\n", " (np.linspace(2.5,4.,3),\n", " np.linspace(7,8.5,3)))[:,None]\n", "m = GPy.models.SparseGPRegression(X,y,kernel=kern,Z=Z)\n", "m.noise_var = noise_var\n", "m.inducing_inputs.constrain_fixed()\n", "display(m)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "fig, ax = plt.subplots(figsize=plot.big_wide_figsize)\n", "plot.model_output(m, ax=ax, xlabel='$x$', ylabel='$y$', fontsize=20, portion=0.2, xlim=xlim, ylim=ylim)\n", "mlai.write_figure(figure=fig,\n", " filename='../slides/diagrams/gp/sparse-demo-constrained-inducing-6-unlearned-gp.svg', \n", " transparent=True, frameon=True)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ " \n", "
\n", "Sparse Gaussian process fitted with six inducing variables, no\n", "optimization of parameters or inducing variables.\n", "
" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "_ = m.optimize(messages=True)\n", "display(m)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "fig, ax = plt.subplots(figsize=plot.big_wide_figsize)\n", "plot.model_output(m, ax=ax, xlabel='$x$', ylabel='$y$', fontsize=20, portion=0.2, xlim=xlim, ylim=ylim)\n", "mlai.write_figure(figure=fig,\n", " filename='../slides/diagrams/gp/sparse-demo-constrained-inducing-6-learned-gp.svg', \n", " transparent=True, frameon=True)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ " \n", "
\n", "Gaussian process fitted with inducing variables fixed and parameters\n", "optimized\n", "
" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "m.randomize()\n", "m.inducing_inputs.unconstrain()\n", "_ = m.optimize(messages=True)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "fig, ax = plt.subplots(figsize=plot.big_wide_figsize)\n", "plot.model_output(m, ax=ax, xlabel='$x$', ylabel='$y$', fontsize=20, portion=0.2,xlim=xlim, ylim=ylim)\n", "mlai.write_figure(figure=fig,\n", " filename='../slides/diagrams/gp/sparse-demo-unconstrained-inducing-6-gp.svg', \n", " transparent=True, frameon=True)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ " \n", "
\n", "Gaussian process fitted with location of inducing variables and\n", "parameters both optimized\n", "
\n", "Now we will vary the number of inducing points used to form the\n", "approximation." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "m.num_inducing=8\n", "m.randomize()\n", "M = 8\n", "m.set_Z(np.random.rand(M,1)*12)\n", "\n", "_ = m.optimize(messages=True)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "fig, ax = plt.subplots(figsize=plot.big_wide_figsize)\n", "plot.model_output(m, ax=ax, xlabel='$x$', ylabel='$y$', fontsize=20, portion=0.2, xlim=xlim, ylim=ylim)\n", "mlai.write_figure(figure=fig,\n", " filename='../slides/diagrams/gp/sparse-demo-sparse-inducing-8-gp.svg', \n", " transparent=True, frameon=True)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "
\n", "Comparison of the full Gaussian process fit with a sparse Gaussian\n", "process using eight inducing varibles. Both inducing variables and\n", "parameters are optimized.\n", "
\n", "And we can compare the probability of the result to the full model." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "print(m.log_likelihood(), m_full.log_likelihood())" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "- Let’s be explicity about storing approximate posterior of\n", " $\\inducingVector$, $q(\\inducingVector)$.\n", "- Now we have\n", " $$p(\\dataVector^*|\\dataVector) = \\int p(\\dataVector^*| \\inducingVector) q(\\inducingVector | \\dataVector) \\text{d} \\inducingVector$$\n", "\n", "- Inducing variables look a lot like regular parameters.\n", "- *But*: their dimensionality does not need to be set at design time.\n", "- They can be modified arbitrarily at run time without effecting the\n", " model likelihood.\n", "- They only effect the quality of compression and the lower bound.\n", "\n", "- Exploit the resulting factorization ...\n", " $$p(\\dataVector^*|\\dataVector) = \\int p(\\dataVector^*| \\inducingVector) q(\\inducingVector | \\dataVector) \\text{d} \\inducingVector$$\n", " \\pause\n", "- The distribution now *factorizes*:\n", " $$p(\\dataVector^*|\\dataVector) = \\int \\prod_{i=1}^{\\numData^*}p(\\dataScalar^*_i| \\inducingVector) q(\\inducingVector | \\dataVector) \\text{d} \\inducingVector$$\n", "- This factorization can be exploited for stochastic variational\n", " inference [@Hoffman:stochastic12].\n", "\n", "
\n", "Modern data availability\n", "
\n", "
\n", "\n", " \n", "\n", "
\n", "\n", "
\n", "Proxy for index of deprivation?\n", "
\n", "
\n", "\n", " \n", "\n", "
\n", "\n", "
\n", "Actually index of deprivation is a proxy for this ...\n", "
\n", "
\n", "\n", " \n", "\n", "
\n", "\n", "\\catdoc\n", " \n", "\n", "\n", "\n", "\n", "\n", "
 \n", "[[@Hensman:bigdata13]]{style=\"text-align:left\"}\n", " \n", "[ ]{style=\"text-align:right\"}\n", "
\n", "
\n", "\n", " \n", "\n", "
\n", "\n", "
\n", "\n", "
\n", "\n", "\n", "\n", "\n", "\n", "
 \n", "[[@Hensman:bigdata13]]{style=\"text-align:left\"}\n", " \n", "[ ]{style=\"text-align:right\"}\n", "
\n", "
\n", "\n", " \n", "\n", "
\n", "\n", "
\n", "\n", "
\n", "- *A Unifying Framework for Gaussian Process Pseudo-Point\n", " Approximations using Power Expectation Propagation*\n", " @Thang:unifying17\n", "\n", "- *Deep Gaussian Processes and Variational Propagation of Uncertainty*\n", " @Damianou:thesis2015\n", "\n", "Even in the early days of Gaussian processes in machine learning, it was\n", "understood that we were throwing something fundamental away. This is\n", "perhaps captured best by David MacKay in his 1997 NeurIPS tutorial on\n", "Gaussian processes, where he asked \"Have we thrown out the baby with the\n", "bathwater?\". The quote below is from his summarization paper.\n", "\n", "> According to the hype of 1987, neural networks were meant to be\n", "> intelligent models which discovered features and patterns in data.\n", "> Gaussian processes in contrast are simply smoothing devices. How can\n", "> Gaussian processes possibly repalce neural networks? What is going on?\n", ">\n", "> @MacKay:gpintroduction98\n", "\n", "bathwater?” [Published as @MacKay:gpintroduction98]}" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import teaching_plots as plot" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "
\n", "A deep neural network. Input nodes are shown at the bottom. Each\n", "hidden layer is the result of applying an affine transformation to the\n", "previous layer and placing through an activation function.\n", "
\n", "Mathematically, each layer of a neural network is given through\n", "computing the activation function, $\\basisFunction(\\cdot)$, contingent\n", "on the previous layer, or the inputs. In this way the activation\n", "functions, are composed to generate more complex interactions than would\n", "be possible with any single layer. \n", "\\begin{align}\n", " \\hiddenVector_{1} &= \\basisFunction\\left(\\mappingMatrix_1 \\inputVector\\right)\\\\\n", " \\hiddenVector_{2} &= \\basisFunction\\left(\\mappingMatrix_2\\hiddenVector_{1}\\right)\\\\\n", " \\hiddenVector_{3} &= \\basisFunction\\left(\\mappingMatrix_3 \\hiddenVector_{2}\\right)\\\\\n", " \\dataVector &= \\mappingVector_4 ^\\top\\hiddenVector_{3}\n", "\\end{align}\n", "\n", "\n", "### Overfitting\n", "\n", "One potential problem is that as the number of nodes in two adjacent\n", "layers increases, the number of parameters in the affine transformation\n", "between layers, $\\mappingMatrix$, increases. If there are $k_{i-1}$\n", "nodes in one layer, and $k_i$ nodes in the following, then that matrix\n", "contains $k_i k_{i-1}$ parameters, when we have layer widths in the\n", "1000s that leads to millions of parameters.\n", "\n", "One proposed solution is known as *dropout* where only a sub-set of the\n", "neural network is trained at each iteration. An alternative solution\n", "would be to reparameterize $\\mappingMatrix$ with its *singular value\n", "decomposition*. $$\n", " \\mappingMatrix = \\eigenvectorMatrix\\eigenvalueMatrix\\eigenvectwoMatrix^\\top\n", "$$ or $$\n", " \\mappingMatrix = \\eigenvectorMatrix\\eigenvectwoMatrix^\\top\n", "$$ where if $\\mappingMatrix \\in \\Re^{k_1\\times k_2}$ then\n", "$\\eigenvectorMatrix\\in \\Re^{k_1\\times q}$ and\n", "$\\eigenvectwoMatrix \\in \\Re^{k_2\\times q}$, i.e. we have a low rank\n", "matrix factorization for the weights." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import teaching_plots as plot" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ " \n", "
\n", "Pictorial representation of the low rank form of the matrix\n", "$\\mappingMatrix$\n", "
" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import teaching_plots as plot" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Including the low rank decomposition of $\\mappingMatrix$ in the neural\n", "network, we obtain a new mathematical form. Effectively, we are adding\n", "additional *latent* layers, $\\latentVector$, in between each of the\n", "existing hidden layers. In a neural network these are sometimes known as\n", "*bottleneck* layers. The network can now be written mathematically as \n", "\\begin{align}\n", " \\latentVector_{1} &= \\eigenvectwoMatrix^\\top_1 \\inputVector\\\\\n", " \\hiddenVector_{1} &= \\basisFunction\\left(\\eigenvectorMatrix_1 \\latentVector_{1}\\right)\\\\\n", " \\latentVector_{2} &= \\eigenvectwoMatrix^\\top_2 \\hiddenVector_{1}\\\\\n", " \\hiddenVector_{2} &= \\basisFunction\\left(\\eigenvectorMatrix_2 \\latentVector_{2}\\right)\\\\\n", " \\latentVector_{3} &= \\eigenvectwoMatrix^\\top_3 \\hiddenVector_{2}\\\\\n", " \\hiddenVector_{3} &= \\basisFunction\\left(\\eigenvectorMatrix_3 \\latentVector_{3}\\right)\\\\\n", " \\dataVector &= \\mappingVector_4^\\top\\hiddenVector_{3}.\n", "\\end{align}\n", "\n", "\n", "\n", "\\begin{align}\n", " \\latentVector_{1} &= \\eigenvectwoMatrix^\\top_1 \\inputVector\\\\\n", " \\latentVector_{2} &= \\eigenvectwoMatrix^\\top_2 \\basisFunction\\left(\\eigenvectorMatrix_1 \\latentVector_{1}\\right)\\\\\n", " \\latentVector_{3} &= \\eigenvectwoMatrix^\\top_3 \\basisFunction\\left(\\eigenvectorMatrix_2 \\latentVector_{2}\\right)\\\\\n", " \\dataVector &= \\mappingVector_4 ^\\top \\latentVector_{3}\n", "\\end{align}\n", "\n", "\n", "Now if we replace each of these neural networks with a Gaussian process.\n", "This is equivalent to taking the limit as the width of each layer goes\n", "to infinity, while appropriately scaling down the outputs.\n", "\n", "\n", "\\begin{align}\n", " \\latentVector_{1} &= \\mappingFunctionVector_1\\left(\\inputVector\\right)\\\\\n", " \\latentVector_{2} &= \\mappingFunctionVector_2\\left(\\latentVector_{1}\\right)\\\\\n", " \\latentVector_{3} &= \\mappingFunctionVector_3\\left(\\latentVector_{2}\\right)\\\\\n", " \\dataVector &= \\mappingFunctionVector_4\\left(\\latentVector_{3}\\right)\n", "\\end{align}\n", "\n", "\n", "
\n", "\n", " \n", "\n", "
\n", "\n", "
\n", "The DeepFace architecture [@Taigman:deepface14], visualized through\n", "colors to represent the functional mappings at each layer. There are 120\n", "million parameters in the model.\n", "
\n", "The DeepFace architecture [@Taigman:deepface14] consists of layers that\n", "deal with *translation* and *rotational* invariances. These layers are\n", "followed by three locally-connected layers and two fully-connected\n", "layers. Color illustrates feature maps produced at each layer. The net\n", "includes more than 120 million parameters, where more than 95% come from\n", "the local and fully connected layers.\n", "\n", "
\n", "\n", " \n", "\n", "
\n", "\n", "
\n", "Deep learning models are composition of simple functions. We can\n", "think of a pinball machine as an analogy. Each layer of pins corresponds\n", "to one of the layers of functions in the model. Input data is\n", "represented by the location of the ball from left to right when it is\n", "dropped in from the top. Output class comes from the position of the\n", "ball as it leaves the pins at the bottom.\n", "
\n", "We can think of what these models are doing as being similar to early\n", "pin ball machines. In a neural network, we input a number (or numbers),\n", "whereas in pinball, we input a ball. The location of the ball on the\n", "left-right axis can be thought of as the number. As the ball falls\n", "through the machine, each layer of pins can be thought of as a different\n", "layer of neurons. Each layer acts to move the ball from left to right.\n", "\n", "In a pinball machine, when the ball gets to the bottom it might fall\n", "into a hole defining a score, in a neural network, that is equivalent to\n", "the decision: a classification of the input object.\n", "\n", "An image has more than one number associated with it, so it's like\n", "playing pinball in a *hyper-space*." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import pods\n", "from ipywidgets import IntSlider" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "pods.notebook.display_plots('pinball{sample:0>3}.svg', \n", " '../slides/diagrams', \n", " sample=IntSlider(1, 1, 2, 1))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "
\n", "\n", " \n", "\n", "
\n", "\n", "
\n", "At initialization, the pins, which represent the parameters of the\n", "function, aren't in the right place to bring the balls to the correct\n", "decisions.\n", "
\n", "
\n", "\n", " \n", "\n", "
\n", "\n", "
\n", "After learning the pins are now in the right place to bring the balls\n", "to the correct decisions.\n", "
\n", "Learning involves moving all the pins to be in the right position, so\n", "that the ball falls in the right place. But moving all these pins in\n", "hyperspace can be difficult. In a hyper space you have to put a lot of\n", "data through the machine for to explore the positions of all the pins.\n", "Adversarial learning reflects the fact that a ball can be moved a small\n", "distance and lead to a very different result.\n", "\n", "Probabilistic methods explore more of the space by considering a range\n", "of possible paths for the ball through the machine.\n", "\n", "Mathematically, a deep Gaussian process can be seen as a composite\n", "*multivariate* function, $$\n", " \\mathbf{g}(\\inputVector)=\\mappingFunctionVector_5(\\mappingFunctionVector_4(\\mappingFunctionVector_3(\\mappingFunctionVector_2(\\mappingFunctionVector_1(\\inputVector))))).\n", "$$ Or if we view it from the probabilistic perspective we can see that\n", "a deep Gaussian process is specifying a factorization of the joint\n", "density, the standard deep model takes the form of a Markov chain." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from matplotlib import rc\n", "\n", "rc(\"font\", **{'family':'sans-serif','sans-serif':['Helvetica'],'size':30})\n", "rc(\"text\", usetex=True)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "$$\n", " p(\\dataVector|\\inputVector)= p(\\dataVector|\\mappingFunctionVector_5)p(\\mappingFunctionVector_5|\\mappingFunctionVector_4)p(\\mappingFunctionVector_4|\\mappingFunctionVector_3)p(\\mappingFunctionVector_3|\\mappingFunctionVector_2)p(\\mappingFunctionVector_2|\\mappingFunctionVector_1)p(\\mappingFunctionVector_1|\\inputVector)\n", "$$\n", "\n", " \n", "
\n", "Probabilistically the deep Gaussian process can be represented as a\n", "Markov chain.\n", "
" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from matplotlib import rc\n", "rc(\"font\", **{'family':'sans-serif','sans-serif':['Helvetica'], 'size':15})\n", "rc(\"text\", usetex=True)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ " \n", "\n", "### Why Deep?\n", "\n", "If the result of composing many functions together is simply another\n", "function, then why do we bother? The key point is that we can change the\n", "class of functions we are modeling by composing in this manner. A\n", "Gaussian process is specifying a prior over functions, and one with a\n", "number of elegant properties. For example, the derivative process (if it\n", "exists) of a Gaussian process is also Gaussian distributed. That makes\n", "it easy to assimilate, for example, derivative observations. But that\n", "also might raise some alarm bells. That implies that the *marginal\n", "derivative distribution* is also Gaussian distributed. If that's the\n", "case, then it means that functions which occasionally exhibit very large\n", "derivatives are hard to model with a Gaussian process. For example, a\n", "function with jumps in.\n", "\n", "A one off discontinuity is easy to model with a Gaussian process, or\n", "even multiple discontinuities. They can be introduced in the mean\n", "function, or independence can be forced between two covariance functions\n", "that apply in different areas of the input space. But in these cases we\n", "will need to specify the number of discontinuities and where they occur.\n", "In otherwords we need to *parameterise* the discontinuities. If we do\n", "not know the number of discontinuities and don't wish to specify where\n", "they occur, i.e. if we want a non-parametric representation of\n", "discontinuities, then the standard Gaussian process doesn't help.\n", "\n", "### Stochastic Process Composition\n", "\n", "The deep Gaussian process leads to *non-Gaussian* models, and\n", "non-Gaussian characteristics in the covariance function. In effect, what\n", "we are proposing is that we change the properties of the functions we\n", "are considering by \\*composing stochastic processes\\$. This is an\n", "approach to creating new stochastic processes from well known processes.\n", "\n", " \n", "\n", "Additionally, we are not constrained to the formalism of the chain. For\n", "example, we can easily add single nodes emerging from some point in the\n", "depth of the chain. This allows us to combine the benefits of the\n", "graphical modelling formalism, but with a powerful framework for\n", "relating one set of variables to another, that of Gaussian processes\n", " \n", "\n", "### Difficulty for Probabilistic Approaches\n", "\n", "The challenge for composition of probabilistic models is that you need\n", "to propagate a probability densities through non linear mappings. This\n", "allows you to create broader classes of probability density.\n", "Unfortunately it renders the resulting densities *intractable*.\n", " \n", "\n", " \n", "\n", " \n", "\n", "The argument in the deep learning revolution is that deep architectures\n", "allow us to develop an abstraction of the feature set through model\n", "composition. Composing Gaussian processes is analytically intractable.\n", "To form deep Gaussian processes we use a variational approach to stack\n", "the models." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import pods" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "pods.notebook.display_plots('stack-gp-sample-Linear-{sample:0>1}.svg', \n", " directory='../../slides/diagrams/deepgp', sample=(0,4))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Stacked PCA\n", "\n", " \n", "Composition of linear functions just leads to a new linear\n", "function.\n", " \n", "Stacking a series of linear functions simply leads to a new linear\n", "function. The use of multiple linear function merely changes the\n", "covariance of the resulting Gaussian. If $$\n", "\\latentMatrix \\sim \\gaussianSamp{\\zerosVector}{\\eye}\n", "$$ and the$i$th hidden layer is a multivariate linear transformation\n", "defined by$\\weightMatrix_i$, $$\n", "\\dataMatrix = \\latentMatrix\\weightMatrix_1 \\weightMatrix_2 \\dots \\weightMatrix_\\numLayers\n", "$$ then the rules of multivariate Gaussians tell us that $$\n", "\\dataMatrix \\sim \\gaussianSamp{\\zerosVector}{\\weightMatrix_\\numLayers \\dots \\weightMatrix_1 \\weightMatrix^\\top_1 \\dots \\weightMatrix^\\top_\\numLayers}.\n", "$$ So the model can be replaced by one where we set\n", "$\\vMatrix = \\weightMatrix_\\numLayers \\dots \\weightMatrix_2 \\weightMatrix_1$.\n", "So is such a model trivial? The answer is that it depends. There are two\n", "cases in which such a model remaisn interesting. Firstly, if we make\n", "intermediate observations stemming from the chain. So, for example, if\n", "we decide that, $$\n", "\\latentMatrix_i = \\weightMatrix_i \\latentMatrix_{i-1}\n", "$$ and set\n", "$\\latentMatrix_{0} = \\inputMatrix \\sim \\gaussianSamp{\\zerosVector}{\\eye}$,\n", "then the matrices$\\weightMatrix$inter-relate a series of jointly\n", "Gaussian observations in an interesting way, stacking the full data\n", "matrix to give $$\n", "\\latentMatrix = \\begin{bmatrix}\n", "\\latentMatrix_0 \\\\\n", "\\latentMatrix_1 \\\\\n", "\\vdots \\\\\n", "\\latentMatrix_\\numLayers\n", "\\end{bmatrix}\n", "$$ we can obtain\n", "$$\\latentMatrix \\sim \\gaussianSamp{\\zerosVector}{\\begin{bmatrix}\n", "\\eye & \\weightMatrix^\\top_1 & \\weightMatrix_1^\\top\\weightMatrix_2^\\top & \\dots & \\vMatrix^\\top \\\\\n", "\\weightMatrix_1 & \\weightMatrix_1 \\weightMatrix_1^\\top & \\weightMatrix_1 \\weightMatrix_1^\\top \\weightMatrix_2^\\top & \\dots & \\weightMatrix_1 \\vMatrix^\\top \\\\\n", "\\weightMatrix_2 \\weightMatrix_1 & \\weightMatrix_2 \\weightMatrix_1 \\weightMatrix_1^\\top & \\weightMatrix_2 \\weightMatrix_1 \\weightMatrix_1^\\top \\weightMatrix_2^\\top & \\dots & \\weightMatrix_2 \\weightMatrix_1 \\vMatrix^\\top \\\\\n", "\\vdots & \\vdots & \\vdots & \\ddots & \\vdots \\\\\n", "\\vMatrix & \\vMatrix \\weightMatrix_1^\\top & \\vMatrix \\weightMatrix_1^\\top \\weightMatrix_2^\\top& \\dots & \\vMatrix\\vMatrix^\\top\n", "\\end{bmatrix}}$$ which is a highly structured Gaussian covariance with\n", "hierarchical dependencies between the variables$\\latentMatrix_i\$.\n", "\n", "### Stacked GP" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "pods.notebook.display_plots('stack-gp-sample-RBF-{sample:0>1}.svg', \n", " directory='../../slides/diagrams/deepgp', sample=(0,4))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "
\n", "Stacking Gaussian process models leads to non linear mappings at each\n", "stage. Here we are mapping from two dimensions to two dimensions in each\n", "layer.\n", "
\n", "Note that once the box has folded over on itself, it cannot be unfolded.\n", "So a feature that is generated near the top of the model cannot be\n", "removed furthr down the model.\n", "\n", "This folding over effect happens in low dimensions. In higher dimensions\n", "it is less common.\n", "\n", "Observation of this effect at a talk in Cambridge was one of the things\n", "that caused David Duvenaud (and collaborators) to consider the behavior\n", "of deeper Gaussian process models [@Duvenaud:pathologies14].\n", "\n", "Such folding over in the latent spaces necessarily forces the density to\n", "be non-Gaussian. Indeed, since folding-over is avoided as we increase\n", "the dimensionality of the latent spaces, such processes become more\n", "Gaussian. If we take the limit of the latent space dimensionality as it\n", "tends to infinity, the entire deep Gaussian process returns to a\n", "standard Gaussian process, with a covariance function given as a deep\n", "kernel (such as those described by @Cho:deep09).\n", "\n", "Further analysis of these deep networks has been conducted by\n", "@Dunlop:deep2017, who use analysis of the deep network's stationary\n", "density (treating it as a Markov chain across layers), to explore the\n", "nature of the implied process prior for a deep GP.\n", "\n", "Both of these works, however, make constraining assumptions on the form\n", "of the Gaussian process prior at each layer (e.g. same covariance at\n", "each layer). In practice, the form of this covariance can be learnt and\n", "the densities described by the deep GP are more general than those\n", "mentioned in either of these papers." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from IPython.lib.display import YouTubeVideo\n", "YouTubeVideo('XhIvygQYFFQ')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "David Duvenaud also created a YouTube video to help visualize what\n", "happens as you drop through the layers of a deep GP.\n", "\n", "### GPy: A Gaussian Process Framework in Python\n", "\n", "
\n", "\n", " \n", "\n", "
\n", "\n", "GPy is a BSD licensed software code base for implementing Gaussian\n", "process models in python. This allows GPs to be combined with a wide\n", "variety of software libraries.\n", "\n", "The software itself is avaialble on\n", "[GitHub](https://github.com/SheffieldML/GPy) and the team welcomes\n", "contributions.\n", "\n", "The aim for GPy is to be a probabilistic-style programming language,\n", "i.e. you specify the model rather than the algorithm. As well as a large\n", "range of covariance functions the software allows for non-Gaussian\n", "likelihoods, multivariate outputs, dimensionality reduction and\n", "approximations for larger data sets.\n", "\n", "The GPy library can be installed via pip:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "pip install GPy" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "This notebook depends on PyDeepGP. These libraries can be installed via\n", "pip:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "pip install git+https://github.com/SheffieldML/PyDeepGP.git" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Olympic Marathon Data\n", "\n", "\n", "\n", "\n", "\n", "\n", "
 \n", "- Gold medal times for Olympic Marathon since 1896.\n", "- Marathons before 1924 didn’t have a standardised distance.\n", "- Present results using pace per km.\n", "- In 1904 Marathon was badly organised leading to very slow times.\n", "\n", " \n", "\n", "\n", " \n", "\n", "\n", "\n", "Image from Wikimedia Commons \n", "
\n", "The first thing we will do is load a standard data set for regression\n", "modelling. The data consists of the pace of Olympic Gold Medal Marathon\n", "winners for the Olympics from 1896 to present. First we load in the data\n", "and plot." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import numpy as np\n", "import pods" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "data = pods.datasets.olympic_marathon_men()\n", "x = data['X']\n", "y = data['Y']\n", "\n", "offset = y.mean()\n", "scale = np.sqrt(y.var())" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import matplotlib.pyplot as plt\n", "import teaching_plots as plot\n", "import mlai" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "\n", "xlim = (1875,2030)\n", "ylim = (2.5, 6.5)\n", "yhat = (y-offset)/scale\n", "\n", "fig, ax = plt.subplots(figsize=plot.big_wide_figsize)\n", "_ = ax.plot(x, y, 'r.',markersize=10)\n", "ax.set_xlabel('year', fontsize=20)\n", "ax.set_ylabel('pace min/km', fontsize=20)\n", "ax.set_xlim(xlim)\n", "ax.set_ylim(ylim)\n", "\n", "mlai.write_figure(figure=fig, \n", " filename='../slides/diagrams/datasets/olympic-marathon.svg', \n", " transparent=True, \n", " frameon=True)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "
\n", "\n", " \n", "\n", "
\n", "\n", "Things to notice about the data include the outlier in 1904, in this\n", "year, the olympics was in St Louis, USA. Organizational problems and\n", "challenges with dust kicked up by the cars following the race meant that\n", "participants got lost, and only very few participants completed.\n", "\n", "More recent years see more consistently quick marathons.\n", "\n", "Data is fine for answering very specific questions, like \"Who won the\n", "Olympic Marathon in 2012?\", because we have that answer stored, however,\n", "we are not given the answer to many other questions. For example, Alan\n", "Turing was a formidable marathon runner, in 1946 he ran a time 2 hours\n", "46 minutes (just under four minutes per kilometer, faster than I and\n", "most of the other [Endcliffe Park\n", "Run](http://www.parkrun.org.uk/sheffieldhallam/) runners can do 5 km).\n", "What is the probability he would have won an Olympics if one had been\n", "held in 1946?\n", "\n", "\n", "\n", "\n", "\n", "\n", "
 \n", " \n", " \n", " \n", "
\n", "
\n", "Alan Turing, in 1946 he was only 11 minutes slower than the winner of\n", "the 1948 games. Would he have won a hypothetical games held in 1946?\n", "Source: [Alan Turing Internet\n", "Scrapbook](http://www.turing.org.uk/scrapbook/run.html)\n", "
\n", "Our first objective will be to perform a Gaussian process fit to the\n", "data, we'll do this using the [GPy\n", "software](https://github.com/SheffieldML/GPy)." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import GPy" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "m_full = GPy.models.GPRegression(x,yhat)\n", "_ = m_full.optimize() # Optimize parameters of covariance function" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The first command sets up the model, then m_full.optimize() optimizes\n", "the parameters of the covariance function and the noise level of the\n", "model. Once the fit is complete, we'll try creating some test points,\n", "and computing the output of the GP model in terms of the mean and\n", "standard deviation of the posterior functions between 1870 and 2030. We\n", "plot the mean function and the standard deviation at 200 locations. We\n", "can obtain the predictions using y_mean, y_var = m_full.predict(xt)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "xt = np.linspace(1870,2030,200)[:,np.newaxis]\n", "yt_mean, yt_var = m_full.predict(xt)\n", "yt_sd=np.sqrt(yt_var)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Now we plot the results using the helper function in teaching_plots." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import teaching_plots as plot" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "fig, ax = plt.subplots(figsize=plot.big_wide_figsize)\n", "plot.model_output(m_full, scale=scale, offset=offset, ax=ax, xlabel='year', ylabel='pace min/km', fontsize=20, portion=0.2)\n", "ax.set_xlim(xlim)\n", "ax.set_ylim(ylim)\n", "mlai.write_figure(figure=fig,\n", " filename='../slides/diagrams/gp/olympic-marathon-gp.svg', \n", " transparent=True, frameon=True)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ " \n", "\n", "### Fit Quality\n", "\n", "In the fit we see that the error bars (coming mainly from the noise\n", "variance) are quite large. This is likely due to the outlier point in\n", "1904, ignoring that point we can see that a tighter fit is obtained. To\n", "see this making a version of the model, m_clean, where that point is\n", "removed." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "x_clean=np.vstack((x[0:2, :], x[3:, :]))\n", "y_clean=np.vstack((y[0:2, :], y[3:, :]))\n", "\n", "m_clean = GPy.models.GPRegression(x_clean,y_clean)\n", "_ = m_clean.optimize()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Deep GP Fit\n", "\n", "Let's see if a deep Gaussian process can help here. We will construct a\n", "deep Gaussian process with one hidden layer (i.e. one Gaussian process\n", "feeding into another).\n", "\n", "Build a Deep GP with an additional hidden layer (one dimensional) to fit\n", "the model." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import GPy\n", "import deepgp" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "hidden = 1\n", "m = deepgp.DeepGP([y.shape,hidden,x.shape],Y=yhat, X=x, inits=['PCA','PCA'], \n", " kernels=[GPy.kern.RBF(hidden,ARD=True),\n", " GPy.kern.RBF(x.shape,ARD=True)], # the kernels for each layer\n", " num_inducing=50, back_constraint=False)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Deep Gaussian process models also can require some thought in\n", "initialization. Here we choose to start by setting the noise variance to\n", "be one percent of the data variance.\n", "\n", "Optimization requires moving variational parameters in the hidden layer\n", "representing the mean and variance of the expected values in that layer.\n", "Since all those values can be scaled up, and this only results in a\n", "downscaling in the output of the first GP, and a downscaling of the\n", "input length scale to the second GP. It makes sense to first of all fix\n", "the scales of the covariance function in each of the GPs.\n", "\n", "Sometimes, deep Gaussian processes can find a local minima which\n", "involves increasing the noise level of one or more of the GPs. This\n", "often occurs because it allows a minimum in the KL divergence term in\n", "the lower bound on the likelihood. To avoid this minimum we habitually\n", "train with the likelihood variance (the noise on the output of the GP)\n", "fixed to some lower value for some iterations.\n", "\n", "Let's create a helper function to initialize the models we use in the\n", "notebook." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import deepgp" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "%load -s initialize deepgp_tutorial.py" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Bind the new method to the Deep GP object.\n", "deepgp.DeepGP.initialize=initialize" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Call the initalization\n", "m.initialize()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Now optimize the model. The first stage of optimization is working on\n", "variational parameters and lengthscales only." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "m.optimize(messages=False,max_iters=100)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Now we remove the constraints on the scale of the covariance functions\n", "associated with each GP and optimize again." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "for layer in m.layers:\n", " pass #layer.kern.variance.constrain_positive(warning=False)\n", "m.obslayer.kern.variance.constrain_positive(warning=False)\n", "m.optimize(messages=False,max_iters=100)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Finally, we allow the noise variance to change and optimize for a large\n", "number of iterations." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "for layer in m.layers:\n", " layer.likelihood.variance.constrain_positive(warning=False)\n", "m.optimize(messages=True,max_iters=10000)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "For our optimization process we define a new function." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "%load -s staged_optimize deepgp_tutorial.py" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Bind the new method to the Deep GP object.\n", "deepgp.DeepGP.staged_optimize=staged_optimize" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "m.staged_optimize(messages=(True,True,True))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Plot the prediction\n", "\n", "The prediction of the deep GP can be extracted in a similar way to the\n", "normal GP. Although, in this case, it is an approximation to the true\n", "distribution, because the true distribution is not Gaussian." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import matplotlib.pyplot as plt" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "fig, ax = plt.subplots(figsize=plot.big_wide_figsize)\n", "plot.model_output(m, scale=scale, offset=offset, ax=ax, xlabel='year', ylabel='pace min/km', \n", " fontsize=20, portion=0.2)\n", "ax.set_xlim(xlim)\n", "\n", "ax.set_ylim(ylim)\n", "mlai.write_figure(figure=fig, filename='../slides/diagrams/deepgp/olympic-marathon-deep-gp.svg', \n", " transparent=True, frameon=True)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Olympic Marathon Data Deep GP\n", "\n", " " ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "%load -s posterior_sample deepgp_tutorial.py" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "deepgp.DeepGP.posterior_sample = posterior_sample" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "fig, ax = plt.subplots(figsize=plot.big_wide_figsize)\n", "plot.model_sample(m, scale=scale, offset=offset, samps=10, ax=ax, \n", " xlabel='year', ylabel='pace min/km', portion = 0.225)\n", "ax.set_xlim(xlim)\n", "ax.set_ylim(ylim)\n", "mlai.write_figure(figure=fig, filename='../slides/diagrams/deepgp/olympic-marathon-deep-gp-samples.svg', \n", " transparent=True, frameon=True)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Olympic Marathon Data Deep GP\n", "\n", " \n", "\n", "### Fitted GP for each layer\n", "\n", "Now we explore the GPs the model has used to fit each layer. First of\n", "all, we look at the hidden layer." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "%load -s visualize deepgp_tutorial.py" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Bind the new method to the Deep GP object.\n", "deepgp.DeepGP.visualize=visualize" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "m.visualize(scale=scale, offset=offset, xlabel='year',\n", " ylabel='pace min/km',xlim=xlim, ylim=ylim,\n", " dataset='olympic-marathon',\n", " diagrams='../slides/diagrams/deepgp')" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import pods" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "pods.notebook.display_plots('olympic-marathon-deep-gp-layer-{sample:0>1}.svg', \n", " '../slides/diagrams/deepgp', sample=(0,1))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ " \n", "\n", " " ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "%load -s visualize_pinball deepgp_tutorial.py" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Bind the new method to the Deep GP object.\n", "deepgp.DeepGP.visualize_pinball=visualize_pinball" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "fig, ax = plt.subplots(figsize=plot.big_wide_figsize)\n", "m.visualize_pinball(ax=ax, scale=scale, offset=offset, points=30, portion=0.1,\n", " xlabel='year', ylabel='pace km/min', vertical=True)\n", "mlai.write_figure(figure=fig, filename='../slides/diagrams/deepgp/olympic-marathon-deep-gp-pinball.svg', \n", " transparent=True, frameon=True)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Olympic Marathon Pinball Plot\n", "\n", " \n", "\n", "The pinball plot shows the flow of any input ball through the deep\n", "Gaussian process. In a pinball plot a series of vertical parallel lines\n", "would indicate a purely linear function. For the olypmic marathon data\n", "we can see the first layer begins to shift from input towards the right.\n", "Note it also does so with some uncertainty (indicated by the shaded\n", "backgrounds). The second layer has less uncertainty, but bunches the\n", "inputs more strongly to the right. This input layer of uncertainty,\n", "followed by a layer that pushes inputs to the right is what gives the\n", "heteroschedastic noise.\n", "\n", "### Della Gatta Gene Data\n", "\n", "- Given given expression levels in the form of a time series from\n", " @DellaGatta:direct08." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import numpy as np\n", "import pods" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "data = pods.datasets.della_gatta_TRP63_gene_expression(data_set='della_gatta',gene_number=937)\n", "\n", "x = data['X']\n", "y = data['Y']\n", "\n", "offset = y.mean()\n", "scale = np.sqrt(y.var())" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import matplotlib.pyplot as plt\n", "import teaching_plots as plot\n", "import mlai" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "\n", "xlim = (-20,260)\n", "ylim = (5, 7.5)\n", "yhat = (y-offset)/scale\n", "\n", "fig, ax = plt.subplots(figsize=plot.big_wide_figsize)\n", "_ = ax.plot(x, y, 'r.',markersize=10)\n", "ax.set_xlabel('time/min', fontsize=20)\n", "ax.set_ylabel('expression', fontsize=20)\n", "ax.set_xlim(xlim)\n", "ax.set_ylim(ylim)\n", "\n", "mlai.write_figure(figure=fig, \n", " filename='../slides/diagrams/datasets/della-gatta-gene.svg', \n", " transparent=True, \n", " frameon=True)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "
\n", "\n", " \n", "\n", "
\n", "\n", "- Want to detect if a gene is expressed or not, fit a GP to each gene\n", " @Kalaitzis:simple11.\n", "\n", "
\n", "\n", " \n", "\n", "
\n", "\n", "
\n", "\n", "
\n", "Our first objective will be to perform a Gaussian process fit to the\n", "data, we'll do this using the [GPy\n", "software](https://github.com/SheffieldML/GPy)." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import GPy" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "m_full = GPy.models.GPRegression(x,yhat)\n", "m_full.kern.lengthscale=50\n", "_ = m_full.optimize() # Optimize parameters of covariance function" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Initialize the length scale parameter (which here actually represents a\n", "*time scale* of the covariance function to a reasonable value. Default\n", "would be 1, but here we set it to 50 minutes, given points are arriving\n", "across zero to 250 minutes." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "xt = np.linspace(-20,260,200)[:,np.newaxis]\n", "yt_mean, yt_var = m_full.predict(xt)\n", "yt_sd=np.sqrt(yt_var)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Now we plot the results using the helper function in teaching_plots." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import teaching_plots as plot" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "fig, ax = plt.subplots(figsize=plot.big_wide_figsize)\n", "plot.model_output(m_full, scale=scale, offset=offset, ax=ax, xlabel='time/min', ylabel='expression', fontsize=20, portion=0.2)\n", "ax.set_xlim(xlim)\n", "ax.set_ylim(ylim)\n", "ax.set_title('log likelihood: {ll:.3}'.format(ll=m_full.log_likelihood()), fontsize=20)\n", "mlai.write_figure(figure=fig,\n", " filename='../slides/diagrams/gp/della-gatta-gene-gp.svg', \n", " transparent=True, frameon=True)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ " \n", "\n", "Now we try a model initialized with a longer length scale." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "m_full2 = GPy.models.GPRegression(x,yhat)\n", "m_full2.kern.lengthscale=2000\n", "_ = m_full2.optimize() # Optimize parameters of covariance function" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import teaching_plots as plot" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "fig, ax = plt.subplots(figsize=plot.big_wide_figsize)\n", "plot.model_output(m_full2, scale=scale, offset=offset, ax=ax, xlabel='time/min', ylabel='expression', fontsize=20, portion=0.2)\n", "ax.set_xlim(xlim)\n", "ax.set_ylim(ylim)\n", "ax.set_title('log likelihood: {ll:.3}'.format(ll=m_full2.log_likelihood()), fontsize=20)\n", "mlai.write_figure(figure=fig,\n", " filename='../slides/diagrams/gp/della-gatta-gene-gp2.svg', \n", " transparent=True, frameon=True)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ " \n", "\n", "Now we try a model initialized with a lower noise." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "m_full3 = GPy.models.GPRegression(x,yhat)\n", "m_full3.kern.lengthscale=20\n", "m_full3.likelihood.variance=0.001\n", "_ = m_full3.optimize() # Optimize parameters of covariance function" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import teaching_plots as plot" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "fig, ax = plt.subplots(figsize=plot.big_wide_figsize)\n", "plot.model_output(m_full3, scale=scale, offset=offset, ax=ax, xlabel='time/min', ylabel='expression', fontsize=20, portion=0.2)\n", "ax.set_xlim(xlim)\n", "ax.set_ylim(ylim)\n", "ax.set_title('log likelihood: {ll:.3}'.format(ll=m_full3.log_likelihood()), fontsize=20)\n", "mlai.write_figure(figure=fig,\n", " filename='../slides/diagrams/gp/della-gatta-gene-gp3.svg', \n", " transparent=True, frameon=True)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ " \n", "\n", " \n", "\n", "" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "layers = [y.shape, 1,x.shape]\n", "inits = ['PCA']*(len(layers)-1)\n", "kernels = []\n", "for i in layers[1:]:\n", " kernels += [GPy.kern.RBF(i)]\n", "m = deepgp.DeepGP(layers,Y=yhat, X=x, \n", " inits=inits, \n", " kernels=kernels, # the kernels for each layer\n", " num_inducing=20, back_constraint=False)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "m.initialize()\n", "m.staged_optimize()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "fig, ax=plt.subplots(figsize=plot.big_wide_figsize)\n", "plot.model_output(m, scale=scale, offset=offset, ax=ax, fontsize=20, portion=0.5)\n", "ax.set_ylim(ylim)\n", "ax.set_xlim(xlim)\n", "mlai.write_figure(filename='../slides/diagrams/deepgp/della-gatta-gene-deep-gp.svg', \n", " transparent=True, frameon=True)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### TP53 Gene Data Deep GP\n", "\n", " " ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "fig, ax=plt.subplots(figsize=plot.big_wide_figsize)\n", "plot.model_sample(m, scale=scale, offset=offset, samps=10, ax=ax, portion = 0.5)\n", "ax.set_ylim(ylim)\n", "ax.set_xlim(xlim)\n", "mlai.write_figure(figure=fig, filename='../slides/diagrams/deepgp/della-gatta-gene-deep-gp-samples.svg', \n", " transparent=True, frameon=True)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### TP53 Gene Data Deep GP\n", "\n", " " ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "m.visualize(offset=offset, scale=scale, xlim=xlim, ylim=ylim,\n", " dataset='della-gatta-gene',\n", " diagrams='../slides/diagrams/deepgp')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### TP53 Gene Data Latent 1\n", "\n", " \n", "\n", "### TP53 Gene Data Latent 2\n", "\n", " " ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "fig, ax=plt.subplots(figsize=plot.big_wide_figsize)\n", "m.visualize_pinball(offset=offset, ax=ax, scale=scale, xlim=xlim, ylim=ylim, portion=0.1, points=50)\n", "mlai.write_figure(figure=fig, filename='../slides/diagrams/deepgp/della-gatta-gene-deep-gp-pinball.svg', \n", " transparent=True, frameon=True, ax=ax)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### TP53 Gene Pinball Plot\n", "\n", " \n", "\n", "### Step Function\n", "\n", "Next we consider a simple step function data set." ] }, { "cell_type": "code", "execution_count": 223, "metadata": {}, "outputs": [], "source": [ "num_low=25\n", "num_high=25\n", "gap = -.1\n", "noise=0.0001\n", "x = np.vstack((np.linspace(-1, -gap/2.0, num_low)[:, np.newaxis],\n", " np.linspace(gap/2.0, 1, num_high)[:, np.newaxis]))\n", "y = np.vstack((np.zeros((num_low, 1)), np.ones((num_high,1))))\n", "scale = np.sqrt(y.var())\n", "offset = y.mean()\n", "yhat = (y-offset)/scale" ] }, { "cell_type": "code", "execution_count": 229, "metadata": {}, "outputs": [ { "data": { "image/png": "iVBORw0KGgoAAAANSUhEUgAAAoAAAAGACAYAAAA9JdO+AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMi4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvhp/UCwAAHSVJREFUeJzt3X+QZWV95/H3Z2cEtsBVcCZIgOFHyRphgzNyCzVQiQbQwbWAje4KSQxGrEkszcYYN0KIWkXWUmMSkyiJzCIBLYNGEuO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