mirror of
https://github.com/SheffieldML/GPy.git
synced 2026-06-11 15:15:15 +02:00
Merge branch 'params' of github.com:SheffieldML/GPy into params
This commit is contained in:
commit
d95da876e0
4 changed files with 12 additions and 16 deletions
|
|
@ -12,7 +12,7 @@ class ListArray(np.ndarray):
|
|||
WARNING: This overrides the functionality of x==y!!!
|
||||
Use numpy.equal(x,y) for element-wise equality testing.
|
||||
"""
|
||||
|
||||
|
||||
def __new__(cls, input_array):
|
||||
obj = np.asanyarray(input_array).view(cls)
|
||||
return obj
|
||||
|
|
@ -26,7 +26,7 @@ class ParamList(list):
|
|||
if el is other:
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
pass
|
||||
|
||||
class ObservableArray(ListArray, Observable):
|
||||
|
|
@ -46,7 +46,6 @@ class ObservableArray(ListArray, Observable):
|
|||
# see InfoArray.__array_finalize__ for comments
|
||||
if obj is None: return
|
||||
self._observers_ = getattr(obj, '_observers_', None)
|
||||
|
||||
def __setitem__(self, s, val, update=True):
|
||||
super(ObservableArray, self).__setitem__(s, val)
|
||||
if update:
|
||||
|
|
@ -54,10 +53,9 @@ class ObservableArray(ListArray, Observable):
|
|||
def __getslice__(self, start, stop):
|
||||
return self.__getitem__(slice(start, stop))
|
||||
def __setslice__(self, start, stop, val):
|
||||
return self.__setitem__(slice(start, stop), val)
|
||||
|
||||
return self.__setitem__(slice(start, stop), val)
|
||||
def __copy__(self, *args):
|
||||
return ObservableArray(self.base.base.copy(*args))
|
||||
return ObservableArray(self.view(np.ndarray).copy())
|
||||
def copy(self, *args):
|
||||
return self.__copy__(*args)
|
||||
|
||||
|
|
@ -65,7 +63,6 @@ class ObservableArray(ListArray, Observable):
|
|||
r = np.ndarray.__ror__(self, *args, **kwargs)
|
||||
self._notify_observers()
|
||||
return r
|
||||
|
||||
|
||||
def __ilshift__(self, *args, **kwargs):
|
||||
r = np.ndarray.__ilshift__(self, *args, **kwargs)
|
||||
|
|
|
|||
|
|
@ -154,14 +154,14 @@ class Param(ObservableArray, Constrainable, Gradcheckable):
|
|||
#===========================================================================
|
||||
def tie_to(self, param):
|
||||
"""
|
||||
:param param: the parameter object to tie this parameter to.
|
||||
:param param: the parameter object to tie this parameter to.
|
||||
Can be ParamConcatenation (retrieved by regexp search)
|
||||
|
||||
|
||||
Tie this parameter to the given parameter.
|
||||
Broadcasting is not allowed, but you can tie a whole dimension to
|
||||
one parameter: self[:,0].tie_to(other), where other is a one-value
|
||||
parameter.
|
||||
|
||||
|
||||
Note: For now only one parameter can have ties, so all of a parameter
|
||||
will be removed, when re-tieing!
|
||||
"""
|
||||
|
|
@ -531,7 +531,7 @@ class ParamConcatenation(object):
|
|||
def checkgrad(self, verbose=0, step=1e-6, tolerance=1e-3):
|
||||
return self.params[0]._highest_parent_._checkgrad(self, verbose, step, tolerance)
|
||||
#checkgrad.__doc__ = Gradcheckable.checkgrad.__doc__
|
||||
|
||||
|
||||
__lt__ = lambda self, val: self._vals() < val
|
||||
__le__ = lambda self, val: self._vals() <= val
|
||||
__eq__ = lambda self, val: self._vals() == val
|
||||
|
|
|
|||
|
|
@ -92,12 +92,11 @@ class LaplaceInference(object):
|
|||
iteration = 0
|
||||
while difference > self._mode_finding_tolerance and iteration < self._mode_finding_max_iter:
|
||||
W = -likelihood.d2logpdf_df2(f, Y, extra_data=Y_metadata)
|
||||
|
||||
W_f = W*f
|
||||
grad = likelihood.dlogpdf_df(f, Y, extra_data=Y_metadata)
|
||||
|
||||
W_f = W*f
|
||||
|
||||
b = W_f + grad # R+W p46 line 6.
|
||||
#W12BiW12Kb, B_logdet = self._compute_B_statistics(K, W.copy(), np.dot(K, b), likelihood.log_concave)
|
||||
W12BiW12, _, _ = self._compute_B_statistics(K, W, likelihood.log_concave)
|
||||
W12BiW12Kb = np.dot(W12BiW12, np.dot(K, b))
|
||||
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
import numpy as np
|
||||
import unittest
|
||||
import GPy
|
||||
from GPy.models import GradientChecker
|
||||
from ..models import GradientChecker
|
||||
import functools
|
||||
import inspect
|
||||
from GPy.likelihoods import link_functions
|
||||
from ..likelihoods import link_functions
|
||||
from ..core.parameterization import Param
|
||||
from functools import partial
|
||||
#np.random.seed(300)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue