diff --git a/GPy/kern/_src/stationary.py b/GPy/kern/_src/stationary.py index 19f531f2..3b8e391b 100644 --- a/GPy/kern/_src/stationary.py +++ b/GPy/kern/_src/stationary.py @@ -215,7 +215,7 @@ class Cosine(Stationary): def __init__(self, input_dim, variance=1., lengthscale=None, ARD=False, name='Cosine'): super(Cosine, self).__init__(input_dim, variance, lengthscale, ARD, name) - def K_of_r(self, r) + def K_of_r(self, r): return self.variance * np.cos(r) def dK_dr(self, r): @@ -238,7 +238,7 @@ class RatQuad(Stationary): self.power = Param('power', power, Logexp()) self.add_parameters(self.power) - def K_of_r(self, r) + def K_of_r(self, r): return self.variance*(1. + r**2/2.)**(-self.power) def dK_dr(self, r): diff --git a/GPy/util/initialization.py b/GPy/util/initialization.py new file mode 100644 index 00000000..24194b41 --- /dev/null +++ b/GPy/util/initialization.py @@ -0,0 +1,17 @@ +''' +Created on 24 Feb 2014 + +@author: maxz +''' + +import numpy as np +from linalg import PCA + +def initialize_latent(init, input_dim, Y): + Xr = np.random.randn(Y.shape[0], input_dim) + if init == 'PCA': + PC = PCA(Y, input_dim)[0] + Xr[:PC.shape[0], :PC.shape[1]] = PC + else: + pass + return Xr \ No newline at end of file