【问题标题】:optuna cmaes with initital value x0?optuna cmaes 初始值为 x0?
【发布时间】:2021-04-23 01:52:26
【问题描述】:

我的代码:

import optuna


def objective(trial):
    x = trial.suggest_float('x', -100.0, 100.0)
    y = trial.suggest_float('y', -100.0, 100.0)
    return x**2 + y**2

study = optuna.create_study(sampler=optuna.samplers.CmaEsSampler(x0={'x':0,'y':0}))
study.optimize(objective, n_trials=100,show_progress_bar=True)

然后输出

[I 2021-04-23 01:45:02,653] Trial 0 finished with value: 6714.428295151254 and parameters: {'x': 63.88749911037144, 'y': 51.310971074162524}. Best is trial 0 with value: 6714.428295151254.
[I 2021-04-23 01:45:02,663] Trial 1 finished with value: 1135.0978476605947 and parameters: {'x': 29.936795325284184, 'y': 15.45594168314043}. Best is trial 1 with value: 1135.0978476605947.
[I 2021-04-23 01:45:02,681] Trial 2 finished with value: 3149.451283583515 and parameters: {'x': 25.743779033527815, 'y': -49.866914128071016}. Best is trial 1 with value: 1135.0978476605947.

为什么算法不按照我给的x0做初值

【问题讨论】:

    标签: optuna


    【解决方案1】:

    x0 不是参数建议,它是由 cmaes sampler 后面的库使用的。

    x0:
                A dictionary of an initial parameter values for CMA-ES. By default, the mean of ``low``
                and ``high`` for each distribution is used. Note that ``x0`` is sampled uniformly
                within the search space domain for each restart if you specify ``restart_strategy``
                argument.
    

    https://optuna.readthedocs.io/en/stable/_modules/optuna/samplers/_cmaes.html#CmaEsSampler

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-04-06
      • 2014-11-04
      • 2021-04-07
      • 1970-01-01
      • 2021-01-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多