mindspore.nn.Sigmoid

class mindspore.nn.Sigmoid[source]

Sigmoid activation function.

Applies sigmoid-type activation element-wise.

Sigmoid function is defined as:

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

where \(x_i\) is the element of the input.

The picture about Sigmoid looks like this Sigmoid.

Inputs:
  • input_data (Tensor) - The input of Sigmoid with data type of float16 or float32.

Outputs:

Tensor, with the same type and shape as the input_data.

Raises

TypeError – If dtype of input_data is neither float16 nor float32.

Supported Platforms:

Ascend GPU CPU

Examples

>>> input_x = Tensor(np.array([-1, -2, 0, 2, 1]), mindspore.float16)
>>> sigmoid = nn.Sigmoid()
>>> output = sigmoid(input_x)
>>> print(output)
[0.2688  0.11914 0.5     0.881   0.7305 ]