泄漏ReLU

classtorch.nn.LeakyReLU(negative_slope=0.01, inplace=False)[源代码]

对每个元素应用LeakyReLU函数。

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

或者

$\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

形状:
  • 输入: $(*)$,其中 * 表示任意数量的额外维度。

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

{BASE_RAW_UPLOAD_URL}/pytorch-doc-2.5/54a37bc88308e141c9078705de017c83.png

示例:

>>> m = nn.LeakyReLU(0.1)
>>> input = torch.randn(2)
>>> output = m(input)
本页目录