How do you express the derivatives of σ(z)=11+e−z and tanh⁡(z)=ez−e−zez+e−z purely in terms of σ(z) and tanh⁡(z), what are their maximum values, and why is tanh⁡ generally preferred over σ in hidden layers?

Deep learning, Neurons and activations
Level L3 Intermediate. Length Medium. Nature Th+Mat Both.

What's being asked

Whether you can differentiate both saturating activations cleanly and explain the optimisation benefit of zero-centred outputs.

Key idea

σ′(z)=σ(z)(1−σ(z)) with maximum 14 at z=0, and tanh⁡′(z)=1−tanh⁡2(z) with maximum 1 at z=0. Unlike σ(z)∈(0,1), tanh⁡(z)∈(−1,1) is zero-centred, so weights feeding from a hidden layer can receive mixed-sign gradients.

Steps

  1. Sigmoid derivative: write σ(z)=(1+e−z)−1. Differentiating gives σ′(z)=e−z(1+e−z)2=11+e−z⋅e−z1+e−z=σ(z)(1−σ(z)). At z=0, σ(0)=12, giving the maximum 14.
  2. Tanh derivative: write tanh⁡(z)=sinh⁡zcosh⁡z. By the quotient rule, tanh⁡′(z)=cosh⁡2z−sinh⁡2zcosh⁡2z=1−tanh⁡2(z) (using cosh⁡2z−sinh⁡2z=1). At z=0, tanh⁡(0)=0, giving the maximum 1.
  3. Why tanh⁡ trains better: for a weight vector w receiving strictly positive inputs x=σ(zprev)>0 and upstream error signal δ=∂L∂z, the gradient ∂L∂w=δ x has the same sign on every coordinate, forcing zig-zagging updates. Zero-centred tanh⁡ inputs avoid this bias and also have a 4× larger peak derivative.
  4. Note the shared limitation: both activations still saturate when ∣z∣ is large, so neither prevents vanishing gradients on its own in very deep networks (which is why ReLU variants are preferred in deep hidden layers).

Common mistakes

How long your answer should be

About half a page; 2–3 minutes covering both derivations, their maxima and the zero-centring reason.

Read this

Previous in Deep learning: For a mini-batch of N examples stacked as rows in X∈RN×d, a two-layer network computes Z=XW1+1b1⊤, H=ϕ(Z) and Y^=HW2+1b2⊤, where W1∈Rd×m, b1∈Rm, W2∈Rm×K, b2∈RK and 1∈RN is the all-ones vector. Given the batch-averaged loss gradient Δ2=∂L∂Y^∈RN×K, what are the gradients with respect to W2,b2,W1,b1, and how do matrix dimensions verify the transposes?
Next in Deep learning: For p=softmax⁡(z)∈RK, how do you derive the full Jacobian matrix J=∂p∂z for both diagonal (i=j) and off-diagonal (i≠j) entries, and why does shifting every logit by a constant c leave p unchanged?