mindspore.mint.nn.ELU
- class mindspore.mint.nn.ELU(alpha=1.0)[source]
Exponential Linear Unit activation function
Applies the exponential linear unit function element-wise.The activation function is defined as:
\[ELU_{i} = \begin{cases} x_i, &\text{if } x_i \geq 0; \cr \alpha * (\exp(x_i) - 1), &\text{otherwise.} \end{cases}\]where \(x_i\) represents the element of the input and \(\alpha\) represents the alpha parameter.
ELU Activation Function Graph:
Warning
This is an experimental API that is subject to change or deletion.
- Parameters
alpha (float, optional) – The alpha value of ELU, the data type is float. Default:
1.0
.
- Inputs:
input (Tensor) - The input of ELU is a Tensor of any dimension.
- Outputs:
Tensor, with the same type and shape as the input.
- Raises
TypeError – If alpha is not a float.
- Supported Platforms:
Ascend
Examples
>>> import mindspore >>> from mindspore import Tensor, mint >>> import numpy as np >>> input = Tensor(np.array([-1, -2, 0, 2, 1]), mindspore.float32) >>> elu = mint.nn.ELU() >>> result = elu(input) >>> print(result) [-0.63212055 -0.86466473 0. 2. 1.]