mindspore.ops.Elu
- class mindspore.ops.Elu(alpha=1.0)[source]
Computes exponential linear:
\[\begin{split}\text{ELU}(x)= \left\{ \begin{array}{align} \alpha(e^{x} - 1) & \text{if } x \le 0\\ x & \text{if } x \gt 0\\ \end{array}\right.\end{split}\]The data type of input tensor must be float.
- Parameters
alpha (float) – The coefficient of negative factor whose type is float, only support ‘1.0’ currently. Default: 1.0.
- Inputs:
input_x (Tensor) - Tensor of shape \((N, *)\), where \(*\) means, any number of additional dimensions, with float16 or float32 data type.
- Outputs:
Tensor, has the same shape and data type as input_x.
- Raises
TypeError – If alpha is not a float.
TypeError – If dtype of input_x 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.0, 4.0, -8.0], [2.0, -5.0, 9.0]]), mindspore.float32) >>> elu = ops.Elu() >>> output = elu(input_x) >>> print(output) [[-0.63212055 4. -0.99966455] [ 2. -0.99326205 9. ]]