input 的字符串长度。
用法
tf.raw_ops.StringLength(
input, unit='BYTE', name=None
)参数
-
inputTensor类型为string。计算每个元素长度的字符串。 -
unit一个可选的string来自:"BYTE", "UTF8_CHAR"。默认为"BYTE"。计算字符串长度的单位。以下之一:"BYTE"(每个字符串中的字节数)或"UTF8_CHAR"(每个字符串中 UTF-8 编码的 Unicode 代码点的数量)。如果unit=UTF8_CHAR和input字符串不包含结构上有效的 UTF-8,则结果未定义。 -
name操作的名称(可选)。
返回
-
Tensor类型为int32。
计算输入张量中给定的每个字符串的长度。
strings = tf.constant(['Hello','TensorFlow', '\U0001F642'])
tf.strings.length(strings).numpy() # default counts bytes
array([ 5, 10, 4], dtype=int32)
tf.strings.length(strings, unit="UTF8_CHAR").numpy()
array([ 5, 10, 1], dtype=int32)
相关用法
- Python tf.raw_ops.StringLower用法及代码示例
- Python tf.raw_ops.StringStrip用法及代码示例
- Python tf.raw_ops.StringToHashBucketStrong用法及代码示例
- Python tf.raw_ops.StringToHashBucketFast用法及代码示例
- Python tf.raw_ops.StringToNumber用法及代码示例
- Python tf.raw_ops.StringJoin用法及代码示例
- Python tf.raw_ops.StringSplitV2用法及代码示例
- Python tf.raw_ops.StringUpper用法及代码示例
- Python tf.raw_ops.StridedSlice用法及代码示例
- Python tf.raw_ops.StatelessCase用法及代码示例
- Python tf.raw_ops.StopGradient用法及代码示例
- Python tf.raw_ops.StatelessSampleDistortedBoundingBox用法及代码示例
- Python tf.raw_ops.SelfAdjointEigV2用法及代码示例
- Python tf.raw_ops.Size用法及代码示例
- Python tf.raw_ops.ScatterUpdate用法及代码示例
- Python tf.raw_ops.ScatterNdUpdate用法及代码示例
- Python tf.raw_ops.SparseCrossV2用法及代码示例
- Python tf.raw_ops.ScatterAdd用法及代码示例
- Python tf.raw_ops.Sub用法及代码示例
- Python tf.raw_ops.SparseCross用法及代码示例
注:本文由纯净天空筛选整理自tensorflow.org大神的英文原创作品 tf.raw_ops.StringLength。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。
