|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v2.21.0/tensorflow/python/ops/math_ops.py#L4150-L4200) |

Computes sigmoid of `x` element-wise.

#### View aliases


**Compat aliases for migration**

See
[Migration guide](https://www.tensorflow.org/guide/migrate) for
more details.

[`tf.compat.v1.nn.sigmoid`](https://www.tensorflow.org/api_docs/python/tf/compat/v1/math/sigmoid)

<br />

    tf.compat.v1.math.sigmoid(
        x, name=None
    )

Formula for calculating \\(\\mathrm{sigmoid}(x) = y = 1 / (1 + \\exp(-x))\\).

For \\(x \\in (-\\infty, \\infty)\\), \\(\\mathrm{sigmoid}(x) \\in (0, 1)\\).

#### Example Usage:

If a positive number is large, then its sigmoid will approach to 1 since the
formula will be `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)>

If a negative number is large, its sigmoid will approach to 0 since the
formula will be `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)>

<br />

<br />

<br />

| ## Args ||
|---|---|
| `x` | A Tensor with type `float16`, `float32`, `float64`, `complex64`, or `complex128`. |
| `name` | A name for the operation (optional). |

<br />

<br />

<br />

<br />

| ## Returns ||
|---|---|
| A Tensor with the same type as `x`. ||

<br />

#### Usage Example:

    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)>

<br />

## scipy compatibility

<br />

Equivalent to scipy.special.expit

<br />

<br />