forked from hyperopt/hyperopt
-
Notifications
You must be signed in to change notification settings - Fork 104
Parallelizing Evaluations During Search via MongoDB
jaberg edited this page Jan 7, 2013
·
10 revisions
Hyperopt is designed to support different kinds of trial databases. The default trial database (Trials
) is based on Python lists and dictionaries, and does not support the asynchronous updates required for the parallel evaluation of trials. However, hyperopt also comes with a MongoTrials
trials implementation that does support asynchronous updates, and the parallel evaluation of trials.
import hyperopt
from hyperopt import fmin, tpe, hp
from hyperopt import Trials
from hyperopt.mongoexp import MongoTrials
trials = Trials()
trials2 = MongoTrials('mongo://localhost:1234/my_db')
def fn(x, y):
return {
'loss': x ** 2 + y ** 2,
'status': hyperopt.STATUS_OK,
}
fmin(fn,
space=[hp.uniform('a', -3, 3), hp.normal('b', 1, 1)],
algo=tpe.suggest,
max_evals=100,
#trials=trials, # -- runs locally, synchronously
trials=trials2, # -- runs async
)
print trials