mirror of
https://github.com/SheffieldML/GPy.git
synced 2026-05-21 14:05:14 +02:00
Merge branch 'devel' into polinomial
This commit is contained in:
commit
460757c048
10 changed files with 280 additions and 87 deletions
|
|
@ -1 +1 @@
|
|||
__version__ = "1.5.3"
|
||||
__version__ = "1.5.5"
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ from .param import Param
|
|||
from paramz.transformations import Logexp, Logistic,__fixed__
|
||||
|
||||
class VariationalPrior(Parameterized):
|
||||
def __init__(self, name='latent space', **kw):
|
||||
def __init__(self, name='latent prior', **kw):
|
||||
super(VariationalPrior, self).__init__(name=name, **kw)
|
||||
|
||||
def KL_divergence(self, variational_posterior):
|
||||
|
|
@ -23,6 +23,9 @@ class VariationalPrior(Parameterized):
|
|||
raise NotImplementedError("override this for variational inference of latent space")
|
||||
|
||||
class NormalPrior(VariationalPrior):
|
||||
def __init__(self, name='normal_prior', **kw):
|
||||
super(VariationalPrior, self).__init__(name=name, **kw)
|
||||
|
||||
def KL_divergence(self, variational_posterior):
|
||||
var_mean = np.square(variational_posterior.mean).sum()
|
||||
var_S = (variational_posterior.variance - np.log(variational_posterior.variance)).sum()
|
||||
|
|
@ -58,7 +61,7 @@ class SpikeAndSlabPrior(VariationalPrior):
|
|||
pi = self.pi[idx]
|
||||
else:
|
||||
pi = self.pi
|
||||
|
||||
|
||||
var_mean = np.square(mu)/self.variance
|
||||
var_S = (S/self.variance - np.log(S))
|
||||
var_gamma = (gamma*np.log(gamma/pi)).sum()+((1-gamma)*np.log((1-gamma)/(1-pi))).sum()
|
||||
|
|
@ -163,12 +166,12 @@ class NormalPosterior(VariationalPosterior):
|
|||
"""Compute the KL divergence to another NormalPosterior Object. This only holds, if the two NormalPosterior objects have the same shape, as we do computational tricks for the multivariate normal KL divergence.
|
||||
"""
|
||||
return .5*(
|
||||
np.sum(self.variance/other.variance)
|
||||
+ ((other.mean-self.mean)**2/other.variance).sum()
|
||||
np.sum(self.variance/other.variance)
|
||||
+ ((other.mean-self.mean)**2/other.variance).sum()
|
||||
- self.num_data * self.input_dim
|
||||
+ np.sum(np.log(other.variance)) - np.sum(np.log(self.variance))
|
||||
)
|
||||
|
||||
|
||||
class SpikeAndSlabPosterior(VariationalPosterior):
|
||||
'''
|
||||
The SpikeAndSlab distribution for variational approximations.
|
||||
|
|
@ -190,11 +193,11 @@ class SpikeAndSlabPosterior(VariationalPosterior):
|
|||
else:
|
||||
self.gamma = Param("binary_prob",binary_prob,Logistic(1e-10,1.-1e-10))
|
||||
self.link_parameter(self.gamma)
|
||||
|
||||
|
||||
def propogate_val(self):
|
||||
if self.group_spike:
|
||||
self.gamma.values[:] = self.gamma_group.values
|
||||
|
||||
|
||||
def collate_gradient(self):
|
||||
if self.group_spike:
|
||||
self.gamma_group.gradient = self.gamma.gradient.reshape(self.gamma.shape).sum(axis=0)
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@
|
|||
import sys
|
||||
import numpy as np
|
||||
from ...core.parameterization.parameterized import Parameterized
|
||||
from paramz.core.observable_array import ObsAr
|
||||
from paramz.caching import Cache_this
|
||||
from .kernel_slice_operations import KernCallsViaSlicerMeta
|
||||
from functools import reduce
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@ class RBF(Stationary):
|
|||
|
||||
def dK2_drdr_diag(self):
|
||||
return -self.variance # as the diagonal of r is always filled with zeros
|
||||
|
||||
def __getstate__(self):
|
||||
dc = super(RBF, self).__getstate__()
|
||||
if self.useGPU:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue