評價此頁

LeakyReLU#

class torch.nn.modules.activation.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)[來源]#

執行前向傳播。

返回型別

張量