deepmd.pt.model.model
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 and communication of the atomic properties according to output variable definition deepmd.dpmodel.OutputVariableDef.
All models should be inherited from A base class to implement common methods for all the Models. Base class for all neural network modules. A base class to implement common methods for all the Models. Load model from a frozen model, which cannot be trained. Base class for all neural network modules. A spin model for energy. A spin model wrapper, with spin input preprocess and output split. Make a model that can compute Hessian. Make a model as a derived class of an atomic model. A base class to implement common methods for all the Models. Bases: Base class for all neural network modules. Your models should also subclass this class. Modules can also contain other Modules, allowing to nest them in a tree structure. You can assign the submodules as regular attributes: Submodules assigned in this way will be registered, and will have their parameters converted too when you call Note As per the example above, an training (bool) – Boolean represents whether this module is in training or evaluation mode. Bases: A base class to implement common methods for all the Models. Bases: Load model from a frozen model, which cannot be trained. The path to the frozen model Get the output def of developer implemented atomic models. 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. Check whether the shape of atomic parameters is (nframes, nall, ndim). If False, the shape is (nframes, nloc, ndim). If true, the model 1. assumes total number of atoms aligned across frames; 2. uses a neighbor list that does not distinguish different atomic types. If false, the model 1. assumes total number of atoms of each atom type aligned across frames; 2. uses a neighbor list that distinguishes different atomic types. Returns the total number of selected neighboring atoms in the cut-off radius. Returns the total number of selected neighboring atoms in the cut-off radius. Make a model that can compute Hessian. LIMITATION: this model is not jitable due to the restrictions of torch jit script. LIMITATION: only the hessian of forward_common is available. The model. Should provide the forward_common and atomic_output_def methods Make a model as a derived class of an atomic model. The model provide two interfaces. 1. the forward_common_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 forward_common, that takes coordinates, atypes and cell and predicts the atomic and reduced property, and derivatives (if required) on the local region. The atomic model. The model. Bases: Base class for all neural network modules. Your models should also subclass this class. Modules can also contain other Modules, allowing to nest them in a tree structure. You can assign the submodules as regular attributes: Submodules assigned in this way will be registered, and will have their parameters converted too when you call Note As per the example above, an training (bool) – Boolean represents whether this module is in training or evaluation mode. Compute or load the statistics parameters of the model, such as mean and standard deviation of descriptors or the energy bias of the fitting net. When sampled is provided, all the statistics parameters will be calculated (or re-calculated for update), and saved in the stat_file_path`(s). When `sampled is not provided, it will check the existence of `stat_file_path`(s) and load the calculated statistics parameters. The sampled data frames from different data systems. The path to the statistics files. Bases: A spin model for energy. Bases: A spin model wrapper, with spin input preprocess and output split. Generate virtual coordinates and types, concat into the input. Add extended_spin into extended_coord to generate virtual atoms, and extend nlist and mapping. Note that the final extended_coord_updated with shape [nframes, nall + nall, 3] has the following order: - [:, :nloc]: original nloc real atoms. - [:, nloc: nloc + nloc]: virtual atoms corresponding to nloc real atoms. - [:, nloc + nloc: nloc + nall]: ghost real atoms. - [:, nloc + nall: nall + nall]: virtual atoms corresponding to ghost real atoms. Split the output both real and virtual atoms, and scale the latter. add_mag: whether to add magnetic tensor onto the real tensor. Default: True. e.g. Ture for forces and False for atomic virials on real atoms. Default: True. e.g. Ture for forces and False for atomic virials on virtual atoms. Split the extended output of both real and virtual atoms with switch, and scale the latter. add_mag: whether to add magnetic tensor onto the real tensor. Default: True. e.g. Ture for forces and False for atomic virials on real atoms. Default: True. e.g. Ture for forces and False for atomic virials on virtual atoms. Concat real and virtual extended tensors, and switch all the local ones to the first nloc * 2 atoms. - [:, :nloc]: original nloc real atoms. - [:, nloc: nloc + nloc]: virtual atoms corresponding to nloc real atoms. - [:, nloc + nloc: nloc + nall]: ghost real atoms. - [:, nloc + nall: nall + nall]: virtual atoms corresponding to ghost real atoms. Expand the atom parameters for virtual atoms if necessary. 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. Check whether the shape of atomic parameters is (nframes, nall, ndim). If False, the shape is (nframes, nloc, ndim). Returns the total number of selected neighboring atoms in the cut-off radius. Returns the total number of selected neighboring atoms in the cut-off radius. Compute or load the statistics parameters of the model, such as mean and standard deviation of descriptors or the energy bias of the fitting net. When sampled is provided, all the statistics parameters will be calculated (or re-calculated for update), and saved in the stat_file_path`(s). When `sampled is not provided, it will check the existence of `stat_file_path`(s) and load the calculated statistics parameters. The lazy sampled function to get data frames from different data systems. The dictionary of paths to the statistics files.deepmd.pt.model.model.model.BaseModel
. Models generated by make_model have already done it.Submodules
deepmd.pt.model.model.dipole_model
deepmd.pt.model.model.dos_model
deepmd.pt.model.model.dp_model
deepmd.pt.model.model.dp_zbl_model
deepmd.pt.model.model.ener_model
deepmd.pt.model.model.frozen
deepmd.pt.model.model.make_hessian_model
deepmd.pt.model.model.make_model
deepmd.pt.model.model.model
deepmd.pt.model.model.polar_model
deepmd.pt.model.model.spin_model
deepmd.pt.model.model.transform_output
Package Contents
Classes
Functions
make_hessian_model
(T_Model)make_model
(T_AtomicModel)get_model
(model_params)DPZBLModel_
import torch.nn as nn
import torch.nn.functional as F
class Model(nn.Module):
def __init__(self):
super().__init__()
self.conv1 = nn.Conv2d(1, 20, 5)
self.conv2 = nn.Conv2d(20, 20, 5)
def forward(self, x):
x = F.relu(self.conv1(x))
return F.relu(self.conv2(x))
to()
, etc.__init__()
call to the parent class must be made before assignment on the child.deepmd.pt.model.model.dp_model.DPModelCommon
, DPEnergyModel_
deepmd.pt.model.model.model.BaseModel
str
The
model
computes
hessian.CM
torch.nn.Module
, make_base_model
()import torch.nn as nn
import torch.nn.functional as F
class Model(nn.Module):
def __init__(self):
super().__init__()
self.conv1 = nn.Conv2d(1, 20, 5)
self.conv2 = nn.Conv2d(20, 20, 5)
def forward(self, x):
x = F.relu(self.conv1(x))
return F.relu(self.conv2(x))
to()
, etc.__init__()
call to the parent class must be made before assignment on the child.SpinModel
torch.nn.Module