mirror of
https://github.com/SheffieldML/GPy.git
synced 2026-05-07 02:52:40 +02:00
implement the gradient_X for standard_periodic kernel
This commit is contained in:
parent
1b85b45a7e
commit
fd2fc557c6
1 changed files with 11 additions and 8 deletions
|
|
@ -155,11 +155,14 @@ class StdPeriodic(Kern):
|
|||
self.period.gradient = 0
|
||||
self.lengthscale.gradient = 0
|
||||
|
||||
# def gradients_X(self, dL_dK, X, X2=None):
|
||||
# """derivative of the covariance matrix with respect to X."""
|
||||
#
|
||||
# raise NotImplemented("Periodic kernel: dK_dX not implemented")
|
||||
#
|
||||
# def gradients_X_diag(self, dL_dKdiag, X):
|
||||
#
|
||||
# raise NotImplemented("Periodic kernel: dKdiag_dX not implemented")
|
||||
def gradients_X(self, dL_dK, X, X2=None):
|
||||
K = self.K(X, X2)
|
||||
if X2 is None:
|
||||
dL_dK = dL_dK+dL_dK.T
|
||||
X2 = X
|
||||
dX = -np.pi*((dL_dK*K)[:,:,None]*np.sin(2*np.pi/self.period*(X[:,None,:] - X2[None,:,:]))/(2.*np.square(self.lengthscale)*self.period)).sum(1)
|
||||
return dX
|
||||
|
||||
def gradients_X_diag(self, dL_dKdiag, X):
|
||||
return np.zeros(X.shape)
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue