https://github.com/GPflow/GPflow
Raw File
Tip revision: 2a30405fefb4de21a0951c885cb38a9d295d68d9 authored by Sergio Diaz on 10 September 2019, 16:00:22 UTC
Merge branch 'awav/gpflow-2.0' into sergio_pasc/gpflow-2.0/adapt-sgpmc-and-gpmc
Tip revision: 2a30405
kufs.py
import tensorflow as tf
from ..inducing_variables import InducingPoints, Multiscale
from ..kernels import Kernel, SquaredExponential
from .dispatch import Kuf


@Kuf.register(InducingPoints, Kernel, object)
def _Kuf(inducing_variable: InducingPoints, kernel: Kernel, Xnew: tf.Tensor):
    return kernel(inducing_variable.Z, Xnew)


@Kuf.register(Multiscale, SquaredExponential, object)
def _Kuf(inducing_variable: Multiscale, kernel: SquaredExponential, Xnew):
    Xnew, _ = kernel.slice(Xnew, None)
    Zmu, Zlen = kernel.slice(inducing_variable.Z, inducing_variable.scales)
    idlengthscale = kernel.lengthscale + Zlen
    d = inducing_variable._cust_square_dist(Xnew, Zmu, idlengthscale)
    lengthscale = tf.reduce_prod(kernel.lengthscale / idlengthscale, 1)
    lengthscale = tf.reshape(lengthscale, (1, -1))
    return tf.transpose(kernel.variance * tf.exp(-0.5 * d) * lengthscale)
back to top