# tf.repeat

<br />

|---|---|
| [![](https://www.tensorflow.org/images/tf_logo_32px.png) TensorFlow 2 version](https://www.tensorflow.org/api_docs/python/tf/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/ops/array_ops.py#L4893-L4927) |

Repeat elements of `input`

#### View aliases


**Compat aliases for migration**

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

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

<br />

    tf.repeat(
        input, repeats, axis=None, name=None
    )

<br />

<br />

<br />

| ## Args ||
|---|---|
| `input` | An `N`-dimensional Tensor. |
| `repeats` | An 1-D `int` Tensor. The number of repetitions for each element. repeats is broadcasted to fit the shape of the given axis. `len(repeats)` must equal `input.shape[axis]` if axis is not None. |
| `axis` | An int. The axis along which to repeat values. By default (axis=None), use the flattened input array, and return a flat output array. |
| `name` | A name for the operation. |

<br />

<br />

<br />

<br />

| ## Returns ||
|---|---|
| A Tensor which has the same shape as `input`, except along the given axis. If axis is None then the output array is flattened to match the flattened input array. ||

<br />

#### Examples:

>     >>> repeat(['a', 'b', 'c'], repeats=[3, 0, 2], axis=0)
>     ['a', 'a', 'a', 'c', 'c']
>     >>> repeat([[1, 2], [3, 4]], repeats=[2, 3], axis=0)
>     [[1, 2], [1, 2], [3, 4], [3, 4], [3, 4]]
>     >>> repeat([[1, 2], [3, 4]], repeats=[2, 3], axis=1)
>     [[1, 1, 2, 2, 2], [3, 3, 4, 4, 4]]
>     >>> repeat(3, repeats=4)
>     [3, 3, 3, 3]
>     >>> repeat([[1,2], [3,4]], repeats=2)
>     [1, 1, 2, 2, 3, 3, 4, 4]