|
a |
|
b/man/remove_checkpoints.Rd |
|
|
1 |
% Generated by roxygen2: do not edit by hand |
|
|
2 |
% Please edit documentation in R/help_functions.R |
|
|
3 |
\name{remove_checkpoints} |
|
|
4 |
\alias{remove_checkpoints} |
|
|
5 |
\title{Remove checkpoints} |
|
|
6 |
\usage{ |
|
|
7 |
remove_checkpoints( |
|
|
8 |
cp_dir, |
|
|
9 |
metric = "acc", |
|
|
10 |
best_n = 1, |
|
|
11 |
ask_before_remove = TRUE |
|
|
12 |
) |
|
|
13 |
} |
|
|
14 |
\arguments{ |
|
|
15 |
\item{cp_dir}{Directory containing checkpoints.} |
|
|
16 |
|
|
|
17 |
\item{metric}{Either \code{"acc"}, \code{"loss"} or \code{"last_ep"}. Condition which checkpoints to keep.} |
|
|
18 |
|
|
|
19 |
\item{best_n}{Number of checkpoints to keep.} |
|
|
20 |
|
|
|
21 |
\item{ask_before_remove}{Whether to show files to keep before deleting rest.} |
|
|
22 |
} |
|
|
23 |
\value{ |
|
|
24 |
None. Deletes certain files. |
|
|
25 |
} |
|
|
26 |
\description{ |
|
|
27 |
Remove all but n 'best' checkpoints, based on some condition. Condition can be |
|
|
28 |
accuracy, loss or epoch number. |
|
|
29 |
} |
|
|
30 |
\examples{ |
|
|
31 |
\dontshow{if (reticulate::py_module_available("tensorflow")) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} |
|
|
32 |
model <- create_model_lstm_cnn(layer_lstm = 8) |
|
|
33 |
checkpoint_folder <- tempfile() |
|
|
34 |
dir.create(checkpoint_folder) |
|
|
35 |
keras::save_model_hdf5(model, file.path(checkpoint_folder, 'Ep.007-val_loss11.07-val_acc0.6.hdf5')) |
|
|
36 |
keras::save_model_hdf5(model, file.path(checkpoint_folder, 'Ep.019-val_loss8.74-val_acc0.7.hdf5')) |
|
|
37 |
keras::save_model_hdf5(model, file.path(checkpoint_folder, 'Ep.025-val_loss0.03-val_acc0.8.hdf5')) |
|
|
38 |
remove_checkpoints(cp_dir = checkpoint_folder, metric = "acc", best_n = 2, |
|
|
39 |
ask_before_remove = FALSE) |
|
|
40 |
list.files(checkpoint_folder) |
|
|
41 |
|
|
|
42 |
\dontshow{\}) # examplesIf} |
|
|
43 |
} |