基于 delimiter 拆分 source 的元素。 (不推荐使用的参数)
用法
tf.compat.v1.string_split(
source, sep=None, skip_empty=True, delimiter=None,
result_type='SparseTensor', name=None
)参数
-
source1-DstringTensor,要拆分的字符串。 -
sep0-D字符串Tensor,分隔符,字符串长度应为 0 或 1。默认为 ' '。 -
skip_empty一个bool。如果True,则跳过结果中的空字符串。 -
delimitersep的已弃用别名。 -
result_type结果的张量类型:"RaggedTensor"或"SparseTensor"之一。 -
name操作的名称(可选)。
抛出
-
ValueError如果分隔符不是字符串。
返回
-
排名为
2的SparseTensor或RaggedTensor,字符串根据分隔符拆分。索引的第一列对应于source中的行,第二列对应于该行中拆分组件的索引。
警告:不推荐使用某些参数:(delimiter)。它们将在未来的版本中被删除。更新说明:分隔符已弃用,请改用 sep。
令 N 为 source 的大小(通常 N 为批量大小)。根据 delimiter 拆分 source 的每个元素,并返回包含拆分标记的 SparseTensor 或 RaggedTensor。空标记被忽略。
如果sep 是一个空字符串,则source 的每个元素都被拆分为单独的字符串,每个字符串包含一个字节。 (这包括拆分 UTF-8 的多字节序列。)如果 delimiter 包含多个字节,则将其视为一组分隔符,每个分隔符都被视为一个潜在的拆分点。
例子:
print(tf.compat.v1.string_split(['hello world', 'a b c']))
SparseTensor(indices=tf.Tensor( [[0 0] [0 1] [1 0] [1 1] [1 2]], ...),
values=tf.Tensor([b'hello' b'world' b'a' b'b' b'c'], ...),
dense_shape=tf.Tensor([2 3], shape=(2,), dtype=int64))
print(tf.compat.v1.string_split(['hello world', 'a b c'],
result_type="RaggedTensor"))
<tf.RaggedTensor [[b'hello', b'world'], [b'a', b'b', b'c']]>
相关用法
- Python tf.compat.v1.string_to_number用法及代码示例
- Python tf.compat.v1.strings.length用法及代码示例
- Python tf.compat.v1.strings.substr用法及代码示例
- Python tf.compat.v1.strings.split用法及代码示例
- Python tf.compat.v1.scatter_min用法及代码示例
- Python tf.compat.v1.summary.merge用法及代码示例
- Python tf.compat.v1.size用法及代码示例
- Python tf.compat.v1.scatter_add用法及代码示例
- Python tf.compat.v1.summary.FileWriter用法及代码示例
- Python tf.compat.v1.scatter_div用法及代码示例
- Python tf.compat.v1.space_to_batch用法及代码示例
- Python tf.compat.v1.squeeze用法及代码示例
- Python tf.compat.v1.set_random_seed用法及代码示例
- Python tf.compat.v1.sparse_to_dense用法及代码示例
- Python tf.compat.v1.sparse_segment_sum用法及代码示例
- Python tf.compat.v1.scatter_update用法及代码示例
- Python tf.compat.v1.sparse_split用法及代码示例
- Python tf.compat.v1.saved_model.simple_save用法及代码示例
- Python tf.compat.v1.scatter_nd_sub用法及代码示例
- Python tf.compat.v1.sparse_reduce_max用法及代码示例
注:本文由纯净天空筛选整理自tensorflow.org大神的英文原创作品 tf.compat.v1.string_split。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。
