Workong on doing explicit gradients

This commit is contained in:
Alan Saul 2013-05-16 12:00:15 +01:00
parent 569311b510
commit 21ae81de29
2 changed files with 14 additions and 1 deletions

View file

@ -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

View file

@ -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()