mindspore.mint.nn.functional.selu

查看源文件
mindspore.mint.nn.functional.selu(input)[源代码]

激活函数selu(Scaled exponential Linear Unit)。

该激活函数定义为:

\[E_{i} = scale * \begin{cases} x_{i}, &\text{if } x_{i} \geq 0; \cr \text{alpha} * (\exp(x_i) - 1), &\text{otherwise.} \end{cases}\]

其中, \(alpha\)\(scale\) 是预定义的常量( \(alpha=1.67326324\)\(scale=1.05070098\) )。

更多详细信息,请参见 Self-Normalizing Neural Networks

SELU函数图:

../../_images/SeLU.png
参数:
  • input (Tensor) - 任意维度的Tensor,数据类型为float16、float32、bfloat16。

返回:

Tensor,数据类型和shape与 input 的相同。

异常:
  • TypeError - input 的数据类型不是float16、float32、bfloat16。

支持平台:

Ascend

样例:

>>> import mindspore
>>> from mindspore import Tensor, mint
>>> import numpy as np
>>> input = Tensor(np.array([[-1.0, 4.0, -8.0], [2.0, -5.0, 9.0]]), mindspore.float32)
>>> output = mint.nn.functional.selu(input)
>>> print(output)
[[-1.1113307 4.202804 -1.7575096]
[ 2.101402 -1.7462534 9.456309 ]]