Correct order of subtraction in SGPR added loss
@@ -12,7 +12,7 @@ class InducingPointKernelAddedLossTerm(AddedLossTerm):
def loss(self, *params):
prior_covar = self.prior_dist.lazy_covariance_matrix
variational_covar = self.variational_dist.lazy_covariance_matrix
- diag = variational_covar.diag() - prior_covar.diag()
+ diag = prior_covar.diag() - variational_covar.diag()
shape = prior_covar.shape[:-1]
noise_diag = self.likelihood._shaped_noise_covar(shape, *params).diag()
- return 0.5 * (diag / noise_diag).sum()
+ return -0.5 * (diag / noise_diag).sum()
