moved randomize() in a more proper place

This commit is contained in:
Nicolo Fusi 2013-02-25 12:20:20 +00:00
parent bc80c0b62d
commit f661b4b64e
2 changed files with 2 additions and 2 deletions

View file

@ -185,7 +185,7 @@ class model(parameterised):
:verbose: whether to show informations about the current restart :verbose: whether to show informations about the current restart
:parallel: whether to run each restart as a separate process. It relies on the multiprocessing module. :parallel: whether to run each restart as a separate process. It relies on the multiprocessing module.
:num_processes: number of workers in the multiprocessing pool :num_processes: number of workers in the multiprocessing pool
..Note: If num_processes is None, the number of workes in the multiprocessing pool is automatically ..Note: If num_processes is None, the number of workes in the multiprocessing pool is automatically
set to the number of processors on the current machine. set to the number of processors on the current machine.
@ -198,6 +198,7 @@ class model(parameterised):
jobs = [] jobs = []
pool = mp.Pool(processes=num_processes) pool = mp.Pool(processes=num_processes)
for i in range(Nrestarts): for i in range(Nrestarts):
self.randomize()
job = pool.apply_async(opt_wrapper, args = (self,), kwds = kwargs) job = pool.apply_async(opt_wrapper, args = (self,), kwds = kwargs)
jobs.append(job) jobs.append(job)

View file

@ -9,7 +9,6 @@ def opt_wrapper(m, **kwargs):
This function just wraps the optimization procedure of a GPy This function just wraps the optimization procedure of a GPy
object so that optimize() pickleable (necessary for multiprocessing). object so that optimize() pickleable (necessary for multiprocessing).
""" """
m.randomize()
m.optimize(**kwargs) m.optimize(**kwargs)
return m.optimization_runs[-1] return m.optimization_runs[-1]