# tf.compat.v1.Print

<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v2.14.0/tensorflow/python/ops/logging_ops.py#L64-L118) |

Prints a list of tensors. (deprecated)

    tf.compat.v1.Print(
        input_, data, message=None, first_n=None, summarize=None, name=None
    )

<br />

## Migrate to TF2

<br />

> [!CAUTION]
> **Caution:** This API was designed for TensorFlow v1. Continue reading for details on how to migrate from this API to a native TensorFlow v2 equivalent. See the [TensorFlow v1 to TensorFlow v2 migration guide](https://www.tensorflow.org/guide/migrate) for instructions on how to migrate the rest of your code.

This API is deprecated. Use [`tf.print`](https://www.tensorflow.org/versions/r2.14/api_docs/python/tf/print) instead. [`tf.print`](https://www.tensorflow.org/versions/r2.14/api_docs/python/tf/print) does not need the
`input_` argument.

[`tf.print`](https://www.tensorflow.org/versions/r2.14/api_docs/python/tf/print) works in TF2 when executing eagerly and inside a [`tf.function`](https://www.tensorflow.org/versions/r2.14/api_docs/python/tf/function).

In TF1-styled sessions, an explicit control dependency declaration is needed
to execute the [`tf.print`](https://www.tensorflow.org/versions/r2.14/api_docs/python/tf/print) operation. Refer to the documentation of
[`tf.print`](https://www.tensorflow.org/versions/r2.14/api_docs/python/tf/print) for more details.

<br />

<br />

## Description

> [!WARNING]
> **Deprecated:** THIS FUNCTION IS DEPRECATED. It will be removed after 2018-08-20. Instructions for updating: Use tf.print instead of tf.Print. Note that tf.print returns a no-output operator that directly prints the output. Outside of defuns or eager mode, this operator will not be executed unless it is directly specified in session.run or used as a control dependency for other operators. This is only a concern in graph mode. Below is an example of how to ensure tf.print executes in graph mode:

This is an identity op (behaves like [`tf.identity`](https://www.tensorflow.org/versions/r2.14/api_docs/python/tf/identity)) with the side effect
of printing `data` when evaluating.

> [!NOTE]
> **Note:** This op prints to the standard error. It is not currently compatible with jupyter notebook (printing to the notebook *server's* output, not into the notebook).

<br />

<br />

<br />

| ## Args ||
|---|---|
| `input_` | A tensor passed through this op. |
| `data` | A list of tensors to print out when op is evaluated. |
| `message` | A string, prefix of the error message. |
| `first_n` | Only log `first_n` number of times. Negative numbers log always; this is the default. |
| `summarize` | Only print this many entries of each tensor. If None, then a maximum of 3 elements are printed per input tensor. |
| `name` | A name for the operation (optional). |

<br />

<br />

<br />

<br />

| ## Returns ||
|---|---|
| A `Tensor`. Has the same type and contents as `input_`. <br /> sess = tf.compat.v1.Session() with sess.as_default(): tensor = tf.range(10) print_op = tf.print(tensor) with tf.control_dependencies([print_op]): out = tf.add(tensor, tensor) sess.run(out) <br /> ||

<br />