keras-tuner icon indicating copy to clipboard operation
keras-tuner copied to clipboard

Why only "epoch_0" is saved in checkpoints ?

Open q-55555 opened this issue 4 years ago • 6 comments

I have noticed that only "epoch_0" is saved in checkpoints. Is this something normal ? Or is there something to do in order to save the best epoch (and not only epoch_0) ?

My point is that I would like to save the best epoch during training but calling "trial.best_step" after having run the trial always returns 'None'.

Thank you !

q-55555 avatar Apr 24 '20 07:04 q-55555

I was just investigating this. It appears that the model saved in epoch_0 is actually the best model and that best_step is simply not being recorded properly. To be clear I believe tuner.get_best_models(1)[0] returns the best, fully trained model from the sweep.

johnhringiv avatar May 12 '20 14:05 johnhringiv

I'm fairly sure this is a bug. Checkpoints should be saved after every epoch, for some reason the tuner's on_epoch_end is being called with epoch = 0 always but other callbacks get the correct epoch number so it seems like the issue is somewhere in the tuner code, I just couldn't figure out where

ysgit avatar Jun 11 '20 21:06 ysgit

Actually I see now that this is intentional, the BayesianOptimization tuner overrides the base tuner's checkpoint behavior and keeps only the best checkpoint

ysgit avatar Jun 12 '20 04:06 ysgit

Wondering if there is a way to override this to checkpoint on every epoch? That to me seems like the expected behavior.

elliotvilhelm avatar Sep 23 '20 22:09 elliotvilhelm

Currently, you cannot override to checkpoint every epoch. However, you can use TensorBoard to visualize the learning curve.

haifeng-jin avatar Feb 17 '21 20:02 haifeng-jin

Actually I see now that this is intentional, the BayesianOptimization tuner overrides the base tuner's checkpoint behavior and keeps only the best checkpoint

Hi @ysgit, I am running into the same issue. Do you happen to have a link to the source saying that the checkpoint is overwritten with the best model?

hp2500 avatar Aug 25 '21 03:08 hp2500