deepmd.tf.utils.tabulate

Module Contents

Classes

DPTabulate

Class for tabulation.

Attributes

log

deepmd.tf.utils.tabulate.log[source]
class deepmd.tf.utils.tabulate.DPTabulate(descrpt: deepmd.tf.descriptor.Descriptor, neuron: List[int], graph: deepmd.tf.env.tf.Graph, graph_def: deepmd.tf.env.tf.GraphDef, type_one_side: bool = False, exclude_types: List[List[int]] = [], activation_fn: Callable[[deepmd.tf.env.tf.Tensor], deepmd.tf.env.tf.Tensor] = tf.nn.tanh, suffix: str = '')[source]

Class for tabulation.

Compress a model, which including tabulating the embedding-net. The table is composed of fifth-order polynomial coefficients and is assembled from two sub-tables. The first table takes the stride(parameter) as it’s uniform stride, while the second table takes 10 * stride as it’s uniform stride The range of the first table is automatically detected by deepmd-kit, while the second table ranges from the first table’s upper boundary(upper) to the extrapolate(parameter) * upper.

Parameters:
descrpt

Descriptor of the original model

neuron

Number of neurons in each hidden layers of the embedding net \(\\mathcal{N}\)

graphtf.Graph

The graph of the original model

graph_deftf.GraphDef

The graph_def of the original model

type_one_side

Try to build N_types tables. Otherwise, building N_types^2 tables

exclude_typesList[List[int]]

The excluded pairs of types which have no interaction with each other. For example, [[0, 1]] means no interaction between type 0 and type 1.

activation_function

The activation function in the embedding net. Supported options are {“tanh”,”gelu”} in common.ACTIVATION_FN_DICT.

suffixstr, optional

The suffix of the scope

property _n_all_excluded: int[source]

Then number of types excluding all types.

build(min_nbor_dist: float, extrapolate: float, stride0: float, stride1: float) Tuple[Dict[str, int], Dict[str, int]][source]

Build the tables for model compression.

Parameters:
min_nbor_dist

The nearest distance between neighbor atoms

extrapolate

The scale of model extrapolation

stride0

The uniform stride of the first table

stride1

The uniform stride of the second table

Returns:
lowerdict[str, int]

The lower boundary of environment matrix by net

upperdict[str, int]

The upper boundary of environment matrix by net

_build_lower(net, xx, idx, upper, lower, stride0, stride1, extrapolate, nspline)[source]
_load_sub_graph()[source]
_get_bias()[source]
_get_matrix()[source]
_make_data(xx, idx)[source]
_layer_0(x, w, b)[source]
_layer_1(x, w, b)[source]
_get_env_mat_range(min_nbor_dist)[source]
_spline5_switch(xx, rmin, rmax)[source]
_get_layer_size()[source]
_all_excluded(ii: int) bool[source]

Check if type ii excluds all types.

Parameters:
iiint

type index

Returns:
bool

if type ii excluds all types

_get_table_size()[source]
_get_data_type()[source]
_get_last_layer_size()[source]
_convert_numpy_to_tensor()[source]

Convert self.data from np.ndarray to tf.Tensor.