在2017年的聖誕節前,我翻譯了有關HyperOpt的中文文檔,這也時填補了空白,以此作為獻給所有中國程序員,以及所有其他機器學習相關行業人員的聖誕禮物。聖誕快樂,各位。
HyperOpt中文文檔導讀
翻譯的文檔已經發布於github,請在我的項目Hyperopt_CN中的wiki查看相應文檔.CSDN,知乎同步更新中.
HyperOpt中文版wiki文檔內容包括以下內容:
- HyperOpt中文文檔導讀,即真正的中文文檔主頁
- Home:主頁
- Cite:引用
- FMin:使用FMin方法
- Installation Notes:安裝說明
- Interfacing With Other Languages:在其他語言中使用Hyperopt
- Parallelizing Evaluations During Search via MongoDB:使用MongoDB進行並行搜索
- Recipes:原文中暫時只有一個給定值區間如何采樣的鏈接
- RelatedWork:相關工作
- Scipy2013
下面是hyperopt的官網首頁,作為對其的簡單介紹
Hyperopt
在Python中進行分布式異步超參數優化
Font Tian translated this article on 22 December 2017
hyperopt 是一個Python庫,可以用來尋找實數,離散值,條件維度等搜索空間的最佳值。
# define an objective function
def objective(args):
case, val = args
if case == 'case 1':
return val
else:
return val ** 2
# define a search space
from hyperopt import hp
space = hp.choice('a',
[
('case 1', 1 + hp.lognormal('c1', 0, 1)),
('case 2', hp.uniform('c2', -10, 10))
])
# minimize the objective over the space
from hyperopt import fmin, tpe
best = fmin(objective, space, algo=tpe.suggest, max_evals=100)
print best
# -> {'a': 1, 'c2': 0.01420615366247227}
print hyperopt.space_eval(space, best)
# -> {'case 2', 0.01420615366247227}
算法
目前兩種算法的實現:
- 隨機搜索
- Tree of Parzen Estimators (TPE)
Hyperopt 設計伊始,是包括基於高斯過程與回歸樹的貝葉斯優化算法的,但是現在這些都還沒有被實現.
同時,Hyperopt所有的算法都可以通過MongoDB進行串行或者並行計算.
安裝
用戶安裝
pip install hyperopt
開發版安裝
git clone https://github.com/hyperopt/hyperopt.git
(cd hyperopt && python setup.py develop)
(cd hyperopt && nosetests)
更多信息,請參見安裝說明。
文檔
文檔現在托管在wiki上,但這里有一些相關頁面的鏈接:
實例
在wiki中打開Hyperot