remove_checkpoints: Remove checkpoints

View source: R/help_functions.R

remove_checkpointsR Documentation

Remove checkpoints

Description

Remove all but n 'best' checkpoints, based on some condition. Condition can be accuracy, loss or epoch number.

Usage

remove_checkpoints(
  cp_dir,
  metric = "acc",
  best_n = 1,
  ask_before_remove = TRUE
)

Arguments

cp_dir

Directory containing checkpoints.

metric

Either "acc", "loss" or "last_ep". Condition which checkpoints to keep.

best_n

Number of checkpoints to keep.

ask_before_remove

Whether to show files to keep before deleting rest.

Value

None. Deletes certain files.

Examples


model <- create_model_lstm_cnn(layer_lstm = 8)
checkpoint_folder <- tempfile()
dir.create(checkpoint_folder)
keras::save_model_hdf5(model, file.path(checkpoint_folder, 'Ep.007-val_loss11.07-val_acc0.6.hdf5'))
keras::save_model_hdf5(model, file.path(checkpoint_folder, 'Ep.019-val_loss8.74-val_acc0.7.hdf5'))
keras::save_model_hdf5(model, file.path(checkpoint_folder, 'Ep.025-val_loss0.03-val_acc0.8.hdf5'))
remove_checkpoints(cp_dir = checkpoint_folder, metric = "acc", best_n = 2,
                   ask_before_remove = FALSE)
list.files(checkpoint_folder)
 


GenomeNet/deepG documentation built on Dec. 24, 2024, 12:11 p.m.