diff --git a/GPy/likelihoods/Laplace.py b/GPy/likelihoods/Laplace.py index ce3f870f..f2197e55 100644 --- a/GPy/likelihoods/Laplace.py +++ b/GPy/likelihoods/Laplace.py @@ -97,6 +97,19 @@ class Laplace(likelihood): a = mdot(dWi_dfhat, Ki, self.f_hat) b = np.dot(self.Sigma_tilde, Ki) + #dytil_dfhat = np.zeros(self.K.shape) + #for col in range(self.N): + #for row in range(self.N): + #t1 = 0 + #for l in range(self.N): + #t1 += dWi_dfhat[col, col]*Ki[col,l]*self.f_hat[l, 0] + ##t2 = np.zeros((1, self.N)) + #t2 = np.dot(self.Sigma_tilde, Ki[:, col]) + ##for k in range(self.N): + ##t2[:] += self.Sigma_tilde[k, k]*Ki[k, col] + #dytil_dfhat[row, col] = (t1 + t2)[row] + #dytil_dfhat += np.eye(self.N) + dytil_dfhat = - np.dot(dWi_dfhat, np.dot(Ki, self.f_hat)) + np.dot(self.Sigma_tilde, Ki) + np.eye(self.N) #dytil_dfhat = - (np.dot(dWi_dfhat, Ki)*self.f_hat[:, None] + np.dot(self.Sigma_tilde, Ki)).sum(-1) + np.eye(self.N) self.dytil_dfhat = dytil_dfhat diff --git a/GPy/testing/laplace_approx.tests.py b/GPy/testing/laplace_approx.tests.py index 394950d5..73dfbfd6 100644 --- a/GPy/testing/laplace_approx.tests.py +++ b/GPy/testing/laplace_approx.tests.py @@ -61,7 +61,7 @@ class LaplaceTests(unittest.TestCase): real_var = 0.1 #Start a function, any function #self.X = np.linspace(0.0, 10.0, 30)[:, None] - self.X = np.random.randn(2,1) + self.X = np.random.randn(9,1) #self.X = np.ones((10,1)) Y = np.sin(self.X) + np.random.randn(*self.X.shape)*real_var self.Y = Y/Y.max()