tf.math.sigmoid
| Просмотреть исходный код на GitHub |
Вычисляет сигмоиду каждого элемента x.
tf.math.sigmoid(
x, name=None
)
Формула для вычисления \(\mathrm{sigmoid}(x) = y = 1 / (1 + \exp(-x))\).
Для \(x \in (-\infty, \infty)\), \(\mathrm{sigmoid}(x) \in (0, 1)\).
Пример использования:
Если положительное число велико, то его сигмоида будет приближаться к 1, так как формула будет y = <large_num> / (1 + <large_num>)
x = tf.constant([0.0, 1.0, 50.0, 100.0]) tf.math.sigmoid(x) <tf.Tensor: shape=(4,), dtype=float32, numpy=array([0.5, 0.7310586, 1.0, 1.0], dtype=float32)>
Если отрицательное число велико, его сигмоида будет приближаться к 0, так как формула будет y = 1 / (1 + <large_num>)
x = tf.constant([-100.0, -50.0, -1.0, 0.0])
tf.math.sigmoid(x)
<tf.Tensor: shape=(4,), dtype=float32, numpy=
array([0.0000000e+00, 1.9287499e-22, 2.6894143e-01, 0.5],
dtype=float32)>
| Аргументы | |
|---|---|
x | Tensor с типом float16, float32, float64, complex64, или complex128. |
name | Имя операции (необязательно). |
| Возвращаемое значение | |
|---|---|
Tensor того же типа, что и x. |
Пример использования:
x = tf.constant([-128.0, 0.0, 128.0], dtype=tf.float32) tf.sigmoid(x) <tf.Tensor: shape=(3,), dtype=float32, numpy=array([0. , 0.5, 1. ], dtype=float32)>
Совместимость с scipy
Эквивалентно scipy.special.expit
© 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/versions/r2.9/api_docs/python/tf/math/sigmoid