This wraps a CallbackSet and annotates it with metadata, most importantly a ParamSet. The callback is created for the given parameter values by calling the $generate() method.
This class is usually used to configure the callback of a torch learner, e.g. when constructing a learner of in a ModelDescriptor.
For a list of available callbacks, see mlr3torch_callbacks. To conveniently retrieve a TorchCallback, use t_clbk().
Parameters
Defined by the constructor argument param_set. If no parameter set is provided during construction, the parameter set is constructed by creating a parameter for each argument of the wrapped loss function, where the parametes are then of type ParamUty.
Examples
# Create a new torch callback from an existing callback settorch_callback = TorchCallback$new(CallbackSetCheckpoint)# The parameters are inferredtorch_callback$param_set
# Retrieve a torch callback from the dictionarytorch_callback = t_clbk("checkpoint", path = tempfile(), freq =1)torch_callback
torch_callback$label
torch_callback$id
# open the help page of the wrapped callback set# torch_callback$help()# Create the callback setcallback = torch_callback$generate()callback
# is the same asCallbackSetCheckpoint$new( path = tempfile(), freq =1)# Use in a learnerlearner = lrn("regr.mlp", callbacks = t_clbk("checkpoint"))# the parameters of the callback are added to the learner's parameter setlearner$param_set