Keras: Remove Old Files in ModelCheckpoint

Created on 15 Feb 2017  路  6Comments  路  Source: keras-team/keras

Please make sure that the boxes below are checked before you submit your issue. If your issue is an implementation question, please ask your question on StackOverflow or join the Keras Slack channel and ask there instead of filing a GitHub issue.

Thank you!

  • [x] Check that you are up-to-date with the master branch of Keras. You can update with:
    pip install git+git://github.com/fchollet/keras.git --upgrade --no-deps

  • [x] If running on TensorFlow, check that you are up-to-date with the latest version. The installation instructions can be found here.

  • [x] If running on Theano, check that you are up-to-date with the master branch of Theano. You can update with:
    pip install git+git://github.com/Theano/Theano.git --upgrade --no-deps

My problem with the current ModelCheckpoint callback is that when I pass in the validation accuracy as a parameter in the filename I get flooded with model checkpoints. To combat this I would propose a flag in the ModelCheckpoint called keep_only_last_file that checks if the old save should be deleted. In combination with the save_best_only flag only the best model is kept.

I would propose following API: keras.callbacks.ModelCheckpoint(filepath, monitor='val_loss', verbose=0, save_best_only=False, save_weights_only=False, keep_only_last_file=False, mode='auto', period=1). I am targeting everyone who wants to use the formatting options in the ModelCheckpoint without saving multiple models.

I can implement this myself.

stale

Most helpful comment

True, but the formatting options are pretty nice to have.

All 6 comments

Agreed. Would be very convenient to not store multiple checkpoints

This issue has been automatically marked as stale because it has not had recent activity. It will be closed after 30 days if no further activity occurs, but feel free to re-open a closed issue if needed.

This can be achieved with using a file name with no formatting for epoch or loss. It's a suboptimal solution for the time being, but does work.

True, but the formatting options are pretty nice to have.

And people may want to save more than only one checkpoints. I suppose we can have a feature just like keep_checkpoint_max in tf estimator:

tf.estimator.RunConfig(model_dir=model_dir,
                       keep_checkpoint_max=3)

This really seems like an issue for a lot of people e.g.

and of course this one.

I wonder, why is there no simple argument such as keep_checkpoint_max for the ModelCheckpoint?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kylemcdonald picture kylemcdonald  路  3Comments

zygmuntz picture zygmuntz  路  3Comments

anjishnu picture anjishnu  路  3Comments

rantsandruse picture rantsandruse  路  3Comments

snakeztc picture snakeztc  路  3Comments