Converts all variables in a graph and checkpoint into constants. Args: input_graph: A `GraphDef` file to load. input_saver: A TensorFlow Saver file. input_binary: A Bool. True means input_graph is .pb, False indicates .pbtxt. input_checkpoint: The prefix of a V1 or V2 checkpoint,
(input_graph,
input_saver,
input_binary,
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=None,
input_saved_model_dir=None,
saved_model_tags=tag_constants.SERVING,
checkpoint_version=saver_pb2.SaverDef.V2)
| 284 | |
| 285 | |
| 286 | def freeze_graph(input_graph, |
| 287 | input_saver, |
| 288 | input_binary, |
| 289 | input_checkpoint, |
| 290 | output_node_names, |
| 291 | restore_op_name, |
| 292 | filename_tensor_name, |
| 293 | output_graph, |
| 294 | clear_devices, |
| 295 | initializer_nodes, |
| 296 | variable_names_whitelist="", |
| 297 | variable_names_blacklist="", |
| 298 | input_meta_graph=None, |
| 299 | input_saved_model_dir=None, |
| 300 | saved_model_tags=tag_constants.SERVING, |
| 301 | checkpoint_version=saver_pb2.SaverDef.V2): |
| 302 | """Converts all variables in a graph and checkpoint into constants. |
| 303 | |
| 304 | Args: |
| 305 | input_graph: A `GraphDef` file to load. |
| 306 | input_saver: A TensorFlow Saver file. |
| 307 | input_binary: A Bool. True means input_graph is .pb, False indicates .pbtxt. |
| 308 | input_checkpoint: The prefix of a V1 or V2 checkpoint, with V2 taking |
| 309 | priority. Typically the result of `Saver.save()` or that of |
| 310 | `tf.train.latest_checkpoint()`, regardless of sharded/non-sharded or |
| 311 | V1/V2. |
| 312 | output_node_names: The name(s) of the output nodes, comma separated. |
| 313 | restore_op_name: Unused. |
| 314 | filename_tensor_name: Unused. |
| 315 | output_graph: String where to write the frozen `GraphDef`. |
| 316 | clear_devices: A Bool whether to remove device specifications. |
| 317 | initializer_nodes: Comma separated list of initializer nodes to run before |
| 318 | freezing. |
| 319 | variable_names_whitelist: The set of variable names to convert (optional, by |
| 320 | default, all variables are converted), |
| 321 | variable_names_blacklist: The set of variable names to omit converting |
| 322 | to constants (optional). |
| 323 | input_meta_graph: A `MetaGraphDef` file to load (optional). |
| 324 | input_saved_model_dir: Path to the dir with TensorFlow 'SavedModel' file and |
| 325 | variables (optional). |
| 326 | saved_model_tags: Group of comma separated tag(s) of the MetaGraphDef to |
| 327 | load, in string format. |
| 328 | checkpoint_version: Tensorflow variable file format (saver_pb2.SaverDef.V1 |
| 329 | or saver_pb2.SaverDef.V2). |
| 330 | Returns: |
| 331 | String that is the location of frozen GraphDef. |
| 332 | """ |
| 333 | input_graph_def = None |
| 334 | if input_saved_model_dir: |
| 335 | input_graph_def = saved_model_utils.get_meta_graph_def( |
| 336 | input_saved_model_dir, saved_model_tags).graph_def |
| 337 | elif input_graph: |
| 338 | input_graph_def = _parse_input_graph_proto(input_graph, input_binary) |
| 339 | input_meta_graph_def = None |
| 340 | if input_meta_graph: |
| 341 | input_meta_graph_def = _parse_input_meta_graph_proto( |
| 342 | input_meta_graph, input_binary) |
| 343 | input_saver_def = None |
no test coverage detected