Hyperopt: Difference between revisions
From charlesreid1
(Created page with "Hyperopt is a hyperparameter optimization library. Origin of the work was in searching through parameter spaces/sampling probability distributions of parameters. Notion of...") |
|||
| (4 intermediate revisions by the same user not shown) | |||
| Line 3: | Line 3: | ||
Origin of the work was in searching through parameter spaces/sampling probability distributions of parameters. | Origin of the work was in searching through parameter spaces/sampling probability distributions of parameters. | ||
==Installing== | |||
Hyperopt relies on an older version of the networkx library. If you see this: | |||
<pre> | |||
$ python myhyper.py | |||
Traceback (most recent call last): | |||
File "myhyper.py", line 14, in <module> | |||
bestr = fmin(f, space, algo=rand.suggest, max_evals=100) | |||
File "/usr/local/lib/python3.6/site-packages/hyperopt/fmin.py", line 314, in fmin | |||
pass_expr_memo_ctrl=pass_expr_memo_ctrl) | |||
File "/usr/local/lib/python3.6/site-packages/hyperopt/base.py", line 786, in __init__ | |||
pyll.toposort(self.expr) | |||
File "/usr/local/lib/python3.6/site-packages/hyperopt/pyll/base.py", line 715, in toposort | |||
assert order[-1] == expr | |||
TypeError: 'generator' object is not subscriptable | |||
</pre> | |||
Do this: | |||
<pre> | |||
$ pip install networkx==1.11 | |||
</pre> | |||
Also see this Github issue: https://github.com/hyperopt/hyperopt/issues/325 | |||
==Usage== | |||
Random search over a space | |||
Start by defining a distribution space | |||
Create a score over the space - you need some way to score the results (your function of interest) | |||
Then, call fmin to minimize the function over your distribution space | |||
Specify max_evals to tell it how many random points to try | |||
===Example=== | |||
Simple example to optimize a 2D quadratic function: <math>x^2 + y^2</math> | Simple example to optimize a 2D quadratic function: <math>x^2 + y^2</math> | ||
==Resources== | |||
Scipy talk on Hyperopt: https://youtube.com/watch?v=Mp1xnPfE4PY | |||
Github notebook on optimizing a Keras network with Hyperopt: https://github.com/Vooban/Hyperopt-Keras-CNN-CIFAR-100 | |||
Latest revision as of 21:18, 17 October 2017
Hyperopt is a hyperparameter optimization library.
Origin of the work was in searching through parameter spaces/sampling probability distributions of parameters.
Installing
Hyperopt relies on an older version of the networkx library. If you see this:
$ python myhyper.py
Traceback (most recent call last):
File "myhyper.py", line 14, in <module>
bestr = fmin(f, space, algo=rand.suggest, max_evals=100)
File "/usr/local/lib/python3.6/site-packages/hyperopt/fmin.py", line 314, in fmin
pass_expr_memo_ctrl=pass_expr_memo_ctrl)
File "/usr/local/lib/python3.6/site-packages/hyperopt/base.py", line 786, in __init__
pyll.toposort(self.expr)
File "/usr/local/lib/python3.6/site-packages/hyperopt/pyll/base.py", line 715, in toposort
assert order[-1] == expr
TypeError: 'generator' object is not subscriptable
Do this:
$ pip install networkx==1.11
Also see this Github issue: https://github.com/hyperopt/hyperopt/issues/325
Usage
Random search over a space
Start by defining a distribution space
Create a score over the space - you need some way to score the results (your function of interest)
Then, call fmin to minimize the function over your distribution space
Specify max_evals to tell it how many random points to try
Example
Simple example to optimize a 2D quadratic function: $ x^2 + y^2 $
Resources
Scipy talk on Hyperopt: https://youtube.com/watch?v=Mp1xnPfE4PY
Github notebook on optimizing a Keras network with Hyperopt: https://github.com/Vooban/Hyperopt-Keras-CNN-CIFAR-100