# tf.compat.v1.graph_util.remove_training_nodes

<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v2.13.1/tensorflow/python/framework/graph_util_impl.py#L279-L376) |

Prunes out nodes that aren't needed for inference. (deprecated)

    tf.compat.v1.graph_util.remove_training_nodes(
        input_graph, protected_nodes=None
    )

> [!WARNING]
> **Deprecated:** THIS FUNCTION IS DEPRECATED. It will be removed in a future version. Instructions for updating: This API was designed for TensorFlow v1. See <https://www.tensorflow.org/guide/migrate> for instructions on how to migrate your code to TensorFlow v2.

There are nodes like Identity and CheckNumerics that are only useful
during training, and can be removed in graphs that will be used for
nothing but inference. Here we identify and remove them, returning an
equivalent graph. To be specific, CheckNumerics nodes are always removed, and
Identity nodes that aren't involved in control edges are spliced out so that
their input and outputs are directly connected.

<br />

<br />

<br />

| ## Args ||
|---|---|
| `input_graph` | Model to analyze and prune. |
| `protected_nodes` | An optional list of names of nodes to be kept unconditionally. This is for example useful to preserve Identity output nodes. |

<br />

<br />

<br />

<br />

| ## Returns ||
|---|---|
| A list of nodes with the unnecessary ones removed. ||

<br />