deepmd.tf.model#
Submodules#
Classes#
Load model from a frozen model, which cannot be trained. | |
Linear energy model make linear combinations of several existing energy models. | |
Pairwise tabulation energy model. | |
Pairwise Deep Potential - Range Correction. | |
DOS model. | |
Energy model. | |
Tensor model. | |
Tensor model. | |
Tensor model. | |
Tensor model. |
Package Contents#
- class deepmd.tf.model.FrozenModel(model_file: str, **kwargs: Any)[source]#
Bases:
deepmd.tf.model.model.ModelLoad model from a frozen model, which cannot be trained.
- Parameters:
- model_file
str The path to the frozen model
- model_file
- model_file#
- model#
- build(coord_: deepmd.tf.env.tf.Tensor, atype_: deepmd.tf.env.tf.Tensor, natoms: deepmd.tf.env.tf.Tensor, box: deepmd.tf.env.tf.Tensor, mesh: deepmd.tf.env.tf.Tensor, input_dict: dict, frz_model: str | None = None, ckpt_meta: str | None = None, suffix: str = '', reuse: bool | enum.Enum | None = None) dict[source]#
Build the model.
- Parameters:
- coord_
tf.Tensor The coordinates of atoms
- atype_
tf.Tensor The atom types of atoms
- natoms
tf.Tensor The number of atoms
- box
tf.Tensor The box vectors
- mesh
tf.Tensor The mesh vectors
- input_dict
dict The input dict
- frz_model
str,optional The path to the frozen model
- ckpt_meta
str,optional The path prefix of the checkpoint and meta files
- suffix
str,optional The suffix of the scope
- reusebool or
tf.AUTO_REUSE,optional Whether to reuse the variables
- coord_
- Returns:
dictThe output dict
- get_fitting() deepmd.tf.fit.fitting.Fitting | dict[source]#
Get the fitting(s).
- get_loss(loss: dict, lr: deepmd.tf.utils.learning_rate.LearningRateExp) deepmd.tf.loss.loss.Loss | dict | None[source]#
Get the loss function(s).
- data_stat(data: deepmd.utils.data_system.DeepmdDataSystem) None[source]#
Data staticis.
- init_variables(graph: deepmd.tf.env.tf.Graph, graph_def: deepmd.tf.env.tf.GraphDef, model_type: str = 'original_model', suffix: str = '') None[source]#
Init the embedding net variables with the given frozen model.
- enable_compression(suffix: str = '') None[source]#
Enable compression.
- Parameters:
- suffix
str suffix to name scope
- suffix
- classmethod update_sel(train_data: deepmd.utils.data_system.DeepmdDataSystem, type_map: list[str] | None, local_jdata: dict) tuple[dict, float | None][source]#
Update the selection and perform neighbor statistics.
- serialize(suffix: str = '') dict[source]#
Serialize the model.
There is no suffix in a native DP model, but it is important for the TF backend.
- classmethod deserialize(data: dict, suffix: str = '') NoReturn[source]#
Deserialize the model.
There is no suffix in a native DP model, but it is important for the TF backend.
- property input_requirement: list[deepmd.utils.data.DataRequirementItem]#
Return data requirements needed for the model input.
- class deepmd.tf.model.LinearEnergyModel(models: list[dict], weights: list[float], **kwargs: Any)[source]#
Bases:
LinearModelLinear energy model make linear combinations of several existing energy models.
- model_type = 'ener'#
- build(coord_: deepmd.tf.env.tf.Tensor, atype_: deepmd.tf.env.tf.Tensor, natoms: deepmd.tf.env.tf.Tensor, box: deepmd.tf.env.tf.Tensor, mesh: deepmd.tf.env.tf.Tensor, input_dict: dict, frz_model: str | None = None, ckpt_meta: str | None = None, suffix: str = '', reuse: bool | enum.Enum | None = None) dict[source]#
Build the model.
- Parameters:
- coord_
tf.Tensor The coordinates of atoms
- atype_
tf.Tensor The atom types of atoms
- natoms
tf.Tensor The number of atoms
- box
tf.Tensor The box vectors
- mesh
tf.Tensor The mesh vectors
- input_dict
dict The input dict
- frz_model
str,optional The path to the frozen model
- ckpt_meta
str,optional The path prefix of the checkpoint and meta files
- suffix
str,optional The suffix of the scope
- reusebool or
tf.AUTO_REUSE,optional Whether to reuse the variables
- coord_
- Returns:
dictThe output dict
- class deepmd.tf.model.PairTabModel(tab_file: str, rcut: float, sel: int | list[int], **kwargs: Any)[source]#
Bases:
deepmd.tf.model.model.ModelPairwise tabulation energy model.
This model can be used to tabulate the pairwise energy between atoms for either short-range or long-range interactions, such as D3, LJ, ZBL, etc. It should not be used alone, but rather as one submodel of a linear (sum) model, such as DP+D3.
Do not put the model on the first model of a linear model, since the linear model fetches the type map from the first model.
At this moment, the model does not smooth the energy at the cutoff radius, so one needs to make sure the energy has been smoothed to zero.
- Parameters:
- model_type = 'ener'#
- tab_file#
- tab#
- ntypes#
- rcut#
- build(coord_: deepmd.tf.env.tf.Tensor, atype_: deepmd.tf.env.tf.Tensor, natoms: deepmd.tf.env.tf.Tensor, box: deepmd.tf.env.tf.Tensor, mesh: deepmd.tf.env.tf.Tensor, input_dict: dict, frz_model: str | None = None, ckpt_meta: str | None = None, suffix: str = '', reuse: bool | enum.Enum | None = None) dict[source]#
Build the model.
- Parameters:
- coord_
tf.Tensor The coordinates of atoms
- atype_
tf.Tensor The atom types of atoms
- natoms
tf.Tensor The number of atoms
- box
tf.Tensor The box vectors
- mesh
tf.Tensor The mesh vectors
- input_dict
dict The input dict
- frz_model
str,optional The path to the frozen model
- ckpt_meta
str,optional The path prefix of the checkpoint and meta files
- suffix
str,optional The suffix of the scope
- reusebool or
tf.AUTO_REUSE,optional Whether to reuse the variables
- coord_
- Returns:
dictThe output dict
- init_variables(graph: deepmd.tf.env.tf.Graph, graph_def: deepmd.tf.env.tf.GraphDef, model_type: str = 'original_model', suffix: str = '') None[source]#
Init the embedding net variables with the given frozen model.
- get_fitting() deepmd.tf.fit.fitting.Fitting | dict[source]#
Get the fitting(s).
- get_loss(loss: dict, lr: deepmd.tf.utils.learning_rate.LearningRateExp) deepmd.tf.loss.loss.Loss | dict | None[source]#
Get the loss function(s).
- enable_compression(suffix: str = '') None[source]#
Enable compression.
- Parameters:
- suffix
str suffix to name scope
- suffix
- classmethod update_sel(train_data: deepmd.utils.data_system.DeepmdDataSystem, type_map: list[str] | None, local_jdata: dict) tuple[dict, float | None][source]#
Update the selection and perform neighbor statistics.
- Parameters:
- Returns:
Notes
Do not modify the input data without copying it.
- property input_requirement: list[deepmd.utils.data.DataRequirementItem]#
Return data requirements needed for the model input.
- class deepmd.tf.model.PairwiseDPRc(qm_model: dict, qmmm_model: dict, type_embedding: dict | deepmd.tf.utils.type_embed.TypeEmbedNet, type_map: list[str], data_stat_nbatch: int = 10, data_stat_nsample: int = 10, data_stat_protect: float = 0.01, use_srtab: str | None = None, smin_alpha: float | None = None, sw_rmin: float | None = None, sw_rmax: float | None = None, spin: deepmd.tf.utils.spin.Spin | None = None, compress: dict | None = None, **kwargs: Any)[source]#
Bases:
deepmd.tf.model.model.ModelPairwise Deep Potential - Range Correction.
- model_type = 'ener'#
- merge_frames = True#
- ntypes#
- qm_model#
- qmmm_model#
- rcut#
- build(coord_: deepmd.tf.env.tf.Tensor, atype_: deepmd.tf.env.tf.Tensor, natoms: deepmd.tf.env.tf.Tensor, box_: deepmd.tf.env.tf.Tensor, mesh: deepmd.tf.env.tf.Tensor, input_dict: dict, frz_model: str | None = None, ckpt_meta: str | None = None, suffix: str = '', reuse: bool | None = None) dict[source]#
Build the model.
- Parameters:
- coord_
tf.Tensor The coordinates of atoms
- atype_
tf.Tensor The atom types of atoms
- natoms
tf.Tensor The number of atoms
- box
tf.Tensor The box vectors
- mesh
tf.Tensor The mesh vectors
- input_dict
dict The input dict
- frz_model
str,optional The path to the frozen model
- ckpt_meta
str,optional The path prefix of the checkpoint and meta files
- suffix
str,optional The suffix of the scope
- reusebool or
tf.AUTO_REUSE,optional Whether to reuse the variables
- coord_
- Returns:
dictThe output dict
- get_loss(loss: dict, lr: deepmd.tf.utils.learning_rate.LearningRateExp) deepmd.tf.loss.loss.Loss | dict[source]#
Get the loss function(s).
- init_variables(graph: deepmd.tf.env.tf.Graph, graph_def: deepmd.tf.env.tf.GraphDef, model_type: str = 'original_model', suffix: str = '') None[source]#
Init the embedding net variables with the given frozen model.
- enable_compression(suffix: str = '') None[source]#
Enable compression.
- Parameters:
- suffix
str suffix to name scope
- suffix
- get_feed_dict(coord_: deepmd.tf.env.tf.Tensor, atype_: deepmd.tf.env.tf.Tensor, natoms: deepmd.tf.env.tf.Tensor, box: deepmd.tf.env.tf.Tensor, mesh: deepmd.tf.env.tf.Tensor, **kwargs: Any) dict[str, deepmd.tf.env.tf.Tensor][source]#
Generate the feed_dict for current descriptor.
- Parameters:
- coord_
tf.Tensor The coordinate of atoms
- atype_
tf.Tensor The type of atoms
- natoms
tf.Tensor The number of atoms. This tensor has the length of Ntypes + 2 natoms[0]: number of local atoms natoms[1]: total number of atoms held by this processor natoms[i]: 2 <= i < Ntypes+2, number of type i atoms
- box
tf.Tensor The box. Can be generated by deepmd.tf.model.make_stat_input
- mesh
tf.Tensor For historical reasons, only the length of the Tensor matters. if size of mesh == 6, pbc is assumed. if size of mesh == 0, no-pbc is assumed.
- aparam
tf.Tensor The parameters of the descriptor
- **kwargs
dict The keyword arguments
- coord_
- Returns:
- classmethod update_sel(train_data: deepmd.utils.data_system.DeepmdDataSystem, type_map: list[str] | None, local_jdata: dict) tuple[dict, float | None][source]#
Update the selection and perform neighbor statistics.
- property input_requirement: list[deepmd.utils.data.DataRequirementItem]#
Return data requirements needed for the model input.
- class deepmd.tf.model.DOSModel(descriptor: dict, fitting_net: dict, type_embedding: dict | deepmd.tf.utils.type_embed.TypeEmbedNet | None = None, type_map: list[str] | None = None, data_stat_nbatch: int = 10, data_stat_protect: float = 0.01, **kwargs: Any)[source]#
Bases:
deepmd.tf.model.model.StandardModelDOS model.
- Parameters:
- descriptor
Descriptor
- fitting_net
Fitting net
- type_embedding
Type embedding net
- type_map
Mapping atom type to the name (str) of the type. For example type_map[1] gives the name of the type 1.
- data_stat_nbatch
Number of frames used for data statistic
- data_stat_protect
Protect parameter for atomic energy regression
- model_type = 'dos'#
- numb_dos#
- numb_fparam#
- numb_aparam#
- data_stat(data: deepmd.utils.data_system.DeepmdDataSystem) None[source]#
Data staticis.
- _compute_input_stat(all_stat: dict, protection: float = 0.01, mixed_type: bool = False) None[source]#
- build(coord_: deepmd.tf.env.tf.Tensor, atype_: deepmd.tf.env.tf.Tensor, natoms: deepmd.tf.env.tf.Tensor, box: deepmd.tf.env.tf.Tensor, mesh: deepmd.tf.env.tf.Tensor, input_dict: dict, frz_model: str | None = None, ckpt_meta: str | None = None, suffix: str = '', reuse: bool | None = None) dict[source]#
Build the model.
- Parameters:
- coord_
tf.Tensor The coordinates of atoms
- atype_
tf.Tensor The atom types of atoms
- natoms
tf.Tensor The number of atoms
- box
tf.Tensor The box vectors
- mesh
tf.Tensor The mesh vectors
- input_dict
dict The input dict
- frz_model
str,optional The path to the frozen model
- ckpt_meta
str,optional The path prefix of the checkpoint and meta files
- suffix
str,optional The suffix of the scope
- reusebool or
tf.AUTO_REUSE,optional Whether to reuse the variables
- coord_
- Returns:
dictThe output dict
- class deepmd.tf.model.EnerModel(descriptor: dict, fitting_net: dict, type_embedding: dict | deepmd.tf.utils.type_embed.TypeEmbedNet | None = None, type_map: list[str] | None = None, data_stat_nbatch: int = 10, data_stat_protect: float = 0.01, use_srtab: str | None = None, smin_alpha: float | None = None, sw_rmin: float | None = None, sw_rmax: float | None = None, srtab_add_bias: bool = True, spin: deepmd.tf.utils.spin.Spin | None = None, data_bias_nsample: int = 10, **kwargs: Any)[source]#
Bases:
deepmd.tf.model.model.StandardModelEnergy model.
- Parameters:
- descriptor
Descriptor
- fitting_net
Fitting net
- type_embedding
Type embedding net
- type_map
Mapping atom type to the name (str) of the type. For example type_map[1] gives the name of the type 1.
- data_stat_nbatch
Number of frames used for data statistic
- data_stat_protect
Protect parameter for atomic energy regression
- use_srtab
The table for the short-range pairwise interaction added on top of DP. The table is a text data file with (N_t + 1) * N_t / 2 + 1 columes. The first colume is the distance between atoms. The second to the last columes are energies for pairs of certain types. For example we have two atom types, 0 and 1. The columes from 2nd to 4th are for 0-0, 0-1 and 1-1 correspondingly.
- smin_alpha
The short-range tabulated interaction will be switched according to the distance of the nearest neighbor. This distance is calculated by softmin. This parameter is the decaying parameter in the softmin. It is only required when use_srtab is provided.
- sw_rmin
The lower boundary of the interpolation between short-range tabulated interaction and DP. It is only required when use_srtab is provided.
- sw_rmin
The upper boundary of the interpolation between short-range tabulated interaction and DP. It is only required when use_srtab is provided.
- srtab_add_biasbool
Whether add energy bias from the statistics of the data to short-range tabulated atomic energy. It only takes effect when use_srtab is provided.
- spin
spin
- data_stat_nsample
The number of training samples in a system to compute and change the energy bias.
- model_type = 'ener'#
- numb_fparam#
- numb_aparam#
- srtab_name = None#
- data_stat(data: deepmd.tf.utils.data_system.DeepmdDataSystem) None[source]#
Data staticis.
- _compute_input_stat(all_stat: dict, protection: float = 0.01, mixed_type: bool = False) None[source]#
- build(coord_: deepmd.tf.env.tf.Tensor, atype_: deepmd.tf.env.tf.Tensor, natoms: deepmd.tf.env.tf.Tensor, box: deepmd.tf.env.tf.Tensor, mesh: deepmd.tf.env.tf.Tensor, input_dict: dict, frz_model: str | None = None, ckpt_meta: str | None = None, suffix: str = '', reuse: bool | None = None) dict[source]#
Build the model.
- Parameters:
- coord_
tf.Tensor The coordinates of atoms
- atype_
tf.Tensor The atom types of atoms
- natoms
tf.Tensor The number of atoms
- box
tf.Tensor The box vectors
- mesh
tf.Tensor The mesh vectors
- input_dict
dict The input dict
- frz_model
str,optional The path to the frozen model
- ckpt_meta
str,optional The path prefix of the checkpoint and meta files
- suffix
str,optional The suffix of the scope
- reusebool or
tf.AUTO_REUSE,optional Whether to reuse the variables
- coord_
- Returns:
dictThe output dict
- init_variables(graph: deepmd.tf.env.tf.Graph, graph_def: deepmd.tf.env.tf.GraphDef, model_type: str = 'original_model', suffix: str = '') None[source]#
Init the embedding net variables with the given frozen model.
- natoms_match(force: deepmd.tf.env.tf.Tensor, natoms: deepmd.tf.env.tf.Tensor) deepmd.tf.env.tf.Tensor[source]#
- natoms_not_match(force: deepmd.tf.env.tf.Tensor, natoms: deepmd.tf.env.tf.Tensor, atype: deepmd.tf.env.tf.Tensor) deepmd.tf.env.tf.Tensor[source]#
- change_energy_bias(data: deepmd.tf.utils.data_system.DeepmdDataSystem, frozen_model: str, origin_type_map: list, full_type_map: str, bias_adjust_mode: str = 'change-by-statistic') None[source]#
Change the energy bias according to the input data and the pretrained model.
- Parameters:
- data
DeepmdDataSystem The training data.
- frozen_model
str The path file of frozen model.
- origin_type_map
list The original type_map in dataset, they are targets to change the energy bias.
- full_type_map
str The full type_map in pretrained model
- bias_adjust_mode
str The mode for changing energy bias : [‘change-by-statistic’, ‘set-by-statistic’] ‘change-by-statistic’ : perform predictions on energies of target dataset,
and do least square on the errors to obtain the target shift as bias.
‘set-by-statistic’ : directly use the statistic energy bias in the target dataset.
- data
- class deepmd.tf.model.DipoleModel(*args: Any, **kwargs: Any)[source]#
Bases:
TensorModelTensor model.
- Parameters:
- tensor_name
Name of the tensor.
- descriptor
Descriptor
- fitting_net
Fitting net
- type_embedding
Type embedding net
- type_map
Mapping atom type to the name (str) of the type. For example type_map[1] gives the name of the type 1.
- data_stat_nbatch
Number of frames used for data statistic
- data_stat_protect
Protect parameter for atomic energy regression
- class deepmd.tf.model.GlobalPolarModel(*args: Any, **kwargs: Any)[source]#
Bases:
TensorModelTensor model.
- Parameters:
- tensor_name
Name of the tensor.
- descriptor
Descriptor
- fitting_net
Fitting net
- type_embedding
Type embedding net
- type_map
Mapping atom type to the name (str) of the type. For example type_map[1] gives the name of the type 1.
- data_stat_nbatch
Number of frames used for data statistic
- data_stat_protect
Protect parameter for atomic energy regression
- class deepmd.tf.model.PolarModel(*args: Any, **kwargs: Any)[source]#
Bases:
TensorModelTensor model.
- Parameters:
- tensor_name
Name of the tensor.
- descriptor
Descriptor
- fitting_net
Fitting net
- type_embedding
Type embedding net
- type_map
Mapping atom type to the name (str) of the type. For example type_map[1] gives the name of the type 1.
- data_stat_nbatch
Number of frames used for data statistic
- data_stat_protect
Protect parameter for atomic energy regression
- class deepmd.tf.model.WFCModel(*args: Any, **kwargs: Any)[source]#
Bases:
TensorModelTensor model.
- Parameters:
- tensor_name
Name of the tensor.
- descriptor
Descriptor
- fitting_net
Fitting net
- type_embedding
Type embedding net
- type_map
Mapping atom type to the name (str) of the type. For example type_map[1] gives the name of the type 1.
- data_stat_nbatch
Number of frames used for data statistic
- data_stat_protect
Protect parameter for atomic energy regression