tf.graph_util.import_graph_def | TensorFlow v2.16.1 (original) (raw)
tf.graph_util.import_graph_def
Stay organized with collections Save and categorize content based on your preferences.
Imports the graph from graph_def
into the current default Graph
. (deprecated arguments)
View aliases
Main aliases
Compat aliases for migration
SeeMigration guide for more details.
tf.compat.v1.graph_util.import_graph_def, tf.compat.v1.import_graph_def
tf.graph_util.import_graph_def(
graph_def,
input_map=None,
return_elements=None,
name=None,
op_dict=None,
producer_op_list=None
)
Used in the notebooks
Used in the guide |
---|
Migrating your TFLite code to TF2 |
This function provides a way to import a serialized TensorFlowGraphDefprotocol buffer, and extract individual objects in the GraphDef
astf.Tensor and tf.Operation objects. Once extracted, these objects are placed into the current default Graph
. Seetf.Graph.as_graph_def for a way to create a GraphDef
proto.
Args | |
---|---|
graph_def | A GraphDef proto containing operations to be imported into the default graph. |
input_map | A dictionary mapping input names (as strings) in graph_defto Tensor objects. The values of the named input tensors in the imported graph will be re-mapped to the respective Tensor values. |
return_elements | A list of strings containing operation names ingraph_def that will be returned as Operation objects; and/or tensor names in graph_def that will be returned as Tensor objects. |
name | (Optional.) A prefix that will be prepended to the names ingraph_def. Note that this does not apply to imported function names. Defaults to "import". |
op_dict | (Optional.) Deprecated, do not use. |
producer_op_list | (Optional.) An OpList proto with the (possibly stripped) list of OpDefs used by the producer of the graph. If provided, unrecognized attrs for ops in graph_def that have their default value according to producer_op_list will be removed. This will allow some moreGraphDefs produced by later binaries to be accepted by earlier binaries. |
Returns |
---|
A list of Operation and/or Tensor objects from the imported graph, corresponding to the names in return_elements, and None if returns_elements is None. |
Raises | |
---|---|
TypeError | If graph_def is not a GraphDef proto,input_map is not a dictionary mapping strings to Tensor objects, or return_elements is not a list of strings. |
ValueError | If input_map, or return_elements contains names that do not appear in graph_def, or graph_def is not well-formed (e.g. it refers to an unknown tensor). |