tf.keras.backend.repeat

TensorFlow 1 version View source on GitHub

Repeats a 2D tensor.

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

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

Arguments:

  • x: Tensor or variable.
  • n: Python integer, number of times to repeat.

Returns:

A tensor.

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)&gt;
    &gt;&gt;&gt; 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)&gt;
  

Compat aliases