MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / import_graph_def

Function import_graph_def

tensorflow/python/framework/importer.py:351–405  ·  view source on GitHub ↗

Imports the graph from `graph_def` into the current default `Graph`. This function provides a way to import a serialized TensorFlow [`GraphDef`](https://www.tensorflow.org/code/tensorflow/core/framework/graph.proto) protocol buffer, and extract individual objects in the `GraphDef` as `tf.Te

(graph_def,
                     input_map=None,
                     return_elements=None,
                     name=None,
                     op_dict=None,
                     producer_op_list=None)

Source from the content-addressed store, hash-verified

349 'https://github.com/tensorflow/tensorflow/issues if you depend'
350 ' on this feature.', 'op_dict')
351def import_graph_def(graph_def,
352 input_map=None,
353 return_elements=None,
354 name=None,
355 op_dict=None,
356 producer_op_list=None):
357 """Imports the graph from `graph_def` into the current default `Graph`.
358
359 This function provides a way to import a serialized TensorFlow
360 [`GraphDef`](https://www.tensorflow.org/code/tensorflow/core/framework/graph.proto)
361 protocol buffer, and extract individual objects in the `GraphDef` as
362 `tf.Tensor` and `tf.Operation` objects. Once extracted,
363 these objects are placed into the current default `Graph`. See
364 `tf.Graph.as_graph_def` for a way to create a `GraphDef`
365 proto.
366
367 Args:
368 graph_def: A `GraphDef` proto containing operations to be imported into
369 the default graph.
370 input_map: A dictionary mapping input names (as strings) in `graph_def`
371 to `Tensor` objects. The values of the named input tensors in the
372 imported graph will be re-mapped to the respective `Tensor` values.
373 return_elements: A list of strings containing operation names in
374 `graph_def` that will be returned as `Operation` objects; and/or
375 tensor names in `graph_def` that will be returned as `Tensor` objects.
376 name: (Optional.) A prefix that will be prepended to the names in
377 `graph_def`. Note that this does not apply to imported function names.
378 Defaults to `"import"`.
379 op_dict: (Optional.) Deprecated, do not use.
380 producer_op_list: (Optional.) An `OpList` proto with the (possibly stripped)
381 list of `OpDef`s used by the producer of the graph. If provided,
382 unrecognized attrs for ops in `graph_def` that have their default value
383 according to `producer_op_list` will be removed. This will allow some more
384 `GraphDef`s produced by later binaries to be accepted by earlier binaries.
385
386 Returns:
387 A list of `Operation` and/or `Tensor` objects from the imported graph,
388 corresponding to the names in `return_elements`,
389 and None if `returns_elements` is None.
390
391 Raises:
392 TypeError: If `graph_def` is not a `GraphDef` proto,
393 `input_map` is not a dictionary mapping strings to `Tensor` objects,
394 or `return_elements` is not a list of strings.
395 ValueError: If `input_map`, or `return_elements` contains names that
396 do not appear in `graph_def`, or `graph_def` is not well-formed (e.g.
397 it refers to an unknown tensor).
398 """
399 return _import_graph_def_internal(
400 graph_def,
401 input_map=input_map,
402 return_elements=return_elements,
403 name=name,
404 op_dict=op_dict,
405 producer_op_list=producer_op_list)
406
407
408def import_graph_def_for_function( # pylint: disable=invalid-name

Callers

nothing calls this directly

Calls 1

Tested by

no test coverage detected