Softplus 函數
Softplus 函數是神經網絡中常用的激活函數之一,定義為:
?
Softplus函數導數
?
是 sigmoid 函數。Softplus 處處可導,并且導數恰好是 sigmoid。
它是 ReLU 函數的平滑近似,具有連續可導的特性,適合需要梯度優化的場景。
數學特性
- 平滑性:導數為 Sigmoid 函數,即
- 與 ReLU 的關系:當
。
- 輸出范圍:
,適合非負輸出的場景。
Rust 實現
以下是一個基礎的 Softplus 函數實現及其導數:
use std::f64::consts::E;fn softplus(x: f64) -> f64 {(1.0 + E.powf(x)).ln()
}fn softplus_derivative(x: