# tf.keras.backend.repeat

<br />

|---|---|
| [![](https://www.tensorflow.org/images/tf_logo_32px.png) TensorFlow 2 version](https://www.tensorflow.org/api_docs/python/tf/keras/backend/repeat) | [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v1.15.0/tensorflow/python/keras/backend.py#L2813-L2845) |

Repeats a 2D tensor.

#### View aliases


**Compat aliases for migration**

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

[`tf.compat.v1.keras.backend.repeat`](https://www.tensorflow.org/api_docs/python/tf/keras/backend/repeat), \`tf.compat.v2.keras.backend.repeat\`

<br />

    tf.keras.backend.repeat(
        x, n
    )

if `x` has shape (samples, dim) and `n` is `2`,
the output will have shape `(samples, 2, dim)`.

<br />

<br />

<br />

| ## Arguments ||
|---|---|
| `x` | Tensor or variable. |
| `n` | Python integer, number of times to repeat. |

<br />

<br />

<br />

<br />

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

<br />

#### Example:

    b = tf.constant([[1, 2], [3, 4]])
    b
    <tf.Tensor: id=78, shape=(2, 2), dtype=int32, numpy=
    array([[1, 2],
           [3, 4]], dtype=int32)>
    tf.keras.backend.repeat(b, n=2)
    <tf.Tensor: id=82, shape=(2, 2, 2), dtype=int32, numpy=
    array([[[1, 2],
            [1, 2]],
           [[3, 4],
            [3, 4]]], dtype=int32)>