mindspore.ops.Elu

class mindspore.ops.Elu(alpha=1.0)[source]

Exponential Linear Uint activation function.

Applies the exponential linear unit function element-wise. The activation function is defined as:

\[\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 picture about ELU looks like this ELU .

Parameters

alpha (float) – The alpha value of ELU, the data type is float. Only support ‘1.0’ currently. Default: 1.0 .

Inputs:
  • input_x (Tensor) - The input of ELU is a Tensor of any dimension with data type of float16, float32 or float64.

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, float32 nor float64.

  • ValueError – If alpha is not equal to 1.0.

Supported Platforms:

Ascend GPU CPU

Examples

>>> import mindspore
>>> import numpy as np
>>> from mindspore import Tensor, ops
>>> 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.        ]]