mindspore.ops.silu

mindspore.ops.silu(x)[source]

Computes Sigmoid Linear Unit of input element-wise. The SiLU function is defined as:

\[\text{SiLU}(x) = x * \sigma(x),\]

where the Logistic Sigmoid function is defined as:

\[\text{sigma}(x_i) = \frac{1}{1 + \exp(-x_i)},\]

where \(x_i\) is an element of the x.

For more details, please refer to mindspore.nn.SiLU.

Supported Platforms:

Ascend GPU CPU

Examples

>>> import numpy as np
>>> import mindspore
>>> from mindspore import Tensor, ops
>>> x = Tensor(np.array([-1, 2, -3, 2, -1]), mindspore.float16)
>>> output = ops.silu(x)
>>> print(output)
[-0.269  1.762  -0.1423  1.762  -0.269]