https://github.com/GPflow/GPflow
Raw File
Tip revision: 2841268118712a6b1edbc4d811e25ae0923357e9 authored by Sergio Diaz on 09 September 2019, 13:05:19 UTC
Merge branch 'sergio_pasc/gpflow-2.0/move-tests-methods' of github.com:GPflow/GPflow into sergio_pasc/gpflow-2.0/move-tests-methods
Tip revision: 2841268
kufs.py
import tensorflow as tf
from ..features import InducingPoints, Multiscale
from ..kernels import Kernel, RBF
from .dispatch import Kuf


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


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