mirror of
https://github.com/SheffieldML/GPy.git
synced 2026-06-14 15:25:15 +02:00
added initial test for warped gps using identity function
This commit is contained in:
parent
7fd8c9c556
commit
76bc0bec25
3 changed files with 15 additions and 6 deletions
|
|
@ -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):
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue