# tf.identity

<br />

|---|---|
| [![](https://www.tensorflow.org/images/tf_logo_32px.png) TensorFlow 1 version](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/identity) | [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v2.6.0/tensorflow/python/ops/array_ops.py#L245-L293) |

Return a Tensor with the same shape and contents as input.

#### View aliases


**Compat aliases for migration**

See
[Migration guide](https://www.tensorflow.org/guide/migrate) for
more details.

[`tf.compat.v1.identity`](https://www.tensorflow.org/api_docs/python/tf/identity)

<br />

    tf.identity(
        input, name=None
    )

The return value is not the same Tensor as the original, but contains the same
values. This operation is fast when used on the same device.

#### For example:

    a = tf.constant([0.78])
    a_identity = tf.identity(a)
    a.numpy()
    array([0.78], dtype=float32)
    a_identity.numpy()
    array([0.78], dtype=float32)

Calling [`tf.identity`](https://www.tensorflow.org/versions/r2.6/api_docs/python/tf/identity) on a variable will make a Tensor that represents the
value of that variable at the time it is called. This is equivalent to calling
`<variable>.read_value()`.

    a = tf.Variable(5)
    a_identity = tf.identity(a)
    a.assign_add(1)
    <tf.Variable ... shape=() dtype=int32, numpy=6>
    a.numpy()
    6
    a_identity.numpy()
    5

<br />

<br />

<br />

| ## Args ||
|---|---|
| `input` | A `Tensor`, a `Variable`, a `CompositeTensor` or anything that can be converted to a tensor using [`tf.convert_to_tensor`](https://www.tensorflow.org/versions/r2.6/api_docs/python/tf/convert_to_tensor). |
| `name` | A name for the operation (optional). |

<br />

<br />

<br />

<br />

| ## Returns ||
|---|---|
| A `Tensor` or CompositeTensor. Has the same type and contents as `input`. ||

<br />