# tf.keras.backend.repeat_elements

<br />

|---|---|
| [![](https://www.tensorflow.org/images/tf_logo_32px.png) TensorFlow 2 version](https://www.tensorflow.org/api_docs/python/tf/keras/backend/repeat_elements) | [![](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#L2752-L2810) |

Repeats the elements of a tensor along an axis, like `np.repeat`.

#### View aliases


**Compat aliases for migration**

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

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

<br />

    tf.keras.backend.repeat_elements(
        x, rep, axis
    )

If `x` has shape `(s1, s2, s3)` and `axis` is `1`, the output
will have shape `(s1, s2 * rep, s3)`.

<br />

<br />

<br />

| ## Arguments ||
|---|---|
| `x` | Tensor or variable. |
| `rep` | Python integer, number of times to repeat. |
| `axis` | Axis along which to repeat. |

<br />

<br />

<br />

<br />

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

<br />

#### Example:

    b = tf.constant([1, 2, 3])
    tf.keras.backend.repeat_elements(b, rep=2, axis=0)
    <tf.Tensor: id=70, shape=(6,), dtype=int32,
        numpy=array([1, 1, 2, 2, 3, 3], dtype=int32)>