将 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。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。
