mirror of
https://github.com/SheffieldML/GPy.git
synced 2026-05-11 21:12:38 +02:00
Bug in prod-coreg kernels fixed, not in the most elegant way though
This commit is contained in:
parent
b47f9a1b06
commit
99c3af63c4
2 changed files with 13 additions and 7 deletions
|
|
@ -259,9 +259,6 @@ class SparseGP(GPBase):
|
||||||
The derivative of the bound wrt the inducing inputs Z
|
The derivative of the bound wrt the inducing inputs Z
|
||||||
"""
|
"""
|
||||||
dL_dZ = self.kern.dK_dX(self.dL_dKmm, self.Z)
|
dL_dZ = self.kern.dK_dX(self.dL_dKmm, self.Z)
|
||||||
if hasattr(self,'multioutput'):
|
|
||||||
dL_dZ = dL_dZ*2 #NOTE Yes, this looks weird... but it works
|
|
||||||
|
|
||||||
if self.has_uncertain_inputs:
|
if self.has_uncertain_inputs:
|
||||||
dL_dZ += self.kern.dpsi1_dZ(self.dL_dpsi1, self.Z, self.X, self.X_variance)
|
dL_dZ += self.kern.dpsi1_dZ(self.dL_dpsi1, self.Z, self.X, self.X_variance)
|
||||||
dL_dZ += self.kern.dpsi2_dZ(self.dL_dpsi2, self.Z, self.X, self.X_variance)
|
dL_dZ += self.kern.dpsi2_dZ(self.dL_dpsi2, self.Z, self.X, self.X_variance)
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
# Licensed under the BSD 3-clause license (see LICENSE.txt)
|
# Licensed under the BSD 3-clause license (see LICENSE.txt)
|
||||||
|
|
||||||
from kernpart import Kernpart
|
from kernpart import Kernpart
|
||||||
|
from coregionalize import Coregionalize
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import hashlib
|
import hashlib
|
||||||
|
|
||||||
|
|
@ -60,7 +61,7 @@ class Prod(Kernpart):
|
||||||
"""Compute the part of the kernel associated with k2."""
|
"""Compute the part of the kernel associated with k2."""
|
||||||
self._K_computations(X, X2)
|
self._K_computations(X, X2)
|
||||||
return self._K2
|
return self._K2
|
||||||
|
|
||||||
def dK_dtheta(self,dL_dK,X,X2,target):
|
def dK_dtheta(self,dL_dK,X,X2,target):
|
||||||
"""Derivative of the covariance matrix with respect to the parameters."""
|
"""Derivative of the covariance matrix with respect to the parameters."""
|
||||||
self._K_computations(X,X2)
|
self._K_computations(X,X2)
|
||||||
|
|
@ -91,9 +92,17 @@ class Prod(Kernpart):
|
||||||
"""derivative of the covariance matrix with respect to X."""
|
"""derivative of the covariance matrix with respect to X."""
|
||||||
self._K_computations(X,X2)
|
self._K_computations(X,X2)
|
||||||
if X2 is None:
|
if X2 is None:
|
||||||
X2 = X
|
if not isinstance(self.k1,Coregionalize) and not isinstance(self.k2,Coregionalize):
|
||||||
self.k1.dK_dX(dL_dK*self._K2, X[:,self.slice1], X2[:,self.slice1], target[:,self.slice1])
|
self.k1.dK_dX(dL_dK*self._K2, X[:,self.slice1], None, target[:,self.slice1])
|
||||||
self.k2.dK_dX(dL_dK*self._K1, X[:,self.slice2], X2[:,self.slice2], target[:,self.slice2])
|
self.k2.dK_dX(dL_dK*self._K1, X[:,self.slice2], None, target[:,self.slice2])
|
||||||
|
else:#if isinstance(self.k1,Coregionalize) or isinstance(self.k2,Coregionalize):
|
||||||
|
#NOTE The indices column in the inputs makes the ki.dK_dX fail when passing None instead of X[:,self.slicei]
|
||||||
|
X2 = X
|
||||||
|
self.k1.dK_dX(2.*dL_dK*self._K2, X[:,self.slice1], X2[:,self.slice1], target[:,self.slice1])
|
||||||
|
self.k2.dK_dX(2.*dL_dK*self._K1, X[:,self.slice2], X2[:,self.slice2], target[:,self.slice2])
|
||||||
|
else:
|
||||||
|
self.k1.dK_dX(dL_dK*self._K2, X[:,self.slice1], X2[:,self.slice1], target[:,self.slice1])
|
||||||
|
self.k2.dK_dX(dL_dK*self._K1, X[:,self.slice2], X2[:,self.slice2], target[:,self.slice2])
|
||||||
|
|
||||||
def dKdiag_dX(self, dL_dKdiag, X, target):
|
def dKdiag_dX(self, dL_dKdiag, X, target):
|
||||||
K1 = np.zeros(X.shape[0])
|
K1 = np.zeros(X.shape[0])
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue