mirror of
https://github.com/SheffieldML/GPy.git
synced 2026-06-02 14:45:15 +02:00
minor edits, like spacing, spelling
This commit is contained in:
parent
cb9056d729
commit
ed6a45fd9b
1 changed files with 14 additions and 3 deletions
|
|
@ -29,7 +29,7 @@ class ListArray(numpy.ndarray):
|
||||||
|
|
||||||
class ObservableArray(ListArray, Observable):
|
class ObservableArray(ListArray, Observable):
|
||||||
"""
|
"""
|
||||||
An ndarray which reports changed to it's observers.
|
An ndarray which reports changes to its observers.
|
||||||
The observers can add themselves with a callable, which
|
The observers can add themselves with a callable, which
|
||||||
will be called every time this array changes. The callable
|
will be called every time this array changes. The callable
|
||||||
takes exactly one argument, which is this array itself.
|
takes exactly one argument, which is this array itself.
|
||||||
|
|
@ -63,7 +63,7 @@ class Param(ObservableArray, Nameable, Pickleable):
|
||||||
:param args: additional arguments to gradient
|
:param args: additional arguments to gradient
|
||||||
:param kwargs: additional keyword arguments to gradient
|
:param kwargs: additional keyword arguments to gradient
|
||||||
|
|
||||||
You can add/remove constraints by calling the constrain on the parameter itself, e.g:
|
You can add/remove constraints by calling constrain on the parameter itself, e.g:
|
||||||
|
|
||||||
- self[:,1].constrain_positive()
|
- self[:,1].constrain_positive()
|
||||||
- self[0].tie_to(other)
|
- self[0].tie_to(other)
|
||||||
|
|
@ -93,6 +93,7 @@ class Param(ObservableArray, Nameable, Pickleable):
|
||||||
obj._tied_to_ = []
|
obj._tied_to_ = []
|
||||||
obj._original_ = True
|
obj._original_ = True
|
||||||
return obj
|
return obj
|
||||||
|
|
||||||
def __init__(self, name, input_array):
|
def __init__(self, name, input_array):
|
||||||
super(Param, self).__init__(name=name)
|
super(Param, self).__init__(name=name)
|
||||||
|
|
||||||
|
|
@ -134,6 +135,7 @@ class Param(ObservableArray, Nameable, Pickleable):
|
||||||
self._updated_,
|
self._updated_,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
def __setstate__(self, state):
|
def __setstate__(self, state):
|
||||||
super(Param, self).__setstate__(state[0])
|
super(Param, self).__setstate__(state[0])
|
||||||
state = list(state[1])
|
state = list(state[1])
|
||||||
|
|
@ -148,9 +150,11 @@ class Param(ObservableArray, Nameable, Pickleable):
|
||||||
self._parent_index_ = state.pop()
|
self._parent_index_ = state.pop()
|
||||||
self._direct_parent_ = state.pop()
|
self._direct_parent_ = state.pop()
|
||||||
self.name = state.pop()
|
self.name = state.pop()
|
||||||
|
|
||||||
#===========================================================================
|
#===========================================================================
|
||||||
# get/set parameters
|
# get/set parameters
|
||||||
#===========================================================================
|
#===========================================================================
|
||||||
|
|
||||||
def _set_params(self, param, update=True):
|
def _set_params(self, param, update=True):
|
||||||
self.flat = param
|
self.flat = param
|
||||||
self._notify_tied_parameters()
|
self._notify_tied_parameters()
|
||||||
|
|
@ -212,6 +216,7 @@ class Param(ObservableArray, Nameable, Pickleable):
|
||||||
self._highest_parent_._add_constrain(self, transform, warning)
|
self._highest_parent_._add_constrain(self, transform, warning)
|
||||||
if update:
|
if update:
|
||||||
self._highest_parent_.parameters_changed()
|
self._highest_parent_.parameters_changed()
|
||||||
|
|
||||||
def constrain_positive(self, warning=True):
|
def constrain_positive(self, warning=True):
|
||||||
"""
|
"""
|
||||||
:param warning: print a warning if re-constraining parameters.
|
:param warning: print a warning if re-constraining parameters.
|
||||||
|
|
@ -219,6 +224,7 @@ class Param(ObservableArray, Nameable, Pickleable):
|
||||||
Constrain this parameter to the default positive constraint.
|
Constrain this parameter to the default positive constraint.
|
||||||
"""
|
"""
|
||||||
self.constrain(Logexp(), warning)
|
self.constrain(Logexp(), warning)
|
||||||
|
|
||||||
def constrain_negative(self, warning=True):
|
def constrain_negative(self, warning=True):
|
||||||
"""
|
"""
|
||||||
:param warning: print a warning if re-constraining parameters.
|
:param warning: print a warning if re-constraining parameters.
|
||||||
|
|
@ -226,6 +232,7 @@ class Param(ObservableArray, Nameable, Pickleable):
|
||||||
Constrain this parameter to the default negative constraint.
|
Constrain this parameter to the default negative constraint.
|
||||||
"""
|
"""
|
||||||
self.constrain(NegativeLogexp(), warning)
|
self.constrain(NegativeLogexp(), warning)
|
||||||
|
|
||||||
def constrain_bounded(self, lower, upper, warning=True):
|
def constrain_bounded(self, lower, upper, warning=True):
|
||||||
"""
|
"""
|
||||||
:param lower, upper: the limits to bound this parameter to
|
:param lower, upper: the limits to bound this parameter to
|
||||||
|
|
@ -234,6 +241,7 @@ class Param(ObservableArray, Nameable, Pickleable):
|
||||||
Constrain this parameter to lie within the given range.
|
Constrain this parameter to lie within the given range.
|
||||||
"""
|
"""
|
||||||
self.constrain(Logistic(lower, upper), warning)
|
self.constrain(Logistic(lower, upper), warning)
|
||||||
|
|
||||||
def unconstrain(self, *transforms):
|
def unconstrain(self, *transforms):
|
||||||
"""
|
"""
|
||||||
:param transforms: The transformations to unconstrain from.
|
:param transforms: The transformations to unconstrain from.
|
||||||
|
|
@ -242,16 +250,19 @@ class Param(ObservableArray, Nameable, Pickleable):
|
||||||
transformats of this parameter object.
|
transformats of this parameter object.
|
||||||
"""
|
"""
|
||||||
self._highest_parent_._remove_constrain(self, *transforms)
|
self._highest_parent_._remove_constrain(self, *transforms)
|
||||||
|
|
||||||
def unconstrain_positive(self):
|
def unconstrain_positive(self):
|
||||||
"""
|
"""
|
||||||
Remove positive constraint of this parameter.
|
Remove positive constraint of this parameter.
|
||||||
"""
|
"""
|
||||||
self.unconstrain(Logexp())
|
self.unconstrain(Logexp())
|
||||||
|
|
||||||
def unconstrain_negative(self):
|
def unconstrain_negative(self):
|
||||||
"""
|
"""
|
||||||
Remove negative constraint of this parameter.
|
Remove negative constraint of this parameter.
|
||||||
"""
|
"""
|
||||||
self.unconstrain(NegativeLogexp())
|
self.unconstrain(NegativeLogexp())
|
||||||
|
|
||||||
def unconstrain_bounded(self, lower, upper):
|
def unconstrain_bounded(self, lower, upper):
|
||||||
"""
|
"""
|
||||||
:param lower, upper: the limits to unbound this parameter from
|
:param lower, upper: the limits to unbound this parameter from
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue