Revision 48270681afc13081094f7f398a1e194c6b07ba9b authored by vdutor on 03 January 2018, 17:44:53 UTC, committed by Mark van der Wilk on 03 January 2018, 17:44:53 UTC
* Outline of new expectations code. * Quadrature code now uses TensorFlow shape inference. * General expectations work. * Expectations RBF kern, not tested * Add Identity mean function * General unittests for Expectations * Add multipledispatch package to travis * Update tests_expectations * Expectations of mean functions * Mean function uncertain conditional * Uncertain conditional with mean_function. Tested. * Support for Add and Prod kernels and quadrature fallback decorator * Refactor expectations unittests * Psi stats Linear kernel * Split expectations in different files * Expectation Linear kernel and Linear mean function * Remove None's from expectations api * Removed old ekernels framework * Add multipledispatch to setup file * Work on PR feedback, not finished * Addressed PR feedback * Support for pairwise xKxz * Enable expectations unittests * Renamed `TimeseriesGaussian` to `MarkovGaussian` and added tests. * Rename some variable, plus note for later test of <x Kxz>_q. * Update conditionals.py Add comment * Change order of inputs to (feat, kern) * Stef/expectations (#601) * adding gaussmarkov quad * don't override the markvogaussian in the quadrature * can't test * adding external test * quadrature code done and works for MarkovGauss * MarkovGaussian with quad implemented. All tests pass * Shape comments. * Removed superfluous autoflow functions for kernel expectations * Update kernels.py * Update quadrature.py
1 parent 2182bf0
reference.py
import numpy as np
def referenceRbfKernel(X, lengthScale, signalVariance):
nDataPoints, _ = X.shape
kernel = np.zeros((nDataPoints, nDataPoints))
for row_index in range(nDataPoints):
for column_index in range(nDataPoints):
vecA = X[row_index,:]
vecB = X[column_index,:]
delta = vecA - vecB
distanceSquared = np.dot(delta.T, delta)
kernel[row_index, column_index] = signalVariance * np.exp(-0.5 * distanceSquared / lengthScale**2)
return kernel
def referenceArcCosineKernel( X, order, weightVariances, biasVariance, signalVariance ):
num_points = X.shape[0]
kernel = np.empty((num_points, num_points))
for row in range(num_points):
for col in range(num_points):
x = X[row]
y = X[col]
numerator = (weightVariances * x).dot(y) + biasVariance
x_denominator = np.sqrt((weightVariances * x).dot(x) + biasVariance)
y_denominator = np.sqrt((weightVariances * y).dot(y) + biasVariance)
denominator = x_denominator * y_denominator
theta = np.arccos(np.clip(numerator / denominator, -1., 1.))
if order == 0:
J = np.pi - theta
elif order == 1:
J = np.sin(theta) + (np.pi - theta) * np.cos(theta)
elif order == 2:
J = 3. * np.sin(theta) * np.cos(theta)
J += (np.pi - theta) * (1. + 2. * np.cos(theta) ** 2)
kernel[row, col] = signalVariance * (1. / np.pi) * J * \
x_denominator ** order * \
y_denominator ** order
return kernel
def referencePeriodicKernel( X, lengthScale, signalVariance, period ):
# Based on the GPy implementation of standard_period kernel
base = np.pi * (X[:, None, :] - X[None, :, :]) / period
exp_dist = np.exp( -0.5* np.sum( np.square( np.sin( base ) / lengthScale ), axis = -1 ) )
return signalVariance * exp_dist
Computing file changes ...