mirror of
https://github.com/SheffieldML/GPy.git
synced 2026-05-24 14:15:14 +02:00
made parallel optimize_restart responsive to ctrl+c
This commit is contained in:
parent
b33d3e4c99
commit
c44493077a
1 changed files with 13 additions and 9 deletions
|
|
@ -188,19 +188,23 @@ class model(parameterised):
|
||||||
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
initial_parameters = self._get_params_transformed()
|
initial_parameters = self._get_params_transformed()
|
||||||
|
|
||||||
if parallel:
|
if parallel:
|
||||||
jobs = []
|
try:
|
||||||
pool = mp.Pool(processes=num_processes)
|
jobs = []
|
||||||
for i in range(Nrestarts):
|
pool = mp.Pool(processes=num_processes)
|
||||||
self.randomize()
|
for i in range(Nrestarts):
|
||||||
job = pool.apply_async(opt_wrapper, args = (self,), kwds = kwargs)
|
self.randomize()
|
||||||
jobs.append(job)
|
job = pool.apply_async(opt_wrapper, args = (self,), kwds = kwargs)
|
||||||
|
jobs.append(job)
|
||||||
|
|
||||||
pool.close() # signal that no more data coming in
|
pool.close() # signal that no more data coming in
|
||||||
pool.join() # wait for all the tasks to complete
|
pool.join() # wait for all the tasks to complete
|
||||||
|
except KeyboardInterrupt:
|
||||||
|
print "Ctrl+c received, terminating and joining pool."
|
||||||
|
pool.terminate()
|
||||||
|
pool.join()
|
||||||
|
|
||||||
for i in range(Nrestarts):
|
for i in range(Nrestarts):
|
||||||
try:
|
try:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue