Configure Optimizer (STL)
Optimizer is the component that manages the learning process by updating model parameters based on the computed gradients.
Optimizers are a sub-config under the experiment index config (CL Main). To configure a custom optimizer, create a YAML file in the optimizer/
folder. As continual learning involves multiple tasks, each task can be assigned an optimizer for training. We support a uniform optimizer across all tasks and distinct optimizers for each task. Below are examples of both configurations.
Example
configs
βββ __init__.py
βββ entrance.yaml
βββ experiment
β βββ example_clmain_train.yaml
β βββ ...
βββ optimizer
β βββ sgd_10_tasks.yaml
β βββ sgd.yaml
...
Uniform Optimizer for All Tasks
configs/experiment/example_clmain_train.yaml
defaults:
...
- /optimizer: sgd.yaml
...
configs/optimizer/sgd.yaml
_target_: torch.optim.SGD
_partial_: true # partially instantiate optimizer without 'params' argument. Make sure this is included in any case!
lr: 0.01
weight_decay: 0.0
Distinct Optimizer For Each Task
Distinct optimizers are specified as a list. The length of the list must match the train_tasks
field in the experiment index config (CL Main). Below is an example of distinct optimizers for 10 tasks.
defaults:
...
- /optimizer: sgd_10_tasks.yaml
...
configs/optimizer/sgd_10_tasks.yaml
- _target_: torch.optim.SGD
_partial_: true # partially instantiate optimizer without 'params' argument. Make sure this is included in any case!
lr: 0.01
weight_decay: 0.0
- _target_: torch.optim.SGD
_partial_: true # partially instantiate optimizer without 'params' argument. Make sure this is included in any case!
lr: 0.01
weight_decay: 0.0
- _target_: torch.optim.SGD
_partial_: true # partially instantiate optimizer without 'params' argument. Make sure this is included in any case!
lr: 0.01
weight_decay: 0.0
- _target_: torch.optim.SGD
_partial_: true # partially instantiate optimizer without 'params' argument. Make sure this is included in any case!
lr: 0.01
weight_decay: 0.0
- _target_: torch.optim.SGD
_partial_: true # partially instantiate optimizer without 'params' argument. Make sure this is included in any case!
lr: 0.01
weight_decay: 0.0
- _target_: torch.optim.SGD
_partial_: true # partially instantiate optimizer without 'params' argument. Make sure this is included in any case!
lr: 0.01
weight_decay: 0.0
- _target_: torch.optim.SGD
_partial_: true # partially instantiate optimizer without 'params' argument. Make sure this is included in any case!
lr: 0.01
weight_decay: 0.0
- _target_: torch.optim.SGD
_partial_: true # partially instantiate optimizer without 'params' argument. Make sure this is included in any case!
lr: 0.01
weight_decay: 0.0
- _target_: torch.optim.SGD
_partial_: true # partially instantiate optimizer without 'params' argument. Make sure this is included in any case!
lr: 0.01
weight_decay: 0.0
- _target_: torch.optim.SGD
_partial_: true # partially instantiate optimizer without 'params' argument. Make sure this is included in any case!
lr: 0.01
weight_decay: 0.0
Supported Optimizers & Required Config Fields
In CLArena, we do not implement custom optimizers. We use the built-in optimizers from PyTorch in the torch.optim
module.
Optimization-based approaches in continual learning methodology focus on designing mechanisms from the perspective of manipulating optimization step. Typically, these approaches involve using different optimizers for various tasks. However, the evolution of optimization can be directly integrated into the CL algorithm so we donβt particularly design our own CL optimizers.
To choose an optimizer, assign the _target_
field to the class name of the optimizer. For example, to use SGD, set the _target_
field to torch.optim.SGD
. Include _partial_: true
as well (see below). Each optimizer has its own hyperparameters and configurations, which means it has its own required fields. The required fields are the same as the arguments of the class specified by _target_
. The arguments for each optimizer class can be found in the PyTorch documentation.
Make sure to include the field _partial_: true
to enable partial instantiation. PyTorch optimizers need the model parameters as an argument to be fully instantiated, but during configuration we do not have that argument yet, so the optimizer can only be partially instantiated.
Optimizer is the component that manages the learning process by updating model parameters based on the computed gradients.
Optimizer is a sub-config under the experiment index config (MTL). To configure a custom optimizer, you need to create a YAML file in optimizer/
folder. Below shows an example of the optimizer config.
Example
configs
βββ __init__.py
βββ entrance.yaml
βββ experiment
β βββ example_mtl_train.yaml
β βββ ...
βββ optimizer
β βββ sgd.yaml
...
configs/experiment/example_mtl_train.yaml
defaults:
...
- /optimizer: sgd.yaml
...
configs/optimizer/sgd.yaml
_target_: torch.optim.SGD
_partial_: true # partially instantiate optimizer without 'params' argument. Make sure this is included in any case!
lr: 0.01
weight_decay: 0.0
Supported Optimizers & Required Config Fields
In CLArena, we didnβt implement our own optimizers, but rather use the built-in optimizers from PyTorch in torch.optim
module.
To choose an optimizer, assign the _target_
field to the class name of the optimizer. For example, to use SGD, set _target_
field to torch.optim.SGD
. Meanwhile, include _partial: true
as well (see below). Each optimizer has its own hyperparameters and configurations, which means it has its own required fields. The required fields are the same as the arguments of the class specified by _target_
. The arguments of each optimizer class can be found in PyTorch documentation.
Make sure to include field _partial_: true
to enable partial instantiation. PyTorch optimizer need the model parameters as an argument to be fully instantiated, but we are now in the phase of configuration and certainly donβt have that argument, so the optimizer can be only partially instantiated.
Optimizer is the component that manages the learning process by updating model parameters based on the computed gradients.
Optimizer is a sub-config under the experiment index config (STL). To configure a custom optimizer, you need to create a YAML file in optimizer/
folder. Below shows an example of the optimizer config.
Example
configs
βββ __init__.py
βββ entrance.yaml
βββ experiment
β βββ example_stl_train.yaml
β βββ ...
βββ optimizer
β βββ sgd.yaml
...
configs/experiment/example_stl_train.yaml
defaults:
...
- /optimizer: sgd.yaml
...
configs/optimizer/sgd.yaml
_target_: torch.optim.SGD
_partial_: true # partially instantiate optimizer without 'params' argument. Make sure this is included in any case!
lr: 0.01
weight_decay: 0.0
Supported Optimizers & Required Config Fields
In CLArena, we didnβt implement our own optimizers, but rather use the built-in optimizers from PyTorch in torch.optim
module.
To choose an optimizer, assign the _target_
field to the class name of the optimizer. For example, to use SGD, set _target_
field to torch.optim.SGD
. Meanwhile, include _partial: true
as well (see below). Each optimizer has its own hyperparameters and configurations, which means it has its own required fields. The required fields are the same as the arguments of the class specified by _target_
. The arguments of each optimizer class can be found in PyTorch documentation.
Make sure to include field _partial_: true
to enable partial instantiation. PyTorch optimizer need the model parameters as an argument to be fully instantiated, but we are now in the phase of configuration and certainly donβt have that argument, so the optimizer can be only partially instantiated.