У меня есть двумерный тензор строк, имеющий размерность [None, None]
. Я хочу разделить каждую строку с помощью функции tf.string_split()
. Я попытался с помощью кода ниже
sentences = tf.placeholder(shape=[None, None], dtype=tf.string)
# remove punctuation
normalized_sentences = tf.regex_replace(input=sentences, pattern=r"\pP", rewrite="")
tokens = tf.map_fn(lambda x: tf.string_split(x, delimiter=" "), normalized_sentences, dtype=tf.string)
Но ошибка выдает мне ошибку.
TypeError: Failed to convert object of type <class 'tensorflow.python.framework.sparse_tensor.SparseTensor'> to Tensor. Contents: SparseTensor(indices=Tensor("map/while/StringSplit:0", shape=(?, 2), dtype=int64), values=Tensor("map/while/StringSplit:1", shape=(?,), dtype=string), dense_shape=Tensor("map/while/StringSplit:2", shape=(2,), dtype=int64)). Consider casting elements to a supported type.