捷徑

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) – 可以選擇是否要原地 (in-place) 執行操作。預設值:False

形狀
  • 輸入: ()(*) 其中 * 表示任意數量的額外維度

  • 輸出: ()(*),與輸入相同的形狀

../_images/LeakyReLU.png

範例

>>> m = nn.LeakyReLU(0.1)
>>> input = torch.randn(2)
>>> output = m(input)

文件

Access comprehensive developer documentation for PyTorch

View Docs

Tutorials

Get in-depth tutorials for beginners and advanced developers

View Tutorials

Resources

Find development resources and get your questions answered

View Resources