(Optional) Model Configuration File Adaptation
File Function
The model configuration file provides the functions of configuring custom hyperparameters and freezing the network.
If you do not configure this file, model hyperparameters are set to the default values defined in the model startup script. In addition, you can freeze the network as required.
To customize model hyperparameters or freeze some network parameters during training, configure this file and pass model_config_path when calling the mxTuningKit APIs (finetune, evaluate, and infer). model_config_path indicates the local absolute path of the model configuration file.
Configuration Rule
The model configuration file must be in YAML format and consists of params and freeze. The configuration rules are as follows:
- paramsConfigure model hyperparameters in the params module based on YAML indentation. Only one-layer key-value pairs are supported. The mxTuningKit passes these configuration parameters to the hyperparameters with the same name predefined in the model startup script.
The configured key values cannot be the same as the parameter names or abbreviations predefined by the mxTuningKit, including dp, data_path, op, output_path, bp, boot_file_path, mc, model_config_path, pm, pretrained_model_path, cp, ckpt_path, q, quiet, t, timeout, and advanced_config. The key value does not support Python data structures such as lists, tuples, dictionaries, and sets.
- freeze
- Configure the name of the network layer to be frozen under freeze based on the YAML indentation. When the mxTuningKit detects that parameters are configured under freeze, it automatically generates the hyperparameter --advanced_config and passes it to the model startup script. --advanced_config indicates the local absolute path of the model configuration file.
- To implement network freezing, the model code needs to adapt to the network freezing code. For details, see Sample Code for Network Freezing.
The following is an example of the model configuration file. For details about the configuration example of the model startup script, see Model Adaptation Examples.
params:
sample_key: sample_value
freeze:
net1:
block1:
layer1
layer2
...
block2:
...
net2:
block1:
layer1
...