input 的字符串長度。
用法
tf.strings.length(
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.strings.lower用法及代碼示例
- Python tf.strings.substr用法及代碼示例
- Python tf.strings.reduce_join用法及代碼示例
- Python tf.strings.regex_full_match用法及代碼示例
- Python tf.strings.regex_replace用法及代碼示例
- Python tf.strings.bytes_split用法及代碼示例
- Python tf.strings.as_string用法及代碼示例
- Python tf.strings.unsorted_segment_join用法及代碼示例
- Python tf.strings.split用法及代碼示例
- Python tf.strings.upper用法及代碼示例
- Python tf.strings.unicode_decode_with_offsets用法及代碼示例
- Python tf.strings.join用法及代碼示例
- Python tf.strings.to_hash_bucket用法及代碼示例
- Python tf.strings.ngrams用法及代碼示例
- Python tf.strings.to_hash_bucket_strong用法及代碼示例
- Python tf.strings.unicode_decode用法及代碼示例
- Python tf.strings.unicode_encode用法及代碼示例
- Python tf.strings.format用法及代碼示例
- Python tf.strings.to_hash_bucket_fast用法及代碼示例
- Python tf.strings.to_number用法及代碼示例
注:本文由純淨天空篩選整理自tensorflow.org大神的英文原創作品 tf.strings.length。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。
