Tensorflow, split tf.string SparseTensor to dense tensor list in dim 0
Does anyone know how to split a tf.string SparseTensor into a dense tensor list in dim 0, like so:
sparse_input -> slice_input_list
SparseTensor:
[["a", "b", "c"],
["d", "e"],
["f", "g", "h", "i"]]
# raw_dense_input = tf.constant(["a b c", "d e", "f g h i"], dtype=tf.string)
# sparse_input = tf.string_split(raw_dense_input)
To: dense list of tensors:
list(["a", "b", "c"], ["d", "e"], ["f", "g", "h", "i"])
# slice_input_list = (tf.constant(["a", "b", "c"], dtype=tf.string),
# tf.constant(["d", "e"], dtype=tf.string),
# tf.constant(["f", "g", "h", "i"], dtype=tf.string))
I tried the following method but couldn't, because num_split needs an int to do this and dense_shape is a dynamic form
slice_input_list = tf.sparse_split(sp_input=sparse_input, num_split=sparse_input.dense_shape[0], axis=0)
+3
source to share
No one has answered this question yet
See similar questions:
or similar: