PRelu
该接口用于构建 PRelu
类的一个可调用对象,具体用法参照 代码示例
。其中实现了 PRelu
激活函数的三种激活方式。
计算公式如下:
- mode (str) - 权重共享模式。共提供三种激活方式:
channel (int,可选) - 通道数。该参数在mode参数为”channel”时是必须的。默认为None。
input_shape (int 或 list 或 tuple,可选) - 输入的维度。该参数在mode参数为”element”时是必须的。默认为None。
param_attr (ParamAttr, 可选) - 指定权重参数属性的对象。默认值为None,表示使用默认的权重参数属性。具体用法请参见 。
返回:无
代码示例:
import paddle.fluid as fluid
from paddle.fluid.dygraph.base import to_variable
inp_np = np.ones([5, 200, 100, 100]).astype('float32')
inp_np = to_variable(inp_np)
prelu0 = fluid.PRelu(
mode='all',
param_attr=fluid.ParamAttr(initializer=fluid.initializer.Constant(1.0)))
dy_rlt0 = prelu0(inp_np)
mode='channel',
channel=200,
dy_rlt1 = prelu1(inp_np)
prelu2 = fluid.PRelu(
mode='element',
input_shape=inp_np.shape,
param_attr=fluid.ParamAttr(initializer=fluid.initializer.Constant(1.0)))
weight