I have the following files:
├── callbacks
│ ├── default.yaml
│ ├── early_stopping.yaml
│ └── finetuning.yaml
├── model
│ ├── model_1.yaml
│ └── model_2.yaml
└── train.yaml
train.yaml
defaults:
- _self_
- model: model_1
- callbacks: default
callbacks/default.yaml
defaults:
- finetuning
- early_stopping
- _self_
callbacks/finetuning.yaml
finetuning:
_target_: callbacks.custom_finetuning.CustomFinetuning
unfreeze_at_epoch: null
refreeze_at_epoch: null
model_1.yaml
_target_: models.Model_1
I want override unfreeze_at_epoch
and refreeze_at_epoch
from model_1.yaml and model_2.yaml so that each model can have different values.
I tried adding the following but it does not work:
callbacks:
finetuning:
unfreeze_at_epoch: 125
refreeze_at_epoch: 350
How can I do that?
The config group for model/model_1.yaml
is model, meaning that by default all the config values defined there are under the model node.
You can change that using the package directive.
In this case, by setting package header to _global_
.
e.g, model_1.yaml can become:
# @package _global_
model:
_target_: models.Model_1
callbacks:
finetuning:
unfreeze_at_epoch: 125
refreeze_at_epoch: 350
A few other things to note is that you config composition order, controlled by the _self_
keyword in the defaults list is correct.
You can learn more about it here.
Finally, you may want to use the pattern of configuring experiments.