Diff of /man/load_cp.Rd [000000] .. [409433]

Switch to side-by-side view

--- a
+++ b/man/load_cp.Rd
@@ -0,0 +1,68 @@
+% Generated by roxygen2: do not edit by hand
+% Please edit documentation in R/create_model_utils.R
+\name{load_cp}
+\alias{load_cp}
+\title{Load checkpoint}
+\usage{
+load_cp(
+  cp_path,
+  cp_filter = "last_ep",
+  ep_index = NULL,
+  compile = FALSE,
+  learning_rate = 0.01,
+  solver = "adam",
+  re_compile = FALSE,
+  loss = "categorical_crossentropy",
+  add_custom_object = NULL,
+  margin = 1,
+  verbose = TRUE,
+  mirrored_strategy = FALSE
+)
+}
+\arguments{
+\item{cp_path}{A directory containing checkpoints or a single checkpoint file.
+If a directory, choose checkpoint based on \code{cp_filter} or \code{ep_index}.}
+
+\item{cp_filter}{Condition to choose checkpoint if \code{cp_path} is a directory.
+Either "acc" for best validation accuracy, "loss" for best validation loss or "last_ep" for last epoch.}
+
+\item{ep_index}{Load checkpoint from specific epoch number. If not \code{NULL}, has priority over \code{cp_filter}.}
+
+\item{compile}{Whether to load compiled model.}
+
+\item{learning_rate}{Learning rate for optimizer.}
+
+\item{solver}{Optimization method, options are \verb{"adam", "adagrad", "rmsprop"} or \code{"sgd"}.}
+
+\item{re_compile}{Whether to compile model with parameters from \code{learning_rate},
+\code{solver} and \code{loss}.}
+
+\item{loss}{Loss function. Only used if model gets compiled.}
+
+\item{add_custom_object}{Named list of custom objects.}
+
+\item{margin}{Margin for contrastive loss, see \link{loss_cl}.}
+
+\item{verbose}{Whether to print chosen checkpoint path.}
+
+\item{mirrored_strategy}{Whether to use distributed mirrored strategy. If NULL, will use distributed mirrored strategy only if >1 GPU available.}
+}
+\value{
+A keras model loaded from a checkpoint.
+}
+\description{
+Load checkpoint from directory. Chooses best checkpoint based on some condition. Condition
+can be best accuracy, best loss, last epoch number or a specified epoch number.
+}
+\examples{
+\donttest{
+library(keras)
+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'))
+model <- load_cp(cp_path = checkpoint_folder, cp_filter = "last_ep")
+}
+}