mirror of
https://github.com/SheffieldML/GPy.git
synced 2026-05-30 14:35:15 +02:00
enable gpu switch in RBF
This commit is contained in:
parent
7d5b4f2769
commit
c7ea906763
2 changed files with 20 additions and 2 deletions
|
|
@ -83,8 +83,17 @@ class Inference_X(Model):
|
||||||
X_grad = self.kern.gradients_qX_expectations(variational_posterior=self.X, Z=self.Z, dL_dpsi0=self.dL_dpsi0, dL_dpsi1=self.dL_dpsi1, dL_dpsi2=self.dL_dpsi2)
|
X_grad = self.kern.gradients_qX_expectations(variational_posterior=self.X, Z=self.Z, dL_dpsi0=self.dL_dpsi0, dL_dpsi1=self.dL_dpsi1, dL_dpsi2=self.dL_dpsi2)
|
||||||
self.X.set_gradients(X_grad)
|
self.X.set_gradients(X_grad)
|
||||||
|
|
||||||
self._log_marginal_likelihood -= self.variational_prior.KL_divergence(self.X)
|
from ...core.parameterization.variational import SpikeAndSlabPrior
|
||||||
self.variational_prior.update_gradients_KL(self.X)
|
if isinstance(self.variational_prior, SpikeAndSlabPrior):
|
||||||
|
# Update Log-likelihood
|
||||||
|
KL_div = self.variational_prior.KL_divergence(self.X, N=self.Y.shape[0])
|
||||||
|
# update for the KL divergence
|
||||||
|
self.variational_prior.update_gradients_KL(self.X, N=self.Y.shape[0])
|
||||||
|
else:
|
||||||
|
# Update Log-likelihood
|
||||||
|
KL_div = self.variational_prior.KL_divergence(self.X)
|
||||||
|
# update for the KL divergence
|
||||||
|
self.variational_prior.update_gradients_KL(self.X)
|
||||||
|
|
||||||
def log_likelihood(self):
|
def log_likelihood(self):
|
||||||
return self._log_marginal_likelihood
|
return self._log_marginal_likelihood
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,15 @@ class RBF(Stationary):
|
||||||
self.psicomp = PSICOMP_RBF_GPU()
|
self.psicomp = PSICOMP_RBF_GPU()
|
||||||
else:
|
else:
|
||||||
self.psicomp = PSICOMP_RBF()
|
self.psicomp = PSICOMP_RBF()
|
||||||
|
|
||||||
|
def useGPU(self,flag=True):
|
||||||
|
if flag:
|
||||||
|
if isinstance(self.psicomp,PSICOMP_RBF):
|
||||||
|
self.useGPU = True
|
||||||
|
self.psicomp = PSICOMP_RBF_GPU()
|
||||||
|
else:
|
||||||
|
if isinstance(self.psicomp,PSICOMP_RBF_GPU):
|
||||||
|
self.psicomp = PSICOMP_RBF()
|
||||||
|
|
||||||
def K_of_r(self, r):
|
def K_of_r(self, r):
|
||||||
return self.variance * np.exp(-0.5 * r**2)
|
return self.variance * np.exp(-0.5 * r**2)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue