將給定張量中的每個條目轉換為字符串。
用法
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。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。
