what is tf.repeat() 1

what is tf.repeat()

# 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.

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

# Result

numpy=array([b'a', b'a', b'a', b'c', b'c'], dtype=object)>

Here is what the above code is Doing:
1. We are creating a tensor with the values [‘a’, ‘b’, ‘c’]
2. We are repeating the values in the tensor 3 times for ‘a’, 0 times for ‘b’ and 2 times for ‘c’
3. We are repeating the values along the axis 0

Similar Posts