Reputation: 11
Origin tensor:
a = tf.constant([[1, 2, 3], [4, 5, 6], [7, 8, 9]])
I want tensor in this way:
result = [[1,2,3],[1,2,3],[1,2,3],[4,5,6],[4,5,6],[4,5,6],[7,8,9],[7,8,9],[7,8,9]]
Using tile api seems not suitable, can anyone help?
Upvotes: 0
Views: 140
Reputation: 36624
Use tf.repeat
.
tf.repeat(a, repeats=3, axis=0)
<tf.Tensor: shape=(9, 3), dtype=int32, numpy=
array([[1, 2, 3],
[1, 2, 3],
[1, 2, 3],
[4, 5, 6],
[4, 5, 6],
[4, 5, 6],
[7, 8, 9],
[7, 8, 9],
[7, 8, 9]])>
Upvotes: 1