There's a tf.tile function, which takes a tensor and copies it a given number of times.
f = tf.tile([5], [3])
f.eval() == array([3, 3, 3], dtype=int32)
How to achieve something similar with SparseTensors:
g = tf.SparseTensorValue([[0, 0]], values=[5], shape=[1, 1])
tiled = tf.tile(g, [10, 1]) <- gives ValueError: Argument must be a dense tensor
?
Ok, I have found a solution (that works on SparseTensors, but not on SparseTensorValues):
tiled = tf.sparse_concat(0, [g] * 10)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With