Main Content

sigmoid

Apply sigmoid activation

Description

The sigmoid activation operation applies the sigmoid function to the input data.

This operation is equivalent to

f(x)=11+ex.

Note

This function applies the sigmoid operation to dlarray data. If you want to apply sigmoid within a dlnetwork object, use sigmoidLayer.

Y = sigmoid(X) computes the sigmoid activation of the input X by applying the sigmoid transfer function. All values in Y are between 0 and 1.

example

Examples

collapse all

Use the sigmoid function to set all values in the input data to a value between 0 and 1.

Create the input data as a single observation of random values with a height and width of seven and 32 channels.

height = 7;
width = 7;
channels = 32;
observations = 1;

X = randn(height,width,channels,observations);
X = dlarray(X,'SSCB');

Compute the sigmoid activation.

Y = sigmoid(X);

All values in Y now range between 0 and 1.

Input Arguments

collapse all

Input data, specified as a formatted dlarray, an unformatted dlarray, or a numeric array.

Data Types: single | double

Output Arguments

collapse all

Sigmoid activations, returned as a dlarray. All values in Y are between 0 and 1. The output Y has the same underlying data type as the input X.

If the input data X is a formatted dlarray, Y has the same dimension format as X. If the input data is not a formatted dlarray, Y is an unformatted dlarray with the same dimension order as the input data.

Extended Capabilities

C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.

GPU Code Generation
Generate CUDA® code for NVIDIA® GPUs using GPU Coder™.

Version History

Introduced in R2019b