This wraps a torch::torch_optimizer_generatora and annotates it with metadata, most importantly a ParamSet. The optimizer is created for the given parameter values by calling the $generate() method.
This class is usually used to configure the optimizer of a torch learner, e.g. when construcing a learner or in a ModelDescriptor.
For a list of available optimizers, see mlr3torch_optimizers. Items from this dictionary can be retrieved using t_opt().
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 losstorch_opt = TorchOptimizer$new(optim_ignite_adam, label ="adam")torch_opt
# If the param set is not specified, parameters are inferred but are of class ParamUtytorch_opt$param_set
# open the help page of the wrapped optimizer# torch_opt$help()# Retrieve an optimizer from the dictionarytorch_opt = t_opt("sgd", lr =0.1)torch_opt
torch_opt$param_set
torch_opt$label
torch_opt$id
# Create the optimizer for a networknet = nn_linear(10,1)opt = torch_opt$generate(net$parameters)# is the same asoptim_sgd(net$parameters, lr =0.1)# Use in a learnerlearner = lrn("regr.mlp", optimizer = t_opt("sgd"))# The parameters of the optimizer are added to the learner's parameter setlearner$param_set