Keras 3 API 文件 / 層 API / 激活層 / LeakyReLU 層

LeakyReLU 層

[原始碼]

LeakyReLU 類別

keras.layers.LeakyReLU(negative_slope=0.3, **kwargs)

修正線性單元激活層的洩漏版本。

此層在單元未啟用時允許一個小的梯度。

公式

f(x) = alpha * x if x < 0
f(x) = x if x >= 0

範例

leaky_relu_layer = LeakyReLU(negative_slope=0.5)
input = np.array([-10, -5, 0.0, 5, 10])
result = leaky_relu_layer(input)
# result = [-5. , -2.5,  0. ,  5. , 10.]

參數

  • negative_slope: 浮點數 >= 0.0。負斜率係數。預設值為 0.3
  • **kwargs:基礎層關鍵字參數,例如 namedtype