评价此页

LeakyReLU#

class torch.nn.LeakyReLU(negative_slope=0.01, inplace=False)[源码]#

逐元素应用 LeakyReLU 函数。

LeakyReLU(x)=max(0,x)+negative_slopemin(0,x)\text{LeakyReLU}(x) = \max(0, x) + \text{negative\_slope} * \min(0, x)

LeakyReLU(x)={x, if x0negative_slope×x, otherwise }\text{LeakyReLU}(x) = \begin{cases} x, & \text{ if } x \geq 0 \\ \text{negative\_slope} \times x, & \text{ otherwise } \end{cases}
参数
  • negative_slope (float) – 控制负斜率(用于负输入值)的角度。默认值:1e-2

  • inplace (bool) – 可以选择是否就地执行操作。默认值:False

形状
  • 输入: ()(*),其中 * 表示任意数量的附加维度

  • 输出: ()(*),与输入形状相同

../_images/LeakyReLU.png

示例

>>> m = nn.LeakyReLU(0.1)
>>> input = torch.randn(2)
>>> output = m(input)
extra_repr()[源码]#

返回模块的额外表示。

返回类型

str

forward(input)[源码]#

运行前向传播。

返回类型

张量