Yes, you can resume an optuna study by using the load_if_exists=True
.
For example, if you have a study named 'example-study'
and an SQLite file example.db
you can:
study = optuna.create_study(study_name='example-study', storage='sqlite:///example.db', load_if_exists=True)
study.optimize(objective, n_trials=3)
You can rerun all the FAIL
trials by:
for trial in study.trials:
if trial.state == optuna.trial.TrialState.FAIL:
study.enqueue_trial(trial.params)
study.optimize(objective)
And also, re-evaluate the last trial:
study.enqueue_trial(study.trials[-1].params)
study.optimize(objective, n_trials=1)
will run the objective function with the incomplete trial parameters.