Skip to contents

Saves the training and validation history during training. The history is saved as a data.table where the validation measures are prefixed with "valid." and the training measures are prefixed with "train.".

Resuming

The epochs of a resumed run are appended to the history of the run it continues. A measure that only one of the two runs recorded is NA for the epochs of the other.

Super class

CallbackSet -> CallbackSetHistory

Methods

Inherited methods


CallbackSetHistory$on_begin()

Initializes lists where the train and validation metrics are stored.

Usage

CallbackSetHistory$on_begin()


CallbackSetHistory$state_dict()

Converts the lists to data.tables.

Usage

CallbackSetHistory$state_dict()


CallbackSetHistory$load_state_dict()

Remembers the history contained in the state dict, so that the epochs of the current run are appended to it by $state_dict().

Usage

CallbackSetHistory$load_state_dict(state_dict)

Arguments

state_dict

(callback_state_history)
The state dict as retrieved via $state_dict().


CallbackSetHistory$on_before_valid()

Add the latest training scores to the history.

Usage

CallbackSetHistory$on_before_valid()


CallbackSetHistory$on_epoch_end()

Add the latest validation scores to the history.

Usage

CallbackSetHistory$on_epoch_end()


CallbackSetHistory$clone()

The objects of this class are cloneable with this method.

Usage

CallbackSetHistory$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

Examples


cb = t_clbk("history")
task = tsk("iris")

learner = lrn("classif.mlp", epochs = 3, batch_size = 1,
  callbacks = t_clbk("history"), validate = 0.3)
learner$param_set$set_values(
  measures_train = msrs(c("classif.acc", "classif.ce")),
  measures_valid = msr("classif.ce")
)
learner$train(task)

print(learner$model$callbacks$history)
#> Key: <epoch>
#>    epoch train.classif.acc train.classif.ce valid.classif.ce
#>    <num>             <num>            <num>            <num>
#> 1:     1         0.3714286        0.6285714        0.7111111
#> 2:     2         0.5333333        0.4666667        0.3555556
#> 3:     3         0.5714286        0.4285714        0.3555556