Changed kern.py so that X2 is correctly passed as None to the kern parts for dK_dX. Modified several kern parts so that dK_dX is correctly computed (factors of 2 missing). Removed spurious factors of 2 from gplvm, bcgplvm, sparse_gp and fitc code.

This commit is contained in:
Neil Lawrence 2013-09-14 20:02:40 +01:00
parent 2e6cac0d34
commit 00d335444d
20 changed files with 259 additions and 68 deletions

View file

@ -133,7 +133,10 @@ class RBFInv(RBF):
def dK_dX(self, dL_dK, X, X2, target):
self._K_computations(X, X2)
_K_dist = X[:, None, :] - X2[None, :, :] # don't cache this in _K_computations because it is high memory. If this function is being called, chances are we're not in the high memory arena.
if X2 is None:
_K_dist = 2*(X[:, None, :] - X[None, :, :])
else:
_K_dist = X[:, None, :] - X2[None, :, :] # don't cache this in _K_computations because it is high memory. If this function is being called, chances are we're not in the high memory arena.
dK_dX = (-self.variance * self.inv_lengthscale2) * np.transpose(self._K_dvar[:, :, np.newaxis] * _K_dist, (1, 0, 2))
target += np.sum(dK_dX * dL_dK.T[:, :, None], 0)