deepmd.pt.model.descriptor.se_t#
Classes#
DeepPot-SE constructed from all information (both angular and radial) of atomic | |
The building block of descriptor. |
Functions#
|
Module Contents#
- deepmd.pt.model.descriptor.se_t.tabulate_fusion_se_t(argument0: torch.Tensor, argument1: torch.Tensor, argument2: torch.Tensor, argument3: torch.Tensor, argument4: int) list[torch.Tensor][source]#
- class deepmd.pt.model.descriptor.se_t.DescrptSeT(rcut: float, rcut_smth: float, sel: list[int], neuron: list[int] = [24, 48, 96], resnet_dt: bool = False, set_davg_zero: bool = False, 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, ntypes: int | None = None, spin=None)[source]#
Bases:
deepmd.pt.model.descriptor.base_descriptor.BaseDescriptor,torch.nn.ModuleDeepPot-SE constructed from all information (both angular and radial) of atomic configurations.
The embedding takes angles between two neighboring atoms as input.
- Parameters:
- rcut
float The cut-off radius
- rcut_smth
float From where the environment matrix should be smoothed
- sel
list[int] sel[i] specifies the maxmum number of type i atoms in the cut-off radius
- neuron
list[int] Number of neurons in each hidden layers of the embedding net
- resnet_dtbool
Time-step dt in the resnet construction: y = x + dt * phi (Wx + b)
- set_davg_zerobool
Set the shift of embedding net input to zero.
- activation_function
str 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[list[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
str The precision of the embedding net parameters. Supported options are “float32”, “float16”, “default”, “float64”.
- trainablebool
If the weights of embedding net are trainable.
- seed
int,Optional Random seed for initializing the network parameters.
- type_map: list[str], Optional
A list of strings. Give the name to each type of atoms.
- rcut
- get_rcut_smth() float[source]#
Returns the radius where the neighbor information starts to smoothly decay to 0.
- mixed_types()[source]#
Returns if the descriptor requires a neighbor list that distinguish different atomic types or not.
- 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 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.
- compute_input_stats(merged: Callable[[], list[dict]] | list[dict], path: deepmd.utils.path.DPPath | None = None)[source]#
Compute the input statistics (e.g. mean and stddev) for the descriptors from packed data.
- Parameters:
- merged
Union[Callable[[],list[dict]],list[dict]] - list[dict]: A list of data samples from various data systems.
Each element, merged[i], is a data dictionary containing keys: torch.Tensor originating from the i-th data system.
- Callable[[], list[dict]]: A lazy function that returns data samples in the above format
only when needed. Since the sampling process can be slow and memory-intensive, the lazy function helps by only sampling once.
- path
Optional[DPPath] The path to the stat file.
- merged
- enable_compression(min_nbor_dist: float, table_extrapolate: float = 5, table_stride_1: float = 0.01, table_stride_2: float = 0.1, check_frequency: int = -1) None[source]#
Receive the statisitcs (distance, max_nbor_size and env_mat_range) of the training data.
- Parameters:
- min_nbor_dist
The nearest distance between atoms
- table_extrapolate
The scale of model extrapolation
- table_stride_1
The uniform stride of the first table
- table_stride_2
The uniform stride of the second table
- check_frequency
The overflow check frequency
- forward(coord_ext: torch.Tensor, atype_ext: torch.Tensor, nlist: torch.Tensor, mapping: torch.Tensor | None = None, comm_dict: dict[str, torch.Tensor] | 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, not required by this descriptor.
- comm_dict
The data needed for communication for parallel inference.
- Returns:
descriptorThe descriptor. shape: nf x nloc x ng
grThe rotationally equivariant and permutationally invariant single particle representation. This descriptor returns None.
g2The rotationally invariant pair-partical representation. This descriptor returns None.
h2The rotationally equivariant pair-partical representation. This descriptor returns None.
swThe smooth switch function.
- set_stat_mean_and_stddev(mean: torch.Tensor, stddev: torch.Tensor) None[source]#
Update mean and stddev for descriptor.
- get_stat_mean_and_stddev() tuple[torch.Tensor, torch.Tensor][source]#
Get mean and stddev for descriptor.
- classmethod deserialize(data: dict) DescrptSeT[source]#
Deserialize the model.
- Parameters:
- data
dict The serialized data
- data
- Returns:
BDThe deserialized descriptor
- class deepmd.pt.model.descriptor.se_t.DescrptBlockSeT(rcut: float, rcut_smth: float, sel: list[int], neuron: list[int] = [24, 48, 96], resnet_dt: bool = False, set_davg_zero: bool = False, 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)[source]#
Bases:
deepmd.pt.model.descriptor.DescriptorBlockThe building block of descriptor. Given the input descriptor, provide with the atomic coordinates, atomic types and neighbor list, calculate the new descriptor.
- 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.
- compute_input_stats(merged: Callable[[], list[dict]] | list[dict], path: deepmd.utils.path.DPPath | None = None) None[source]#
Compute the input statistics (e.g. mean and stddev) for the descriptors from packed data.
- Parameters:
- merged
Union[Callable[[],list[dict]],list[dict]] - list[dict]: A list of data samples from various data systems.
Each element, merged[i], is a data dictionary containing keys: torch.Tensor originating from the i-th data system.
- Callable[[], list[dict]]: A lazy function that returns data samples in the above format
only when needed. Since the sampling process can be slow and memory-intensive, the lazy function helps by only sampling once.
- path
Optional[DPPath] The path to the stat file.
- merged
- get_stats() dict[str, deepmd.utils.env_mat_stat.StatItem][source]#
Get the statistics of the descriptor.
- forward(nlist: torch.Tensor, extended_coord: torch.Tensor, extended_atype: torch.Tensor, extended_atype_embd: torch.Tensor | None = None, mapping: torch.Tensor | None = None, type_embedding: torch.Tensor | None = None)[source]#
Compute the descriptor.
- Parameters:
- nlist
The neighbor list. shape: nf x nloc x nnei
- extended_coord
The extended coordinates of atoms. shape: nf x (nallx3)
- extended_atype
The extended aotm types. shape: nf x nall x nt
- extended_atype_embd
The extended type embedding of atoms. shape: nf x nall
- mapping
The index mapping, not required by this descriptor.
- type_embedding
Full type embeddings. shape: (ntypes+1) x nt Required for stripped type embeddings.
- Returns:
resultThe descriptor. shape: nf x nloc x ng
grThe rotationally equivariant and permutationally invariant single particle representation. This descriptor returns None.
g2The rotationally invariant pair-partical representation. This descriptor returns None.
h2The rotationally equivariant pair-partical representation. This descriptor returns None.
swThe smooth switch function. shape: nf x nloc x nnei