Python:可以支持多处理的hyperopt的替代方案?

时间:2018-03-19 22:55:29

标签: python mongodb deep-learning hyperparameters

HyperOpt以外是否还有其他可以支持超参数搜索的多处理?我知道可以将HyperOpt配置为使用MongoDB,但似乎很容易弄错并在杂草中度过一个星期,是否有更流行和有效的内容?

2 个答案:

答案 0 :(得分:1)

查看Ray Tune!

您可以将它用于随机搜索,网格搜索和进化方法的多处理和多机器执行。它还具有流行算法的实现,如HyperBand。

以下是文档页面 - ray.readthedocs.io/en/latest/tune.html

作为一次运行4个并行实验的示例:

import ray
import ray.tune as tune


def my_func(config, reporter):  # add the reporter parameter
    import time, numpy as np
    i = 0
    while True:
        reporter(timesteps_total=i, 
                 mean_accuracy=i ** config["alpha"])
        i += 1
        time.sleep(.01)


tune.register_trainable("my_func", my_func)
ray.init(num_cpus=4)
tune.run_experiments({
    "my_experiment": { 
        "run": "my_func", 
        "stop": { "mean_accuracy": 100 }, 
        "config": { 
            "alpha": tune.grid_search([0.2, 0.4, 0.6]), 
            "beta": tune.grid_search([1, 2]) } } })

免责声明:我参与此项目 - 如果您有任何反馈,请与我联系!

答案 1 :(得分:1)

某些模型(例如,RandomForest)具有“ njobs”参数,以使用核数。您可以尝试njobs = -1;因此,即使hyperopt使用1个内核,每个试验都将使用所有内核,从而加快了处理速度。