deepmd.tf.utils.graph

Module Contents

Functions

load_graph_def(→ Tuple[deepmd.tf.env.tf.Graph, ...)

Load graph as well as the graph_def from the frozen model(model_file).

get_tensor_by_name_from_graph(→ deepmd.tf.env.tf.Tensor)

Load tensor value from the given tf.Graph object.

get_tensor_by_name(→ deepmd.tf.env.tf.Tensor)

Load tensor value from the frozen model(model_file).

get_pattern_nodes_from_graph_def(→ Dict)

Get the pattern nodes with the given tf.GraphDef object.

get_embedding_net_nodes_from_graph_def(→ Dict)

Get the embedding net nodes with the given tf.GraphDef object.

get_embedding_net_nodes(→ Dict)

Get the embedding net nodes with the given frozen model(model_file).

get_embedding_net_variables_from_graph_def(→ Dict)

Get the embedding net variables with the given tf.GraphDef object.

get_extra_embedding_net_suffix(type_one_side)

Get the extra embedding net suffix according to the value of type_one_side.

get_variables_from_graph_def_as_numpy_array(graph_def, ...)

Get variables from the given tf.GraphDef object, with numpy array returns.

get_extra_embedding_net_variables_from_graph_def(...)

Get extra embedding net variables from the given tf.GraphDef object.

get_embedding_net_variables(→ Dict)

Get the embedding net variables with the given frozen model(model_file).

get_fitting_net_nodes_from_graph_def(→ Dict)

Get the fitting net nodes with the given tf.GraphDef object.

get_fitting_net_nodes(→ Dict)

Get the fitting net nodes with the given frozen model(model_file).

get_fitting_net_variables_from_graph_def(→ Dict)

Get the fitting net variables with the given tf.GraphDef object.

get_fitting_net_variables(→ Dict)

Get the fitting net variables with the given frozen model(model_file).

get_type_embedding_net_nodes_from_graph_def(→ Dict)

Get the type embedding net nodes with the given tf.GraphDef object.

get_type_embedding_net_variables_from_graph_def(→ Dict)

Get the type embedding net variables with the given tf.GraphDef object.

get_attention_layer_nodes_from_graph_def(→ Dict)

Get the attention layer nodes with the given tf.GraphDef object.

get_attention_layer_variables_from_graph_def(→ Dict)

Get the attention layer variables with the given tf.GraphDef object.

convert_tensor_to_ndarray_in_dict(→ Dict[str, ...)

Convert tensor to ndarray in dict.

deepmd.tf.utils.graph.load_graph_def(model_file: str) Tuple[deepmd.tf.env.tf.Graph, deepmd.tf.env.tf.GraphDef][source]

Load graph as well as the graph_def from the frozen model(model_file).

Parameters:
model_filestr

The input frozen model path

Returns:
tf.Graph

The graph loaded from the frozen model

tf.GraphDef

The graph_def loaded from the frozen model

deepmd.tf.utils.graph.get_tensor_by_name_from_graph(graph: deepmd.tf.env.tf.Graph, tensor_name: str) deepmd.tf.env.tf.Tensor[source]

Load tensor value from the given tf.Graph object.

Parameters:
graphtf.Graph

The input TensorFlow graph

tensor_namestr

Indicates which tensor which will be loaded from the frozen model

Returns:
tf.Tensor

The tensor which was loaded from the frozen model

Raises:
GraphWithoutTensorError

Whether the tensor_name is within the frozen model

deepmd.tf.utils.graph.get_tensor_by_name(model_file: str, tensor_name: str) deepmd.tf.env.tf.Tensor[source]

Load tensor value from the frozen model(model_file).

Parameters:
model_filestr

The input frozen model path

tensor_namestr

Indicates which tensor which will be loaded from the frozen model

Returns:
tf.Tensor

The tensor which was loaded from the frozen model

Raises:
GraphWithoutTensorError

Whether the tensor_name is within the frozen model

deepmd.tf.utils.graph.get_pattern_nodes_from_graph_def(graph_def: deepmd.tf.env.tf.GraphDef, pattern: str) Dict[source]

Get the pattern nodes with the given tf.GraphDef object.

Parameters:
graph_def

The input tf.GraphDef object

pattern

The node pattern within the graph_def

Returns:
Dict

The fitting net nodes within the given tf.GraphDef object

deepmd.tf.utils.graph.get_embedding_net_nodes_from_graph_def(graph_def: deepmd.tf.env.tf.GraphDef, suffix: str = '') Dict[source]

Get the embedding net nodes with the given tf.GraphDef object.

Parameters:
graph_def

The input tf.GraphDef object

suffixstr, optional

The scope suffix

Returns:
Dict

The embedding net nodes within the given tf.GraphDef object

deepmd.tf.utils.graph.get_embedding_net_nodes(model_file: str, suffix: str = '') Dict[source]

Get the embedding net nodes with the given frozen model(model_file).

Parameters:
model_file

The input frozen model path

suffixstr, optional

The suffix of the scope

Returns:
Dict

The embedding net nodes with the given frozen model

deepmd.tf.utils.graph.get_embedding_net_variables_from_graph_def(graph_def: deepmd.tf.env.tf.GraphDef, suffix: str = '') Dict[source]

Get the embedding net variables with the given tf.GraphDef object.

Parameters:
graph_def

The input tf.GraphDef object

suffixstr, optional

The suffix of the scope

Returns:
Dict

The embedding net variables within the given tf.GraphDef object

deepmd.tf.utils.graph.get_extra_embedding_net_suffix(type_one_side: bool)[source]

Get the extra embedding net suffix according to the value of type_one_side.

Parameters:
type_one_side

The value of type_one_side

Returns:
str

The extra embedding net suffix

deepmd.tf.utils.graph.get_variables_from_graph_def_as_numpy_array(graph_def: deepmd.tf.env.tf.GraphDef, pattern: str)[source]

Get variables from the given tf.GraphDef object, with numpy array returns.

Parameters:
graph_def

The input tf.GraphDef object

patternstr

The name of variable

Returns:
np.ndarray

The numpy array of the variable

deepmd.tf.utils.graph.get_extra_embedding_net_variables_from_graph_def(graph_def: deepmd.tf.env.tf.GraphDef, suffix: str, extra_suffix: str, layer_size: int)[source]

Get extra embedding net variables from the given tf.GraphDef object. The “extra embedding net” means the embedding net with only type embeddings input, which occurs in “se_atten_v2” and “se_a_ebd_v2” descriptor.

Parameters:
graph_def

The input tf.GraphDef object

suffixstr

The “common” suffix in the descriptor

extra_suffixstr

This value depends on the value of “type_one_side”. It should always be “_one_side_ebd” or “_two_side_ebd”

layer_sizeint

The layer size of the embedding net

Returns:
Dict

The extra embedding net variables within the given tf.GraphDef object

deepmd.tf.utils.graph.get_embedding_net_variables(model_file: str, suffix: str = '') Dict[source]

Get the embedding net variables with the given frozen model(model_file).

Parameters:
model_file

The input frozen model path

suffixstr, optional

The suffix of the scope

Returns:
Dict

The embedding net variables within the given frozen model

deepmd.tf.utils.graph.get_fitting_net_nodes_from_graph_def(graph_def: deepmd.tf.env.tf.GraphDef, suffix: str = '') Dict[source]

Get the fitting net nodes with the given tf.GraphDef object.

Parameters:
graph_def

The input tf.GraphDef object

suffix

suffix of the scope

Returns:
Dict

The fitting net nodes within the given tf.GraphDef object

deepmd.tf.utils.graph.get_fitting_net_nodes(model_file: str) Dict[source]

Get the fitting net nodes with the given frozen model(model_file).

Parameters:
model_file

The input frozen model path

Returns:
Dict

The fitting net nodes with the given frozen model

deepmd.tf.utils.graph.get_fitting_net_variables_from_graph_def(graph_def: deepmd.tf.env.tf.GraphDef, suffix: str = '') Dict[source]

Get the fitting net variables with the given tf.GraphDef object.

Parameters:
graph_def

The input tf.GraphDef object

suffix

suffix of the scope

Returns:
Dict

The fitting net variables within the given tf.GraphDef object

deepmd.tf.utils.graph.get_fitting_net_variables(model_file: str, suffix: str = '') Dict[source]

Get the fitting net variables with the given frozen model(model_file).

Parameters:
model_file

The input frozen model path

suffix

suffix of the scope

Returns:
Dict

The fitting net variables within the given frozen model

deepmd.tf.utils.graph.get_type_embedding_net_nodes_from_graph_def(graph_def: deepmd.tf.env.tf.GraphDef, suffix: str = '') Dict[source]

Get the type embedding net nodes with the given tf.GraphDef object.

Parameters:
graph_def

The input tf.GraphDef object

suffixstr, optional

The scope suffix

Returns:
Dict

The type embedding net nodes within the given tf.GraphDef object

deepmd.tf.utils.graph.get_type_embedding_net_variables_from_graph_def(graph_def: deepmd.tf.env.tf.GraphDef, suffix: str = '') Dict[source]

Get the type embedding net variables with the given tf.GraphDef object.

Parameters:
graph_deftf.GraphDef

The input tf.GraphDef object

suffixstr, optional

The suffix of the scope

Returns:
Dict

The embedding net variables within the given tf.GraphDef object

deepmd.tf.utils.graph.get_attention_layer_nodes_from_graph_def(graph_def: deepmd.tf.env.tf.GraphDef, suffix: str = '') Dict[source]

Get the attention layer nodes with the given tf.GraphDef object.

Parameters:
graph_def

The input tf.GraphDef object

suffixstr, optional

The scope suffix

Returns:
Dict

The attention layer nodes within the given tf.GraphDef object

deepmd.tf.utils.graph.get_attention_layer_variables_from_graph_def(graph_def: deepmd.tf.env.tf.GraphDef, suffix: str = '') Dict[source]

Get the attention layer variables with the given tf.GraphDef object.

Parameters:
graph_deftf.GraphDef

The input tf.GraphDef object

suffixstr, optional

The suffix of the scope

Returns:
Dict

The attention layer variables within the given tf.GraphDef object

deepmd.tf.utils.graph.convert_tensor_to_ndarray_in_dict(tensor_dict: Dict[str, deepmd.tf.env.tf.Tensor]) Dict[str, numpy.ndarray][source]

Convert tensor to ndarray in dict.

Parameters:
tensor_dictDict[str, tf.Tensor]

The input tensor dict

Returns:
Dict[str, np.ndarray]

The converted tensor dict