Machine learning building blocks
Softplus
ml.softplusAlso called softplus, soft plus, smooth relu, log1pexp
Smooth approximation of max(0, x). As written it overflows for x above about 709; the stable form max(x, 0) + ln(1 + e−|x|) gives the same value everywhere.
Notation
input
x ∈ ℝ
Result: the activation
scalar
Worked examples
Each result is solved exactly and confirmed by two independent computations.
Given
Result
≈ 0.69314718056
Given
Result
≈ 1.31326168752
Given
Result
≈ 0.313261687518
Given
Result
≈ 800
Common mistakes
Evaluates ln(1 + e×) directly
e× overflows to inf for x above about 709, so the result is inf instead of about x.
Fix: Use max(x, 0) + log1p(exp(−|x|)), or call torch.nn.functional.softplus / numpy.logaddexp(0, x).
Source
Goodfellow et al. 2016, §3.10, eq. 3.31
Goodfellow, Ian; Bengio, Yoshua; Courville, Aaron. Deep Learning. MIT Press, 2016.