PRelu

    该接口用于构建 PRelu 类的一个可调用对象,具体用法参照 代码示例 。其中实现了 PRelu 激活函数的三种激活方式。

    计算公式如下:

    • mode (str) - 权重共享模式。共提供三种激活方式:
    • channel (int,可选) - 通道数。该参数在mode参数为”channel”时是必须的。默认为None。

    • input_shape (int 或 list 或 tuple,可选) - 输入的维度。该参数在mode参数为”element”时是必须的。默认为None。

    • param_attr (ParamAttr, 可选) - 指定权重参数属性的对象。默认值为None,表示使用默认的权重参数属性。具体用法请参见 。

    返回:无

    代码示例:

    1. import paddle.fluid as fluid
    2. from paddle.fluid.dygraph.base import to_variable
    3. inp_np = np.ones([5, 200, 100, 100]).astype('float32')
    4. inp_np = to_variable(inp_np)
    5. prelu0 = fluid.PRelu(
    6. mode='all',
    7. param_attr=fluid.ParamAttr(initializer=fluid.initializer.Constant(1.0)))
    8. dy_rlt0 = prelu0(inp_np)
    9. mode='channel',
    10. channel=200,
    11. dy_rlt1 = prelu1(inp_np)
    12. prelu2 = fluid.PRelu(
    13. mode='element',
    14. input_shape=inp_np.shape,
    15. param_attr=fluid.ParamAttr(initializer=fluid.initializer.Constant(1.0)))

    weight