ReLU 層

[原始碼]

ReLU 類別

keras.layers.ReLU(max_value=None, negative_slope=0.0, threshold=0.0, **kwargs)

線性整流單元激活函數層。

公式

f(x) = max(x,0)
f(x) = max_value if x >= max_value
f(x) = x if threshold <= x < max_value
f(x) = negative_slope * (x - threshold) otherwise

範例

relu_layer = keras.layers.ReLU(
    max_value=10,
    negative_slope=0.5,
    threshold=0,
)
input = np.array([-10, -5, 0.0, 5, 10])
result = relu_layer(input)
# result = [-5. , -2.5,  0. ,  5. , 10.]

參數

  • max_value: Float >= 0。最大激活值。None 表示無上限。預設為 None
  • negative_slope: Float >= 0。負斜率係數。預設為 0.0
  • threshold: Float >= 0。閾值激活的閾值。預設為 0.0
  • **kwargs:基礎層關鍵字參數,例如 namedtype