将给定张量中的每个条目转换为字符串。
用法
tf.strings.as_string(
input, precision=-1, scientific=False, shortest=False, width=-1,
fill='', name=None
)参数
-
input一个Tensor。必须是以下类型之一:float32,float64,int32,uint8,int16,int8,int64,bfloat16,uint16,half,uint32,uint64,complex64,complex128,bool,variant。 -
precision可选的int。默认为-1。用于浮点数的post-decimal 精度。仅在精度 > -1 时使用。 -
scientific可选的bool。默认为False。对浮点数使用科学计数法。 -
shortest可选的bool。默认为False。对浮点数使用最短的表示(科学或标准)。 -
width可选的int。默认为-1。将前十进制数字填充到此宽度。适用于浮点数和整数。仅在宽度 > -1 时使用。 -
fill可选的string。默认为""。如果宽度 > -1 则填充的值。如果为空,则用空格填充。另一个典型值是'0'。字符串不能超过 1 个字符。 -
name操作的名称(可选)。
返回
-
Tensor类型为string。
支持许多数字类型和布尔值。
对于 Unicode,请参阅https://www.tensorflow.org/tutorials/representation/unicode教程。
例子:
tf.strings.as_string([3, 2])
<tf.Tensor:shape=(2,), dtype=string, numpy=array([b'3', b'2'], dtype=object)>
tf.strings.as_string([3.1415926, 2.71828], precision=2).numpy()
array([b'3.14', b'2.72'], dtype=object)
相关用法
- 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.unsorted_segment_join用法及代码示例
- Python tf.strings.lower用法及代码示例
- 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.as_string。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。
