将输入张量中的每个字符串转换为指定的数值类型。
用法
tf.strings.to_number(
input, out_type=tf.dtypes.float32, name=None
)参数
-
inputTensor类型为string。 -
out_type一个可选的tf.DType来自:tf.float32, tf.float64, tf.int32, tf.int64。默认为tf.float32。将string_tensor中的每个字符串解释为的数字类型。 -
name操作的名称(可选)。
返回
-
Tensor类型为out_type。
(请注意,int32 溢出会导致错误,而浮点溢出会导致舍入值。)
例子:
tf.strings.to_number("1.55")
<tf.Tensor:shape=(), dtype=float32, numpy=1.55>
tf.strings.to_number("3", tf.int32)
<tf.Tensor:shape=(), dtype=int32, numpy=3>
相关用法
- Python tf.strings.to_hash_bucket用法及代码示例
- Python tf.strings.to_hash_bucket_strong用法及代码示例
- Python tf.strings.to_hash_bucket_fast用法及代码示例
- 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.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.ngrams用法及代码示例
- Python tf.strings.unicode_decode用法及代码示例
- Python tf.strings.unicode_encode用法及代码示例
- Python tf.strings.format用法及代码示例
注:本文由纯净天空筛选整理自tensorflow.org大神的英文原创作品 tf.strings.to_number。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。
