mindspore.ops.selu

查看源文件
mindspore.ops.selu(input_x)[源代码]

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

该激活函数定义为:

Ei=scale{xi,if xi0;alpha(exp(xi)1),otherwise.

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

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

SeLU函数图:

../../_images/SeLU.png
参数:
  • input_x (Tensor) - 任意维度的Tensor,数据类型为int8、int32、float16、float32、float64(仅CPU、GPU)。

返回:

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

异常:
  • TypeError - input_x 的数据类型不是int8、int32、float16、float32、float64。

支持平台:

Ascend GPU CPU

样例:

>>> 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)
>>> output = ops.selu(input_x)
>>> print(output)
[[-1.1113307 4.202804 -1.7575096]
[ 2.101402 -1.7462534 9.456309 ]]