mirror of
https://github.com/SheffieldML/GPy.git
synced 2026-05-27 14:25:16 +02:00
variational returns now the right raveled indices
This commit is contained in:
parent
ae81cbce6c
commit
ed2aaab4bb
1 changed files with 15 additions and 9 deletions
|
|
@ -60,8 +60,6 @@ class SpikeAndSlabPrior(VariationalPrior):
|
||||||
S.gradient -= (1. - (1. / (S))) * gamma /2.
|
S.gradient -= (1. - (1. / (S))) * gamma /2.
|
||||||
self.pi.gradient = (gamma/self.pi - (1.-gamma)/(1.-self.pi)).sum(axis=0)
|
self.pi.gradient = (gamma/self.pi - (1.-gamma)/(1.-self.pi)).sum(axis=0)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class VariationalPosterior(Parameterized):
|
class VariationalPosterior(Parameterized):
|
||||||
def __init__(self, means=None, variances=None, name=None, *a, **kw):
|
def __init__(self, means=None, variances=None, name=None, *a, **kw):
|
||||||
super(VariationalPosterior, self).__init__(name=name, *a, **kw)
|
super(VariationalPosterior, self).__init__(name=name, *a, **kw)
|
||||||
|
|
@ -75,6 +73,14 @@ class VariationalPosterior(Parameterized):
|
||||||
if self.has_uncertain_inputs():
|
if self.has_uncertain_inputs():
|
||||||
assert self.variance.shape == self.mean.shape, "need one variance per sample and dimenion"
|
assert self.variance.shape == self.mean.shape, "need one variance per sample and dimenion"
|
||||||
|
|
||||||
|
def _raveled_index(self):
|
||||||
|
index = np.empty(dtype=int, shape=0)
|
||||||
|
size = 0
|
||||||
|
for p in self._parameters_:
|
||||||
|
index = np.hstack((index, p._raveled_index()+size))
|
||||||
|
size += p._realsize_ if hasattr(p, '_realsize_') else p.size
|
||||||
|
return index
|
||||||
|
|
||||||
def has_uncertain_inputs(self):
|
def has_uncertain_inputs(self):
|
||||||
return not self.variance is None
|
return not self.variance is None
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue