optuna.study.load_study¶
-
optuna.study.
load_study
(study_name, storage, sampler=None, pruner=None)[source]¶ Load the existing
Study
that has the specified name.Example
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)
- Parameters
study_name (Optional[str]) – Study’s name. Each study has a unique name as an identifier. If
None
, checks whether the storage contains a single study, and if so loads that study.storage (Union[str, optuna.storages._base.BaseStorage]) – Database URL such as
sqlite:///example.db
. Please see also the documentation ofcreate_study()
for further details.sampler (Optional[optuna.samplers._base.BaseSampler]) – A sampler object that implements background algorithm for value suggestion. If
None
is specified,TPESampler
is used as the default. See alsosamplers
.pruner (Optional[optuna.pruners._base.BasePruner]) – A pruner object that decides early stopping of unpromising trials. If
None
is specified,MedianPruner
is used as the default. See alsopruners
.
- Raises
ValueError – If
study_name
isNone
and the storage contains more than 1 study.- Return type
optuna.study.study.Study
See also
optuna.load_study()
is an alias ofoptuna.study.load_study()
.