deepmd.tf.common
Collection of functions and classes used throughout the whole package. Specify data requirements for training. Recursively iterate over directories taking those that contain type.raw file. Get numpy precision constant from string. Load yaml or json settings file. Assert that supplied dictionary conaines specified key. Make mesh. Build map of indices for element supplied element types from all atoms list. Gaussian Error Linear Unit. Gaussian Error Linear Unit. Get activation function callable based on string name. Convert str to TF DType constant. Convert a Tensor from a precision to another precision. A decorator that casts and casts back the input Reset all state generated by DeePMD-kit. Specify data requirements for training. type of data stored in corresponding *.npy file e.g. forces or energy number of the degrees of freedom, this is tied to atomic parameter e.g. forces have atomic=True and ndof=3 specifies whwther the ndof keyworrd applies to per atom quantity or not, by default False specifi if the *.npy data file must exist, by default False if true load data to np.float64 else np.float32, by default False select only certain type of atoms, by default None if specify repaeat data repeat times, by default 1 default value of data the dtype of data, overwrites high_prec if provided if True and type_sel is True, the atomic dimension will be natoms instead of nsel Recursively iterate over directories taking those that contain type.raw file. Get numpy precision constant from string. string name of numpy constant or default numpy presicion constant if string is invalid Load yaml or json settings file. Assert that supplied dictionary conaines specified key. value that was store unde supplied key if the key is not present 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 mesh Build map of indices for element supplied element types from all atoms list. array specifing type for each atoms as integer types of atoms you want to find indices for 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 Gaussian Error Linear Unit. This is a smoother version of the RELU, implemented by custom operator. float Tensor to perform activation x with the GELU activation applied References Original paper https://arxiv.org/abs/1606.08415 Gaussian Error Linear Unit. This is a smoother version of the RELU, implemented by TF. float Tensor to perform activation x with the GELU activation applied References Original paper https://arxiv.org/abs/1606.08415 Get activation function callable based on string name. one of the defined activation functions if unknown activation function is specified Convert str to TF DType constant. one of the allowed precisions appropriate TF constant if supplied precision string does not have acorresponding TF constant 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. 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. a decorator that casts and casts back the input and output tensor of a method ExamplesModule Contents
Functions
add_data_requirement
(key, ndof[, atomic, must, ...])expand_sys_str
(→ List[str])get_np_precision
(→ numpy.dtype)j_loader
(→ Dict[str, Any])j_must_have
(→ _DICT_VAL)make_default_mesh
(→ numpy.ndarray)select_idx_map
(→ numpy.ndarray)gelu
(→ deepmd.tf.env.tf.Tensor)gelu_tf
(→ deepmd.tf.env.tf.Tensor)get_activation_func
(...)get_precision
(→ Any)safe_cast_tensor
(→ deepmd.tf.env.tf.Tensor)cast_precision
(→ Callable)Attributes
str
int
optional
optional
optional
optional
int
, optional
float
, optional
, default=0.np.dtype
, optional
optional
_PRECISION
np.dtype
RuntimeError
_DICT_VAL
RuntimeError
np.ndarray
np.ndarray
np.ndarray
np.ndarray
tf.Tensor
tf.Tensor
tf.Tensor
tf.Tensor
_ACTIVATION
RuntimeError
_PRECISION
tf.python.framework.dtypes.DType
RuntimeError
Callable
>>> 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