roundtrip error fixed for likelihood tests

This commit is contained in:
Max Zwiessele 2014-02-14 13:43:43 +00:00
parent 0919544eb7
commit f21e8e2394
3 changed files with 10 additions and 11 deletions

View file

@ -154,8 +154,7 @@ class Model(Parameterized):
x = np.random.randn(self.size_transformed)
x = self._untransform_params(x)
# now draw from prior where possible
if self.priors is not None and len(self.priors):
[np.put(x, i, p.rvs(1)) for i, p in enumerate(self.priors) if not p is None]
[np.put(x, ind, p.rvs(ind.size)) for p, ind in self.priors.iteritems() if not p is None]
self._set_params(x)
# self._set_params_transformed(self._get_params_transformed()) # makes sure all of the tied parameters get the same init (since there's only one prior object...)

View file

@ -145,7 +145,7 @@ class Param(ObservableArray, Constrainable, Gradcheckable, Indexable, Parameteri
return new_arr
def __setitem__(self, s, val, update=True):
super(Param, self).__setitem__(s, val, update=update)
self._notify_tied_parameters()
#self._notify_tied_parameters()
if update:
self._highest_parent_.parameters_changed()
@ -201,11 +201,11 @@ class Param(ObservableArray, Constrainable, Gradcheckable, Indexable, Parameteri
@property
def is_fixed(self):
return self._highest_parent_._is_fixed(self)
def round(self, decimals=0, out=None):
view = super(Param, self).round(decimals, out).view(Param)
view.__array_finalize__(self)
return view
round.__doc__ = numpy.round.__doc__
#def round(self, decimals=0, out=None):
# view = super(Param, self).round(decimals, out).view(Param)
# view.__array_finalize__(self)
# return view
#round.__doc__ = numpy.round.__doc__
def _get_original(self, param):
return self
@ -337,8 +337,8 @@ class ParamConcatenation(object):
def __setitem__(self, s, val, update=True):
ind = numpy.zeros(sum(self._param_sizes), dtype=bool); ind[s] = True;
vals = self._vals(); vals[s] = val; del val
[numpy.place(p, ind[ps], vals[ps]) and p._notify_tied_parameters()
for p, ps in zip(self.params, self._param_slices_)]
[numpy.place(p, ind[ps], vals[ps])# and p._notify_tied_parameters()
for p, ps in zip(self.params, self._param_slices_)]
if update:
self.params[0]._highest_parent_.parameters_changed()
def _vals(self):

View file

@ -216,7 +216,7 @@ class Laplace(object):
"""
if not log_concave:
#print "Under 1e-10: {}".format(np.sum(W < 1e-6))
W[W < 1e-6] = 1e-6 # FIXME-HACK: This is a hack since GPy can't handle negative variances which can occur
W.__setitem__(W < 1e-6, 1e-6, update=False) # FIXME-HACK: This is a hack since GPy can't handle negative variances which can occur
# If the likelihood is non-log-concave. We wan't to say that there is a negative variance
# To cause the posterior to become less certain than the prior and likelihood,
# This is a property only held by non-log-concave likelihoods