Md. Asif Uddin
I.3.X02

Softplus and its derivative

symbolic▲△△

Softplus is ς(z)=log(1+ez)\varsigma(z) = \log(1 + e^{z}). Show that ς(z)=σ(z)\varsigma'(z) = \sigma(z), that ς(z)>ReLU(z)\varsigma(z) > \mathrm{ReLU}(z) everywhere, and that ς(z)ReLU(z)0\varsigma(z) - \mathrm{ReLU}(z) \to 0 as z|z| \to \infty. Then say why softplus is nevertheless rarely used.

Hint

For the last part, evaluate ς\varsigma naively at z=100z = 100 in fp32.

Solution

The derivative. By the chain rule,

ς(z)=11+ezez=ez1+ez=11+ez=σ(z)\varsigma'(z) = \frac{1}{1+e^{z}} \cdot e^{z} = \frac{e^{z}}{1+e^{z}} = \frac{1}{1+e^{-z}} = \sigma(z)

dividing through by eze^{z} at the last step. Softplus is the antiderivative of the sigmoid — a fact worth carrying, because it means the smooth gate and the smooth rectifier are the same object seen at two orders of differentiation.

It dominates ReLU. For z0z \le 0, ς(z)=log(1+ez)>log1=0=ReLU(z)\varsigma(z) = \log(1+e^{z}) > \log 1 = 0 = \mathrm{ReLU}(z). For z>0z > 0, write ς(z)=z+log(1+ez)>z=ReLU(z)\varsigma(z) = z + \log(1 + e^{-z}) > z = \mathrm{ReLU}(z), since the log term is positive. So ς>ReLU\varsigma > \mathrm{ReLU} everywhere.

The gap vanishes. From the two forms above, the gap is log(1+ez)\log(1+e^{z}) for z<0z<0 and log(1+ez)\log(1+e^{-z}) for z>0z>0 — in both cases log(1+ez)\log(1+e^{-|z|}), which tends to log1=0\log 1 = 0. At z=5|z| = 5 the gap is already 0.00670.0067.

Why it is rarely used. Three reasons, in decreasing order of importance.

It overflows if written naively. At z=100z = 100, e100=2.7×1043e^{100} = 2.7\times10^{43} — fine in fp32, but at z=800z = 800 it is \infty and log()=\log(\infty) = \infty. The correct implementation is max(z,0)+log(1+ez)\max(z,0) + \log(1 + e^{-|z|}) (Log-sum-exp 0.NU.02), which never overflows. Every framework does this; the point is that the naive form is a real trap.

It costs more. Roughly 66 FLOPs per element against ReLU’s 11 — though I.3.B07 showed that difference is under 0.2%0.2\% of the layer, so this reason is weaker than it is usually stated.

It has no exact zeros. ς(z)>0\varsigma(z) > 0 always, so no unit is ever silent and no activation is ever sparse. Sparsity was the original argument for ReLU, and whether it matters is still debated — but softplus definitively does not have it.

What it is used for. Where a strictly positive output is required and smoothness matters: a predicted variance, a rate parameter, a scale in a distribution. Chapter I.13 uses it exactly there.

Draws on