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

Function import_scoped_meta_graph

tensorflow/python/framework/meta_graph.py:658–708  ·  view source on GitHub ↗

Recreates a `Graph` saved in a `MetaGraphDef` proto. This function takes a `MetaGraphDef` protocol buffer as input. If the argument is a file containing a `MetaGraphDef` protocol buffer , it constructs a protocol buffer from the file content. The function then adds all the nodes from the `g

(meta_graph_or_file,
                             clear_devices=False,
                             graph=None,
                             import_scope=None,
                             input_map=None,
                             unbound_inputs_col_name="unbound_inputs",
                             restore_collections_predicate=(lambda key: True))

Source from the content-addressed store, hash-verified

656
657
658def import_scoped_meta_graph(meta_graph_or_file,
659 clear_devices=False,
660 graph=None,
661 import_scope=None,
662 input_map=None,
663 unbound_inputs_col_name="unbound_inputs",
664 restore_collections_predicate=(lambda key: True)):
665 """Recreates a `Graph` saved in a `MetaGraphDef` proto.
666
667 This function takes a `MetaGraphDef` protocol buffer as input. If
668 the argument is a file containing a `MetaGraphDef` protocol buffer ,
669 it constructs a protocol buffer from the file content. The function
670 then adds all the nodes from the `graph_def` field to the
671 current graph, recreates the desired collections, and returns a dictionary of
672 all the Variables imported into the name scope.
673
674 In combination with `export_scoped_meta_graph()`, this function can be used to
675
676 * Serialize a graph along with other Python objects such as `QueueRunner`,
677 `Variable` into a `MetaGraphDef`.
678
679 * Restart training from a saved graph and checkpoints.
680
681 * Run inference from a saved graph and checkpoints.
682
683 Args:
684 meta_graph_or_file: `MetaGraphDef` protocol buffer or filename (including
685 the path) containing a `MetaGraphDef`.
686 clear_devices: Boolean which controls whether to clear device information
687 from graph_def. Default false.
688 graph: The `Graph` to import into. If `None`, use the default graph.
689 import_scope: Optional `string`. Name scope into which to import the
690 subgraph. If `None`, the graph is imported to the root name scope.
691 input_map: A dictionary mapping input names (as strings) in `graph_def` to
692 `Tensor` objects. The values of the named input tensors in the imported
693 graph will be re-mapped to the respective `Tensor` values.
694 unbound_inputs_col_name: Collection name for looking up unbound inputs.
695 restore_collections_predicate: a predicate on collection names. A collection
696 named c (i.e whose key is c) will be restored iff
697 1) `restore_collections_predicate(c)` is True, and
698 2) `c != unbound_inputs_col_name`.
699
700 Returns:
701 A dictionary of all the `Variables` imported into the name scope.
702
703 Raises:
704 ValueError: If the graph_def contains unbound inputs.
705 """
706 return import_scoped_meta_graph_with_return_elements(
707 meta_graph_or_file, clear_devices, graph, import_scope, input_map,
708 unbound_inputs_col_name, restore_collections_predicate)[0]
709
710
711def import_scoped_meta_graph_with_return_elements(

Callers 1

copy_scoped_meta_graphFunction · 0.85

Tested by

no test coverage detected