tensorflow,将tf.string SparseTensor拆分为dim 0中的密集Tensor列表

时间:2017-04-06 09:20:16

标签: split tensorflow

任何人都知道如何将tf.string SparseTensor拆分为dim 0中的密集Tensor列表,如下所示:

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:密集张量列表:

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))

我尝试使用以下方法,但失败了,因为num_split需要int,而dense_shape是动态形状

slice_input_list = tf.sparse_split(sp_input=sparse_input, num_split=sparse_input.dense_shape[0], axis=0)

0 个答案:

没有答案