deepmd.dpmodel.model package
The model that takes the coordinates, cell and atom types as input and predicts some property. The models are automatically generated from atomic models by the deepmd.dpmodel.make_model method.
The make_model method does the reduction, auto-differentiation (dummy for dpmodels) and communication of the atomic properties according to output variable definition deepmd.dpmodel.OutputVariableDef.
- class deepmd.dpmodel.model.DPModel(*args, **kwargs)[source]
Bases:
CM,BaseModelMethods
__call__(*args, **kwargs)Forward pass in NumPy implementation.
atomic_output_def()Get the output def of the atomic model.
call(coord, atype[, box, fparam, aparam, ...])Return model prediction.
call_lower(extended_coord, extended_atype, nlist)Return model prediction.
deserialize(data)Deserialize the model.
do_grad_(var_name, base)Tell if the output variable var_name is differentiable.
do_grad_c([var_name])Tell if the output variable var_name is c_differentiable.
do_grad_r([var_name])Tell if the output variable var_name is r_differentiable.
fitting_output_def()Get the output def of the fitting net.
format_nlist(extended_coord, extended_atype, ...)Format the neighbor list.
forward_atomic(extended_coord, ...[, ...])Models' atomic predictions.
get_class_by_type(class_type)Get the class by the plugin type.
get_dim_aparam()Get the number (dimension) of atomic parameters of this atomic model.
get_dim_fparam()Get the number (dimension) of frame parameters of this atomic model.
get_nnei()Returns the total number of selected neighboring atoms in the cut-off radius.
get_nsel()Returns the total number of selected neighboring atoms in the cut-off radius.
get_ntypes()Get the number of atom types.
get_plugins()Get all the registered plugins.
get_rcut()Get the cut-off radius.
get_sel()Get the neighbor selection.
get_sel_type()Get the selected atom types of this model.
get_type_map()Get the type map.
input_type_cast(coord[, box, fparam, aparam])Cast the input data to global float type.
is_aparam_nall()Check whether the shape of atomic parameters is (nframes, nall, ndim).
mixed_types()If true, the model 1.
model_output_def()Get the output def for the model.
model_output_type()Get the output type for the model.
output_type_cast(model_ret, input_prec)Convert the model output to the input prec.
register(key)Register a descriptor plugin.
update_sel(global_jdata, local_jdata)Update the selection and perform neighbor statistics.
forward_common_atomic
get_model_def_script
reinit_atom_exclude
reinit_pair_exclude
serialize
- deepmd.dpmodel.model.make_model(T_AtomicModel)[source]
Make a model as a derived class of an atomic model.
The model provide two interfaces.
1. the call_lower, that takes extended coordinates, atyps and neighbor list, and outputs the atomic and property and derivatives (if required) on the extended region.
2. the call, that takes coordinates, atypes and cell and predicts the atomic and reduced property, and derivatives (if required) on the local region.
- Parameters
- T_AtomicModel
The atomic model.
- Returns
CMThe model.
Submodules
deepmd.dpmodel.model.base_model module
- class deepmd.dpmodel.model.base_model.BaseModel(*args, **kwargs)[source]
Bases:
BaseBaseModelBase class for final exported model that will be directly used for inference.
The class defines some abstractmethods that will be directly called by the inference interface. If the final model class inherbits some of those methods from other classes, BaseModel should be inherited as the last class to ensure the correct method resolution order.
This class is for the DPModel backend.
See also
deepmd.dpmodel.model.base_model.BaseBaseModelBackend-independent BaseModel class.
Methods
__call__(*args, **kwds)Inference method.
deserialize(data)Deserialize the model.
get_class_by_type(class_type)Get the class by the plugin type.
get_dim_aparam()Get the number (dimension) of atomic parameters of this atomic model.
get_dim_fparam()Get the number (dimension) of frame parameters of this atomic model.
get_model_def_script()Get the model definition script.
get_nnei()Returns the total number of selected neighboring atoms in the cut-off radius.
get_nsel()Returns the total number of selected neighboring atoms in the cut-off radius.
get_plugins()Get all the registered plugins.
get_rcut()Get the cut-off radius.
get_sel_type()Get the selected atom types of this model.
get_type_map()Get the type map.
is_aparam_nall()Check whether the shape of atomic parameters is (nframes, nall, ndim).
model_output_type()Get the output type for the model.
register(key)Register a descriptor plugin.
serialize()Serialize the model.
update_sel(global_jdata, local_jdata)Update the selection and perform neighbor statistics.
deepmd.dpmodel.model.dp_model module
- class deepmd.dpmodel.model.dp_model.DPModel(*args, **kwargs)[source]
Bases:
CM,BaseModelMethods
__call__(*args, **kwargs)Forward pass in NumPy implementation.
atomic_output_def()Get the output def of the atomic model.
call(coord, atype[, box, fparam, aparam, ...])Return model prediction.
call_lower(extended_coord, extended_atype, nlist)Return model prediction.
deserialize(data)Deserialize the model.
do_grad_(var_name, base)Tell if the output variable var_name is differentiable.
do_grad_c([var_name])Tell if the output variable var_name is c_differentiable.
do_grad_r([var_name])Tell if the output variable var_name is r_differentiable.
fitting_output_def()Get the output def of the fitting net.
format_nlist(extended_coord, extended_atype, ...)Format the neighbor list.
forward_atomic(extended_coord, ...[, ...])Models' atomic predictions.
get_class_by_type(class_type)Get the class by the plugin type.
get_dim_aparam()Get the number (dimension) of atomic parameters of this atomic model.
get_dim_fparam()Get the number (dimension) of frame parameters of this atomic model.
get_nnei()Returns the total number of selected neighboring atoms in the cut-off radius.
get_nsel()Returns the total number of selected neighboring atoms in the cut-off radius.
get_ntypes()Get the number of atom types.
get_plugins()Get all the registered plugins.
get_rcut()Get the cut-off radius.
get_sel()Get the neighbor selection.
get_sel_type()Get the selected atom types of this model.
get_type_map()Get the type map.
input_type_cast(coord[, box, fparam, aparam])Cast the input data to global float type.
is_aparam_nall()Check whether the shape of atomic parameters is (nframes, nall, ndim).
mixed_types()If true, the model 1.
model_output_def()Get the output def for the model.
model_output_type()Get the output type for the model.
output_type_cast(model_ret, input_prec)Convert the model output to the input prec.
register(key)Register a descriptor plugin.
update_sel(global_jdata, local_jdata)Update the selection and perform neighbor statistics.
forward_common_atomic
get_model_def_script
reinit_atom_exclude
reinit_pair_exclude
serialize
deepmd.dpmodel.model.make_model module
- deepmd.dpmodel.model.make_model.make_model(T_AtomicModel)[source]
Make a model as a derived class of an atomic model.
The model provide two interfaces.
1. the call_lower, that takes extended coordinates, atyps and neighbor list, and outputs the atomic and property and derivatives (if required) on the extended region.
2. the call, that takes coordinates, atypes and cell and predicts the atomic and reduced property, and derivatives (if required) on the local region.
- Parameters
- T_AtomicModel
The atomic model.
- Returns
CMThe model.
deepmd.dpmodel.model.model module
deepmd.dpmodel.model.transform_output module
- deepmd.dpmodel.model.transform_output.communicate_extended_output(model_ret: Dict[str, ndarray], model_output_def: ModelOutputDef, mapping: ndarray, do_atomic_virial: bool = False) Dict[str, ndarray][source]
Transform the output of the model network defined on local and ghost (extended) atoms to local atoms.