LeakyReLU¶ class torch.nn.LeakyReLU(negative_slope=0.01, inplace=False)[source][source]¶ 逐元素應用 LeakyReLU 函式。 LeakyReLU(x)=max(0,x)+negative_slope∗min(0,x)\text{LeakyReLU}(x) = \max(0, x) + \text{negative\_slope} * \min(0, x) LeakyReLU(x)=max(0,x)+negative_slope∗min(0,x)或 LeakyReLU(x)={x, if x≥0negative_slope×x, otherwise \text{LeakyReLU}(x) = \begin{cases} x, & \text{ if } x \geq 0 \\ \text{negative\_slope} \times x, & \text{ otherwise } \end{cases} LeakyReLU(x)={x,negative_slope×x, if x≥0 otherwise 引數 negative_slope (float) – 控制負斜率(用於負輸入值)的角度。預設值:1e-2 inplace (bool) – 可選地進行原地操作。預設值:False 形狀 輸入: (∗)(*)(∗) 其中 * 表示任意數量的附加維度 輸出: (∗)(*)(∗),與輸入形狀相同 示例 >>> m = nn.LeakyReLU(0.1) >>> input = torch.randn(2) >>> output = m(input)