tf.keras.backend.repeat_elements
Stay organized with collections
Save and categorize content based on your preferences.
Repeats the elements of a tensor along an axis, like np.repeat
.
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)
.
Arguments |
x
|
Tensor or variable.
|
rep
|
Python integer, number of times to repeat.
|
axis
|
Axis along which to repeat.
|
Example:
b = tf.constant([1, 2, 3])
tf.keras.backend.repeat_elements(b, rep=2, axis=0)
<tf.Tensor: shape=(6,), dtype=int32,
numpy=array([1, 1, 2, 2, 3, 3], 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_elements\n\n\u003cbr /\u003e\n\n|------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------|\n| [TensorFlow 1 version](/versions/r1.15/api_docs/python/tf/keras/backend/repeat_elements) | [View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v2.3.0/tensorflow/python/keras/backend.py#L3043-L3102) |\n\nRepeats the elements of a tensor along an axis, like `np.repeat`.\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_elements`](/api_docs/python/tf/keras/backend/repeat_elements)\n\n\u003cbr /\u003e\n\n tf.keras.backend.repeat_elements(\n x, rep, axis\n )\n\nIf `x` has shape `(s1, s2, s3)` and `axis` is `1`, the output\nwill have shape `(s1, s2 * rep, s3)`.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Arguments --------- ||\n|--------|--------------------------------------------|\n| `x` | Tensor or variable. |\n| `rep` | Python integer, number of times to repeat. |\n| `axis` | Axis along which 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])\n tf.keras.backend.repeat_elements(b, rep=2, axis=0)\n \u003ctf.Tensor: shape=(6,), dtype=int32,\n numpy=array([1, 1, 2, 2, 3, 3], dtype=int32)\u003e"]]