Skip to content

Commit

Permalink
Remove _optimization_loop StopIteration catching
Browse files Browse the repository at this point in the history
- This is a remnant from `UninformedOptimizationProtocol`, whose
  :meth:`_get_current_hyperparameters` would try to return
  `next(self.space)`, which would, in turn, raise `StopIteration`
  once `space` had been exhausted
- This is no longer necessary since `UninformedOptimizationProtocol`
  was never finished and removed long ago
- If reimplementing a standard grid search protocol (which sounds
  like a pretty good idea), refer to the content removed in this
  commit, as well as commits 9b7ca73 and e2c3b73 from October 25, 2018
  for some "pro" tips
  • Loading branch information
HunterMcGushion committed Jul 9, 2019
1 parent e9a9f08 commit 8e407b0
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions hyperparameter_hunter/optimization/protocol_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -372,20 +372,16 @@ def _optimization_loop(self, iteration=0):
break
self.skipped_iterations += 1
continue
except StopIteration:
if len(self.similar_experiments) + len(self.tested_keys) >= self.search_space_size:
G.log_(f"Hyperparameter search space has been exhausted")
break
# G.debug_(f'Re-initializing hyperparameter grid after testing {len(self.tested_keys)} keys')
self._set_hyperparameter_space()
continue
# NOTE: If reimplementing grid search, like `UninformedOptimizationProtocol`, add
# `except StopIteration` and see this commit, and 9b7ca73 / e2c3b73 (October 25, 2018)

self.logger.print_result(
self.current_hyperparameters_list,
self.current_score,
experiment_id=self.current_experiment.experiment_id,
)

#################### Update Best Experiment ####################
if (
(self.best_experiment is None) # First evaluation
or (self.do_maximize and (self.best_score < self.current_score)) # New best max
Expand Down

0 comments on commit 8e407b0

Please sign in to comment.