Skip to content

Commit

Permalink
Added additional kwarg for successful running of optuna hyperparamete…
Browse files Browse the repository at this point in the history
…r search (huggingface#31924)

Update integration_utils.py

Added additional kwarg
  • Loading branch information
DeF0017 authored and MHRDYN7 committed Jul 23, 2024
1 parent fe44226 commit 84af8ac
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/transformers/integrations/integration_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,10 +252,11 @@ def _objective(trial, checkpoint_dir=None):

timeout = kwargs.pop("timeout", None)
n_jobs = kwargs.pop("n_jobs", 1)
gc_after_trial = kwargs.pop("gc_after_trial", False)
directions = direction if isinstance(direction, list) else None
direction = None if directions is not None else direction
study = optuna.create_study(direction=direction, directions=directions, **kwargs)
study.optimize(_objective, n_trials=n_trials, timeout=timeout, n_jobs=n_jobs)
study.optimize(_objective, n_trials=n_trials, timeout=timeout, n_jobs=n_jobs, gc_after_trial=gc_after_trial)
if not study._is_multi_objective():
best_trial = study.best_trial
return BestRun(str(best_trial.number), best_trial.value, best_trial.params)
Expand Down

0 comments on commit 84af8ac

Please sign in to comment.