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

Function freeze_graph_with_def_protos

tensorflow/python/tools/freeze_graph.py:77–240  ·  view source on GitHub ↗

Converts all variables in a graph and checkpoint into constants. Args: input_graph_def: A `GraphDef`. input_saver_def: A `SaverDef` (optional). input_checkpoint: The prefix of a V1 or V2 checkpoint, with V2 taking priority. Typically the result of `Saver.save()` or that of

(input_graph_def,
                                 input_saver_def,
                                 input_checkpoint,
                                 output_node_names,
                                 restore_op_name,
                                 filename_tensor_name,
                                 output_graph,
                                 clear_devices,
                                 initializer_nodes,
                                 variable_names_whitelist="",
                                 variable_names_blacklist="",
                                 input_meta_graph_def=None,
                                 input_saved_model_dir=None,
                                 saved_model_tags=None,
                                 checkpoint_version=saver_pb2.SaverDef.V2)

Source from the content-addressed store, hash-verified

75
76
77def freeze_graph_with_def_protos(input_graph_def,
78 input_saver_def,
79 input_checkpoint,
80 output_node_names,
81 restore_op_name,
82 filename_tensor_name,
83 output_graph,
84 clear_devices,
85 initializer_nodes,
86 variable_names_whitelist="",
87 variable_names_blacklist="",
88 input_meta_graph_def=None,
89 input_saved_model_dir=None,
90 saved_model_tags=None,
91 checkpoint_version=saver_pb2.SaverDef.V2):
92 """Converts all variables in a graph and checkpoint into constants.
93
94 Args:
95 input_graph_def: A `GraphDef`.
96 input_saver_def: A `SaverDef` (optional).
97 input_checkpoint: The prefix of a V1 or V2 checkpoint, with V2 taking
98 priority. Typically the result of `Saver.save()` or that of
99 `tf.train.latest_checkpoint()`, regardless of sharded/non-sharded or
100 V1/V2.
101 output_node_names: The name(s) of the output nodes, comma separated.
102 restore_op_name: Unused.
103 filename_tensor_name: Unused.
104 output_graph: String where to write the frozen `GraphDef`.
105 clear_devices: A Bool whether to remove device specifications.
106 initializer_nodes: Comma separated string of initializer nodes to run before
107 freezing.
108 variable_names_whitelist: The set of variable names to convert (optional, by
109 default, all variables are converted).
110 variable_names_blacklist: The set of variable names to omit converting
111 to constants (optional).
112 input_meta_graph_def: A `MetaGraphDef` (optional),
113 input_saved_model_dir: Path to the dir with TensorFlow 'SavedModel' file
114 and variables (optional).
115 saved_model_tags: Group of comma separated tag(s) of the MetaGraphDef to
116 load, in string format (optional).
117 checkpoint_version: Tensorflow variable file format (saver_pb2.SaverDef.V1
118 or saver_pb2.SaverDef.V2)
119
120 Returns:
121 Location of the output_graph_def.
122 """
123 del restore_op_name, filename_tensor_name # Unused by updated loading code.
124
125 # 'input_checkpoint' may be a prefix if we're using Saver V2 format
126 if (not input_saved_model_dir and
127 not checkpoint_management.checkpoint_exists(input_checkpoint)):
128 raise ValueError("Input checkpoint '" + input_checkpoint +
129 "' doesn't exist!")
130
131 if not output_node_names:
132 raise ValueError(
133 "You need to supply the name of a node to --output_node_names.")
134

Callers 1

freeze_graphFunction · 0.85

Calls 13

restoreMethod · 0.95
anyFunction · 0.85
_has_no_variablesFunction · 0.85
replaceMethod · 0.80
get_operationsMethod · 0.80
get_tensor_by_nameMethod · 0.80
SessionMethod · 0.45
runMethod · 0.45
splitMethod · 0.45
loadMethod · 0.45
valuesMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected