Skip to content

Commit

Permalink
Add summary information to tune_and_save
Browse files Browse the repository at this point in the history
  • Loading branch information
Acbarakat committed Aug 21, 2023
1 parent 49b7a3e commit 0b9f1e1
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,12 +177,17 @@ def tune_and_save(self,
(defaults is 1)
"""
self.search(train_ds, test_ds, validation_ds)
best_models = self.tuner.get_best_models(num_models=num_models)
for idx, bm in enumerate(best_models):
best_models, best_hparams = (
self.tuner.get_best_models(num_models=num_models),
self.tuner.get_best_hyperparameters(num_trials=num_models)
)
print(self.tuner.results_summary())
for idx, (bm, bhp) in enumerate(zip(best_models, best_hparams)):
# print(bm.summary())
# print(bm.optimizer.get_config())
# test_loss, test_acc = bm.evaluate(test_ds)
# print('Test accuracy:', test_acc)
print(bm.name, bhp.values)
test_loss, test_acc = bm.evaluate(test_ds)
print('test_loss:', test_loss, "test_accuracy:", test_acc)
bm.save(os.path.join(MODEL_DIR,
f"{self.name}_{idx + 1}.h5"))

Expand Down

0 comments on commit 0b9f1e1

Please sign in to comment.