diff --git a/GPy/models/warped_gp.py b/GPy/models/warped_gp.py index 0be3d2fe..1ce0e92b 100644 --- a/GPy/models/warped_gp.py +++ b/GPy/models/warped_gp.py @@ -64,7 +64,6 @@ class WarpedGP(GP): def log_likelihood(self): ll = GP.log_likelihood(self) jacobian = self.warping_function.fgrad_y(self.Y_untransformed) - print np.log(jacobian) return ll + np.log(jacobian).sum() def plot_warping(self): diff --git a/GPy/testing/model_tests.py b/GPy/testing/model_tests.py index f609f378..feec7211 100644 --- a/GPy/testing/model_tests.py +++ b/GPy/testing/model_tests.py @@ -205,7 +205,8 @@ class MiscTests(unittest.TestCase): def test_warped_gp(self): k = GPy.kern.RBF(1) - m = GPy.models.WarpedGP(self.X, self.Y, kernel=k) + warp = GPy.util.warping_functions.IdentityFunction() + m = GPy.models.WarpedGP(self.X, self.Y, kernel=k, warping_function=warp) m.randomize() m.optimize() print(m) diff --git a/GPy/util/warping_functions.py b/GPy/util/warping_functions.py index 00e24c4b..a3a282c8 100644 --- a/GPy/util/warping_functions.py +++ b/GPy/util/warping_functions.py @@ -301,17 +301,26 @@ class IdentityFunction(WarpingFunction): and should not be used in practice. """ def __init__(self): - self.num_parameters = 0 + self.num_parameters = 4 + self.psi = Param('psi', np.zeros((1,3))) + self.d = Param('%s' % ('d'), 1.0, Logexp()) super(IdentityFunction, self).__init__(name='identity') + self.link_parameter(self.psi) + self.link_parameter(self.d) + def f(self, y): return y def fgrad_y(self, y): - return 1.0 + return np.ones(y.shape) - def fgrad_y_psi(self,y): - return 1.0 + def fgrad_y_psi(self, y, return_covar_chain=False): + gradients = np.ones((y.shape[0], y.shape[1], len(self.psi), 4)) + if return_covar_chain: + return gradients, gradients + return gradients + def f_inv(self,z): return z