tf.math.reciprocal_no_nan
Выполняет безопасную операцию нахождения обратной величины по элементам.
tf.math.reciprocal_no_nan(
x, name=None
)
Если какой-либо элемент равен нулю, то обратная величина для этого элемента также устанавливается в ноль.
Например:
x = tf.constant([2.0, 0.5, 0, 1], dtype=tf.float32) tf.math.reciprocal_no_nan(x) # [ 0.5, 2, 0.0, 1.0 ]
| Аргументы | |
|---|---|
x | A Tensor типа float16, float32, float64 complex64 или complex128. |
name | Имя операции (необязательно). |
| Возвращаемое значение | |
|---|---|
A Tensor такой же формы и типа, что и x. |
| Исключения | |
|---|---|
TypeError | x должен иметь допустимый тип данных. |
© 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/math/reciprocal_no_nan