Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SparseTensor equivalent of tf.tile?

Tags:

tensorflow

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

?

like image 608
sygi Avatar asked Oct 23 '25 19:10

sygi


1 Answers

Ok, I have found a solution (that works on SparseTensors, but not on SparseTensorValues):

tiled = tf.sparse_concat(0, [g] * 10)
like image 156
sygi Avatar answered Oct 26 '25 16:10

sygi