mirror of
https://github.com/SheffieldML/GPy.git
synced 2026-05-30 14:35:15 +02:00
some little changes
This commit is contained in:
parent
39327e0789
commit
59939bd50c
3 changed files with 10 additions and 16 deletions
|
|
@ -515,19 +515,12 @@ class Indexable(Nameable, Observable):
|
||||||
#===========================================================================
|
#===========================================================================
|
||||||
# Tie parameters together
|
# Tie parameters together
|
||||||
#===========================================================================
|
#===========================================================================
|
||||||
|
|
||||||
def _has_ties(self):
|
|
||||||
if self._highest_parent_.ties.tied_param is None:
|
|
||||||
return False
|
|
||||||
if self.has_parent():
|
|
||||||
return self._highest_parent_.ties.label_buf[self._highest_parent_._raveled_index_for(self)].sum()>0
|
|
||||||
return True
|
|
||||||
|
|
||||||
def tie_together(self, *plist):
|
def tie_together(self, *plist):
|
||||||
plist = list(plist)
|
plist = list(plist)
|
||||||
plist.append(self)
|
plist.append(self)
|
||||||
self._highest_parent_.ties.tie_together(plist)
|
self._highest_parent_.ties.tie_together(plist)
|
||||||
self._highest_parent_._set_fixed(self,self._raveled_index())
|
# self._highest_parent_._set_fixed(self,self._raveled_index())
|
||||||
self._trigger_params_changed()
|
self._trigger_params_changed()
|
||||||
|
|
||||||
#===========================================================================
|
#===========================================================================
|
||||||
|
|
@ -683,9 +676,10 @@ class OptimizationHandlable(Indexable):
|
||||||
if self.has_parent() and (self.constraints[__fixed__].size != 0 or self._has_ties()):
|
if self.has_parent() and (self.constraints[__fixed__].size != 0 or self._has_ties()):
|
||||||
fixes = np.ones(self.size).astype(bool)
|
fixes = np.ones(self.size).astype(bool)
|
||||||
fixes[self.constraints[__fixed__]] = FIXED
|
fixes[self.constraints[__fixed__]] = FIXED
|
||||||
return self._optimizer_copy_[np.logical_and(fixes, self._highest_parent_.ties.getTieFlag(self))]
|
fixes[self._highest_parent_.ties.label_buf[self._highest_parent_._raveled_index_for(self)]] = FIXED
|
||||||
|
return self._optimizer_copy_[fixes]
|
||||||
elif self._has_fixes():
|
elif self._has_fixes():
|
||||||
return self._optimizer_copy_[self._fixes_]
|
return self._optimizer_copy_[np.logical_and(self._fixes_,self.ties.label_buf==0)]
|
||||||
|
|
||||||
self._optimizer_copy_transformed = True
|
self._optimizer_copy_transformed = True
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,7 @@ class Tie(Parameterized):
|
||||||
TODO:
|
TODO:
|
||||||
1. Add the support for multiple parameter tie_together and tie_vector
|
1. Add the support for multiple parameter tie_together and tie_vector
|
||||||
2. Properly handling parameters with constraints
|
2. Properly handling parameters with constraints
|
||||||
3. Properly handling the merging of two models
|
3. Properly handling the merging of two models [DONE]
|
||||||
4. Properly handling initialization
|
4. Properly handling initialization
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
@ -64,7 +64,6 @@ class Tie(Parameterized):
|
||||||
# If ture, it does not need to check consistency
|
# If ture, it does not need to check consistency
|
||||||
self._PROPAGATE_VAL_ = False
|
self._PROPAGATE_VAL_ = False
|
||||||
super(Tie, self).__init__(name)
|
super(Tie, self).__init__(name)
|
||||||
self.size = sum(p.size for p in self.parameters)
|
|
||||||
self.tied_param = None
|
self.tied_param = None
|
||||||
# The buffer keeps track of tie status
|
# The buffer keeps track of tie status
|
||||||
self.label_buf = None
|
self.label_buf = None
|
||||||
|
|
@ -146,7 +145,6 @@ class Tie(Parameterized):
|
||||||
self.tied_param.tie[:old_size] = old_tie_
|
self.tied_param.tie[:old_size] = old_tie_
|
||||||
self.tied_param.tie[old_size:] = range(start_label,start_label+num)
|
self.tied_param.tie[old_size:] = range(start_label,start_label+num)
|
||||||
self.add_parameter(self.tied_param)
|
self.add_parameter(self.tied_param)
|
||||||
self.size = sum(p.size for p in self.parameters)
|
|
||||||
return range(start_label,start_label+num)
|
return range(start_label,start_label+num)
|
||||||
|
|
||||||
def _remove_tie_param(self, labels):
|
def _remove_tie_param(self, labels):
|
||||||
|
|
@ -163,7 +161,6 @@ class Tie(Parameterized):
|
||||||
self.tied_param = Param('tied',new_buf)
|
self.tied_param = Param('tied',new_buf)
|
||||||
self.tied_param.tie[:] = old_tie_[idx]
|
self.tied_param.tie[:] = old_tie_[idx]
|
||||||
self.add_parameter(self.tied_param)
|
self.add_parameter(self.tied_param)
|
||||||
self.size = sum(p.size for p in self.parameters)
|
|
||||||
|
|
||||||
def _merge_tie_labels(self, labels):
|
def _merge_tie_labels(self, labels):
|
||||||
"""Merge all the labels in the list to the first one"""
|
"""Merge all the labels in the list to the first one"""
|
||||||
|
|
@ -177,7 +174,7 @@ class Tie(Parameterized):
|
||||||
self.label_buf = None
|
self.label_buf = None
|
||||||
self.buf_idx = None
|
self.buf_idx = None
|
||||||
else:
|
else:
|
||||||
self.label_buf = np.zeros((self._highest_parent_.size,),dtype=np.uint32)
|
self.label_buf = np.zeros((self._highest_parent_.param_array.size,),dtype=np.uint32)
|
||||||
self._traverse_param(lambda x:np.put(self.label_buf,self._highest_parent_._raveled_index_for(x),x.tie), self._highest_parent_, [])
|
self._traverse_param(lambda x:np.put(self.label_buf,self._highest_parent_._raveled_index_for(x),x.tie), self._highest_parent_, [])
|
||||||
self.buf_idx = self._highest_parent_._raveled_index_for(self.tied_param)
|
self.buf_idx = self._highest_parent_._raveled_index_for(self.tied_param)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,9 @@ class PSICOMP_RBF(Pickleable):
|
||||||
return ssrbf_psi_comp.psiDerivativecomputations(dL_dpsi0, dL_dpsi1, dL_dpsi2, variance, lengthscale, Z, variational_posterior)
|
return ssrbf_psi_comp.psiDerivativecomputations(dL_dpsi0, dL_dpsi1, dL_dpsi2, variance, lengthscale, Z, variational_posterior)
|
||||||
else:
|
else:
|
||||||
raise ValueError, "unknown distriubtion received for psi-statistics"
|
raise ValueError, "unknown distriubtion received for psi-statistics"
|
||||||
|
|
||||||
|
def _setup_observers(self):
|
||||||
|
pass
|
||||||
|
|
||||||
class PSICOMP_Linear(Pickleable):
|
class PSICOMP_Linear(Pickleable):
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue