deepmd.utils.finetune#

Attributes#

Classes#

Functions#

get_index_between_two_maps(old_map, new_map)

Returns the mapping index of types in new_map to those in the old_map.

map_atom_exclude_types(atom_exclude_types, remap_index)

Return the remapped atom_exclude_types according to remap_index.

map_pair_exclude_types(pair_exclude_types, remap_index)

Return the remapped atom_exclude_types according to remap_index.

Module Contents#

deepmd.utils.finetune.log[source]#
class deepmd.utils.finetune.FinetuneRuleItem(p_type_map: list[str], type_map: list[str], model_branch: str = 'Default', random_fitting: bool = False, resuming: bool = False)[source]#
p_type_map[source]#
type_map[source]#
model_branch = 'Default'[source]#
random_fitting = False[source]#
resuming = False[source]#
update_type[source]#
get_index_mapping()[source]#

Returns the mapping index of newly defined types to those in the pretrained model.

get_has_new_type()[source]#

Returns whether there are unseen types in the new type_map.

get_model_branch()[source]#

Returns the chosen model branch.

get_random_fitting()[source]#

Returns whether to use random fitting.

get_resuming()[source]#

Returns whether to only do resuming.

get_update_type()[source]#

Returns whether to update the type related params when loading from pretrained model with redundant types.

get_pretrained_tmap()[source]#

Returns the type map in the pretrained model.

get_finetune_tmap()[source]#

Returns the type map in the fine-tuned model.

deepmd.utils.finetune.get_index_between_two_maps(old_map: list[str], new_map: list[str])[source]#

Returns the mapping index of types in new_map to those in the old_map.

Parameters:
old_maplist[str]

The old list of atom type names.

new_maplist[str]

The new list of atom type names.

Returns:
index_map: list[int]

List contains len(new_map) indices, where index_map[i] is the index of new_map[i] in old_map. If new_map[i] is not in the old_map, the index will be i - len(new_map).

has_new_type: bool

Whether there are unseen types in the new type_map. If True, some type related params in the model, such as statistics, need to be extended to have a length of len(old_map) + len(new_map) in the type related dimension. Then positive indices from 0 to len(old_map) - 1 will select old params of types in old_map, while negative indices from -len(new_map) to -1 will select new params of types in new_map.

deepmd.utils.finetune.map_atom_exclude_types(atom_exclude_types: list[int], remap_index: list[int])[source]#

Return the remapped atom_exclude_types according to remap_index.

Parameters:
atom_exclude_typeslist[int]

Exclude the atomic contribution of the given types.

remap_indexlist[int]

The indices in the old type list that correspond to the types in the new type list.

Returns:
remapped_atom_exclude_types: list[int]

Remapped atom_exclude_types that only keeps the types in the new type list.

deepmd.utils.finetune.map_pair_exclude_types(pair_exclude_types: list[tuple[int, int]], remap_index: list[int])[source]#

Return the remapped atom_exclude_types according to remap_index.

Parameters:
pair_exclude_typeslist[tuple[int, int]]

Exclude the pair of atoms of the given types from computing the output of the atomic model.

remap_indexlist[int]

The indices in the old type list that correspond to the types in the new type list.

Returns:
remapped_pair_exclude_typess: list[tuple[int, int]]

Remapped pair_exclude_types that only keeps the types in the new type list.