Skip to content

Commit

Permalink
Add additional hyperopt callbacks (#1388)
Browse files Browse the repository at this point in the history
  • Loading branch information
hungcs committed Oct 15, 2021
1 parent 8545f51 commit e6abdf9
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
6 changes: 6 additions & 0 deletions ludwig/callbacks.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,15 @@ def on_cmdline(self, cmd, *args):
def on_hyperopt_init(self, experiment_name):
pass

def on_hyperopt_finish(self, experiment_name):
pass

def on_hyperopt_trial_start(self, parameters):
pass

def on_hyperopt_trial_end(self, parameters):
pass

def on_train_init(
self,
base_config,
Expand Down
4 changes: 4 additions & 0 deletions ludwig/hyperopt/execution.py
Original file line number Diff line number Diff line change
Expand Up @@ -1288,6 +1288,10 @@ def run_experiment(
random_seed=random_seed,
debug=debug,
)

for callback in callbacks or []:
callback.on_hyperopt_trial_end(parameters)

return train_stats, eval_stats


Expand Down
4 changes: 4 additions & 0 deletions ludwig/hyperopt/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,10 @@ def hyperopt(
save_hyperopt_stats(hyperopt_stats, output_directory)
logger.info('Hyperopt stats saved to: {}'.format(output_directory))

if callbacks:
for callback in callbacks:
callback.on_hyperopt_finish(experiment_name)

logger.info('Finished hyperopt')

return hyperopt_results
Expand Down

0 comments on commit e6abdf9

Please sign in to comment.