tf.keras.backend.repeat
Stay organized with collections
Save and categorize content based on your preferences.
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.
|
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)>
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2020-10-01 UTC.
[null,null,["Last updated 2020-10-01 UTC."],[],[],null,["# tf.keras.backend.repeat\n\n\u003cbr /\u003e\n\n|---------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------|\n| [TensorFlow 1 version](/versions/r1.15/api_docs/python/tf/keras/backend/repeat) | [View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v2.0.0/tensorflow/python/keras/backend.py#L2927-L2959) |\n\nRepeats a 2D tensor.\n\n#### View aliases\n\n\n**Compat aliases for migration**\n\nSee\n[Migration guide](https://www.tensorflow.org/guide/migrate) for\nmore details.\n\n[`tf.compat.v1.keras.backend.repeat`](/api_docs/python/tf/keras/backend/repeat)\n\n\u003cbr /\u003e\n\n tf.keras.backend.repeat(\n x, n\n )\n\nif `x` has shape (samples, dim) and `n` is `2`,\nthe output will have shape `(samples, 2, dim)`.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Arguments --------- ||\n|-----|--------------------------------------------|\n| `x` | Tensor or variable. |\n| `n` | Python integer, number of times to repeat. |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ------- ||\n|---|---|\n| A tensor. ||\n\n\u003cbr /\u003e\n\n#### Example:\n\n b = tf.constant([[1, 2], [3, 4]])\n b\n \u003ctf.Tensor: id=78, shape=(2, 2), dtype=int32, numpy=\n array([[1, 2],\n [3, 4]], dtype=int32)\u003e\n tf.keras.backend.repeat(b, n=2)\n \u003ctf.Tensor: id=82, shape=(2, 2, 2), dtype=int32, numpy=\n array([[[1, 2],\n [1, 2]],\n [[3, 4],\n [3, 4]]], dtype=int32)\u003e"]]