Skip to content

Commit

Permalink
Fix OpperArchambeau and Hensman models for GPU
Browse files Browse the repository at this point in the history
  • Loading branch information
tdewolff committed Dec 8, 2023
1 parent d43e5c6 commit aea3d2e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion mogptk/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""
.. include:: ./documentation.md
"""
from .gpr import *
from .gpr.config import *
from .util import *

from .transformer import *
Expand Down
8 changes: 4 additions & 4 deletions mogptk/gpr/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -572,11 +572,11 @@ def elbo(self):
qf_mu = Kff.mm(q_nu)
qf_var_diag = 1.0/q_lambda.square() - (invL.T.mm(invL)/q_lambda/q_lambda.T).diagonal().reshape(-1,1)

kl = -q_nu.shape[0]
kl += q_nu.T.mm(qf_mu).squeeze() # Mahalanobis
kl = q_nu.T.mm(qf_mu).squeeze() # Mahalanobis
kl += L.diagonal().square().log().sum() # determinant TODO: is this correct?
#kl += invL.diagonal().square().sum() # trace
kl += invL.square().sum() # trace
kl -= q_nu.shape[0]

if self.mean is not None:
qf_mu = qf_mu - self.mean(self.X).reshape(-1,1) # Sx1
Expand Down Expand Up @@ -780,10 +780,10 @@ def __init__(self, kernel, X, y, Z=None, Z_init='grid', likelihood=GaussianLikel

def kl_gaussian(self, q_mu, q_sqrt):
S_diag = q_sqrt.diagonal().square() # NxN
kl = -q_mu.shape[0]
kl += q_mu.T.mm(q_mu).squeeze() # Mahalanobis
kl = q_mu.T.mm(q_mu).squeeze() # Mahalanobis
kl -= S_diag.log().sum() # determinant of q_var
kl += S_diag.sum() # same as Trace(p_var^(-1).q_var)
kl -= q_mu.shape[0]
return 0.5*kl

def elbo(self):
Expand Down

0 comments on commit aea3d2e

Please sign in to comment.