Main Content


Apply sigmoid activation


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

This operation is equivalent to



This function applies the sigmoid operation to dlarray data. If you want to apply sigmoid within a layerGraph object or Layer array, use the following layer:


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


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);
dlX = dlarray(X,'SSCB');

Compute the sigmoid activation.

dlY = sigmoid(dlX);

All values in dlY now range between 0 and 1.

Input Arguments

collapse all

Input data, specified as a dlarray with or without dimension labels.

Data Types: single | double

Output Arguments

collapse all

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

If the input data dlX is a formatted dlarray, dlY has the same dimension labels as dlX. If the input data is not a formatted dlarray, dlY 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™.

Introduced in R2019b