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。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。
