elu

paddle.nn.functional. elu ( x, alpha=1.0, name=None ) [源代码]

elu 激活层(ELU Activation Operator)

根据 Exponential Linear Units 对输入 Tensor 中每个元素应用以下计算。

\[\begin{split}elu(x)= \left\{ \begin{array}{lcl} x,& &\text{if } \ x > 0 \\ alpha * (e^{x} - 1),& &\text{if } \ x <= 0 \end{array} \right.\end{split}\]

其中,\(x\) 为输入的 Tensor。

参数

  • name (str,可选) - 具体用法请参见 Name,一般无需设置,默认值为 None。

返回

Tensor,数据类型和形状同 x 一致。

代码示例

>>> import paddle
>>> import paddle.nn.functional as F

>>> x = paddle.to_tensor([[-1., 6.], [1., 15.6]])
>>> out = F.elu(x, alpha=0.2)
>>> print(out)
Tensor(shape=[2, 2], dtype=float32, place=Place(cpu), stop_gradient=True,
[[-0.12642412,  6.        ],
 [ 1.        , 15.60000038]])