Preprocess the x and y before calling the base run_trial.
fit_kwargs.update(dict(zip(tf.keras.Model.fit.__code__.co_varnames,
fit_args)))
fit_args = []
x, y, val_x, val_y = self.hypermodel.preprocess(hp, *fit_args, **fit_kwargs)
fit_kwargs["x"] = x
fit_kwargs["y"] = y
fit_kwargs["validation_data"] = (val_x, val_y)
After Change
def run_trial(self, trial, hp, fit_args, fit_kwargs):
Preprocess the x and y before calling the base run_trial.
new_fit_kwargs = copy.copy(fit_kwargs)
new_fit_kwargs.update(
dict(zip(inspect.getfullargspec(tf.keras.Model.fit).args, fit_args)))
x, y, validation_data = self.hypermodel.preprocess(
hp,
new_fit_kwargs.get("x", None),
new_fit_kwargs.get("y", None),
new_fit_kwargs.get("validation_data", None))
new_fit_kwargs["x"], new_fit_kwargs["validation_data"] = \
utils.prepare_model_input(
x=x,
y=y,
validation_data=validation_data,
batch_size=fit_kwargs.get("batch_size", 32))
new_fit_kwargs["batch_size"] = None
new_fit_kwargs["y"] = None
super(AutoTuner, self).run_trial(trial, hp, [], new_fit_kwargs)
def get_best_hp(self, num_models=1):