From b7c0e009a13e219ce08c5857d895c5677ff5925a Mon Sep 17 00:00:00 2001 From: ST John Date: Thu, 4 Jun 2020 12:52:23 +0100 Subject: [PATCH 1/2] give each multipledispatch-registered implementation a unique name so that docs are generated correctly. resolves #1494 --- gpflow/conditionals/conditionals.py | 6 ++---- .../conditionals/multioutput/conditionals.py | 5 ----- .../multioutput/sample_conditionals.py | 2 +- gpflow/conditionals/sample_conditionals.py | 2 +- gpflow/covariances/kufs.py | 10 +++++----- gpflow/covariances/kuus.py | 6 +++--- gpflow/covariances/multioutput/kufs.py | 16 ++++++++-------- gpflow/covariances/multioutput/kuus.py | 10 +++++----- gpflow/expectations/cross_kernels.py | 4 ++-- gpflow/expectations/linears.py | 10 +++++----- gpflow/expectations/mean_functions.py | 18 ++++++++---------- gpflow/expectations/misc.py | 14 +++++++------- gpflow/expectations/products.py | 6 +++--- gpflow/expectations/quadratures.py | 4 ++-- gpflow/expectations/squared_exponentials.py | 10 +++++----- gpflow/expectations/sums.py | 10 +++++----- gpflow/kullback_leiblers.py | 2 +- 17 files changed, 63 insertions(+), 72 deletions(-) diff --git a/gpflow/conditionals/conditionals.py b/gpflow/conditionals/conditionals.py index 29e850deb..47f196d95 100644 --- a/gpflow/conditionals/conditionals.py +++ b/gpflow/conditionals/conditionals.py @@ -1,5 +1,3 @@ -# noqa: F811 - import tensorflow as tf from ..covariances import Kuf, Kuu @@ -12,7 +10,7 @@ @conditional.register(object, InducingVariables, Kernel, object) -def _conditional( +def single_output_conditional( Xnew: tf.Tensor, inducing_variable: InducingVariables, kernel: Kernel, @@ -64,7 +62,7 @@ def _conditional( @conditional.register(object, object, Kernel, object) -def _conditional( +def plain_conditional( Xnew: tf.Tensor, X: tf.Tensor, kernel: Kernel, diff --git a/gpflow/conditionals/multioutput/conditionals.py b/gpflow/conditionals/multioutput/conditionals.py index 910cc2755..cc1f769a4 100644 --- a/gpflow/conditionals/multioutput/conditionals.py +++ b/gpflow/conditionals/multioutput/conditionals.py @@ -1,8 +1,3 @@ -# flake8: ignore=F811 -# noqa: ignore=F811 -# flake8: F811 -# noqa: F811 - import tensorflow as tf from ... import covariances diff --git a/gpflow/conditionals/multioutput/sample_conditionals.py b/gpflow/conditionals/multioutput/sample_conditionals.py index 37fef7dc6..b5f067aa5 100644 --- a/gpflow/conditionals/multioutput/sample_conditionals.py +++ b/gpflow/conditionals/multioutput/sample_conditionals.py @@ -12,7 +12,7 @@ @sample_conditional.register( object, SharedIndependentInducingVariables, LinearCoregionalization, object ) -def _sample_conditional( +def sample_conditional__SharedIndependentInducingVariables__LinearCoregionalization( Xnew, inducing_variable, kernel, diff --git a/gpflow/conditionals/sample_conditionals.py b/gpflow/conditionals/sample_conditionals.py index 31ff72476..e14c7c1c7 100644 --- a/gpflow/conditionals/sample_conditionals.py +++ b/gpflow/conditionals/sample_conditionals.py @@ -8,7 +8,7 @@ @sample_conditional.register(object, object, Kernel, object) @sample_conditional.register(object, InducingVariables, Kernel, object) -def _sample_conditional( +def sample_conditional__InducingVariables__Kernel( Xnew: tf.Tensor, inducing_variable: InducingVariables, kernel: Kernel, diff --git a/gpflow/covariances/kufs.py b/gpflow/covariances/kufs.py index effbf9c07..6e2136824 100644 --- a/gpflow/covariances/kufs.py +++ b/gpflow/covariances/kufs.py @@ -23,8 +23,8 @@ def Kuf_sqexp_multiscale(inducing_variable: Multiscale, kernel: SquaredExponenti @Kuf.register(InducingPatches, Convolutional, object) -def Kuf_conv_patch(feat, kern, Xnew): - Xp = kern.get_patches(Xnew) # [N, num_patches, patch_len] - bigKzx = kern.base_kernel.K(feat.Z, Xp) # [M, N, P] -- thanks to broadcasting of kernels - Kzx = tf.reduce_sum(bigKzx * kern.weights if hasattr(kern, "weights") else bigKzx, [2]) - return Kzx / kern.num_patches +def Kuf_conv_patch(inducing_variable: InducingPatches, kernel: Convolutional, Xnew): + Xp = kernel.get_patches(Xnew) # [N, num_patches, patch_len] + bigKzx = kernel.base_kernel.K(inducing_variable.Z, Xp) # [M, N, P] -- thanks to broadcasting of kernels + Kzx = tf.reduce_sum(bigKzx * kernel.weights if hasattr(kernel, "weights") else bigKzx, [2]) + return Kzx / kernel.num_patches diff --git a/gpflow/covariances/kuus.py b/gpflow/covariances/kuus.py index 35413a612..c7376995e 100644 --- a/gpflow/covariances/kuus.py +++ b/gpflow/covariances/kuus.py @@ -14,7 +14,7 @@ def Kuu_kernel_inducingpoints(inducing_variable: InducingPoints, kernel: Kernel, @Kuu.register(Multiscale, SquaredExponential) -def Kuu_sqexp_multiscale(inducing_variable: Multiscale, kernel: SquaredExponential, *, jitter=0.0): +def Kuu_squaredexponential_multiscale(inducing_variable: Multiscale, kernel: SquaredExponential, *, jitter=0.0): Zmu, Zlen = kernel.slice(inducing_variable.Z, inducing_variable.scales) idlengthscales2 = tf.square(kernel.lengthscales + Zlen) sc = tf.sqrt( @@ -27,5 +27,5 @@ def Kuu_sqexp_multiscale(inducing_variable: Multiscale, kernel: SquaredExponenti @Kuu.register(InducingPatches, Convolutional) -def Kuu_conv_patch(feat, kern, jitter=0.0): - return kern.base_kernel.K(feat.Z) + jitter * tf.eye(len(feat), dtype=default_float()) +def Kuu_conv_patch(inducing_variable: InducingPatches, kernel: Convolutional, jitter=0.0): + return kernel.base_kernel.K(inducing_variable.Z) + jitter * tf.eye(len(inducing_variable), dtype=default_float()) diff --git a/gpflow/covariances/multioutput/kufs.py b/gpflow/covariances/multioutput/kufs.py index 84caad7b4..91bf91b55 100644 --- a/gpflow/covariances/multioutput/kufs.py +++ b/gpflow/covariances/multioutput/kufs.py @@ -19,12 +19,12 @@ @Kuf.register(InducingPoints, MultioutputKernel, object) -def _Kuf(inducing_variable: InducingPoints, kernel: MultioutputKernel, Xnew: tf.Tensor): +def _Kuf__InducingPoints__MultioutputKernel(inducing_variable: InducingPoints, kernel: MultioutputKernel, Xnew: tf.Tensor): return kernel(inducing_variable.Z, Xnew, full_cov=True, full_output_cov=True) # [M, P, N, P] @Kuf.register(SharedIndependentInducingVariables, SharedIndependent, object) -def _Kuf( +def _Kuf__SharedIndependentInducingVariables__SharedIndependent( inducing_variable: SharedIndependentInducingVariables, kernel: SharedIndependent, Xnew: tf.Tensor, @@ -33,7 +33,7 @@ def _Kuf( @Kuf.register(SeparateIndependentInducingVariables, SharedIndependent, object) -def _Kuf( +def _Kuf__SeparateIndependentInducingVariables__SharedIndependent( inducing_variable: SeparateIndependentInducingVariables, kernel: SharedIndependent, Xnew: tf.Tensor, @@ -44,7 +44,7 @@ def _Kuf( @Kuf.register(SharedIndependentInducingVariables, SeparateIndependent, object) -def _Kuf( +def _Kuf__SharedIndependentInducingVariables__SeparateIndependent( inducing_variable: SharedIndependentInducingVariables, kernel: SeparateIndependent, Xnew: tf.Tensor, @@ -55,7 +55,7 @@ def _Kuf( @Kuf.register(SeparateIndependentInducingVariables, SeparateIndependent, object) -def _Kuf( +def _Kuf__SeparateIndependentInducingVariables__SeparateIndependent( inducing_variable: SeparateIndependentInducingVariables, kernel: SeparateIndependent, Xnew: tf.Tensor, @@ -71,7 +71,7 @@ def _Kuf( LinearCoregionalization, object, ) -def _Kuf( +def _Kuf__Fallback__LinearCoregionalization( inducing_variable: Union[ SeparateIndependentInducingVariables, SharedIndependentInducingVariables ], @@ -84,7 +84,7 @@ def _Kuf( @Kuf.register(SharedIndependentInducingVariables, LinearCoregionalization, object) -def _Kuf( +def _Kuf__SharedIndependentInducingVariables__LinearCoregionalization( inducing_variable: SharedIndependentInducingVariables, kernel: SeparateIndependent, Xnew: tf.Tensor, @@ -95,7 +95,7 @@ def _Kuf( @Kuf.register(SeparateIndependentInducingVariables, LinearCoregionalization, object) -def _Kuf(inducing_variable, kernel, Xnew): +def _Kuf__SeparateIndependentInducingVariables__LinearCoregionalization(inducing_variable: SeparateIndependentInducingVariables, kernel: LinearCoregionalization, Xnew: tf.Tensor): return tf.stack( [Kuf(f, k, Xnew) for f, k in zip(inducing_variable.inducing_variable_list, kernel.kernels)], axis=0, diff --git a/gpflow/covariances/multioutput/kuus.py b/gpflow/covariances/multioutput/kuus.py index e4cf040ec..c7595784f 100644 --- a/gpflow/covariances/multioutput/kuus.py +++ b/gpflow/covariances/multioutput/kuus.py @@ -19,7 +19,7 @@ @Kuu.register(InducingPoints, MultioutputKernel) -def _Kuu(inducing_variable: InducingPoints, kernel: MultioutputKernel, *, jitter=0.0): +def _Kuu__InducingPoints__MultioutputKernel(inducing_variable: InducingPoints, kernel: MultioutputKernel, *, jitter=0.0): Kmm = kernel(inducing_variable.Z, full_cov=True, full_output_cov=True) # [M, P, M, P] M = tf.shape(Kmm)[0] * tf.shape(Kmm)[1] jittermat = jitter * tf.reshape(tf.eye(M, dtype=Kmm.dtype), tf.shape(Kmm)) @@ -27,7 +27,7 @@ def _Kuu(inducing_variable: InducingPoints, kernel: MultioutputKernel, *, jitter @Kuu.register(FallbackSharedIndependentInducingVariables, SharedIndependent) -def _Kuu( +def _Kuu__FallbackSharedIndependentInducingVariables__shared( inducing_variable: FallbackSharedIndependentInducingVariables, kernel: SharedIndependent, *, @@ -39,7 +39,7 @@ def _Kuu( @Kuu.register(FallbackSharedIndependentInducingVariables, (SeparateIndependent, IndependentLatent)) -def _Kuu( +def _Kuu__FallbackSharedIndependentInducingVariables__independent( inducing_variable: FallbackSharedIndependentInducingVariables, kernel: Union[SeparateIndependent, IndependentLatent], *, @@ -53,7 +53,7 @@ def _Kuu( @Kuu.register(FallbackSeparateIndependentInducingVariables, SharedIndependent) -def _Kuu( +def _Kuu__FallbackSeparateIndependentInducingVariables__shared( inducing_variable: FallbackSeparateIndependentInducingVariables, kernel: SharedIndependent, *, @@ -69,7 +69,7 @@ def _Kuu( @Kuu.register( FallbackSeparateIndependentInducingVariables, (SeparateIndependent, LinearCoregionalization) ) -def _Kuu( +def _Kuu__FallbackSeparateIndependentInducingVariables__independent( inducing_variable: FallbackSeparateIndependentInducingVariables, kernel: Union[SeparateIndependent, LinearCoregionalization], *, diff --git a/gpflow/expectations/cross_kernels.py b/gpflow/expectations/cross_kernels.py index eeb2d9c4e..45f368154 100644 --- a/gpflow/expectations/cross_kernels.py +++ b/gpflow/expectations/cross_kernels.py @@ -14,7 +14,7 @@ kernels.Linear, InducingPoints, ) -def _E(p, sqexp_kern, feat1, lin_kern, feat2, nghp=None): +def _E__Gaussian__SquaredExponential__InducingPoints__Linear__InducingPoints(p, sqexp_kern, feat1, lin_kern, feat2, nghp=None): """ Compute the expectation: expectation[n] = _p(x_n) @@ -96,7 +96,7 @@ def take_with_ard(value): kernels.SquaredExponential, InducingPoints, ) -def _E(p, lin_kern, feat1, sqexp_kern, feat2, nghp=None): +def _E__Gaussian__Linear__InducingPoints__SquaredExponential__InducingPoints(p, lin_kern, feat1, sqexp_kern, feat2, nghp=None): """ Compute the expectation: expectation[n] = _p(x_n) diff --git a/gpflow/expectations/linears.py b/gpflow/expectations/linears.py index d2c49b9f7..db6c83cd7 100644 --- a/gpflow/expectations/linears.py +++ b/gpflow/expectations/linears.py @@ -12,7 +12,7 @@ @dispatch.expectation.register(Gaussian, kernels.Linear, NoneType, NoneType, NoneType) -def _E(p, kernel, _, __, ___, nghp=None): +def _E__Gaussian__Linear(p, kernel, _, __, ___, nghp=None): """ Compute the expectation: _p(X) @@ -28,7 +28,7 @@ def _E(p, kernel, _, __, ___, nghp=None): @dispatch.expectation.register(Gaussian, kernels.Linear, InducingPoints, NoneType, NoneType) -def _E(p, kernel, inducing_variable, _, __, nghp=None): +def _E__Gaussian__Linear__InducingPoints(p, kernel, inducing_variable, _, __, nghp=None): """ Compute the expectation: _p(X) @@ -43,7 +43,7 @@ def _E(p, kernel, inducing_variable, _, __, nghp=None): @dispatch.expectation.register(Gaussian, kernels.Linear, InducingPoints, mfn.Identity, NoneType) -def _E(p, kernel, inducing_variable, mean, _, nghp=None): +def _E__Gaussian__Linear__InducingPoints__Identity(p, kernel, inducing_variable, mean, _, nghp=None): """ Compute the expectation: expectation[n] = _p(x_n) @@ -62,7 +62,7 @@ def _E(p, kernel, inducing_variable, mean, _, nghp=None): @dispatch.expectation.register( MarkovGaussian, kernels.Linear, InducingPoints, mfn.Identity, NoneType ) -def _E(p, kernel, inducing_variable, mean, _, nghp=None): +def _E__MarkovGaussian__Linear__InducingPoints__Identity(p, kernel, inducing_variable, mean, _, nghp=None): """ Compute the expectation: expectation[n] = _p(x_{n:n+1}) @@ -83,7 +83,7 @@ def _E(p, kernel, inducing_variable, mean, _, nghp=None): @dispatch.expectation.register( (Gaussian, DiagonalGaussian), kernels.Linear, InducingPoints, kernels.Linear, InducingPoints ) -def _E(p, kern1, feat1, kern2, feat2, nghp=None): +def _E__Gaussian__Linear__InducingPoints__Linear__InducingPoints(p, kern1, feat1, kern2, feat2, nghp=None): """ Compute the expectation: expectation[n] = _p(x_n) diff --git a/gpflow/expectations/mean_functions.py b/gpflow/expectations/mean_functions.py index 3375586c8..2242b5551 100644 --- a/gpflow/expectations/mean_functions.py +++ b/gpflow/expectations/mean_functions.py @@ -1,5 +1,3 @@ -# noqa: F811 - import tensorflow as tf from .. import mean_functions as mfn @@ -11,7 +9,7 @@ @dispatch.expectation.register(Gaussian, (mfn.Linear, mfn.Constant), NoneType, NoneType, NoneType) -def _E(p, mean, _, __, ___, nghp=None): +def _E__Gaussian__Linear(p, mean, _, __, ___, nghp=None): """ Compute the expectation: _p(X) @@ -23,7 +21,7 @@ def _E(p, mean, _, __, ___, nghp=None): @dispatch.expectation.register(Gaussian, mfn.Constant, NoneType, mfn.Constant, NoneType) -def _E(p, mean1, _, mean2, __, nghp=None): +def _E__Gaussian__Constant__Constant(p, mean1, _, mean2, __, nghp=None): """ Compute the expectation: expectation[n] = _p(x_n) @@ -35,7 +33,7 @@ def _E(p, mean1, _, mean2, __, nghp=None): @dispatch.expectation.register(Gaussian, mfn.Constant, NoneType, mfn.MeanFunction, NoneType) -def _E(p, mean1, _, mean2, __, nghp=None): +def _E__Gaussian__Constant__MeanFunction(p, mean1, _, mean2, __, nghp=None): """ Compute the expectation: expectation[n] = _p(x_n) @@ -49,7 +47,7 @@ def _E(p, mean1, _, mean2, __, nghp=None): @dispatch.expectation.register(Gaussian, mfn.MeanFunction, NoneType, mfn.Constant, NoneType) -def _E(p, mean1, _, mean2, __, nghp=None): +def _E__Gaussian__MeanFunction__Constant(p, mean1, _, mean2, __, nghp=None): """ Compute the expectation: expectation[n] = _p(x_n) @@ -63,7 +61,7 @@ def _E(p, mean1, _, mean2, __, nghp=None): @dispatch.expectation.register(Gaussian, mfn.Identity, NoneType, mfn.Identity, NoneType) -def _E(p, mean1, _, mean2, __, nghp=None): +def _E__Gaussian__Identity__Identity(p, mean1, _, mean2, __, nghp=None): """ Compute the expectation: expectation[n] = _p(x_n) @@ -75,7 +73,7 @@ def _E(p, mean1, _, mean2, __, nghp=None): @dispatch.expectation.register(Gaussian, mfn.Identity, NoneType, mfn.Linear, NoneType) -def _E(p, mean1, _, mean2, __, nghp=None): +def _E__Gaussian__Identity__Linear(p, mean1, _, mean2, __, nghp=None): """ Compute the expectation: expectation[n] = _p(x_n) @@ -93,7 +91,7 @@ def _E(p, mean1, _, mean2, __, nghp=None): @dispatch.expectation.register(Gaussian, mfn.Linear, NoneType, mfn.Identity, NoneType) -def _E(p, mean1, _, mean2, __, nghp=None): +def _E__Gaussian__Linear__Identity(p, mean1, _, mean2, __, nghp=None): """ Compute the expectation: expectation[n] = _p(x_n) @@ -113,7 +111,7 @@ def _E(p, mean1, _, mean2, __, nghp=None): @dispatch.expectation.register(Gaussian, mfn.Linear, NoneType, mfn.Linear, NoneType) -def _E(p, mean1, _, mean2, __, nghp=None): +def _E__Gaussian__Linear__Linear(p, mean1, _, mean2, __, nghp=None): """ Compute the expectation: expectation[n] = _p(x_n) diff --git a/gpflow/expectations/misc.py b/gpflow/expectations/misc.py index cf154047d..ed18ca136 100644 --- a/gpflow/expectations/misc.py +++ b/gpflow/expectations/misc.py @@ -16,7 +16,7 @@ @dispatch.expectation.register( (Gaussian, MarkovGaussian), mfn.Identity, NoneType, kernels.Linear, InducingPoints ) -def _E(p, mean, _, kernel, inducing_variable, nghp=None): +def _E__Gaussian__Identity__Linear__InducingPoints(p, mean, _, kernel, inducing_variable, nghp=None): """ Compute the expectation: expectation[n] = _p(x_n) @@ -31,7 +31,7 @@ def _E(p, mean, _, kernel, inducing_variable, nghp=None): @dispatch.expectation.register( (Gaussian, MarkovGaussian), kernels.Kernel, InducingVariables, mfn.MeanFunction, NoneType ) -def _E(p, kernel, inducing_variable, mean, _, nghp=None): +def _E__Gaussian__Kernel__InducingVariables__MeanFunction(p, kernel, inducing_variable, mean, _, nghp=None): """ Compute the expectation: expectation[n] = _p(x_n) @@ -43,7 +43,7 @@ def _E(p, kernel, inducing_variable, mean, _, nghp=None): @dispatch.expectation.register(Gaussian, mfn.Constant, NoneType, kernels.Kernel, InducingPoints) -def _E(p, constant_mean, _, kernel, inducing_variable, nghp=None): +def _E__Gaussian__ConstantMF__Kernel__InducingPoints(p, constant_mean, _, kernel, inducing_variable, nghp=None): """ Compute the expectation: expectation[n] = _p(x_n) @@ -59,7 +59,7 @@ def _E(p, constant_mean, _, kernel, inducing_variable, nghp=None): @dispatch.expectation.register(Gaussian, mfn.Linear, NoneType, kernels.Kernel, InducingPoints) -def _E(p, linear_mean, _, kernel, inducing_variable, nghp=None): +def _E__Gaussian__LinearMF__Kernel__InducingPoints(p, linear_mean, _, kernel, inducing_variable, nghp=None): """ Compute the expectation: expectation[n] = _p(x_n) @@ -80,7 +80,7 @@ def _E(p, linear_mean, _, kernel, inducing_variable, nghp=None): @dispatch.expectation.register(Gaussian, mfn.Identity, NoneType, kernels.Kernel, InducingPoints) -def _E(p, identity_mean, _, kernel, inducing_variable, nghp=None): +def _E__Gaussian__Identity__Kernel__InducingPoints(p, identity_mean, _, kernel, inducing_variable, nghp=None): """ This prevents infinite recursion for kernels that don't have specific implementations of _expectation(p, identity_mean, None, kernel, inducing_variable). @@ -99,7 +99,7 @@ def _E(p, identity_mean, _, kernel, inducing_variable, nghp=None): @dispatch.expectation.register( DiagonalGaussian, object, (InducingVariables, NoneType), object, (InducingVariables, NoneType) ) -def _E(p, obj1, feat1, obj2, feat2, nghp=None): +def _E__DiagonalGaussian__fallback(p, obj1, feat1, obj2, feat2, nghp=None): gaussian = Gaussian(p.mu, tf.linalg.diag(p.cov)) return expectation(gaussian, (obj1, feat1), (obj2, feat2), nghp=nghp) @@ -110,7 +110,7 @@ def _E(p, obj1, feat1, obj2, feat2, nghp=None): @dispatch.expectation.register( MarkovGaussian, object, (InducingVariables, NoneType), object, (InducingVariables, NoneType) ) -def _E(p, obj1, feat1, obj2, feat2, nghp=None): +def _E__MarkovGaussian__fallback(p, obj1, feat1, obj2, feat2, nghp=None): """ Nota Bene: if only one object is passed, obj1 is associated with x_n, whereas obj2 with x_{n+1} diff --git a/gpflow/expectations/products.py b/gpflow/expectations/products.py index 5a44e1209..b0d47d75a 100644 --- a/gpflow/expectations/products.py +++ b/gpflow/expectations/products.py @@ -12,7 +12,7 @@ @dispatch.expectation.register(DiagonalGaussian, kernels.Product, NoneType, NoneType, NoneType) -def _E(p, kernel, _, __, ___, nghp=None): +def _E__DiagonalGaussian__Product(p, kernel, _, __, ___, nghp=None): r""" Compute the expectation: <\HadamardProd_i diag(Ki_{X[:, active_dims_i], X[:, active_dims_i]})>_p(X) @@ -33,7 +33,7 @@ def _E(p, kernel, _, __, ___, nghp=None): @dispatch.expectation.register( DiagonalGaussian, kernels.Product, InducingPoints, NoneType, NoneType ) -def _E(p, kernel, inducing_variable, __, ___, nghp=None): +def _E__DiagonalGaussian__Product__InducingPoints(p, kernel, inducing_variable, __, ___, nghp=None): r""" Compute the expectation: <\HadamardProd_i Ki_{X[:, active_dims_i], Z[:, active_dims_i]}>_p(X) @@ -54,7 +54,7 @@ def _E(p, kernel, inducing_variable, __, ___, nghp=None): @dispatch.expectation.register( DiagonalGaussian, kernels.Product, InducingPoints, kernels.Product, InducingPoints ) -def _E(p, kern1, feat1, kern2, feat2, nghp=None): +def _E__DiagonalGaussian__Product__InducingPoints__Product__InducingPoints(p, kern1, feat1, kern2, feat2, nghp=None): r""" Compute the expectation: expectation[n] = < prodK_{Z, x_n} prodK_{x_n, Z} >_p(x_n) diff --git a/gpflow/expectations/quadratures.py b/gpflow/expectations/quadratures.py index d2d8dc918..3b02d1a1f 100644 --- a/gpflow/expectations/quadratures.py +++ b/gpflow/expectations/quadratures.py @@ -45,7 +45,7 @@ def get_eval_func(obj, inducing_variable, slice=None): object, (InducingVariables, NoneType), ) -def _quadrature_expectation(p, obj1, inducing_variable1, obj2, inducing_variable2, nghp=None): +def _quadrature_expectation__Gaussian(p, obj1, inducing_variable1, obj2, inducing_variable2, nghp=None): """ General handling of quadrature expectations for Gaussians and DiagonalGaussians Fallback method for missing analytic expectations @@ -90,7 +90,7 @@ def eval_func(x): @dispatch.quadrature_expectation.register( MarkovGaussian, object, (InducingVariables, NoneType), object, (InducingVariables, NoneType) ) -def _quadrature_expectation(p, obj1, inducing_variable1, obj2, inducing_variable2, nghp=None): +def _quadrature_expectation__MarkovGaussian(p, obj1, inducing_variable1, obj2, inducing_variable2, nghp=None): """ Handling of quadrature expectations for Markov Gaussians (useful for time series) Fallback method for missing analytic expectations wrt Markov Gaussians diff --git a/gpflow/expectations/squared_exponentials.py b/gpflow/expectations/squared_exponentials.py index c604cdac5..a89b46599 100644 --- a/gpflow/expectations/squared_exponentials.py +++ b/gpflow/expectations/squared_exponentials.py @@ -12,7 +12,7 @@ @dispatch.expectation.register(Gaussian, kernels.SquaredExponential, NoneType, NoneType, NoneType) -def _E(p, kernel, _, __, ___, nghp=None): +def _E__Gaussian__SquaredExponential(p, kernel, _, __, ___, nghp=None): """ Compute the expectation: _p(X) @@ -26,7 +26,7 @@ def _E(p, kernel, _, __, ___, nghp=None): @dispatch.expectation.register( Gaussian, kernels.SquaredExponential, InducingPoints, NoneType, NoneType ) -def _E(p, kernel, inducing_variable, _, __, nghp=None): +def _E__Gaussian__SquaredExponential__InducingPoints(p, kernel, inducing_variable, _, __, nghp=None): """ Compute the expectation: _p(X) @@ -64,7 +64,7 @@ def _E(p, kernel, inducing_variable, _, __, nghp=None): @dispatch.expectation.register( Gaussian, mfn.Identity, NoneType, kernels.SquaredExponential, InducingPoints ) -def _E(p, mean, _, kernel, inducing_variable, nghp=None): +def _E__Gaussian__Identity__SquaredExponential__InducingPoints(p, mean, _, kernel, inducing_variable, nghp=None): """ Compute the expectation: expectation[n] = _p(x_n) @@ -106,7 +106,7 @@ def _E(p, mean, _, kernel, inducing_variable, nghp=None): @dispatch.expectation.register( MarkovGaussian, mfn.Identity, NoneType, kernels.SquaredExponential, InducingPoints ) -def _E(p, mean, _, kernel, inducing_variable, nghp=None): +def _E__MarkovGaussian__Identity__SquaredExponential__InducingPoints(p, mean, _, kernel, inducing_variable, nghp=None): """ Compute the expectation: expectation[n] = _p(x_{n:n+1}) @@ -152,7 +152,7 @@ def _E(p, mean, _, kernel, inducing_variable, nghp=None): kernels.SquaredExponential, InducingPoints, ) -def _E(p, kern1, feat1, kern2, feat2, nghp=None): +def _E__Gaussian__SquaredExponential__InducingPoints__SquaredExponential__InducingPoints(p, kern1, feat1, kern2, feat2, nghp=None): """ Compute the expectation: expectation[n] = _p(x_n) diff --git a/gpflow/expectations/sums.py b/gpflow/expectations/sums.py index 32069219c..fec5d9565 100644 --- a/gpflow/expectations/sums.py +++ b/gpflow/expectations/sums.py @@ -14,7 +14,7 @@ @dispatch.expectation.register(Gaussian, kernels.Sum, NoneType, NoneType, NoneType) -def _E(p, kernel, _, __, ___, nghp=None): +def _E__Gaussian__Sum(p, kernel, _, __, ___, nghp=None): r""" Compute the expectation: <\Sum_i diag(Ki_{X, X})>_p(X) @@ -27,7 +27,7 @@ def _E(p, kernel, _, __, ___, nghp=None): @dispatch.expectation.register(Gaussian, kernels.Sum, InducingPoints, NoneType, NoneType) -def _E(p, kernel, inducing_variable, _, __, nghp=None): +def _E__Gaussian__Sum__InducingPoints(p, kernel, inducing_variable, _, __, nghp=None): r""" Compute the expectation: <\Sum_i Ki_{X, Z}>_p(X) @@ -42,7 +42,7 @@ def _E(p, kernel, inducing_variable, _, __, nghp=None): @dispatch.expectation.register( Gaussian, (mfn.Linear, mfn.Identity, mfn.Constant), NoneType, kernels.Sum, InducingPoints ) -def _E(p, mean, _, kernel, inducing_variable, nghp=None): +def _E__Gaussian__Linear__Sum__InducingPoints(p, mean, _, kernel, inducing_variable, nghp=None): r""" Compute the expectation: expectation[n] = _p(x_n) @@ -55,7 +55,7 @@ def _E(p, mean, _, kernel, inducing_variable, nghp=None): @dispatch.expectation.register(MarkovGaussian, mfn.Identity, NoneType, kernels.Sum, InducingPoints) -def _E(p, mean, _, kernel, inducing_variable, nghp=None): +def _E__MarkovGaussian__Identity__Sum__InducingPoints(p, mean, _, kernel, inducing_variable, nghp=None): r""" Compute the expectation: expectation[n] = _p(x_{n:n+1}) @@ -70,7 +70,7 @@ def _E(p, mean, _, kernel, inducing_variable, nghp=None): @dispatch.expectation.register( (Gaussian, DiagonalGaussian), kernels.Sum, InducingPoints, kernels.Sum, InducingPoints ) -def _E(p, kern1, feat1, kern2, feat2, nghp=None): +def _E__Gaussian__Sum__InducingPoints__Sum__InducingPoints(p, kern1, feat1, kern2, feat2, nghp=None): r""" Compute the expectation: expectation[n] = <(\Sum_i K1_i_{Z1, x_n}) (\Sum_j K2_j_{x_n, Z2})>_p(x_n) diff --git a/gpflow/kullback_leiblers.py b/gpflow/kullback_leiblers.py index 80488790b..42ebbe945 100644 --- a/gpflow/kullback_leiblers.py +++ b/gpflow/kullback_leiblers.py @@ -25,7 +25,7 @@ @prior_kl.register(InducingVariables, Kernel, object, object) -def _(inducing_variable, kernel, q_mu, q_sqrt, whiten=False): +def prior_kl__InducingVariables__Kernel(inducing_variable, kernel, q_mu, q_sqrt, whiten=False): if whiten: return gauss_kl(q_mu, q_sqrt, None) else: From c194230647e142ea49894df97ef082b4330bd533 Mon Sep 17 00:00:00 2001 From: ST John Date: Thu, 4 Jun 2020 12:53:21 +0100 Subject: [PATCH 2/2] format --- gpflow/covariances/kufs.py | 4 +++- gpflow/covariances/kuus.py | 8 ++++++-- gpflow/covariances/multioutput/kufs.py | 10 ++++++++-- gpflow/covariances/multioutput/kuus.py | 4 +++- gpflow/expectations/cross_kernels.py | 8 ++++++-- gpflow/expectations/linears.py | 12 +++++++++--- gpflow/expectations/misc.py | 20 +++++++++++++++----- gpflow/expectations/products.py | 4 +++- gpflow/expectations/quadratures.py | 8 ++++++-- gpflow/expectations/squared_exponentials.py | 16 ++++++++++++---- gpflow/expectations/sums.py | 8 ++++++-- 11 files changed, 77 insertions(+), 25 deletions(-) diff --git a/gpflow/covariances/kufs.py b/gpflow/covariances/kufs.py index 6e2136824..b41605b9d 100644 --- a/gpflow/covariances/kufs.py +++ b/gpflow/covariances/kufs.py @@ -25,6 +25,8 @@ def Kuf_sqexp_multiscale(inducing_variable: Multiscale, kernel: SquaredExponenti @Kuf.register(InducingPatches, Convolutional, object) def Kuf_conv_patch(inducing_variable: InducingPatches, kernel: Convolutional, Xnew): Xp = kernel.get_patches(Xnew) # [N, num_patches, patch_len] - bigKzx = kernel.base_kernel.K(inducing_variable.Z, Xp) # [M, N, P] -- thanks to broadcasting of kernels + bigKzx = kernel.base_kernel.K( + inducing_variable.Z, Xp + ) # [M, N, P] -- thanks to broadcasting of kernels Kzx = tf.reduce_sum(bigKzx * kernel.weights if hasattr(kernel, "weights") else bigKzx, [2]) return Kzx / kernel.num_patches diff --git a/gpflow/covariances/kuus.py b/gpflow/covariances/kuus.py index c7376995e..58e5925cb 100644 --- a/gpflow/covariances/kuus.py +++ b/gpflow/covariances/kuus.py @@ -14,7 +14,9 @@ def Kuu_kernel_inducingpoints(inducing_variable: InducingPoints, kernel: Kernel, @Kuu.register(Multiscale, SquaredExponential) -def Kuu_squaredexponential_multiscale(inducing_variable: Multiscale, kernel: SquaredExponential, *, jitter=0.0): +def Kuu_squaredexponential_multiscale( + inducing_variable: Multiscale, kernel: SquaredExponential, *, jitter=0.0 +): Zmu, Zlen = kernel.slice(inducing_variable.Z, inducing_variable.scales) idlengthscales2 = tf.square(kernel.lengthscales + Zlen) sc = tf.sqrt( @@ -28,4 +30,6 @@ def Kuu_squaredexponential_multiscale(inducing_variable: Multiscale, kernel: Squ @Kuu.register(InducingPatches, Convolutional) def Kuu_conv_patch(inducing_variable: InducingPatches, kernel: Convolutional, jitter=0.0): - return kernel.base_kernel.K(inducing_variable.Z) + jitter * tf.eye(len(inducing_variable), dtype=default_float()) + return kernel.base_kernel.K(inducing_variable.Z) + jitter * tf.eye( + len(inducing_variable), dtype=default_float() + ) diff --git a/gpflow/covariances/multioutput/kufs.py b/gpflow/covariances/multioutput/kufs.py index 91bf91b55..f2dc244f0 100644 --- a/gpflow/covariances/multioutput/kufs.py +++ b/gpflow/covariances/multioutput/kufs.py @@ -19,7 +19,9 @@ @Kuf.register(InducingPoints, MultioutputKernel, object) -def _Kuf__InducingPoints__MultioutputKernel(inducing_variable: InducingPoints, kernel: MultioutputKernel, Xnew: tf.Tensor): +def _Kuf__InducingPoints__MultioutputKernel( + inducing_variable: InducingPoints, kernel: MultioutputKernel, Xnew: tf.Tensor +): return kernel(inducing_variable.Z, Xnew, full_cov=True, full_output_cov=True) # [M, P, N, P] @@ -95,7 +97,11 @@ def _Kuf__SharedIndependentInducingVariables__LinearCoregionalization( @Kuf.register(SeparateIndependentInducingVariables, LinearCoregionalization, object) -def _Kuf__SeparateIndependentInducingVariables__LinearCoregionalization(inducing_variable: SeparateIndependentInducingVariables, kernel: LinearCoregionalization, Xnew: tf.Tensor): +def _Kuf__SeparateIndependentInducingVariables__LinearCoregionalization( + inducing_variable: SeparateIndependentInducingVariables, + kernel: LinearCoregionalization, + Xnew: tf.Tensor, +): return tf.stack( [Kuf(f, k, Xnew) for f, k in zip(inducing_variable.inducing_variable_list, kernel.kernels)], axis=0, diff --git a/gpflow/covariances/multioutput/kuus.py b/gpflow/covariances/multioutput/kuus.py index c7595784f..f9ba786ff 100644 --- a/gpflow/covariances/multioutput/kuus.py +++ b/gpflow/covariances/multioutput/kuus.py @@ -19,7 +19,9 @@ @Kuu.register(InducingPoints, MultioutputKernel) -def _Kuu__InducingPoints__MultioutputKernel(inducing_variable: InducingPoints, kernel: MultioutputKernel, *, jitter=0.0): +def _Kuu__InducingPoints__MultioutputKernel( + inducing_variable: InducingPoints, kernel: MultioutputKernel, *, jitter=0.0 +): Kmm = kernel(inducing_variable.Z, full_cov=True, full_output_cov=True) # [M, P, M, P] M = tf.shape(Kmm)[0] * tf.shape(Kmm)[1] jittermat = jitter * tf.reshape(tf.eye(M, dtype=Kmm.dtype), tf.shape(Kmm)) diff --git a/gpflow/expectations/cross_kernels.py b/gpflow/expectations/cross_kernels.py index 45f368154..79661d181 100644 --- a/gpflow/expectations/cross_kernels.py +++ b/gpflow/expectations/cross_kernels.py @@ -14,7 +14,9 @@ kernels.Linear, InducingPoints, ) -def _E__Gaussian__SquaredExponential__InducingPoints__Linear__InducingPoints(p, sqexp_kern, feat1, lin_kern, feat2, nghp=None): +def _E__Gaussian__SquaredExponential__InducingPoints__Linear__InducingPoints( + p, sqexp_kern, feat1, lin_kern, feat2, nghp=None +): """ Compute the expectation: expectation[n] = _p(x_n) @@ -96,7 +98,9 @@ def take_with_ard(value): kernels.SquaredExponential, InducingPoints, ) -def _E__Gaussian__Linear__InducingPoints__SquaredExponential__InducingPoints(p, lin_kern, feat1, sqexp_kern, feat2, nghp=None): +def _E__Gaussian__Linear__InducingPoints__SquaredExponential__InducingPoints( + p, lin_kern, feat1, sqexp_kern, feat2, nghp=None +): """ Compute the expectation: expectation[n] = _p(x_n) diff --git a/gpflow/expectations/linears.py b/gpflow/expectations/linears.py index db6c83cd7..aa4fac89a 100644 --- a/gpflow/expectations/linears.py +++ b/gpflow/expectations/linears.py @@ -43,7 +43,9 @@ def _E__Gaussian__Linear__InducingPoints(p, kernel, inducing_variable, _, __, ng @dispatch.expectation.register(Gaussian, kernels.Linear, InducingPoints, mfn.Identity, NoneType) -def _E__Gaussian__Linear__InducingPoints__Identity(p, kernel, inducing_variable, mean, _, nghp=None): +def _E__Gaussian__Linear__InducingPoints__Identity( + p, kernel, inducing_variable, mean, _, nghp=None +): """ Compute the expectation: expectation[n] = _p(x_n) @@ -62,7 +64,9 @@ def _E__Gaussian__Linear__InducingPoints__Identity(p, kernel, inducing_variable, @dispatch.expectation.register( MarkovGaussian, kernels.Linear, InducingPoints, mfn.Identity, NoneType ) -def _E__MarkovGaussian__Linear__InducingPoints__Identity(p, kernel, inducing_variable, mean, _, nghp=None): +def _E__MarkovGaussian__Linear__InducingPoints__Identity( + p, kernel, inducing_variable, mean, _, nghp=None +): """ Compute the expectation: expectation[n] = _p(x_{n:n+1}) @@ -83,7 +87,9 @@ def _E__MarkovGaussian__Linear__InducingPoints__Identity(p, kernel, inducing_var @dispatch.expectation.register( (Gaussian, DiagonalGaussian), kernels.Linear, InducingPoints, kernels.Linear, InducingPoints ) -def _E__Gaussian__Linear__InducingPoints__Linear__InducingPoints(p, kern1, feat1, kern2, feat2, nghp=None): +def _E__Gaussian__Linear__InducingPoints__Linear__InducingPoints( + p, kern1, feat1, kern2, feat2, nghp=None +): """ Compute the expectation: expectation[n] = _p(x_n) diff --git a/gpflow/expectations/misc.py b/gpflow/expectations/misc.py index ed18ca136..c603af8f1 100644 --- a/gpflow/expectations/misc.py +++ b/gpflow/expectations/misc.py @@ -16,7 +16,9 @@ @dispatch.expectation.register( (Gaussian, MarkovGaussian), mfn.Identity, NoneType, kernels.Linear, InducingPoints ) -def _E__Gaussian__Identity__Linear__InducingPoints(p, mean, _, kernel, inducing_variable, nghp=None): +def _E__Gaussian__Identity__Linear__InducingPoints( + p, mean, _, kernel, inducing_variable, nghp=None +): """ Compute the expectation: expectation[n] = _p(x_n) @@ -31,7 +33,9 @@ def _E__Gaussian__Identity__Linear__InducingPoints(p, mean, _, kernel, inducing_ @dispatch.expectation.register( (Gaussian, MarkovGaussian), kernels.Kernel, InducingVariables, mfn.MeanFunction, NoneType ) -def _E__Gaussian__Kernel__InducingVariables__MeanFunction(p, kernel, inducing_variable, mean, _, nghp=None): +def _E__Gaussian__Kernel__InducingVariables__MeanFunction( + p, kernel, inducing_variable, mean, _, nghp=None +): """ Compute the expectation: expectation[n] = _p(x_n) @@ -43,7 +47,9 @@ def _E__Gaussian__Kernel__InducingVariables__MeanFunction(p, kernel, inducing_va @dispatch.expectation.register(Gaussian, mfn.Constant, NoneType, kernels.Kernel, InducingPoints) -def _E__Gaussian__ConstantMF__Kernel__InducingPoints(p, constant_mean, _, kernel, inducing_variable, nghp=None): +def _E__Gaussian__ConstantMF__Kernel__InducingPoints( + p, constant_mean, _, kernel, inducing_variable, nghp=None +): """ Compute the expectation: expectation[n] = _p(x_n) @@ -59,7 +65,9 @@ def _E__Gaussian__ConstantMF__Kernel__InducingPoints(p, constant_mean, _, kernel @dispatch.expectation.register(Gaussian, mfn.Linear, NoneType, kernels.Kernel, InducingPoints) -def _E__Gaussian__LinearMF__Kernel__InducingPoints(p, linear_mean, _, kernel, inducing_variable, nghp=None): +def _E__Gaussian__LinearMF__Kernel__InducingPoints( + p, linear_mean, _, kernel, inducing_variable, nghp=None +): """ Compute the expectation: expectation[n] = _p(x_n) @@ -80,7 +88,9 @@ def _E__Gaussian__LinearMF__Kernel__InducingPoints(p, linear_mean, _, kernel, in @dispatch.expectation.register(Gaussian, mfn.Identity, NoneType, kernels.Kernel, InducingPoints) -def _E__Gaussian__Identity__Kernel__InducingPoints(p, identity_mean, _, kernel, inducing_variable, nghp=None): +def _E__Gaussian__Identity__Kernel__InducingPoints( + p, identity_mean, _, kernel, inducing_variable, nghp=None +): """ This prevents infinite recursion for kernels that don't have specific implementations of _expectation(p, identity_mean, None, kernel, inducing_variable). diff --git a/gpflow/expectations/products.py b/gpflow/expectations/products.py index b0d47d75a..c8e8d3fe0 100644 --- a/gpflow/expectations/products.py +++ b/gpflow/expectations/products.py @@ -54,7 +54,9 @@ def _E__DiagonalGaussian__Product__InducingPoints(p, kernel, inducing_variable, @dispatch.expectation.register( DiagonalGaussian, kernels.Product, InducingPoints, kernels.Product, InducingPoints ) -def _E__DiagonalGaussian__Product__InducingPoints__Product__InducingPoints(p, kern1, feat1, kern2, feat2, nghp=None): +def _E__DiagonalGaussian__Product__InducingPoints__Product__InducingPoints( + p, kern1, feat1, kern2, feat2, nghp=None +): r""" Compute the expectation: expectation[n] = < prodK_{Z, x_n} prodK_{x_n, Z} >_p(x_n) diff --git a/gpflow/expectations/quadratures.py b/gpflow/expectations/quadratures.py index 3b02d1a1f..5dd969f81 100644 --- a/gpflow/expectations/quadratures.py +++ b/gpflow/expectations/quadratures.py @@ -45,7 +45,9 @@ def get_eval_func(obj, inducing_variable, slice=None): object, (InducingVariables, NoneType), ) -def _quadrature_expectation__Gaussian(p, obj1, inducing_variable1, obj2, inducing_variable2, nghp=None): +def _quadrature_expectation__Gaussian( + p, obj1, inducing_variable1, obj2, inducing_variable2, nghp=None +): """ General handling of quadrature expectations for Gaussians and DiagonalGaussians Fallback method for missing analytic expectations @@ -90,7 +92,9 @@ def eval_func(x): @dispatch.quadrature_expectation.register( MarkovGaussian, object, (InducingVariables, NoneType), object, (InducingVariables, NoneType) ) -def _quadrature_expectation__MarkovGaussian(p, obj1, inducing_variable1, obj2, inducing_variable2, nghp=None): +def _quadrature_expectation__MarkovGaussian( + p, obj1, inducing_variable1, obj2, inducing_variable2, nghp=None +): """ Handling of quadrature expectations for Markov Gaussians (useful for time series) Fallback method for missing analytic expectations wrt Markov Gaussians diff --git a/gpflow/expectations/squared_exponentials.py b/gpflow/expectations/squared_exponentials.py index a89b46599..db6764624 100644 --- a/gpflow/expectations/squared_exponentials.py +++ b/gpflow/expectations/squared_exponentials.py @@ -26,7 +26,9 @@ def _E__Gaussian__SquaredExponential(p, kernel, _, __, ___, nghp=None): @dispatch.expectation.register( Gaussian, kernels.SquaredExponential, InducingPoints, NoneType, NoneType ) -def _E__Gaussian__SquaredExponential__InducingPoints(p, kernel, inducing_variable, _, __, nghp=None): +def _E__Gaussian__SquaredExponential__InducingPoints( + p, kernel, inducing_variable, _, __, nghp=None +): """ Compute the expectation: _p(X) @@ -64,7 +66,9 @@ def _E__Gaussian__SquaredExponential__InducingPoints(p, kernel, inducing_variabl @dispatch.expectation.register( Gaussian, mfn.Identity, NoneType, kernels.SquaredExponential, InducingPoints ) -def _E__Gaussian__Identity__SquaredExponential__InducingPoints(p, mean, _, kernel, inducing_variable, nghp=None): +def _E__Gaussian__Identity__SquaredExponential__InducingPoints( + p, mean, _, kernel, inducing_variable, nghp=None +): """ Compute the expectation: expectation[n] = _p(x_n) @@ -106,7 +110,9 @@ def _E__Gaussian__Identity__SquaredExponential__InducingPoints(p, mean, _, kerne @dispatch.expectation.register( MarkovGaussian, mfn.Identity, NoneType, kernels.SquaredExponential, InducingPoints ) -def _E__MarkovGaussian__Identity__SquaredExponential__InducingPoints(p, mean, _, kernel, inducing_variable, nghp=None): +def _E__MarkovGaussian__Identity__SquaredExponential__InducingPoints( + p, mean, _, kernel, inducing_variable, nghp=None +): """ Compute the expectation: expectation[n] = _p(x_{n:n+1}) @@ -152,7 +158,9 @@ def _E__MarkovGaussian__Identity__SquaredExponential__InducingPoints(p, mean, _, kernels.SquaredExponential, InducingPoints, ) -def _E__Gaussian__SquaredExponential__InducingPoints__SquaredExponential__InducingPoints(p, kern1, feat1, kern2, feat2, nghp=None): +def _E__Gaussian__SquaredExponential__InducingPoints__SquaredExponential__InducingPoints( + p, kern1, feat1, kern2, feat2, nghp=None +): """ Compute the expectation: expectation[n] = _p(x_n) diff --git a/gpflow/expectations/sums.py b/gpflow/expectations/sums.py index fec5d9565..82c794ee9 100644 --- a/gpflow/expectations/sums.py +++ b/gpflow/expectations/sums.py @@ -55,7 +55,9 @@ def _E__Gaussian__Linear__Sum__InducingPoints(p, mean, _, kernel, inducing_varia @dispatch.expectation.register(MarkovGaussian, mfn.Identity, NoneType, kernels.Sum, InducingPoints) -def _E__MarkovGaussian__Identity__Sum__InducingPoints(p, mean, _, kernel, inducing_variable, nghp=None): +def _E__MarkovGaussian__Identity__Sum__InducingPoints( + p, mean, _, kernel, inducing_variable, nghp=None +): r""" Compute the expectation: expectation[n] = _p(x_{n:n+1}) @@ -70,7 +72,9 @@ def _E__MarkovGaussian__Identity__Sum__InducingPoints(p, mean, _, kernel, induci @dispatch.expectation.register( (Gaussian, DiagonalGaussian), kernels.Sum, InducingPoints, kernels.Sum, InducingPoints ) -def _E__Gaussian__Sum__InducingPoints__Sum__InducingPoints(p, kern1, feat1, kern2, feat2, nghp=None): +def _E__Gaussian__Sum__InducingPoints__Sum__InducingPoints( + p, kern1, feat1, kern2, feat2, nghp=None +): r""" Compute the expectation: expectation[n] = <(\Sum_i K1_i_{Z1, x_n}) (\Sum_j K2_j_{x_n, Z2})>_p(x_n)