deepmd.tf package
Root of the deepmd package, exposes all public classes and submodules.
- class deepmd.tf.DeepEval(model_file: str, *args, **kwargs)[source]
Bases:
DeepEvalBackend
TensorFlow backend implementation for 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.
- load_prefix: str
The prefix in the load computational graph
- default_tf_graphbool
If uses the default tf graph, otherwise build a new tf graph for evaluation
- auto_batch_sizebool or
int
orAutomaticBatchSize
, default:False
If True, automatic batch size will be used. If int, it will be used as the initial batch size.
- input_map
dict
,optional
The input map for tf.import_graph_def. Only work with default tf graph
- 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
- Attributes
model_type
Get type of model.
model_version
Get version of model.
sess
Get TF session.
Methods
build_neighbor_list
(coords, cell, atype, ...)Make the mesh with neighbor list for a single frame.
eval
(coords, cells, atom_types[, atomic, ...])Evaluate the energy, force and virial by using this DP.
eval_descriptor
(coords, cells, atom_types[, ...])Evaluate descriptors by using this DP.
Evaluate output of type embedding network by using this model.
Get the number (dimension) of atomic parameters of this DP.
Get the number (dimension) of frame parameters of this DP.
Check if the model has efield.
Get the number of atom types of this model.
Get the number of spin atom types of this model.
Get the number of DOS.
get_rcut
()Get the cut-off radius of this model.
Get the selected atom types of this model.
Get the type map (element name of the atom types) of this model.
make_natoms_vec
(atom_types)Make the natom vector used by deepmd-kit.
reverse_map
(vec, imap)Reverse mapping of a vector according to the index map.
sort_input
(coord, atom_type[, sel_atoms])Sort atoms in the system according their types.
- build_neighbor_list(coords: ndarray, cell: Optional[ndarray], atype: ndarray, imap: ndarray, neighbor_list)[source]
Make the mesh with neighbor list for a single frame.
- Parameters
- coords
np.ndarray
The coordinates of atoms. Should be of shape [natoms, 3]
- cell
Optional
[np.ndarray
] The cell of the system. Should be of shape [3, 3]
- atype
np.ndarray
The type of atoms. Should be of shape [natoms]
- imap
np.ndarray
The index map of atoms. Should be of shape [natoms]
- neighbor_list
ase.neighborlist.NewPrimitiveNeighborList
ASE neighbor list. The following method or attribute will be used/set: bothways, self_interaction, update, build, first_neigh, pair_second, offset_vec.
- coords
- Returns
- natoms_vec
np.ndarray
The number of atoms. This tensor has the length of Ntypes + 2 natoms[0]: nloc natoms[1]: nall natoms[i]: 2 <= i < Ntypes+2, number of type i atoms for nloc
- coords
np.ndarray
The coordinates of atoms, including ghost atoms. Should be of shape [nframes, nall, 3]
- atype
np.ndarray
The type of atoms, including ghost atoms. Should be of shape [nall]
- mesh
np.ndarray
The mesh in nei_mode=4.
- imap
np.ndarray
The index map of atoms. Should be of shape [nall]
- ghost_map
np.ndarray
The index map of ghost atoms. Should be of shape [nghost]
- natoms_vec
- eval(coords: ndarray, cells: ndarray, atom_types: ndarray, atomic: bool = False, fparam: Optional[ndarray] = None, aparam: Optional[ndarray] = None, efield: Optional[ndarray] = None) Dict[str, 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.
- efield
The external field on atoms. The array should be of size nframes x natoms x 3
- 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
- eval_descriptor(coords: ndarray, cells: ndarray, atom_types: ndarray, fparam: Optional[ndarray] = None, aparam: Optional[ndarray] = None, efield: Optional[ndarray] = None) 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.
- efield
The external field on atoms. The array should be of size nframes x natoms x 3
- Returns
descriptor
Descriptors.
- eval_typeebd() ndarray [source]
Evaluate output of type embedding network by using this model.
- Returns
np.ndarray
The output of type embedding network. The shape is [ntypes, o_size], where ntypes is the number of types, and o_size is the number of nodes in the output layer.
- Raises
KeyError
If the model does not enable type embedding.
See also
deepmd.tf.utils.type_embed.TypeEmbedNet
The type embedding network.
Examples
Get the output of type embedding network of graph.pb:
>>> from deepmd.tf.infer import DeepPotential >>> dp = DeepPotential("graph.pb") >>> dp.eval_typeebd()
- get_sel_type() Optional[ndarray] [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.
- make_natoms_vec(atom_types: ndarray) ndarray [source]
Make the natom vector used by deepmd-kit.
- Parameters
- atom_types
The type of atoms
- Returns
natoms
The number of atoms. This tensor has the length of Ntypes + 2 natoms[0]: number of local atoms natoms[1]: total number of atoms held by this processor natoms[i]: 2 <= i < Ntypes+2, number of type i atoms
- property model_type: DeepEvalWrapper
Get type of model.
:type:str
- static reverse_map(vec: ndarray, imap: List[int]) ndarray [source]
Reverse mapping of a vector according to the index map.
- Parameters
- vec
Input vector. Be of shape [nframes, natoms, -1]
- imap
Index map. Be of shape [natoms]
- Returns
vec_out
Reverse mapped vector.
- property sess: Session
Get TF session.
- static sort_input(coord: ndarray, atom_type: ndarray, sel_atoms: Optional[List[int]] = None)[source]
Sort atoms in the system according their types.
- Parameters
- coord
The coordinates of atoms. Should be of shape [nframes, natoms, 3]
- atom_type
The type of atoms Should be of shape [natoms]
- sel_atoms
The selected atoms by type
- Returns
coord_out
The coordinates after sorting
atom_type_out
The atom types after sorting
idx_map
The index mapping from the input to the output. For example coord_out = coord[:,idx_map,:]
sel_atom_type
Only output if sel_atoms is not None The sorted selected atom types
sel_idx_map
Only output if sel_atoms is not None The index mapping from the selected atoms to sorted selected atoms.
- deepmd.tf.DeepPotential(*args, **kwargs) DeepEval [source]
Factory function that forwards to DeepEval (for compatbility).
- Parameters
- *args
positional arguments
- **kwargs
keyword arguments
- Returns
DeepEval
potentials
- class deepmd.tf.DipoleChargeModifier(model_name: str, model_charge_map: List[float], sys_charge_map: List[float], ewald_h: float = 1, ewald_beta: float = 1)[source]
Bases:
DeepDipoleOld
- Parameters
- model_name
The model file for the DeepDipole model
- model_charge_map
Gives the amount of charge for the wfcc
- sys_charge_map
Gives the amount of charge for the real atoms
- ewald_h
Grid spacing of the reciprocal part of Ewald sum. Unit: A
- ewald_beta
Splitting parameter of the Ewald sum. Unit: A^{-1}
- Attributes
model_type
Get type of model.
model_version
Get version of model.
sess
Get TF session.
Methods
Build the computational graph for the force and virial inference.
build_neighbor_list
(coords, cell, atype, ...)Make the mesh with neighbor list for a single frame.
eval
(coord, box, atype[, eval_fv])Evaluate the modification.
eval_full
(coords, cells, atom_types[, ...])Evaluate the model with interface similar to the energy model.
eval_typeebd
()Evaluate output of type embedding network by using this model.
get_dim_aparam
()Unsupported in this model.
get_dim_fparam
()Unsupported in this model.
get_ntypes
()Get the number of atom types of this model.
get_rcut
()Get the cut-off radius of this model.
get_sel_type
()Get the selected atom types of this model.
get_type_map
()Get the type map (element name of the atom types) of this model.
make_natoms_vec
(atom_types[, mixed_type])Make the natom vector used by deepmd-kit.
modify_data
(data, data_sys)Modify data.
reverse_map
(vec, imap)Reverse mapping of a vector according to the index map.
sort_input
(coord, atom_type[, sel_atoms, ...])Sort atoms in the system according their types.
- eval(coord: ndarray, box: ndarray, atype: ndarray, eval_fv: bool = True) Tuple[ndarray, ndarray, ndarray] [source]
Evaluate the modification.
- Parameters
- coord
The coordinates of atoms
- box
The simulation region. PBC is assumed
- atype
The atom types
- eval_fv
Evaluate force and virial
- Returns
tot_e
The energy modification
tot_f
The force modification
tot_v
The virial modification
- modify_data(data: dict, data_sys: DeepmdData) None [source]
Modify data.
- Parameters
- data
Internal data of DeepmdData. Be a dict, has the following keys - coord coordinates - box simulation box - type atom types - find_energy tells if data has energy - find_force tells if data has force - find_virial tells if data has virial - energy energy - force force - virial virial
- data_sys
DeepmdData
The data system.
Subpackages
- deepmd.tf.cluster package
- deepmd.tf.descriptor package
Descriptor
Descriptor.build()
Descriptor.build_type_exclude_mask()
Descriptor.compute_input_stats()
Descriptor.deserialize()
Descriptor.enable_compression()
Descriptor.enable_mixed_precision()
Descriptor.explicit_ntypes
Descriptor.get_dim_out()
Descriptor.get_dim_rot_mat_1()
Descriptor.get_nlist()
Descriptor.get_ntypes()
Descriptor.get_rcut()
Descriptor.get_tensor_names()
Descriptor.init_variables()
Descriptor.pass_tensors_from_frz_model()
Descriptor.prod_force_virial()
Descriptor.serialize()
Descriptor.update_sel()
DescrptHybrid
DescrptHybrid.build()
DescrptHybrid.compute_input_stats()
DescrptHybrid.deserialize()
DescrptHybrid.enable_compression()
DescrptHybrid.enable_mixed_precision()
DescrptHybrid.explicit_ntypes
DescrptHybrid.get_dim_out()
DescrptHybrid.get_nlist()
DescrptHybrid.get_nlist_i()
DescrptHybrid.get_ntypes()
DescrptHybrid.get_rcut()
DescrptHybrid.get_tensor_names()
DescrptHybrid.init_variables()
DescrptHybrid.merge_input_stats()
DescrptHybrid.pass_tensors_from_frz_model()
DescrptHybrid.prod_force_virial()
DescrptHybrid.serialize()
DescrptHybrid.update_sel()
DescrptLocFrame
DescrptLocFrame.build()
DescrptLocFrame.compute_input_stats()
DescrptLocFrame.get_dim_out()
DescrptLocFrame.get_nlist()
DescrptLocFrame.get_ntypes()
DescrptLocFrame.get_rcut()
DescrptLocFrame.get_rot_mat()
DescrptLocFrame.init_variables()
DescrptLocFrame.prod_force_virial()
DescrptLocFrame.update_sel()
DescrptSeA
DescrptSeA.build()
DescrptSeA.compute_input_stats()
DescrptSeA.deserialize()
DescrptSeA.enable_compression()
DescrptSeA.enable_mixed_precision()
DescrptSeA.explicit_ntypes
DescrptSeA.get_dim_out()
DescrptSeA.get_dim_rot_mat_1()
DescrptSeA.get_nlist()
DescrptSeA.get_ntypes()
DescrptSeA.get_rcut()
DescrptSeA.get_rot_mat()
DescrptSeA.init_variables()
DescrptSeA.merge_input_stats()
DescrptSeA.prod_force_virial()
DescrptSeA.serialize()
DescrptSeAEbd
DescrptSeAEbdV2
DescrptSeAEf
DescrptSeAEfLower
DescrptSeAMask
DescrptSeAtten
DescrptSeAttenV2
DescrptSeR
DescrptSeT
- Submodules
- deepmd.tf.descriptor.descriptor module
Descriptor
Descriptor.build()
Descriptor.build_type_exclude_mask()
Descriptor.compute_input_stats()
Descriptor.deserialize()
Descriptor.enable_compression()
Descriptor.enable_mixed_precision()
Descriptor.explicit_ntypes
Descriptor.get_dim_out()
Descriptor.get_dim_rot_mat_1()
Descriptor.get_nlist()
Descriptor.get_ntypes()
Descriptor.get_rcut()
Descriptor.get_tensor_names()
Descriptor.init_variables()
Descriptor.pass_tensors_from_frz_model()
Descriptor.prod_force_virial()
Descriptor.serialize()
Descriptor.update_sel()
- deepmd.tf.descriptor.hybrid module
DescrptHybrid
DescrptHybrid.build()
DescrptHybrid.compute_input_stats()
DescrptHybrid.deserialize()
DescrptHybrid.enable_compression()
DescrptHybrid.enable_mixed_precision()
DescrptHybrid.explicit_ntypes
DescrptHybrid.get_dim_out()
DescrptHybrid.get_nlist()
DescrptHybrid.get_nlist_i()
DescrptHybrid.get_ntypes()
DescrptHybrid.get_rcut()
DescrptHybrid.get_tensor_names()
DescrptHybrid.init_variables()
DescrptHybrid.merge_input_stats()
DescrptHybrid.pass_tensors_from_frz_model()
DescrptHybrid.prod_force_virial()
DescrptHybrid.serialize()
DescrptHybrid.update_sel()
- deepmd.tf.descriptor.loc_frame module
DescrptLocFrame
DescrptLocFrame.build()
DescrptLocFrame.compute_input_stats()
DescrptLocFrame.get_dim_out()
DescrptLocFrame.get_nlist()
DescrptLocFrame.get_ntypes()
DescrptLocFrame.get_rcut()
DescrptLocFrame.get_rot_mat()
DescrptLocFrame.init_variables()
DescrptLocFrame.prod_force_virial()
DescrptLocFrame.update_sel()
- deepmd.tf.descriptor.se module
- deepmd.tf.descriptor.se_a module
DescrptSeA
DescrptSeA.build()
DescrptSeA.compute_input_stats()
DescrptSeA.deserialize()
DescrptSeA.enable_compression()
DescrptSeA.enable_mixed_precision()
DescrptSeA.explicit_ntypes
DescrptSeA.get_dim_out()
DescrptSeA.get_dim_rot_mat_1()
DescrptSeA.get_nlist()
DescrptSeA.get_ntypes()
DescrptSeA.get_rcut()
DescrptSeA.get_rot_mat()
DescrptSeA.init_variables()
DescrptSeA.merge_input_stats()
DescrptSeA.prod_force_virial()
DescrptSeA.serialize()
- deepmd.tf.descriptor.se_a_ebd module
- deepmd.tf.descriptor.se_a_ebd_v2 module
- deepmd.tf.descriptor.se_a_ef module
- deepmd.tf.descriptor.se_a_mask module
- deepmd.tf.descriptor.se_atten module
- deepmd.tf.descriptor.se_atten_v2 module
- deepmd.tf.descriptor.se_r module
- deepmd.tf.descriptor.se_t module
- deepmd.tf.entrypoints package
compress()
convert()
doc_train_input()
freeze()
make_model_devi()
neighbor_stat()
start_dpgui()
test()
train_dp()
transfer()
- Submodules
- deepmd.tf.entrypoints.compress module
- deepmd.tf.entrypoints.convert module
- deepmd.tf.entrypoints.doc module
- deepmd.tf.entrypoints.freeze module
- deepmd.tf.entrypoints.gui module
- deepmd.tf.entrypoints.ipi module
- deepmd.tf.entrypoints.main module
- deepmd.tf.entrypoints.neighbor_stat module
- deepmd.tf.entrypoints.test module
- deepmd.tf.entrypoints.train module
- deepmd.tf.entrypoints.transfer module
- deepmd.tf.fit package
DOSFitting
DipoleFittingSeA
EnerFitting
EnerFitting.build()
EnerFitting.change_energy_bias()
EnerFitting.compute_input_stats()
EnerFitting.compute_output_stats()
EnerFitting.deserialize()
EnerFitting.enable_mixed_precision()
EnerFitting.get_loss()
EnerFitting.get_numb_aparam()
EnerFitting.get_numb_fparam()
EnerFitting.init_variables()
EnerFitting.serialize()
Fitting
GlobalPolarFittingSeA
PolarFittingSeA
- Submodules
- deepmd.tf.fit.dipole module
- deepmd.tf.fit.dos module
- deepmd.tf.fit.ener module
EnerFitting
EnerFitting.build()
EnerFitting.change_energy_bias()
EnerFitting.compute_input_stats()
EnerFitting.compute_output_stats()
EnerFitting.deserialize()
EnerFitting.enable_mixed_precision()
EnerFitting.get_loss()
EnerFitting.get_numb_aparam()
EnerFitting.get_numb_fparam()
EnerFitting.init_variables()
EnerFitting.serialize()
- deepmd.tf.fit.fitting module
- deepmd.tf.fit.polar module
- deepmd.tf.infer package
DeepDOS
DeepDipole
DeepEval
DeepEval.build_neighbor_list()
DeepEval.eval()
DeepEval.eval_descriptor()
DeepEval.eval_typeebd()
DeepEval.get_dim_aparam()
DeepEval.get_dim_fparam()
DeepEval.get_has_efield()
DeepEval.get_ntypes()
DeepEval.get_ntypes_spin()
DeepEval.get_numb_dos()
DeepEval.get_rcut()
DeepEval.get_sel_type()
DeepEval.get_type_map()
DeepEval.make_natoms_vec()
DeepEval.model_type
DeepEval.model_version
DeepEval.reverse_map()
DeepEval.sess
DeepEval.sort_input()
DeepGlobalPolar
DeepPolar
DeepPot
DeepPotential()
DeepWFC
DipoleChargeModifier
EwaldRecp
calc_model_devi()
- Submodules
- deepmd.tf.infer.data_modifier module
- deepmd.tf.infer.deep_dipole module
- deepmd.tf.infer.deep_dos module
- deepmd.tf.infer.deep_eval module
DeepEval
DeepEval.build_neighbor_list()
DeepEval.eval()
DeepEval.eval_descriptor()
DeepEval.eval_typeebd()
DeepEval.get_dim_aparam()
DeepEval.get_dim_fparam()
DeepEval.get_has_efield()
DeepEval.get_ntypes()
DeepEval.get_ntypes_spin()
DeepEval.get_numb_dos()
DeepEval.get_rcut()
DeepEval.get_sel_type()
DeepEval.get_type_map()
DeepEval.make_natoms_vec()
DeepEval.model_type
DeepEval.model_version
DeepEval.reverse_map()
DeepEval.sess
DeepEval.sort_input()
DeepEvalOld
- deepmd.tf.infer.deep_polar module
- deepmd.tf.infer.deep_pot module
- deepmd.tf.infer.deep_tensor module
- deepmd.tf.infer.deep_wfc module
- deepmd.tf.infer.ewald_recp module
- deepmd.tf.infer.model_devi module
- deepmd.tf.loggers package
- deepmd.tf.loss package
- deepmd.tf.model package
DOSModel
DipoleModel
EnerModel
FrozenModel
GlobalPolarModel
LinearEnergyModel
MultiModel
MultiModel.build()
MultiModel.data_stat()
MultiModel.enable_mixed_precision()
MultiModel.get_fitting()
MultiModel.get_loss()
MultiModel.get_ntypes()
MultiModel.get_numb_aparam()
MultiModel.get_numb_dos()
MultiModel.get_numb_fparam()
MultiModel.get_rcut()
MultiModel.get_type_map()
MultiModel.init_variables()
MultiModel.model_type
MultiModel.update_sel()
PairTabModel
PairwiseDPRc
PolarModel
WFCModel
- Submodules
- deepmd.tf.model.dos module
- deepmd.tf.model.ener module
- deepmd.tf.model.frozen module
- deepmd.tf.model.linear module
- deepmd.tf.model.model module
Model
Model.build()
Model.build_descrpt()
Model.build_type_embedding()
Model.change_energy_bias()
Model.data_stat()
Model.deserialize()
Model.enable_compression()
Model.enable_mixed_precision()
Model.get_feed_dict()
Model.get_fitting()
Model.get_loss()
Model.get_ntypes()
Model.get_numb_aparam()
Model.get_numb_dos()
Model.get_numb_fparam()
Model.get_rcut()
Model.get_type_map()
Model.init_variables()
Model.serialize()
Model.update_sel()
StandardModel
- deepmd.tf.model.model_stat module
- deepmd.tf.model.multi module
MultiModel
MultiModel.build()
MultiModel.data_stat()
MultiModel.enable_mixed_precision()
MultiModel.get_fitting()
MultiModel.get_loss()
MultiModel.get_ntypes()
MultiModel.get_numb_aparam()
MultiModel.get_numb_dos()
MultiModel.get_numb_fparam()
MultiModel.get_rcut()
MultiModel.get_type_map()
MultiModel.init_variables()
MultiModel.model_type
MultiModel.update_sel()
- deepmd.tf.model.pairtab module
- deepmd.tf.model.pairwise_dprc module
- deepmd.tf.model.tensor module
- deepmd.tf.nvnmd package
- Subpackages
- deepmd.tf.nvnmd.data package
- deepmd.tf.nvnmd.descriptor package
- deepmd.tf.nvnmd.entrypoints package
- deepmd.tf.nvnmd.fit package
- deepmd.tf.nvnmd.utils package
Encode
FioBin
FioDic
FioTxt
get_filter_weight()
get_fitnet_weight()
map_nvnmd()
nvnmd_args()
one_layer()
- Submodules
- deepmd.tf.nvnmd.utils.argcheck module
- deepmd.tf.nvnmd.utils.config module
- deepmd.tf.nvnmd.utils.encode module
- deepmd.tf.nvnmd.utils.fio module
- deepmd.tf.nvnmd.utils.network module
- deepmd.tf.nvnmd.utils.op module
- deepmd.tf.nvnmd.utils.weight module
- Subpackages
- deepmd.tf.op package
- deepmd.tf.train package
- deepmd.tf.utils package
DeepmdData
DeepmdData.add()
DeepmdData.avg()
DeepmdData.check_batch_size()
DeepmdData.check_test_size()
DeepmdData.get_atom_type()
DeepmdData.get_batch()
DeepmdData.get_data_dict()
DeepmdData.get_item_torch()
DeepmdData.get_natoms()
DeepmdData.get_natoms_vec()
DeepmdData.get_ntypes()
DeepmdData.get_numb_batch()
DeepmdData.get_numb_set()
DeepmdData.get_sys_numb_batch()
DeepmdData.get_test()
DeepmdData.get_type_map()
DeepmdData.reduce()
DeepmdData.reformat_data_torch()
DeepmdData.reset_get_batch()
DeepmdDataSystem
DeepmdDataSystem.add()
DeepmdDataSystem.add_dict()
DeepmdDataSystem.compute_energy_shift()
DeepmdDataSystem.default_mesh
DeepmdDataSystem.get_batch()
DeepmdDataSystem.get_batch_mixed()
DeepmdDataSystem.get_batch_size()
DeepmdDataSystem.get_batch_standard()
DeepmdDataSystem.get_data_dict()
DeepmdDataSystem.get_nbatches()
DeepmdDataSystem.get_nsystems()
DeepmdDataSystem.get_ntypes()
DeepmdDataSystem.get_sys()
DeepmdDataSystem.get_sys_ntest()
DeepmdDataSystem.get_test()
DeepmdDataSystem.get_type_map()
DeepmdDataSystem.print_summary()
DeepmdDataSystem.reduce()
DeepmdDataSystem.set_sys_probs()
LearningRateExp
PairTab
Plugin
PluginVariant
- Submodules
- deepmd.tf.utils.argcheck module
- deepmd.tf.utils.batch_size module
- deepmd.tf.utils.compat module
- deepmd.tf.utils.compress module
- deepmd.tf.utils.convert module
- deepmd.tf.utils.data module
DeepmdData
DeepmdData.add()
DeepmdData.avg()
DeepmdData.check_batch_size()
DeepmdData.check_test_size()
DeepmdData.get_atom_type()
DeepmdData.get_batch()
DeepmdData.get_data_dict()
DeepmdData.get_item_torch()
DeepmdData.get_natoms()
DeepmdData.get_natoms_vec()
DeepmdData.get_ntypes()
DeepmdData.get_numb_batch()
DeepmdData.get_numb_set()
DeepmdData.get_sys_numb_batch()
DeepmdData.get_test()
DeepmdData.get_type_map()
DeepmdData.reduce()
DeepmdData.reformat_data_torch()
DeepmdData.reset_get_batch()
- deepmd.tf.utils.data_system module
DeepmdDataSystem
DeepmdDataSystem.add()
DeepmdDataSystem.add_dict()
DeepmdDataSystem.compute_energy_shift()
DeepmdDataSystem.default_mesh
DeepmdDataSystem.get_batch()
DeepmdDataSystem.get_batch_mixed()
DeepmdDataSystem.get_batch_size()
DeepmdDataSystem.get_batch_standard()
DeepmdDataSystem.get_data_dict()
DeepmdDataSystem.get_nbatches()
DeepmdDataSystem.get_nsystems()
DeepmdDataSystem.get_ntypes()
DeepmdDataSystem.get_sys()
DeepmdDataSystem.get_sys_ntest()
DeepmdDataSystem.get_test()
DeepmdDataSystem.get_type_map()
DeepmdDataSystem.print_summary()
DeepmdDataSystem.reduce()
DeepmdDataSystem.set_sys_probs()
prob_sys_size_ext()
process_sys_probs()
- deepmd.tf.utils.errors module
- deepmd.tf.utils.finetune module
- deepmd.tf.utils.graph module
get_attention_layer_nodes_from_graph_def()
get_attention_layer_variables_from_graph_def()
get_embedding_net_nodes()
get_embedding_net_nodes_from_graph_def()
get_embedding_net_variables()
get_embedding_net_variables_from_graph_def()
get_extra_embedding_net_suffix()
get_extra_embedding_net_variables_from_graph_def()
get_fitting_net_nodes()
get_fitting_net_nodes_from_graph_def()
get_fitting_net_variables()
get_fitting_net_variables_from_graph_def()
get_pattern_nodes_from_graph_def()
get_tensor_by_name()
get_tensor_by_name_from_graph()
get_tensor_by_type()
get_type_embedding_net_nodes_from_graph_def()
get_type_embedding_net_variables_from_graph_def()
get_variables_from_graph_def_as_numpy_array()
load_graph_def()
- deepmd.tf.utils.learning_rate module
- deepmd.tf.utils.multi_init module
- deepmd.tf.utils.neighbor_stat module
- deepmd.tf.utils.network module
- deepmd.tf.utils.nlist module
- deepmd.tf.utils.pair_tab module
- deepmd.tf.utils.parallel_op module
- deepmd.tf.utils.path module
- deepmd.tf.utils.plugin module
- deepmd.tf.utils.random module
- deepmd.tf.utils.region module
- deepmd.tf.utils.serialization module
- deepmd.tf.utils.sess module
- deepmd.tf.utils.spin module
- deepmd.tf.utils.tabulate module
- deepmd.tf.utils.type_embed module
- deepmd.tf.utils.update_sel module
- deepmd.tf.utils.weight_avg module
Submodules
deepmd.tf.calculator module
- class deepmd.tf.calculator.DP(model: Union[str, Path], label: str = 'DP', type_dict: Optional[Dict[str, int]] = None, neighbor_list=None, **kwargs)[source]
Bases:
Calculator
Implementation of ASE deepmd calculator.
Implemented propertie are energy, forces and stress
- Parameters
- model
Union
[str
,Path
] path to the model
- label
str
,optional
calculator label, by default “DP”
- type_dict
Dict
[str
,int
],optional
mapping of element types and their numbers, best left None and the calculator will infer this information from model, by default None
- neighbor_list
ase.neighborlist.NeighborList
,optional
The neighbor list object. If None, then build the native neighbor list.
- model
Examples
Compute potential energy
>>> from ase import Atoms >>> from deepmd.tf.calculator import DP >>> water = Atoms('H2O', >>> positions=[(0.7601, 1.9270, 1), >>> (1.9575, 1, 1), >>> (1., 1., 1.)], >>> cell=[100, 100, 100], >>> calculator=DP(model="frozen_model.pb")) >>> print(water.get_potential_energy()) >>> print(water.get_forces())
Run BFGS structure optimization
>>> from ase.optimize import BFGS >>> dyn = BFGS(water) >>> dyn.run(fmax=1e-6) >>> print(water.get_positions())
- Attributes
- directory
- label
Methods
band_structure
()Create band-structure object for plotting.
calculate
([atoms, properties, system_changes])Run calculation with deepmd model.
calculate_numerical_forces
(atoms[, d])Calculate numerical forces using finite difference.
calculate_numerical_stress
(atoms[, d, voigt])Calculate numerical stress using finite difference.
calculate_properties
(atoms, properties)This method is experimental; currently for internal use.
check_state
(atoms[, tol])Check for any system changes since last calculation.
get_magnetic_moments
([atoms])Calculate magnetic moments projected onto atoms.
get_property
(name[, atoms, allow_calculation])Get the named property.
get_stresses
([atoms])the calculator should return intensive stresses, i.e., such that stresses.sum(axis=0) == stress
read
(label)Read atoms, parameters and calculated properties from output file.
reset
()Clear all information from old calculation.
set
(**kwargs)Set parameters like set(key1=value1, key2=value2, ...).
set_label
(label)Set label and convert label to directory and prefix.
calculation_required
export_properties
get_atoms
get_charges
get_default_parameters
get_dipole_moment
get_forces
get_magnetic_moment
get_potential_energies
get_potential_energy
get_stress
read_atoms
todict
- calculate(atoms: Optional[Atoms] = None, properties: List[str] = ['energy', 'forces', 'virial'], system_changes: List[str] = ['positions', 'numbers', 'cell', 'pbc', 'initial_charges', 'initial_magmoms'])[source]
Run calculation with deepmd model.
- Parameters
- atoms
Optional
[Atoms
],optional
atoms object to run the calculation on, by default None
- properties
List
[str
],optional
unused, only for function signature compatibility, by default [“energy”, “forces”, “stress”]
- system_changes
List
[str
],optional
unused, only for function signature compatibility, by default all_changes
- atoms
- implemented_properties: ClassVar[List[str]] = ['energy', 'free_energy', 'forces', 'virial', 'stress']
Properties calculator can handle (energy, forces, …)
- name = 'DP'
deepmd.tf.common module
Collection of functions and classes used throughout the whole package.
- deepmd.tf.common.add_data_requirement(key: str, ndof: int, atomic: bool = False, must: bool = False, high_prec: bool = False, type_sel: Optional[bool] = None, repeat: int = 1, default: float = 0.0, dtype: Optional[dtype] = None, output_natoms_for_type_sel: bool = False)[source]
Specify data requirements for training.
- Parameters
- key
str
type of data stored in corresponding *.npy file e.g. forces or energy
- ndof
int
number of the degrees of freedom, this is tied to atomic parameter e.g. forces have atomic=True and ndof=3
- atomicbool,
optional
specifies whwther the ndof keyworrd applies to per atom quantity or not, by default False
- mustbool,
optional
specifi if the *.npy data file must exist, by default False
- high_precbool,
optional
if true load data to np.float64 else np.float32, by default False
- type_selbool,
optional
select only certain type of atoms, by default None
- repeat
int
,optional
if specify repaeat data repeat times, by default 1
- default
float
,optional
, default=0. default value of data
- dtype
np.dtype
,optional
the dtype of data, overwrites high_prec if provided
- output_natoms_for_type_selbool,
optional
if True and type_sel is True, the atomic dimension will be natoms instead of nsel
- key
- deepmd.tf.common.cast_precision(func: Callable) Callable [source]
A decorator that casts and casts back the input and output tensor of a method.
The decorator should be used in a classmethod.
The decorator will do the following thing: (1) It casts input Tensors from GLOBAL_TF_FLOAT_PRECISION to precision defined by property precision. (2) It casts output Tensors from precision to GLOBAL_TF_FLOAT_PRECISION. (3) It checks inputs and outputs and only casts when input or output is a Tensor and its dtype matches GLOBAL_TF_FLOAT_PRECISION and precision, respectively. If it does not match (e.g. it is an integer), the decorator will do nothing on it.
- Returns
Callable
a decorator that casts and casts back the input and output tensor of a method
Examples
>>> class A: ... @property ... def precision(self): ... return tf.float32 ... ... @cast_precision ... def f(x: tf.Tensor, y: tf.Tensor) -> tf.Tensor: ... return x**2 + y
- deepmd.tf.common.expand_sys_str(root_dir: Union[str, Path]) List[str] [source]
Recursively iterate over directories taking those that contain type.raw file.
- deepmd.tf.common.gelu(x: Tensor) Tensor [source]
Gaussian Error Linear Unit.
This is a smoother version of the RELU, implemented by custom operator.
- Parameters
- x
tf.Tensor
float Tensor to perform activation
- x
- Returns
tf.Tensor
x with the GELU activation applied
References
Original paper https://arxiv.org/abs/1606.08415
- deepmd.tf.common.gelu_tf(x: Tensor) Tensor [source]
Gaussian Error Linear Unit.
This is a smoother version of the RELU, implemented by TF.
- Parameters
- x
tf.Tensor
float Tensor to perform activation
- x
- Returns
tf.Tensor
x with the GELU activation applied
References
Original paper https://arxiv.org/abs/1606.08415
- deepmd.tf.common.get_activation_func(activation_fn: Optional[_ACTIVATION]) Optional[Callable[[Tensor], Tensor]] [source]
Get activation function callable based on string name.
- Parameters
- activation_fn
_ACTIVATION
one of the defined activation functions
- activation_fn
- Returns
- Raises
RuntimeError
if unknown activation function is specified
- deepmd.tf.common.get_np_precision(precision: _PRECISION) dtype [source]
Get numpy precision constant from string.
- Parameters
- precision
_PRECISION
string name of numpy constant or default
- precision
- Returns
np.dtype
numpy presicion constant
- Raises
RuntimeError
if string is invalid
- deepmd.tf.common.get_precision(precision: _PRECISION) Any [source]
Convert str to TF DType constant.
- Parameters
- precision
_PRECISION
one of the allowed precisions
- precision
- Returns
tf.python.framework.dtypes.DType
appropriate TF constant
- Raises
RuntimeError
if supplied precision string does not have acorresponding TF constant
- deepmd.tf.common.j_loader(filename: Union[str, Path]) Dict[str, Any] [source]
Load yaml or json settings file.
- deepmd.tf.common.j_must_have(jdata: Dict[str, _DICT_VAL], key: str, deprecated_key: List[str] = []) _DICT_VAL [source]
Assert that supplied dictionary conaines specified key.
- Returns
_DICT_VAL
value that was store unde supplied key
- Raises
RuntimeError
if the key is not present
- deepmd.tf.common.make_default_mesh(pbc: bool, mixed_type: bool) ndarray [source]
Make mesh.
Only the size of mesh matters, not the values: * 6 for PBC, no mixed types * 0 for no PBC, no mixed types * 7 for PBC, mixed types * 1 for no PBC, mixed types
- Parameters
- Returns
np.ndarray
mesh
- deepmd.tf.common.safe_cast_tensor(input: Tensor, from_precision: DType, to_precision: DType) Tensor [source]
Convert a Tensor from a precision to another precision.
If input is not a Tensor or without the specific precision, the method will not cast it.
- deepmd.tf.common.select_idx_map(atom_types: ndarray, select_types: ndarray) ndarray [source]
Build map of indices for element supplied element types from all atoms list.
- Parameters
- atom_types
np.ndarray
array specifing type for each atoms as integer
- select_types
np.ndarray
types of atoms you want to find indices for
- atom_types
- Returns
np.ndarray
indices of types of atoms defined by select_types in atom_types array
Warning
select_types array will be sorted before finding indices in atom_types
deepmd.tf.env module
Module that sets tensorflow working environment and exports inportant constants.
- deepmd.tf.env.GLOBAL_ENER_FLOAT_PRECISION
alias of
float64
- deepmd.tf.env.GLOBAL_NP_FLOAT_PRECISION
alias of
float64
- deepmd.tf.env.global_cvt_2_ener_float(xx: Tensor) Tensor [source]
Cast tensor to globally set energy precision.
deepmd.tf.lmp module
Register entry points for lammps-wheel.
- deepmd.tf.lmp.get_env(paths: List[Optional[str]]) str [source]
Get the environment variable from given paths.