原型
CLASS torch.nn.PReLU(num_parameters=1, init=0.25, device=None, dtype=None)
参数
1
或者 输入的通道数,默认为 1
。0.25
。定义
PReLU(x)=max(0,x)+a∗min(0,x)\text{PReLU}(x)= \max(0, x) + a * \min(0, x) PReLU(x)=max(0,x)+a∗min(0,x)
or
PReLU(x)={x,ifx≥0ax,otherwise\text{PReLU}(x) = \begin{cases} x, & \text{if} x \geq 0 \\ ax, & \text{otherwise} \end{cases} PReLU(x)={x,ax,ifx≥0otherwise
图
代码
import torch
import torch.nn as nnm = nn.PReLU()
input = torch.randn(4)
output = m(input)print("input: ", input) # input: tensor([ 0.1061, -2.0532, 1.4081, -0.1516])
print("output: ", output) # output: tensor([ 0.1061, -0.5133, 1.4081, -0.0379], grad_fn=)
PReLU — PyTorch 1.13 documentation