MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / repeat

Function repeat

tensorflow/python/ops/array_ops.py:4987–5020  ·  view source on GitHub ↗

Repeat elements of `input` 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:

(input, repeats, axis=None, name=None)

Source from the content-addressed store, hash-verified

4985
4986@tf_export("repeat")
4987def repeat(input, repeats, axis=None, name=None): # pylint: disable=redefined-builtin
4988 """Repeat elements of `input`
4989
4990 Args:
4991 input: An `N`-dimensional Tensor.
4992 repeats: An 1-D `int` Tensor. The number of repetitions for each element.
4993 repeats is broadcasted to fit the shape of the given axis. `len(repeats)`
4994 must equal `input.shape[axis]` if axis is not None.
4995 axis: An int. The axis along which to repeat values. By default (axis=None),
4996 use the flattened input array, and return a flat output array.
4997 name: A name for the operation.
4998
4999 Returns:
5000 A Tensor which has the same shape as `input`, except along the given axis.
5001 If axis is None then the output array is flattened to match the flattened
5002 input array.
5003 #### Examples:
5004 ```python
5005 >>> repeat(['a', 'b', 'c'], repeats=[3, 0, 2], axis=0)
5006 ['a', 'a', 'a', 'c', 'c']
5007 >>> repeat([[1, 2], [3, 4]], repeats=[2, 3], axis=0)
5008 [[1, 2], [1, 2], [3, 4], [3, 4], [3, 4]]
5009 >>> repeat([[1, 2], [3, 4]], repeats=[2, 3], axis=1)
5010 [[1, 1, 2, 2, 2], [3, 3, 4, 4, 4]]
5011 >>> repeat(3, repeats=4)
5012 [3, 3, 3, 3]
5013 >>> repeat([[1,2], [3,4]], repeats=2)
5014 [1, 1, 2, 2, 3, 3, 4, 4]
5015 ```
5016 """
5017 if axis is None:
5018 input = reshape(input, [-1])
5019 axis = 0
5020 return repeat_with_axis(input, repeats, axis, name)

Callers 1

repeat_rangesFunction · 0.50

Calls 2

repeat_with_axisFunction · 0.85
reshapeFunction · 0.70

Tested by

no test coverage detected