Other local changes.

This commit is contained in:
Neil Lawrence 2013-09-16 11:32:03 +01:00
parent 6d5d4da133
commit 336fe164fa
6 changed files with 21 additions and 24 deletions

View file

@ -22,7 +22,7 @@ def coregionalisation_toy2(max_iters=100):
Y = np.vstack((Y1, Y2))
k1 = GPy.kern.rbf(1) + GPy.kern.bias(1)
k2 = GPy.kern.coregionalise(2,1)
k2 = GPy.kern.coregionalize(2,1)
k = k1**k2 #k = k1.prod(k2,tensor=True)
m = GPy.models.GPRegression(X, Y, kernel=k)
m.constrain_fixed('.*rbf_var', 1.)
@ -82,7 +82,7 @@ def coregionalisation_sparse(max_iters=100):
k1 = GPy.kern.rbf(1)
m = GPy.models.SparseGPMultioutputRegression(X_list=[X1,X2],Y_list=[Y1,Y2],kernel_list=[k1],num_inducing=20)
#k2 = GPy.kern.coregionalise(2, 2)
#k2 = GPy.kern.coregionalize(2, 2)
#k = k1**k2 #.prod(k2, tensor=True) # + GPy.kern.white(2,0.001)
#m = GPy.models.SparseGPRegression(X, Y, kernel=k, Z=Z)
m.constrain_fixed('.*rbf_var', 1.)
@ -135,7 +135,7 @@ def epomeo_gpx(max_iters=100):
np.random.randint(0, 4, num_inducing)[:, None]))
k1 = GPy.kern.rbf(1)
k2 = GPy.kern.coregionalise(output_dim=5, rank=5)
k2 = GPy.kern.coregionalize(output_dim=5, rank=5)
k = k1**k2
m = GPy.models.SparseGPRegression(t, Y, kernel=k, Z=Z, normalize_Y=True)

View file

@ -346,7 +346,7 @@ def symmetric(k):
k_.parts = [symmetric.Symmetric(p) for p in k.parts]
return k_
def coregionalise(num_outputs,W_columns=1, W=None, kappa=None):
def coregionalize(num_outputs,W_columns=1, W=None, kappa=None):
"""
Coregionlization matrix B, of the form:
.. math::
@ -369,7 +369,7 @@ def coregionalise(num_outputs,W_columns=1, W=None, kappa=None):
:rtype: kernel object
"""
p = parts.coregionalise.Coregionalise(num_outputs,W_columns,W,kappa)
p = parts.coregionalize.Coregionalize(num_outputs,W_columns,W,kappa)
return kern(1,[p])
@ -448,11 +448,11 @@ def build_lcm(input_dim, num_outputs, kernel_list = [], W_columns=1,W=None,kappa
k.input_dim = input_dim
warnings.warn("kernel's input dimension overwritten to fit input_dim parameter.")
k_coreg = coregionalise(num_outputs,W_columns,W,kappa)
k_coreg = coregionalize(num_outputs,W_columns,W,kappa)
kernel = kernel_list[0]**k_coreg.copy()
for k in kernel_list[1:]:
k_coreg = coregionalise(num_outputs,W_columns,W,kappa)
k_coreg = coregionalize(num_outputs,W_columns,W,kappa)
kernel += k**k_coreg.copy()
return kernel

View file

@ -7,30 +7,31 @@ from GPy.util.linalg import mdot, pdinv
import pdb
from scipy import weave
class Coregionalise(Kernpart):
class Coregionalize(Kernpart):
"""
Kernel for intrinsic/linear coregionalization models
Covariance function for intrinsic/linear coregionalization models
This kernel has the form
This covariance has the form
.. math::
\mathbf{B} = \mathbf{W}\mathbf{W}^\top + kappa \mathbf{I}
An intrinsic/linear coregionalization kernel of the form
An intrinsic/linear coregionalization covariance function of the form
.. math::
k_2(x, y)=\mathbf{B} k(x, y)
it is obtainded as the tensor product between a kernel k(x,y) and B.
it is obtained as the tensor product between a covariance function
k(x,y) and B.
:param num_outputs: number of outputs to coregionalize
:type num_outputs: int
:param W_columns: number of columns of the W matrix (this parameter is ignored if parameter W is not None)
:type W_colunns: int
:param W: a low rank matrix that determines the correlations between the different outputs, together with kappa it forms the coregionalisation matrix B
:param W: a low rank matrix that determines the correlations between the different outputs, together with kappa it forms the coregionalization matrix B
:type W: numpy array of dimensionality (num_outpus, W_columns)
:param kappa: a vector which allows the outputs to behave independently
:type kappa: numpy array of dimensionality (num_outputs,)
.. Note: see coregionalisation examples in GPy.examples.regression for some usage.
.. Note: see coregionalization examples in GPy.examples.regression for some usage.
"""
def __init__(self,num_outputs,W_columns=1, W=None, kappa=None):
self.input_dim = 1

View file

@ -38,7 +38,7 @@ In sparse GPs wouldn't it be clearer to call Z inducing?
In coregionalisation matrix, setting the W to all ones will (surely?) ensure that symmetry isn't broken. Also, but allowing it to scale like that, the output variance increases as rank is increased (and if user sets rank to more than output dim they could get very different results).
We are inconsistent about our use of ise and ize e.g. optimize and normalize_X, but coregionalise, we should choose one and stick to it. Suggest -ize.
We are inconsistent about our use of ise and ize e.g. optimize and normalize_X, but coregionalise, we should choose one and stick to it. Suggest -ize. Neil- I'm imposing the US spellings to keep things consistent, so -ize it is.
Exceptions: we need to provide a list of exceptions we throw and specify what is thrown where.

View file

@ -4,12 +4,8 @@
import unittest
import numpy as np
import GPy
<<<<<<< HEAD
verbose = False
=======
>>>>>>> 1bc93747178b0bab1b7177568388ebd4207647e0
class KernelTests(unittest.TestCase):
def test_kerneltie(self):
@ -93,7 +89,7 @@ class KernelTests(unittest.TestCase):
Y = np.vstack((Y1,Y2))
k1 = GPy.kern.rbf(1) + GPy.kern.bias(1)
k2 = GPy.kern.coregionalise(2,1)
k2 = GPy.kern.coregionalize(2,1)
kern = k1**k2
self.assertTrue(GPy.kern.kern_test(kern, verbose=verbose))

View file

@ -9,8 +9,8 @@ def build_lcm(input_dim, num_outputs, CK = [], NC = [], W_columns=1,W=None,kappa
:input_dim: Input dimensionality
:num_outputs: Number of outputs
:param CK: List of coregionalized kernels (i.e., this will be multiplied by a coregionalise kernel).
:param K: List of kernels that will be added up together with CK, but won't be multiplied by a coregionalise kernel
:param CK: List of coregionalized kernels (i.e., this will be multiplied by a coregionalize kernel).
:param K: List of kernels that will be added up together with CK, but won't be multiplied by a coregionalize kernel
:param W_columns: number tuples of the corregionalization parameters 'coregion_W'
:type W_columns: integer
"""
@ -25,9 +25,9 @@ def build_lcm(input_dim, num_outputs, CK = [], NC = [], W_columns=1,W=None,kappa
k.input_dim = input_dim + 1
warnings.warn("kernel's input dimension overwritten to fit input_dim parameter.")
kernel = CK[0].prod(kern.coregionalise(num_outputs,W_columns,W,kappa),tensor=True)
kernel = CK[0].prod(kern.coregionalize(num_outputs,W_columns,W,kappa),tensor=True)
for k in CK[1:]:
k_coreg = kern.coregionalise(num_outputs,W_columns,W,kappa)
k_coreg = kern.coregionalize(num_outputs,W_columns,W,kappa)
kernel += k.prod(k_coreg,tensor=True)
for k in NC:
kernel += k