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)
| 75 | |
| 76 | |
| 77 | def 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 |
no test coverage detected