mirror of
https://github.com/SheffieldML/GPy.git
synced 2026-06-11 15:15:15 +02:00
bug fix
This commit is contained in:
parent
0e109cd3da
commit
f7d09f0c75
3 changed files with 11 additions and 5 deletions
|
|
@ -69,6 +69,8 @@ class _Slice_wrap(object):
|
|||
ret[:, self.k._all_dims_active] = return_val
|
||||
elif len(self.shape) == 3:
|
||||
ret[:, :, self.k._all_dims_active] = return_val
|
||||
elif len(self.shape) == 4:
|
||||
ret[:, :, :, self.k._all_dims_active] = return_val
|
||||
return ret
|
||||
return return_val
|
||||
|
||||
|
|
@ -120,12 +122,12 @@ def _slice_gradients_XX(f):
|
|||
else:
|
||||
N, M = X.shape[0], X2.shape[0]
|
||||
if cov: # full covariance
|
||||
with _Slice_wrap(self, X, X2, ret_shape=(N, M, X.shape[1], X.shape[1])) as s:
|
||||
#with _Slice_wrap(self, X, X2, ret_shape=None) as s:
|
||||
with _Slice_wrap(self, X, X2, ret_shape=(N, M, X.shape[1], X.shape[1])) as s:
|
||||
ret = s.handle_return_array(f(self, dL_dK, s.X, s.X2, cov))
|
||||
else: # diagonal covariance
|
||||
with _Slice_wrap(self, X, X2, ret_shape=(N, M, X.shape[1])) as s:
|
||||
#with _Slice_wrap(self, X, X2, ret_shape=None) as s:
|
||||
with _Slice_wrap(self, X, X2, ret_shape=(N, M, X.shape[1])) as s:
|
||||
ret = s.handle_return_array(f(self, dL_dK, s.X, s.X2, cov))
|
||||
return ret
|
||||
return wrap
|
||||
|
|
|
|||
|
|
@ -27,7 +27,10 @@ class Static(Kern):
|
|||
def gradients_XX(self, dL_dK, X, X2=None, cov=True):
|
||||
if X2 is None:
|
||||
X2 = X
|
||||
return np.zeros((X.shape[0], X2.shape[0], X.shape[1]), dtype=np.float64)
|
||||
if cov:
|
||||
return np.zeros((X.shape[0], X2.shape[0], X.shape[1],X.shape[1]), dtype=np.float64)
|
||||
else:
|
||||
return np.zeros((X.shape[0], X2.shape[0], X.shape[1]), dtype=np.float64)
|
||||
def gradients_XX_diag(self, dL_dKdiag, X):
|
||||
return np.zeros(X.shape)
|
||||
|
||||
|
|
|
|||
|
|
@ -108,8 +108,8 @@ class Kern_check_d2K_dXdX(Kern_check_model):
|
|||
"""This class allows gradient checks for the secondderivative of a kernel with respect to X. """
|
||||
def __init__(self, kernel=None, dL_dK=None, X=None, X2=None):
|
||||
Kern_check_model.__init__(self,kernel=kernel,dL_dK=dL_dK, X=X, X2=X2)
|
||||
#self.X = Param('X',X)
|
||||
#self.link_parameter(self.X)
|
||||
self.X = Param('X',X)
|
||||
self.link_parameter(self.X)
|
||||
|
||||
def log_likelihood(self):
|
||||
return np.sum(self.kernel.gradients_X(self.dL_dK,self.X, self.X2))
|
||||
|
|
@ -117,6 +117,7 @@ class Kern_check_d2K_dXdX(Kern_check_model):
|
|||
def parameters_changed(self):
|
||||
self.X.gradient[:] = self.kernel.gradients_XX(self.dL_dK, self.X, self.X2)
|
||||
|
||||
|
||||
# class Kern_check_d2Kdiag_dXdX(Kern_check_model):
|
||||
# """This class allows gradient checks for the secondderivative of a kernel diagonal with respect to X. """
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue