selu

paddle.fluid.layers.nn. selu ( x, scale=None, alpha=None, name=None ) [source]

Warning: API “paddle.fluid.layers.nn.selu” is deprecated since 2.0.0, and will be removed in future versions. Please use “paddle.nn.functional.selu” instead.

Selu Operator.

The equation is:

\[\begin{split}selu= \\lambda* \\begin{cases} x &\\quad \\text{ if } x>0 \n \\alpha * e^x - \\alpha &\\quad \\text{ if } x<=0 \\end{cases}\end{split}\]

The input X can carry the LoD (Level of Details) information, or not. And the output shares the LoD information with input X.

Args:

x (Variable): The input N-D Tensor. scale(float, optional): lambda in selu activation function,

System Message: ERROR/3 (/usr/local/lib/python3.8/site-packages/paddle/fluid/layers/nn.py:docstring of paddle.fluid.layers.nn.selu, line 22)

Unexpected indentation.

the default value is 1.0507009873554804934193349852946. For more information about this value, please refer to: https://arxiv.org/abs/1706.02515.

System Message: WARNING/2 (/usr/local/lib/python3.8/site-packages/paddle/fluid/layers/nn.py:docstring of paddle.fluid.layers.nn.selu, line 25)

Block quote ends without a blank line; unexpected unindent.

alpha(float, optional): alpha in selu activation function,

the default value is 1.6732632423543772848170429916717. For more information about this value, please refer to: https://arxiv.org/abs/1706.02515.

System Message: WARNING/2 (/usr/local/lib/python3.8/site-packages/paddle/fluid/layers/nn.py:docstring of paddle.fluid.layers.nn.selu, line 29)

Definition list ends without a blank line; unexpected unindent.

name(str, optional): The default value is None. Normally there is no need for user to set this property. For more information, please refer to Name .

Returns:

Variable(Tensor|LoDTensor): The output Tensor or LoDTensor with the same shape and LoD information as input.

Examples:

import paddle.fluid as fluid
import numpy as np

inputs = fluid.layers.data(name="x", shape=[2, 2], dtype="float32")
output = fluid.layers.selu(inputs)

exe = fluid.Executor(fluid.CPUPlace())
exe.run(fluid.default_startup_program())

img = np.array([[0, 1],[2, 3]]).astype(np.float32)

res = exe.run(fluid.default_main_program(), feed={'x':img}, fetch_list=[output])
print(res) # [array([[0.      , 1.050701],[2.101402, 3.152103]], dtype=float32)]