From 91d1cd3131628064bd4bc648ac1ecaa1a39f2253 Mon Sep 17 00:00:00 2001 From: Zhenwen Dai Date: Thu, 28 Aug 2014 17:57:29 +0100 Subject: [PATCH] fix the bug: the randomize function cannot properly handle variables with prior --- GPy/core/parameterization/parameter_core.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/GPy/core/parameterization/parameter_core.py b/GPy/core/parameterization/parameter_core.py index 16c382b8..2adc318e 100644 --- a/GPy/core/parameterization/parameter_core.py +++ b/GPy/core/parameterization/parameter_core.py @@ -778,9 +778,15 @@ class OptimizationHandlable(Indexable): """ # first take care of all parameters (from N(0,1)) x = rand_gen(size=self._size_transformed(), *args, **kwargs) - # now draw from prior where possible - [np.put(x, ind, p.rvs(ind.size)) for p, ind in self.priors.iteritems() if not p is None] + self.updates = False # Switch off the updates self.optimizer_array = x # makes sure all of the tied parameters get the same init (since there's only one prior object...) + # now draw from prior where possible + x = self.param_array.copy() + [np.put(x, ind, p.rvs(ind.size)) for p, ind in self.priors.iteritems() if not p is None] + unfixlist = np.ones((self.size,),dtype=np.bool) + unfixlist[self.constraints[__fixed__]] = False + self.param_array[unfixlist] = x[unfixlist] + self.updates = True #=========================================================================== # For shared memory arrays. This does nothing in Param, but sets the memory