Foundations to Frontier
Tests
E. Deep Learning › E1 Activation Functions (one page each)

Softplus

Softplus, log(1 + eᶻ), is a smooth version of ReLU: always positive, differentiable everywhere, with the logistic sigmoid as its derivative. It is rarely the best hidden activation, but it is everywhere in deep learning as a tool: it maps unconstrained outputs to positive quantities such as variances, rates and scales, it appears inside cross-entropy and log-sigmoid, and its sharpened form (1/β)log(1 + e^(βz)) interpolates between a smooth curve and ReLU. This page covers its definition, stable computation, identities, inverse, and the role of its sharpness. In the exercises you build a softplus that never overflows, then show that softplus with β = 1 trains far more slowly than ReLU as a hidden activation because it is nearly linear over the typical range of pre-activations.

Level 0: Foundation

★☆☆☆☆ Introductory⏱ 5 minGeneral audience. No mathematics required.

ReLU with the corner sanded off

Softplus, log(1 + eᶻ), looks like ReLU from a distance: near zero for very negative inputs, close to z for large positive ones. Near zero it is a smooth curve instead of a corner, and it is always strictly positive. That makes it the standard way to turn a network’s raw output into something that must be positive, like a standard deviation or a rate.

Activation lab: the curve, its slope, and what a network learns with it
z from −4 to 4 · orange f · dashed blue f′
softplus: training accuracy after 300 steps 0.883
Compare activations at the same number of steps. Smooth, non-saturating units usually fit the spirals fastest. Sigmoid and the hard-threshold units learn slowly or need surrogate gradients. Gated and maxout units use twice as many hidden pre-activations. Learning rates are fixed per activation and not tuned, so treat small differences as noise (press "new data and weights").
Why engineers care

Uncertainty-aware models predict a mean and a positive variance; Kalman-style learned filters need positive noise covariances; control and physics models need positive masses, stiffnesses and time constants. Softplus is the usual way to produce such outputs, and computing it naively overflows for inputs above about 710 in double precision.

📝 Quick check (Level 0)
0/3 answered
  1. 1. softplus(0) =
  2. 2. For large positive z, softplus(z) ≈
  3. 3. Softplus outputs are always…

Level 1: Beginner

★★☆☆☆ Basic⏱ 20 minSecondary-school mathematics: arithmetic and elementary algebra.

Identities by hand

  • Definition: softplus(z) = log(1 + eᶻ). softplus(1) = log(1 + e) ≈ 1.313.
  • Derivative: softplus′(z) = eᶻ/(1 + eᶻ) = σ(z), the logistic sigmoid. At z = 0 it is 0.5, so softplus never has a zero gradient.
  • Symmetry: softplus(z) − softplus(−z) = z.
  • Bounds: max(0, z) < softplus(z) ≤ max(0, z) + log 2.
  • Log-sigmoid: log σ(z) = −softplus(−z).
  • Binary cross-entropy from a logit z: −[y log σ(z) + (1 − y) log(1 − σ(z))] = softplus(z) − y·z.
  • Sharpness: softplus_β(z) = (1/β)·log(1 + e^(βz)) → ReLU as β → ∞. At z = 0 it equals log 2/β.
  • Inverse: for y > 0, softplus⁻¹(y) = log(eʸ − 1) = y + log(1 − e⁻ʸ). To start a positive parameter at 1, set its raw value to log(e − 1) ≈ 0.541.
📝 Quick check (Level 1)
0/3 answered
  1. 1. The derivative of softplus is…
  2. 2. softplus(3) − softplus(−3) =
  3. 3. BCE from a logit equals…

Level 2: Intermediate

★★★☆☆ Intermediate⏱ 25 minUndergraduate students and practising engineers.

Computing it safely

Exercise 1. The naive log(1 + eᶻ) has two failure modes.

  • Overflow: e¹⁰⁰⁰ is infinite in double precision, so the naive softplus(1000) is inf.
  • Underflow of precision: at z = −40, 1 + e⁻⁴⁰ rounds to exactly 1, so the naive result is 0 instead of e⁻⁴⁰ ≈ 4.2 × 10⁻¹⁸.

The stable form max(z, 0) + log1p(e^(−|z|)) fixes both. The exponent is never positive, and log1p keeps tiny arguments accurate. It returned 1000 at z = 1000 and matched e⁻⁴⁰ to relative error 10⁻¹².

Using it for positive outputs.

  • std = softplus(raw) + eps keeps the predicted standard deviation positive with a floor.
  • Compared with exp(raw), softplus grows linearly rather than exponentially for large raw values, so one large raw value cannot produce an astronomically large variance.
  • That does not make heteroscedastic training stable on its own. A probe for this page compared exp and softplus variance links on a regression task, and across six seeds both diverged at high learning rates with no consistent winner. The fragile part is the 1/variance factor in the likelihood, which a link function does not remove.
F.softplus(x, beta=1, threshold=20)     # PyTorch switches to x above the threshold for stability
F.binary_cross_entropy_with_logits(z, y) # softplus(z) - y*z inside
🐍 Exercise 1: a softplus that never overflows
Implement the naive and stable softplus, its gradient, log-sigmoid and the inverse softplus, and check the identities.
📝 Quick check (Level 2)
0/3 answered
  1. 1. The naive softplus overflows in float64 for z above about…
  2. 2. To start a softplus-parameterised std at 1, initialise the raw value to…
  3. 3. Why use log1p in the stable form?

Level 3: Advanced

★★★★☆ Advanced⏱ 25 minGraduate level, with full derivations and proofs.

Theory

Softplus as a smooth maximum. softplus_β(z) = (1/β)·log(e^(β·0) + e^(βz)) is the log-sum-exp smooth maximum of 0 and z. The approximation error is at most log 2/β, at z = 0.

Probabilistic meaning. Softplus is the antiderivative of the sigmoid, so it is the integral of a smoothed step. It also appears as the negative log-likelihood of logistic regression: −log σ(−z) = softplus(z).

Why ReLU usually beats softplus as a hidden activation. Glorot, Bordes and Bengio (2011) found rectifier networks matched or beat softplus networks despite the latter’s smoothness. Exercise 2 points to a reason. With standard initialisation, pre-activations are of order 1. Over that range softplus with β = 1 bends gently, and a straight line explains 92% of its variance (R² 0.92), against 74% for ReLU, so each layer adds less nonlinearity. It also lacks exact zeros, so activations are not sparse, and it always outputs at least a positive offset.

Where smoothness is needed. Smooth activations are required when second derivatives of the network matter:

  • physics-informed losses with ∂²u/∂x²;
  • Hessian-based methods;
  • Lipschitz or curvature analysis.

ReLU’s second derivative is zero almost everywhere, which makes those quantities vanish. Softplus, GELU and SiLU are used there instead.

📝 Quick check (Level 3)
0/3 answered
  1. 1. The maximum gap between softplus_β and ReLU is…
  2. 2. Softplus is the antiderivative of…
  3. 3. Physics-informed networks avoid ReLU because…

Level 4: Expert

★★★★★ Expert⏱ 25 minResearchers: original papers and open problems.

Is smoothness worth the slowdown?

History.

  • C. Dugas, Y. Bengio and colleagues (2001) proposed softplus, motivated by smooth, positive functions for option pricing.
  • X. Glorot, A. Bordes and Y. Bengio (2011) compared softplus and rectifiers in deep networks.
  • Softplus later became the standard positivity link in variational autoencoders, mixture density networks and probabilistic forecasting.

Exercise 2. A 3-hidden-layer network (width 64) on spirals, He initialisation, minibatch SGD. The table gives training accuracy, averaged over three seeds with the individual seeds in brackets. R² is the fraction of the activation’s variance over z ~ N(0, 1) explained by the best straight line: higher means closer to linear.

activation linear fit R² learning rate after 100 steps after 300 steps
ReLU 0.736 0.1 0.971 0.999
ReLU 0.736 0.5 0.999 1.000
softplus, β = 1 0.921 0.1 0.627 0.773 (0.667, 0.858, 0.795)
softplus, β = 1 0.921 0.5 0.739 0.834 (0.770, 0.763, 0.968)
softplus, β = 4 0.779 0.1 0.753 0.975
softplus, β = 4 0.779 0.5 0.913 0.999
softplus, β = 16 0.740 0.1 0.957 0.998
softplus, β = 16 0.740 0.5 0.999 1.000
  • Standard softplus trained far more slowly than ReLU. It was still below 0.86 on average after 300 steps, where ReLU had reached 1.0. The result held for three further seeds.
  • Sharpness was the cause. As β rose, the activation became less linear at the initialisation scale (R² 0.92 → 0.78 → 0.74), and training speed rose with it. At β = 16, softplus was indistinguishable from ReLU.
  • Practical rule: use softplus to produce positive outputs, not as a hidden activation. If a smooth hidden activation is needed, use GELU or SiLU (E1-8, E1-9), or a sharper softplus.
🐍 Exercise 2 (research): is smoothness worth the slowdown?
Train spiral classifiers with ReLU and softplus of sharpness 1, 4 and 16 at learning rates 0.1 and 0.5, and relate training speed to how linear each activation is over N(0, 1).

Softplus in AI, robotics and aerospace

  • Uncertainty estimation: networks predicting trajectory or state uncertainty output softplus standard deviations.
  • Learned dynamics: physical parameters (mass, damping, drag coefficients) are kept positive by a softplus reparameterisation.
  • Physics-informed networks: smooth activations are needed when PDE residuals involve second derivatives.

References

  1. C. Dugas, Y. Bengio, F. Bélisle, C. Nadeau, R. Garcia (2001). “Incorporating second-order functional knowledge for better option pricing.” Advances in NeurIPS 13.
  2. X. Glorot, A. Bordes, Y. Bengio (2011). “Deep sparse rectifier neural networks.” Proc. AISTATS.
  3. D. A. Nix, A. S. Weigend (1994). “Estimating the mean and variance of the target probability distribution.” Proc. IEEE ICNN.