optuna.study.load_study
- optuna.study.load_study(*, study_name, storage, sampler=None, pruner=None)[源码]
加载具有指定名称的现有
Study。示例
import optuna def objective(trial): x = trial.suggest_float("x", 0, 10) return x**2 study = optuna.create_study(storage="sqlite:///example.db", study_name="my_study") study.optimize(objective, n_trials=3) loaded_study = optuna.load_study(study_name="my_study", storage="sqlite:///example.db") assert len(loaded_study.trials) == len(study.trials)
- 参数:
study_name (str | None) – Study 的名称。每个 Study 都有一个唯一的名称作为标识符。如果为
None,则检查存储中是否只有一个 Study,如果是,则加载该 Study。study_name在存储中有多个 Study 时是必需的。storage (str | storages.BaseStorage) – 数据库 URL,例如
sqlite:///example.db。有关更多详细信息,请参阅create_study()的文档。sampler ('samplers.BaseSampler' | None) – 实现值建议后台算法的采样器对象。如果指定了
None,则默认使用TPESampler。另请参阅samplers。pruner (pruners.BasePruner | None) – 决定不希望的试验提前停止的剪枝器对象。如果指定
None,则默认使用MedianPruner。另请参阅pruners。
- 返回:
一个
Study对象。- 返回类型:
另请参阅