# tf.keras.backend.reshape

<br />

|---|---|
| [![](https://www.tensorflow.org/images/tf_logo_32px.png) TensorFlow 1 version](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/keras/backend/reshape) | [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v2.1.0/tensorflow/python/keras/backend.py#L2687-L2713) |

Reshapes a tensor to the specified shape.

#### View aliases


**Compat aliases for migration**

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

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

<br />

    tf.keras.backend.reshape(
        x, shape
    )

<br />

<br />

<br />

| ## Arguments ||
|---|---|
| `x` | Tensor or variable. |
| `shape` | Target shape tuple. |

<br />

<br />

<br />

<br />

| ## Returns ||
|---|---|
| A tensor. ||

<br />

#### Example:

    a = tf.constant([[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12]])
    a
    <tf.Tensor: shape=(4, 3), dtype=int32, numpy=
    array([[ 1,  2,  3],
           [ 4,  5,  6],
           [ 7,  8,  9],
           [10, 11, 12]], dtype=int32)>
    tf.keras.backend.reshape(a, shape=(2, 6))
    <tf.Tensor: shape=(2, 6), dtype=int32, numpy=
    array([[ 1,  2,  3,  4,  5,  6],
           [ 7,  8,  9, 10, 11, 12]], dtype=int32)>