快捷方式

LeakyReLU

class torch.nn.LeakyReLU(negative_slope=0.01, inplace=False)[source][source]

逐元素應用 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)

文件

獲取 PyTorch 的全面開發者文件

檢視文件

教程

獲取面向初學者和高階開發者的深度教程

檢視教程

資源

查詢開發資源並獲得問題解答

檢視資源