mindspore.nn.ELU
- class mindspore.nn.ELU(alpha=1.0)[source]
Exponential Linear Uint activation function.
Applies the exponential linear unit function element-wise. The activation function is defined as:
\[E_{i} = \begin{cases} x, &\text{if } x \geq 0; \cr \text{alpha} * (\exp(x_i) - 1), &\text{otherwise.} \end{cases}\]The picture about ELU looks like this ELU.
- Parameters
alpha (float) – The coefficient of negative factor whose type is float. Default: 1.0.
- Inputs:
input_data (Tensor) - The input of ELU with data type of float16 or float32.
- Outputs:
Tensor, with the same type and shape as the input_data.
- Raises
TypeError – If alpha is not a float.
TypeError – If dtype of input_data is neither float16 nor float32.
ValueError – If alpha is not equal to 1.0.
- Supported Platforms:
Ascend
GPU
CPU
Examples
>>> input_x = Tensor(np.array([-1, -2, 0, 2, 1]), mindspore.float32) >>> elu = nn.ELU() >>> result = elu(input_x) >>> print(result) [-0.63212055 -0.86466473 0. 2. 1.]