From 91e625a9bdf549934dcac75b8ab4820a37a9dcdf Mon Sep 17 00:00:00 2001 From: beckdaniel Date: Wed, 24 Feb 2016 13:27:19 +0000 Subject: [PATCH] logistic seems working but more tests are needed --- GPy/testing/model_tests.py | 4 +++- GPy/util/warping_functions.py | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/GPy/testing/model_tests.py b/GPy/testing/model_tests.py index ab88d011..4b9d11ee 100644 --- a/GPy/testing/model_tests.py +++ b/GPy/testing/model_tests.py @@ -316,10 +316,12 @@ class MiscTests(unittest.TestCase): X = (2 * np.pi) * np.random.random(151) - np.pi Y = np.sin(X) + np.random.normal(0,0.2,151) Y = np.array([np.power(abs(y),float(1)/3) * (1,-1)[y<0] for y in Y]) + Y = np.abs(Y) import matplotlib.pyplot as plt warp_k = GPy.kern.RBF(1) - warp_f = GPy.util.warping_functions.TanhFunction(n_terms=2) + #warp_f = GPy.util.warping_functions.TanhFunction(n_terms=2) + warp_f = GPy.util.warping_functions.LogisticFunction(n_terms=2) warp_m = GPy.models.WarpedGP(X[:, None], Y[:, None], kernel=warp_k, warping_function=warp_f) m = GPy.models.GPRegression(X[:, None], Y[:, None]) diff --git a/GPy/util/warping_functions.py b/GPy/util/warping_functions.py index 10fddb50..c62ed08e 100644 --- a/GPy/util/warping_functions.py +++ b/GPy/util/warping_functions.py @@ -338,7 +338,7 @@ class LogisticFunction(WarpingFunction): return grad, logistic_term, logistic_grad return grad - def fgrad_y_psi(self, y, psi): + def fgrad_y_psi(self, y, return_covar_chain=False): """ gradient of f w.r.t to y and psi @@ -351,7 +351,7 @@ class LogisticFunction(WarpingFunction): for i in xrange(self.n_terms): a, b, c = mpsi[i] gradients[:, :, i, 0] = b * l_grad[i].T - b2l_term = b - (2 * l_term[i]) + b2l_term = b - (2 * l_term[i].T) al_grad = a * l_grad[i].T #gradients[:, :, i, 1] = a * (d[i] - 2.0 * s[i] * r[i] * (1.0/np.cosh(s[i])) ** 2).T gradients[:, :, i, 1] = (1 + ((y + c) * b2l_term)) * al_grad