Get the training history of Bayesian optimized keras model?

I used BayesianOptimization to optimize hyper-parameters of a Keras model. I got best_model as a result. Is it possible to get the training history of best_model (training loss and validation loss during epochs)? I tried to get best_model.history but the result is empty. Thank you for your help

tuner_bo = BayesianOptimization(
hypermodel,
objective=‘mse’,
max_trials=10,
seed=42,
executions_per_trial=2,
overwrite=True
)
tuner_bo.search(x_train_scaled, y_train, epochs=nb_epochs, validation_split=0.2, verbose=0)
best_model = tuner_bo.get_best_models(num_models=1)[0]
pred = best_model.predict(x_test_scaled, batch_size = 32)

Hi @cours_systeme,

As per my understanding, to access the training history of the best model obtained from Bayesian optimization in Keras, you need to train the best model separately and then access the training loss and validation loss. This is because the history attribute is only available for models that were trained using the fit() function in Keras, and not for models obtained through Bayesian optimization.

Hope this helps you.

Thanks.