If you have a trained graph containing Variable ops, it can be convenient to
convert them all to Const ops holding the same values. This makes it possible
to describe the network fully with a single GraphDef file, and allows the
removal of a lot of ops related to loading and saving the variables.
Args
sess
Active TensorFlow session containing the variables.
input_graph_def
GraphDef object holding the network.
output_node_names
List of name strings for the result nodes of the graph.
variable_names_whitelist
The set of variable names to convert (by default,
all variables are converted).
variable_names_blacklist
The set of variable names to omit converting to
constants.
Returns
GraphDef containing a simplified version of the original.
Raises
RuntimeError
if a DT_RESOURCE op is found whose ancestor Variables are both
denylisted AND whitelisted for freezing.
[null,null,["Last updated 2024-04-26 UTC."],[],[],null,["# tf.compat.v1.graph_util.convert_variables_to_constants\n\n\u003cbr /\u003e\n\n|------------------------------------------------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v2.16.1/tensorflow/python/framework/convert_to_constants.py#L1295-L1336) |\n\nReplaces all the variables in a graph with constants of the same values. (deprecated) \n\n tf.compat.v1.graph_util.convert_variables_to_constants(\n sess,\n input_graph_def,\n output_node_names,\n variable_names_whitelist=None,\n variable_names_blacklist=None\n )\n\n| **Deprecated:** THIS FUNCTION IS DEPRECATED. It will be removed in a future version. Instructions for updating: This API was designed for TensorFlow v1. See \u003chttps://www.tensorflow.org/guide/migrate\u003e for instructions on how to migrate your code to TensorFlow v2.\n\nIf you have a trained graph containing Variable ops, it can be convenient to\nconvert them all to Const ops holding the same values. This makes it possible\nto describe the network fully with a single GraphDef file, and allows the\nremoval of a lot of ops related to loading and saving the variables.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|----------------------------|---------------------------------------------------------------------------------|\n| `sess` | Active TensorFlow session containing the variables. |\n| `input_graph_def` | GraphDef object holding the network. |\n| `output_node_names` | List of name strings for the result nodes of the graph. |\n| `variable_names_whitelist` | The set of variable names to convert (by default, all variables are converted). |\n| `variable_names_blacklist` | The set of variable names to omit converting to constants. |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ------- ||\n|---|---|\n| GraphDef containing a simplified version of the original. ||\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Raises ------ ||\n|----------------|---------------------------------------------------------------------------------------------------------|\n| `RuntimeError` | if a DT_RESOURCE op is found whose ancestor Variables are both denylisted AND whitelisted for freezing. |\n\n\u003cbr /\u003e"]]