tf.import_graph_def
tf.import_graph_def
tf.import_graph_def
import_graph_def( graph_def, input_map=None, return_elements=None, name=None, op_dict=None, producer_op_list=None )
Defined in tensorflow/python/framework/importer.py
.
See the guide: Building Graphs > Utility functions
Imports the graph from graph_def
into the current default Graph
.
This function provides a way to import a serialized TensorFlow GraphDef
protocol buffer, and extract individual objects in the GraphDef
as tf.Tensor
and tf.Operation
objects. Once extracted, these objects are placed into the current default Graph
. See tf.Graph.as_graph_def
for a way to create a GraphDef
proto.
Args:
-
graph_def
: AGraphDef
proto containing operations to be imported into the default graph. -
input_map
: A dictionary mapping input names (as strings) ingraph_def
toTensor
objects. The values of the named input tensors in the imported graph will be re-mapped to the respectiveTensor
values. -
return_elements
: A list of strings containing operation names ingraph_def
that will be returned asOperation
objects; and/or tensor names ingraph_def
that will be returned asTensor
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.) A dictionary mapping op type names toOpDef
protos. Must contain anOpDef
proto for each op type named ingraph_def
. If omitted, uses theOpDef
protos registered in the global registry. -
producer_op_list
: (Optional.) AnOpList
proto with the (possibly stripped) list ofOpDef
s used by the producer of the graph. If provided, attrs for ops ingraph_def
that are not inop_dict
that have their default value according toproducer_op_list
will be removed. This will allow some moreGraphDef
s 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
.
Raises:
-
TypeError
: Ifgraph_def
is not aGraphDef
proto,input_map
is not a dictionary mapping strings toTensor
objects, orreturn_elements
is not a list of strings. -
ValueError
: Ifinput_map
, orreturn_elements
contains names that do not appear ingraph_def
, orgraph_def
is not well-formed (e.g. it refers to an unknown tensor).
© 2017 The TensorFlow Authors. All rights reserved.
Licensed under the Creative Commons Attribution License 3.0.
Code samples licensed under the Apache 2.0 License.
https://www.tensorflow.org/api_docs/python/tf/import_graph_def