deepmd.dpmodel.descriptor.se_t_tebd#
Classes#
Construct an embedding net that takes angles between two neighboring atoms and type embeddings as input. | |
The unit operation of a native model. |
Module Contents#
- class deepmd.dpmodel.descriptor.se_t_tebd.DescrptSeTTebd(rcut: float, rcut_smth: float, sel: list[int] | int, ntypes: int, neuron: list = [2, 4, 8], tebd_dim: int = 8, tebd_input_mode: str = 'concat', resnet_dt: bool = False, set_davg_zero: bool = True, activation_function: str = 'tanh', env_protection: float = 0.0, exclude_types: list[tuple[int, int]] = [], precision: str = 'float64', trainable: bool = True, seed: int | list[int] | None = None, type_map: list[str] | None = None, concat_output_tebd: bool = True, use_econf_tebd: bool = False, use_tebd_bias=False, smooth: bool = True)[source]#
Bases:
deepmd.dpmodel.NativeOP,deepmd.dpmodel.descriptor.base_descriptor.BaseDescriptorConstruct an embedding net that takes angles between two neighboring atoms and type embeddings as input.
- Parameters:
- rcut
The cut-off radius
- rcut_smth
From where the environment matrix should be smoothed
- sel
Union[list[int],int] list[int]: sel[i] specifies the maxmum number of type i atoms in the cut-off radius int: the total maxmum number of atoms in the cut-off radius
- ntypes
int Number of element types
- neuron
list[int] Number of neurons in each hidden layers of the embedding net
- tebd_dim
int Dimension of the type embedding
- tebd_input_mode
str The input mode of the type embedding. Supported modes are [“concat”, “strip”]. - “concat”: Concatenate the type embedding with the smoothed angular information as the union input for the embedding network. - “strip”: Use a separated embedding network for the type embedding and combine the output with the angular embedding network output.
- resnet_dt
Time-step dt in the resnet construction: y = x + dt * phi (Wx + b)
- set_davg_zero
Set the shift of embedding net input to zero.
- activation_function
The activation function in the embedding net. Supported options are “linear”, “sigmoid”, “relu6”, “softplus”, “none”, “gelu_tf”, “tanh”, “gelu”, “relu”.
- env_protection: float
Protection parameter to prevent division by zero errors during environment matrix calculations.
- exclude_types
list[tuple[int,int]] The excluded pairs of types which have no interaction with each other. For example, [[0, 1]] means no interaction between type 0 and type 1.
- precision
The precision of the embedding net parameters. Supported options are “float32”, “float16”, “default”, “float64”.
- trainable
If the weights of embedding net are trainable.
- seed
Random seed for initializing the network parameters.
- type_map: list[str], Optional
A list of strings. Give the name to each type of atoms.
- concat_output_tebd: bool
Whether to concat type embedding at the output of the descriptor.
- use_econf_tebd: bool, Optional
Whether to use electronic configuration type embedding.
- use_tebd_biasbool,
Optional Whether to use bias in the type embedding layer.
- smooth: bool
Whether to use smooth process in calculation.
- get_rcut_smth() float[source]#
Returns the radius where the neighbor information starts to smoothly decay to 0.
- mixed_types() bool[source]#
If true, the descriptor 1. assumes total number of atoms aligned across frames; 2. requires a neighbor list that does not distinguish different atomic types.
If false, the descriptor 1. assumes total number of atoms of each atom type aligned across frames; 2. requires a neighbor list that distinguishes different atomic types.
- need_sorted_nlist_for_lower() bool[source]#
Returns whether the descriptor needs sorted nlist when using forward_lower.
Share the parameters of self to the base_class with shared_level during multitask training. If not start from checkpoint (resume is False), some separated parameters (e.g. mean and stddev) will be re-calculated across different classes.
- abstract compute_input_stats(merged: list[dict], path: deepmd.utils.path.DPPath | None = None) NoReturn[source]#
Update mean and stddev for descriptor elements.
- set_stat_mean_and_stddev(mean: numpy.ndarray, stddev: numpy.ndarray) None[source]#
Update mean and stddev for descriptor.
- get_stat_mean_and_stddev() tuple[numpy.ndarray, numpy.ndarray][source]#
Get mean and stddev for descriptor.
- change_type_map(type_map: list[str], model_with_new_type_stat=None) None[source]#
Change the type related params to new ones, according to type_map and the original one in the model. If there are new types in type_map, statistics will be updated accordingly to model_with_new_type_stat for these new types.
- call(coord_ext, atype_ext, nlist, mapping: numpy.ndarray | None = None)[source]#
Compute the descriptor.
- Parameters:
- coord_ext
The extended coordinates of atoms. shape: nf x (nallx3)
- atype_ext
The extended aotm types. shape: nf x nall
- nlist
The neighbor list. shape: nf x nloc x nnei
- mapping
The index mapping from extended to local region. not used by this descriptor.
- Returns:
descriptorThe descriptor. shape: nf x nloc x (ng x axis_neuron)
grThe rotationally equivariant and permutationally invariant single particle representation. shape: nf x nloc x ng x 3
g2The rotationally invariant pair-partical representation. this descriptor returns None
h2The rotationally equivariant pair-partical representation. this descriptor returns None
swThe smooth switch function.
- classmethod deserialize(data: dict) DescrptSeTTebd[source]#
Deserialize from dict.
- class deepmd.dpmodel.descriptor.se_t_tebd.DescrptBlockSeTTebd(rcut: float, rcut_smth: float, sel: list[int] | int, ntypes: int, neuron: list = [25, 50, 100], tebd_dim: int = 8, tebd_input_mode: str = 'concat', set_davg_zero: bool = True, activation_function='tanh', precision: str = 'float64', resnet_dt: bool = False, exclude_types: list[tuple[int, int]] = [], env_protection: float = 0.0, smooth: bool = True, seed: int | list[int] | None = None)[source]#
Bases:
deepmd.dpmodel.NativeOP,deepmd.dpmodel.descriptor.descriptor.DescriptorBlockThe unit operation of a native model.
- get_rcut_smth() float[source]#
Returns the radius where the neighbor information starts to smoothly decay to 0.
- mixed_types() bool[source]#
If true, the descriptor 1. assumes total number of atoms aligned across frames; 2. requires a neighbor list that does not distinguish different atomic types.
If false, the descriptor 1. assumes total number of atoms of each atom type aligned across frames; 2. requires a neighbor list that distinguishes different atomic types.
- abstract compute_input_stats(merged: Callable[[], list[dict]] | list[dict], path: deepmd.utils.path.DPPath | None = None) NoReturn[source]#
Compute the input statistics (e.g. mean and stddev) for the descriptors from packed data.
- call(nlist: numpy.ndarray, coord_ext: numpy.ndarray, atype_ext: numpy.ndarray, atype_embd_ext: numpy.ndarray | None = None, mapping: numpy.ndarray | None = None, type_embedding: numpy.ndarray | None = None)[source]#
Forward pass in NumPy implementation.
- need_sorted_nlist_for_lower() bool[source]#
Returns whether the descriptor block needs sorted nlist when using forward_lower.
- classmethod deserialize(data: dict) DescrptSeTTebd[source]#
Deserialize from dict.