Base R6 class for Keras callbacks
Base R6 class for Keras callbacks
KerasCallbackFormat
An R6Class generator object
Value
KerasCallback.
Details
The logs named list that callback methods take as argument will
contain keys for quantities relevant to the current batch or epoch.
Currently, the fit() method for sequential models will include the following quantities in the logs that
it passes to its callbacks:
on_epoch_end: logs includeaccandloss, and optionally includeval_loss(if validation is enabled infit), andval_acc(if validation and accuracy monitoring are enabled).on_batch_begin: logs includesize, the number of samples in the current batch.on_batch_end: logs includeloss, and optionallyacc(if accuracy monitoring is enabled).
Fields
paramsNamed list with training parameters (eg. verbosity, batch size, number of epochs...).
modelReference to the Keras model being trained.
Methods
on_epoch_begin(epoch, logs)Called at the beginning of each epoch.
on_epoch_end(epoch, logs)Called at the end of each epoch.
on_batch_begin(batch, logs)Called at the beginning of each batch.
on_batch_end(batch, logs)Called at the end of each batch.
on_train_begin(logs)Called at the beginning of training.
on_train_end(logs)Called at the end of training.
Examples
# NOT RUN {
library(keras)
LossHistory <- R6::R6Class("LossHistory",
inherit = KerasCallback,
public = list(
losses = NULL,
on_batch_end = function(batch, logs = list()) {
self$losses <- c(self$losses, logs[["loss"]])
}
)
)
# }