將 input 中的每個字符串解碼為 Unicode 代碼點序列。
用法
tf.strings.unicode_decode(
input, input_encoding, errors='replace', replacement_char=65533,
replace_control_characters=False, name=None
)參數
-
input一個N維度可能參差不齊的string張量,形狀為[D1...DN]。N必須是靜態已知的。 -
input_encoding用於解碼每個字符串的 unicode 編碼的字符串名稱。 -
errors指定無法使用指示的編碼轉換輸入字符串時的響應。之一:'strict':為任何非法子字符串引發異常。'replace':用replacement_char替換非法子字符串。'ignore':跳過非法子串。
-
replacement_char當errors='replace'時用於代替input中的無效子字符串的替換代碼點;並在replace_control_characters=True時代替input中的 C0 控製字符。 -
replace_control_characters是否將 C0 控製字符(U+0000 - U+001F)替換為replacement_char。 -
name操作的名稱(可選)。
返回
-
一個
N+1維度int32張量,形狀為[D1...DN, (num_chars)]。如果input是標量,則返回的張量為tf.Tensor,否則為tf.RaggedTensor。
result[i1...iN, j] 是使用 input_encoding 解碼時 input[i1...iN] 中第 j 字符的 Unicode 代碼點。
例子:
input = [s.encode('utf8') for s in (u'G\xf6\xf6dnight', u'\U0001f60a')]
tf.strings.unicode_decode(input, 'UTF-8').to_list()
[[71, 246, 246, 100, 110, 105, 103, 104, 116], [128522]]
相關用法
- Python tf.strings.unicode_decode_with_offsets用法及代碼示例
- Python tf.strings.unicode_encode用法及代碼示例
- Python tf.strings.unicode_split用法及代碼示例
- Python tf.strings.unicode_split_with_offsets用法及代碼示例
- Python tf.strings.unicode_script用法及代碼示例
- Python tf.strings.unicode_transcode用法及代碼示例
- Python tf.strings.unsorted_segment_join用法及代碼示例
- Python tf.strings.upper用法及代碼示例
- Python tf.strings.substr用法及代碼示例
- Python tf.strings.reduce_join用法及代碼示例
- Python tf.strings.regex_full_match用法及代碼示例
- Python tf.strings.regex_replace用法及代碼示例
- Python tf.strings.length用法及代碼示例
- Python tf.strings.bytes_split用法及代碼示例
- Python tf.strings.as_string用法及代碼示例
- Python tf.strings.lower用法及代碼示例
- Python tf.strings.split用法及代碼示例
- Python tf.strings.join用法及代碼示例
- Python tf.strings.to_hash_bucket用法及代碼示例
- Python tf.strings.ngrams用法及代碼示例
注:本文由純淨天空篩選整理自tensorflow.org大神的英文原創作品 tf.strings.unicode_decode。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。
