deepmd.pd.model.descriptor.se_atten#
Classes#
The building block of descriptor. | |
Module Contents#
- class deepmd.pd.model.descriptor.se_atten.DescrptBlockSeAtten(rcut: float, rcut_smth: float, sel: list[int] | int, ntypes: int, neuron: list = [25, 50, 100], axis_neuron: int = 16, tebd_dim: int = 8, tebd_input_mode: str = 'concat', set_davg_zero: bool = True, attn: int = 128, attn_layer: int = 2, attn_dotr: bool = True, attn_mask: bool = False, activation_function: str = 'tanh', precision: str = 'float64', resnet_dt: bool = False, scaling_factor: float = 1.0, normalize: bool = True, temperature: float | None = None, smooth: bool = True, type_one_side: bool = False, exclude_types: list[tuple[int, int]] = [], env_protection: float = 0.0, trainable_ln: bool = True, ln_eps: float | None = 1e-05, seed: int | list[int] | None = None, type: str | None = None, trainable: bool = True)[source]#
Bases:
deepmd.pd.model.descriptor.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.
- get_buffer_rcut_smth() paddle.Tensor[source]#
Returns the radius where the neighbor information starts to smoothly decay to 0 as a buffer-style Tensor.
- get_dim_rot_mat_1() int[source]#
Returns the first dimension of the rotation matrix. The rotation is of shape dim_1 x 3.
- 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: collections.abc.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: paddle.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.
- enable_compression(table_data: dict[str, paddle.Tensor], table_config: list[float], lower: dict[str, float], upper: dict[str, float]) None[source]#
- forward(nlist: paddle.Tensor, extended_coord: paddle.Tensor, extended_atype: paddle.Tensor, extended_atype_embd: paddle.Tensor | None = None, mapping: paddle.Tensor | None = None, type_embedding: paddle.Tensor | None = None) tuple[paddle.Tensor, paddle.Tensor | None, paddle.Tensor, paddle.Tensor, paddle.Tensor][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 x axis_neuron)
g2The rotationally invariant pair-partical representation. shape: nf x nloc x nnei x ng
h2The rotationally equivariant pair-partical representation. shape: nf x nloc x nnei x 3
grThe rotationally equivariant and permutationally invariant single particle representation. shape: nf x nloc x ng x 3
swThe smooth switch function. shape: nf x nloc x nnei
- class deepmd.pd.model.descriptor.se_atten.NeighborGatedAttention(layer_num: int, nnei: int, embed_dim: int, hidden_dim: int, dotr: bool = False, do_mask: bool = False, scaling_factor: float = 1.0, normalize: bool = True, temperature: float | None = None, trainable_ln: bool = True, ln_eps: float = 1e-05, smooth: bool = True, precision: str = DEFAULT_PRECISION, seed: int | list[int] | None = None, trainable: bool = True)[source]#
Bases:
paddle.nn.Layer- forward(input_G: paddle.Tensor, nei_mask: paddle.Tensor, input_r: paddle.Tensor | None = None, sw: paddle.Tensor | None = None) paddle.Tensor[source]#
Compute the multi-layer gated self-attention.
- Parameters:
- input_G
inputs with shape: (nf x nloc) x nnei x embed_dim.
- nei_mask
neighbor mask, with paddings being 0. shape: (nf x nloc) x nnei.
- input_r
normalized radial. shape: (nf x nloc) x nnei x 3.
- sw
The smooth switch function. shape: nf x nloc x nnei
- classmethod deserialize(data: dict) NeighborGatedAttention[source]#
Deserialize the networks from a dict.
- Parameters:
- data
dict The dict to deserialize from.
- data
- class deepmd.pd.model.descriptor.se_atten.NeighborGatedAttentionLayer(nnei: int, embed_dim: int, hidden_dim: int, dotr: bool = False, do_mask: bool = False, scaling_factor: float = 1.0, normalize: bool = True, temperature: float | None = None, smooth: bool = True, trainable_ln: bool = True, ln_eps: float = 1e-05, precision: str = DEFAULT_PRECISION, seed: int | list[int] | None = None, trainable: bool = True)[source]#
Bases:
paddle.nn.Layer- forward(x: paddle.Tensor, nei_mask: paddle.Tensor, input_r: paddle.Tensor | None = None, sw: paddle.Tensor | None = None) paddle.Tensor[source]#
- classmethod deserialize(data: dict) NeighborGatedAttentionLayer[source]#
Deserialize the networks from a dict.
- Parameters:
- data
dict The dict to deserialize from.
- data
- class deepmd.pd.model.descriptor.se_atten.GatedAttentionLayer(nnei: int, embed_dim: int, hidden_dim: int, num_heads: int = 1, dotr: bool = False, do_mask: bool = False, scaling_factor: float = 1.0, normalize: bool = True, temperature: float | None = None, bias: bool = True, smooth: bool = True, precision: str = DEFAULT_PRECISION, seed: int | list[int] | None = None, trainable: bool = True)[source]#
Bases:
paddle.nn.Layer- forward(query: paddle.Tensor, nei_mask: paddle.Tensor, input_r: paddle.Tensor | None = None, sw: paddle.Tensor | None = None, attnw_shift: float = 20.0) tuple[paddle.Tensor, paddle.Tensor][source]#
Compute the multi-head gated self-attention.
- Parameters:
- query
inputs with shape: (nf x nloc) x nnei x embed_dim.
- nei_mask
neighbor mask, with paddings being 0. shape: (nf x nloc) x nnei.
- input_r
normalized radial. shape: (nf x nloc) x nnei x 3.
- sw
The smooth switch function. shape: (nf x nloc) x nnei
- attnw_shift
float The attention weight shift to preserve smoothness when doing padding before softmax.
- classmethod deserialize(data: dict) GatedAttentionLayer[source]#
Deserialize the networks from a dict.
- Parameters:
- data
dict The dict to deserialize from.
- data