deepmd.pt.utils.finetune#

Attributes#

Functions#

get_finetune_rule_single(_single_param_target, ...[, ...])

get_finetune_rules(finetune_model, model_config[, ...])

Get fine-tuning rules and (optionally) change the model_params according to the pretrained one.

Module Contents#

deepmd.pt.utils.finetune.log[source]#
deepmd.pt.utils.finetune.get_finetune_rule_single(_single_param_target, _model_param_pretrained, from_multitask=False, model_branch='Default', model_branch_from='', change_model_params=False)[source]#
deepmd.pt.utils.finetune.get_finetune_rules(finetune_model, model_config, model_branch='', change_model_params=True)[source]#

Get fine-tuning rules and (optionally) change the model_params according to the pretrained one.

This function gets the fine-tuning rules and (optionally) changes input in different modes as follows: 1. Single-task fine-tuning from a single-task pretrained model:

  • The model will be fine-tuned based on the pretrained model.

  • (Optional) Updates the model parameters based on the pretrained model.

  1. Single-task fine-tuning from a multi-task pretrained model:
    • The model will be fine-tuned based on the selected branch in the pretrained model. The chosen branch can be defined from the command-line or finetune_head input parameter. If not defined, model parameters in the fitting network will be randomly initialized.

    • (Optional) Updates the model parameters based on the selected branch in the pretrained model.

  2. Multi-task fine-tuning from a single-task pretrained model:
    • The model in each branch will be fine-tuned or resumed based on the single branch (‘Default’) in the pretrained model. The chosen branches can be defined from the finetune_head input parameter of each branch. - If finetune_head is defined as ‘Default’,

      it will be fine-tuned based on the single branch (‘Default’) in the pretrained model.

      • If finetune_head is not defined and the model_key is ‘Default’, it will resume from the single branch (‘Default’) in the pretrained model without fine-tuning.

      • If finetune_head is not defined and the model_key is not ‘Default’, it will be fine-tuned based on the single branch (‘Default’) in the pretrained model, while model parameters in the fitting network of the branch will be randomly initialized.

    • (Optional) Updates model parameters in each branch based on the single branch (‘Default’) in the pretrained model.

  3. Multi-task fine-tuning from a multi-task pretrained model:
    • The model in each branch will be fine-tuned or resumed based on the chosen branches in the pretrained model. The chosen branches can be defined from the finetune_head input parameter of each branch.

      • If finetune_head is defined as one of the branches in the pretrained model, it will be fine-tuned based on the chosen branch in the pretrained model.

      • If finetune_head is not defined and the model_key is the same as one of those in the pretrained model, it will resume from the model_key branch in the pretrained model without fine-tuning.

      • If finetune_head is not defined and a new model_key is used, it will be fine-tuned based on the chosen branch in the pretrained model, while model parameters in the fitting network of the branch will be randomly initialized.

    • (Optional) Updates model parameters in each branch based on the chosen branches in the pretrained model.

Parameters:
finetune_model

The pretrained model.

model_config

The fine-tuning input parameters.

model_branch

The model branch chosen in command-line mode, only for single-task fine-tuning.

change_model_params

Whether to change the model parameters according to the pretrained one.

Returns:
model_config:

Updated model parameters.

finetune_links:

Fine-tuning rules in a dict format, with model_branch: FinetuneRuleItem pairs.