scikit-optimize中的ask函数可以并行化吗?

发布于 2025-01-10 14:14:12 字数 853 浏览 2 评论 0原文

我正在使用 skopt (scikit-optimize) 包,使用 Ask-tell 语法。我在 Windows 机器上使用 python 3.7 询问函数调用需要很长时间(第一次调用约 1 分钟,然后每次迭代增加 1 分钟,所以最终多达 20 分钟)。有没有办法并行化这个调用(不是我已经并行化的成本函数评估,而是询问函数)?我有一台 40 核机器,还有一个很好的 GPU,可以使用其中任何一个。

谢谢 马克

回复 杰罗姆: 谢谢您的浏览,抱歉没说清楚。我意识到 CPU 代码不能在 GPU 上运行,但如果有一种方法可以做到这一点,那将是一个选择。我正在做一个非常简单的优化(目前使用 GP,但也想使用 RF 和 GBRF)。我正在使用“ask-tell”语法。基本代码是:

    from skopt import Optimizer
    opt = Optimizer(20,n_jobs = 5, base_estimator='GP')
    # the ask step below is what I'd like to parallelize, 
    # if possible, I tried setting n_jobs above, didn't help
    suggested = opt.ask(n_points = 20)
    # calculate fitness - this part is parallelized, works nicely
    fitnesses = calc_fitness(suggested)
    # the tell step is fast, no need to parallelize
    res = opt.tell( suggested, fitnesses)

任何建议将不胜感激。 谢谢

I'm using the skopt (scikit-optimize) package, using the ask-tell syntax. I'm using python 3.7, on a windows machine The ask function call takes a long time (first call ~1 minute, then increases 1 minute for each iteration, so ultimately as much as 20 minutes). Is there a way to parallelize this call (not the cost function evaluation, which I've already parallelized, but the ask function)? I have a 40 core machine, and also a good GPU, could use either.

thanks
Mark

Reply to Jerome:
Thanks for taking a look, sorry it wasn't clear. I realize that CPU code cannot be run on a GPU, but if there is a method to do either, that would be an option. I'm doing a pretty straightforward optimization (currently using GP, but would also like to use RF and GBRF). I'm using the ask-tell syntax. Basic code is:

    from skopt import Optimizer
    opt = Optimizer(20,n_jobs = 5, base_estimator='GP')
    # the ask step below is what I'd like to parallelize, 
    # if possible, I tried setting n_jobs above, didn't help
    suggested = opt.ask(n_points = 20)
    # calculate fitness - this part is parallelized, works nicely
    fitnesses = calc_fitness(suggested)
    # the tell step is fast, no need to parallelize
    res = opt.tell( suggested, fitnesses)

Any suggestions would be appreciated.
thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文