mirror of
https://github.com/SheffieldML/GPy.git
synced 2026-06-02 14:45:15 +02:00
Merge branch 'params' of github.com:SheffieldML/GPy into params
This commit is contained in:
commit
f7cdf598a6
14 changed files with 61 additions and 98 deletions
|
|
@ -77,6 +77,12 @@ class ParameterIndexOperations(object):
|
|||
def iter_properties(self):
|
||||
return self._properties.iterkeys()
|
||||
|
||||
def shift(self, start, size):
|
||||
for ind in self.iterindices():
|
||||
toshift = ind>=start
|
||||
if len(toshift) > 0:
|
||||
ind[toshift] += size
|
||||
|
||||
def clear(self):
|
||||
self._properties.clear()
|
||||
|
||||
|
|
|
|||
|
|
@ -154,6 +154,8 @@ class Parameterized(Constrainable, Pickleable, Observable, Gradcheckable):
|
|||
elif param._has_fixes(): self._fixes_ = np.r_[np.ones(self.size, dtype=bool), fixes_param]
|
||||
|
||||
else:
|
||||
start = sum(p.size for p in self._parameters_[:index])
|
||||
self.constraints.shift(start, param.size)
|
||||
self._parameters_.insert(index, param)
|
||||
|
||||
# make sure fixes and constraints are indexed right
|
||||
|
|
@ -165,10 +167,13 @@ class Parameterized(Constrainable, Pickleable, Observable, Gradcheckable):
|
|||
self._fixes_ = np.ones(self.size+param.size, dtype=bool)
|
||||
self._fixes_[ins:ins+param.size] = fixes_param
|
||||
self.size += param.size
|
||||
else:
|
||||
raise RuntimeError, """Parameter exists already added and no copy made"""
|
||||
self._connect_parameters()
|
||||
# make sure the constraints are pulled over:
|
||||
if hasattr(param, "_constraints_") and param._constraints_ is not None:
|
||||
for t, ind in param._constraints_.iteritems():
|
||||
|
||||
self.constraints.add(t, ind+self._offset_for(param))
|
||||
param._constraints_.clear()
|
||||
if param._default_constraint_ is not None:
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ Created on 6 Nov 2013
|
|||
'''
|
||||
from parameterized import Parameterized
|
||||
from param import Param
|
||||
from transformations import Logexp
|
||||
|
||||
class Normal(Parameterized):
|
||||
'''
|
||||
|
|
@ -15,7 +16,7 @@ class Normal(Parameterized):
|
|||
def __init__(self, means, variances, name='latent space'):
|
||||
Parameterized.__init__(self, name=name)
|
||||
self.means = Param("mean", means)
|
||||
self.variances = Param('variance', variances)
|
||||
self.variances = Param('variance', variances, Logexp())
|
||||
self.add_parameters(self.means, self.variances)
|
||||
|
||||
def plot(self, *args):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue