keras_tuner.oracles.HyperbandOracle( objective, max_epochs, factor=3, hyperband_iterations=1, seed=None, hyperparameters=None, allow_new_entries=True, tune_new_entries=True, )
Oracle class for Hyperband.
Note that to use this Oracle with your own subclassed Tuner, your Tuner
class must be able to handle in
Tuner.run_trial three special hyperparameters
that will be set by this Tuner:
These hyperparameters will be set during the "successive halving" portion of the Hyperband algorithm.
def run_trial(self, trial, *args, **kwargs): hp = trial.hyperparameters if "tuner/trial_id" in hp: past_trial = self.oracle.get_trial(hp['tuner/trial_id']) model = self.load_model(past_trial) else: model = self.hypermodel.build(hp) initial_epoch = hp['tuner/initial_epoch'] last_epoch = hp['tuner/epochs'] for epoch in range(initial_epoch, last_epoch): self.on_epoch_begin(...) for step in range(...): # Run model training step here. self.on_epoch_end(...)
keras_tuner.Objectiveinstance. If a string, the direction of the optimization (min or max) will be inferred.
max_epochs * (math.log(max_epochs, factor) ** 2)cumulative epochs across all trials. It is recommended to set this to as high a value as is within your resource budget. Defaults to 1.
hyperparametersshould be added to the search space, or not. If not, then the default value for these parameters will be used. Defaults to True.
hyperparameters. Defaults to True.