deepmd.pt.infer.deep_eval#
Classes#
PyTorch backend implementation of DeepEval. |
Module Contents#
- class deepmd.pt.infer.deep_eval.DeepEval(model_file: str, output_def: deepmd.dpmodel.output_def.ModelOutputDef, *args: Any, auto_batch_size: bool | int | deepmd.pt.utils.auto_batch_size.AutoBatchSize = True, neighbor_list: ase.neighborlist.NewPrimitiveNeighborList | None = None, head: str | int | None = None, **kwargs: Any)[source]#
Bases:
deepmd.infer.deep_eval.DeepEvalBackendPyTorch backend implementation of DeepEval.
- Parameters:
- model_file
Path The name of the frozen model file.
- output_def
ModelOutputDef The output definition of the model.
- *args
list Positional arguments.
- auto_batch_sizebool or
intorAutomaticBatchSize, default:False If True, automatic batch size will be used. If int, it will be used as the initial batch size.
- neighbor_list
ase.neighborlist.NewPrimitiveNeighborList,optional The ASE neighbor list class to produce the neighbor list. If None, the neighbor list will be built natively in the model.
- **kwargs
dict Keyword arguments.
- model_file
- property model_type: type[deepmd.infer.deep_eval.DeepEval][source]#
The the evaluator of the model type.
- get_sel_type() list[int][source]#
Get the selected atom types of this model.
Only atoms with selected atom types have atomic contribution to the result of the model. If returning an empty list, all atom types are selected.
- get_ntypes_spin() int[source]#
Get the number of spin atom types of this model. Only used in old implement.
- eval(coords: numpy.ndarray, cells: numpy.ndarray | None, atom_types: numpy.ndarray, atomic: bool = False, fparam: numpy.ndarray | None = None, aparam: numpy.ndarray | None = None, **kwargs: Any) dict[str, numpy.ndarray][source]#
Evaluate the energy, force and virial by using this DP.
- Parameters:
- coords
The coordinates of atoms. The array should be of size nframes x natoms x 3
- cells
The cell of the region. If None then non-PBC is assumed, otherwise using PBC. The array should be of size nframes x 9
- atom_types
The atom types The list should contain natoms ints
- atomic
Calculate the atomic energy and virial
- fparam
The frame parameter. The array can be of size : - nframes x dim_fparam. - dim_fparam. Then all frames are assumed to be provided with the same fparam.
- aparam
The atomic parameter The array can be of size : - nframes x natoms x dim_aparam. - natoms x dim_aparam. Then all frames are assumed to be provided with the same aparam. - dim_aparam. Then all frames and atoms are provided with the same aparam.
- **kwargs
Other parameters
- Returns:
- output_dict
dict The output of the evaluation. The keys are the names of the output variables, and the values are the corresponding output arrays.
- output_dict
- _get_request_defs(atomic: bool) list[deepmd.dpmodel.output_def.OutputVariableDef][source]#
Get the requested output definitions.
When atomic is True, all output_def are requested. When atomic is False, only energy (tensor), force, and virial are requested.
- _eval_func(inner_func: Callable, numb_test: int, natoms: int) Callable[source]#
Wrapper method with auto batch size.
- _get_natoms_and_nframes(coords: numpy.ndarray, atom_types: numpy.ndarray, mixed_type: bool = False) tuple[int, int][source]#
- _eval_model(coords: numpy.ndarray, cells: numpy.ndarray | None, atom_types: numpy.ndarray, fparam: numpy.ndarray | None, aparam: numpy.ndarray | None, request_defs: list[deepmd.dpmodel.output_def.OutputVariableDef])[source]#
- _eval_model_spin(coords: numpy.ndarray, cells: numpy.ndarray | None, atom_types: numpy.ndarray, spins: numpy.ndarray, fparam: numpy.ndarray | None, aparam: numpy.ndarray | None, request_defs: list[deepmd.dpmodel.output_def.OutputVariableDef])[source]#
- eval_typeebd() numpy.ndarray[source]#
Evaluate output of type embedding network by using this model.
- Returns:
np.ndarrayThe output of type embedding network. The shape is [ntypes, o_size] or [ntypes + 1, o_size], where ntypes is the number of types, and o_size is the number of nodes in the output layer. If there are multiple type embedding networks, these outputs will be concatenated along the second axis.
- Raises:
KeyErrorIf the model does not enable type embedding.
See also
deepmd.pt.model.network.network.TypeEmbedNetConsistentThe type embedding network.
- eval_descriptor(coords: numpy.ndarray, cells: numpy.ndarray | None, atom_types: numpy.ndarray, fparam: numpy.ndarray | None = None, aparam: numpy.ndarray | None = None, **kwargs: Any) numpy.ndarray[source]#
Evaluate descriptors by using this DP.
- Parameters:
- coords
The coordinates of atoms. The array should be of size nframes x natoms x 3
- cells
The cell of the region. If None then non-PBC is assumed, otherwise using PBC. The array should be of size nframes x 9
- atom_types
The atom types The list should contain natoms ints
- fparam
The frame parameter. The array can be of size : - nframes x dim_fparam. - dim_fparam. Then all frames are assumed to be provided with the same fparam.
- aparam
The atomic parameter The array can be of size : - nframes x natoms x dim_aparam. - natoms x dim_aparam. Then all frames are assumed to be provided with the same aparam. - dim_aparam. Then all frames and atoms are provided with the same aparam.
- Returns:
descriptorDescriptors.