deepmd.pt.model.descriptor.se_a#
Classes#
Base descriptor provides the interfaces of descriptor. | |
The building block of descriptor. |
Functions#
|
Module Contents#
- deepmd.pt.model.descriptor.se_a.tabulate_fusion_se_a(argument0: torch.Tensor, argument1: torch.Tensor, argument2: torch.Tensor, argument3: torch.Tensor, argument4: int) list[torch.Tensor][source]#
- class deepmd.pt.model.descriptor.se_a.DescrptSeA(rcut: float, rcut_smth: float, sel: list[int] | int, neuron: list[int] = [25, 50, 100], axis_neuron: int = 16, set_davg_zero: bool = False, activation_function: str = 'tanh', precision: str = 'float64', resnet_dt: bool = False, exclude_types: list[tuple[int, int]] = [], env_protection: float = 0.0, type_one_side: bool = True, trainable: bool = True, seed: int | list[int] | None = None, ntypes: int | None = None, type_map: list[str] | None = None, spin: Any | None = None)[source]#
Bases:
deepmd.pt.model.descriptor.base_descriptor.BaseDescriptor,torch.nn.ModuleBase descriptor provides the interfaces of descriptor.
- get_rcut_smth() float[source]#
Returns the radius where the neighbor information starts to smoothly decay to 0.
- mixed_types() bool[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.
- abstractmethod change_type_map(type_map: list[str], model_with_new_type_stat: Any | None = 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: 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: 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 statistics (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, fparam: torch.Tensor | None = None, charge_spin: torch.Tensor | None = None) tuple[torch.Tensor, torch.Tensor | None, torch.Tensor | None, torch.Tensor | None, torch.Tensor | 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 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.
- 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) DescrptSeA[source]#
Deserialize the model.
- Parameters:
- data
dict The serialized data
- data
- Returns:
BDThe deserialized descriptor
- class deepmd.pt.model.descriptor.se_a.DescrptBlockSeA(rcut: float, rcut_smth: float, sel: int | list[int], neuron: list[int] = [25, 50, 100], axis_neuron: int = 16, set_davg_zero: bool = False, activation_function: str = 'tanh', precision: str = 'float64', resnet_dt: bool = False, exclude_types: list[tuple[int, int]] = [], env_protection: float = 0.0, type_one_side: bool = True, trainable: bool = True, seed: int | list[int] | None = None, **kwargs: Any)[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.
- 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.
- __setitem__(key: str, value: torch.Tensor) None[source]#
- __getitem__(key: str) torch.Tensor[source]#
- 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: 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.
- enable_compression(table_data: dict[str, torch.Tensor], table_config: list[int | float], lower: dict[str, int], upper: dict[str, int]) None[source]#
- 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) tuple[torch.Tensor, torch.Tensor | None, torch.Tensor | None, torch.Tensor | None, torch.Tensor | None][source]#
Calculate decoded embedding for each atom.
Args: - coord: Tell atom coordinates with shape [nframes, natoms[1]*3]. - atype: Tell atom types with shape [nframes, natoms[1]]. - natoms: Tell atom count and element count. Its shape is [2+self.ntypes]. - box: Tell simulation box with shape [nframes, 9].
- Returns:
- torch.Tensor:
descriptormatrixwithshape[nframes,natoms[0]*self.filter_neuron[-1]*self.axis_neuron].
- torch.Tensor: