tf.raw_ops.StringToNumber
Преобразует каждую строку в тензоре входных данных в указанный числовой тип.
tf.raw_ops.StringToNumber(
string_tensor,
out_type=tf.dtypes.float32,
name=None
)
(Обратите внимание, что переполнение int32 приводит к ошибке, в то время как переполнение float приводит к округленному значению.)
Пример:
strings = ["5.0", "3.0", "7.0"] tf.strings.to_number(strings) <tf.Tensor: shape=(3,), dtype=float32, numpy=array([5., 3., 7.], dtype=float32)>
| Аргументы | |
|---|---|
string_tensor | A Tensor типа string. |
out_type | Необязательный tf.DType из: tf.float32, tf.float64, tf.int32, tf.int64. По умолчанию tf.float32. Тип числового значения, в который интерпретируется каждая строка в string_tensor. |
name | Имя операции (необязательно). |
| Возвращает | |
|---|---|
A Tensor типа out_type. |
© 2022 The TensorFlow Authors. All rights reserved.
Licensed under the Creative Commons Attribution License 4.0.
Code samples licensed under the Apache 2.0 License.
https://www.tensorflow.org/api_docs/python/tf/raw_ops/StringToNumber