sigmoid - Apply sigmoid activation - MATLAB (original) (raw)
Main Content
Syntax
Description
The sigmoid activation operation applies the sigmoid function to the input data.
This operation is equivalent to
[Y](#mw%5F12bcee23-017e-409f-b554-ec11b2e912d3) = sigmoid([X](#mw%5F744e6690-0629-4ffc-a5d9-58d67ec6c2f5))
computes the sigmoid activation of the input X
by applying the sigmoid transfer function. All values in Y
are between 0
and1
.
Examples
Apply Sigmoid Activation
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.
All values in Y
now range between 0
and1
.
Input Arguments
X
— Input data
dlarray
Input data, specified as a formatted dlarray
, an unformatteddlarray
, or a numeric array.
Data Types: single
| double
Output Arguments
Y
— Sigmoid activations
dlarray
Sigmoid activations, returned as a dlarray
. All values inY
are between 0
and 1
. The output Y
has the same underlying data type as the inputX
.
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™.
GPU Arrays
Accelerate code by running on a graphics processing unit (GPU) using Parallel Computing Toolbox™.
The sigmoid
function supports GPU array input with these usage notes and limitations:
- When the input argument
X
is adlarray
with underlying data of typegpuArray
, this function runs on the GPU.
For more information, see Run MATLAB Functions on a GPU (Parallel Computing Toolbox).
Version History
Introduced in R2019b