mirror of
https://github.com/SheffieldML/GPy.git
synced 2026-05-09 03:52:39 +02:00
some updates for params changes and likelihood fixes
This commit is contained in:
parent
6419401d60
commit
345e5b3e7c
3 changed files with 22 additions and 4 deletions
|
|
@ -37,10 +37,26 @@ class ObservableArray(np.ndarray, Observable):
|
|||
if obj is None: return
|
||||
self._observers_ = getattr(obj, '_observers_', None)
|
||||
|
||||
def _s_not_empty(self, s):
|
||||
# this checks whether there is something picked by this slice.
|
||||
return True
|
||||
# TODO: disarmed, for performance increase,
|
||||
if not isinstance(s, (list,tuple,np.ndarray)):
|
||||
return True
|
||||
if isinstance(s, (list,tuple)):
|
||||
return len(s)!=0
|
||||
if isinstance(s, np.ndarray):
|
||||
if s.dtype is bool:
|
||||
return np.all(s)
|
||||
else:
|
||||
return s.size != 0
|
||||
|
||||
def __setitem__(self, s, val, update=True):
|
||||
super(ObservableArray, self).__setitem__(s, val)
|
||||
if update:
|
||||
self._notify_observers()
|
||||
if self._s_not_empty(s):
|
||||
super(ObservableArray, self).__setitem__(s, val)
|
||||
if update:
|
||||
self._notify_observers()
|
||||
|
||||
def __getslice__(self, start, stop):
|
||||
return self.__getitem__(slice(start, stop))
|
||||
def __setslice__(self, start, stop, val):
|
||||
|
|
|
|||
|
|
@ -146,7 +146,7 @@ class Param(ObservableArray, Constrainable, Gradcheckable, Indexable, Parameteri
|
|||
def __setitem__(self, s, val, update=True):
|
||||
super(Param, self).__setitem__(s, val, update=update)
|
||||
#self._notify_tied_parameters()
|
||||
if update:
|
||||
if update and self._s_not_empty(s):
|
||||
self._notify_parameters_changed()
|
||||
|
||||
#===========================================================================
|
||||
|
|
|
|||
|
|
@ -216,6 +216,8 @@ class Laplace(object):
|
|||
"""
|
||||
if not log_concave:
|
||||
#print "Under 1e-10: {}".format(np.sum(W < 1e-6))
|
||||
# W[W<1e-6] = 1e-6
|
||||
# NOTE: when setting a parameter inside parameters_changed it will allways come to closed update circles!!!
|
||||
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,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue