KerasCallback: Base R6 class for Keras callbacks

Description Format Details Value Fields Methods Examples

Description

Base R6 class for Keras callbacks

Format

An R6Class generator object

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.keras.engine.training.Model() method for sequential models will include the following quantities in the logs that it passes to its callbacks:

Value

KerasCallback.

Fields

params

Named list with training parameters (eg. verbosity, batch size, number of epochs...).

model

Reference 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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
## 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"]])
    }
  )
)

## End(Not run)

dfalbel/keras documentation built on Nov. 27, 2019, 8:16 p.m.