From e785668417ab472c607d9fa8b71b8d92519bd023 Mon Sep 17 00:00:00 2001 From: Fariba Date: Mon, 27 Jul 2015 17:30:24 +0100 Subject: [PATCH] changes --- GPy/core/parameterization/priors.py | 10 +++++----- GPy/core/sparse_gp.py | 4 +++- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/GPy/core/parameterization/priors.py b/GPy/core/parameterization/priors.py index 3c474438..5dad088a 100644 --- a/GPy/core/parameterization/priors.py +++ b/GPy/core/parameterization/priors.py @@ -843,7 +843,7 @@ class DGPLVM_Lamda(Prior, Parameterized): # Calculating beta and Bi for Sb def compute_sig_beta_Bi(self, data_idx, M_i, M_0, lst_idx_all): - import pdb + # import pdb # pdb.set_trace() B_i = np.zeros((self.classnum, self.dim)) Sig_beta_B_i_all = np.zeros((self.datanum, self.dim)) @@ -909,8 +909,8 @@ class DGPLVM_Lamda(Prior, Parameterized): Sw = self.compute_Sw(cls, M_i) # Sb_inv_N = np.linalg.inv(Sb + np.eye(Sb.shape[0]) * (np.diag(Sb).min() * 0.1)) #Sb_inv_N = np.linalg.inv(Sb+np.eye(Sb.shape[0])*0.1) - #Sb_inv_N = pdinv(Sb+ np.eye(Sb.shape[0]) * (np.diag(Sb).min() * 0.1))[0] - Sb_inv_N = pdinv(Sb + np.eye(Sb.shape[0])*0.1)[0] + #Sb_inv_N = pdinv(Sb+ np.eye(Sb.shape[0]) * (np.diag(Sb).min() * 0.5))[0] + Sb_inv_N = pdinv(Sb + np.eye(Sb.shape[0])*0.9)[0] return (-1 / self.sigma2) * np.trace(Sb_inv_N.dot(Sw)) # This function calculates derivative of the log of prior function @@ -933,8 +933,8 @@ class DGPLVM_Lamda(Prior, Parameterized): # Calculating inverse of Sb and its transpose and minus # Sb_inv_N = np.linalg.inv(Sb + np.eye(Sb.shape[0]) * (np.diag(Sb).min() * 0.1)) #Sb_inv_N = np.linalg.inv(Sb+np.eye(Sb.shape[0])*0.1) - #Sb_inv_N = pdinv(Sb+ np.eye(Sb.shape[0]) * (np.diag(Sb).min() * 0.1))[0] - Sb_inv_N = pdinv(Sb + np.eye(Sb.shape[0])*0.1)[0] + #Sb_inv_N = pdinv(Sb+ np.eye(Sb.shape[0]) * (np.diag(Sb).min() * 0.5))[0] + Sb_inv_N = pdinv(Sb + np.eye(Sb.shape[0])*0.9)[0] Sb_inv_N_trans = np.transpose(Sb_inv_N) Sb_inv_N_trans_minus = -1 * Sb_inv_N_trans Sw_trans = np.transpose(Sw) diff --git a/GPy/core/sparse_gp.py b/GPy/core/sparse_gp.py index 624a8f9c..f8d458ce 100644 --- a/GPy/core/sparse_gp.py +++ b/GPy/core/sparse_gp.py @@ -137,7 +137,9 @@ class SparseGP(GP): else: Kxx = kern.Kdiag(Xnew) if self.posterior.woodbury_inv.ndim == 2: - var = Kxx - np.sum(np.dot(self.posterior.woodbury_inv.T, Kx) * Kx, 0) + var = (Kxx - np.sum(np.dot(np.atleast_3d(self.posterior.woodbury_inv).T, Kx) * Kx[None,:,:], 1)).T + #For plot_latent, the below code doesn't work! + #var = Kxx - np.sum(np.dot(self.posterior.woodbury_inv.T, Kx) * Kx, 0) elif self.posterior.woodbury_inv.ndim == 3: var = np.empty((Kxx.shape[0],self.posterior.woodbury_inv.shape[2])) for i in range(var.shape[1]):