Backpropagation › Gradient Flow Through Activation Functions
Language AI HandbookAll chapters Backpropagation › Gradient Flow Through Activation FunctionsOne section · Sections in this chapter7 / 20 ↓
Reading tools Definitions & inline links
Choose your expertise level to adjust how many terms are explained. Beginners see more tooltips, experts see fewer to maintain reading flow. Hover over underlined terms for instant definitions.
Article links
Make inline references clickable
The backward pass depends critically on the derivatives of activation functions. Different activations have very different gradient behaviors, which directly affects how well information flows backward through deep networks. We covered activation functions in depth in the Activation Functions chapter, so here we focus on their gradient properties specifically in the context of backpropagation.
Sigmoid Gradient
The sigmoid function has derivative:
where:
- : the sigmoid output, a value in
- : the derivative, which equals
The maximum value of is , achieved at . For large, the sigmoid saturates (output near 0 or 1), and the derivative approaches 0. This vanishing gradient problem is severe: each sigmoid layer multiplies the gradient by at most 0.25. In a 10-layer network, the gradient at the first layer could be multiplied by relative to the last layer.
There is another way to see why this is so problematic. The gradient of the loss with respect to the first layer's weights is computed as a product of gradients across all intermediate layers. If those gradients are small fractions (as they are for sigmoid in saturation), their product is tiny. This means the first-layer weights barely move during training. The network effectively cannot learn any useful feature representation in its early layers when trained with sigmoid activations in deep networks.
Tanh Gradient
The hyperbolic tangent has derivative:
This has maximum value 1.0 at and decays toward 0 as grows. Tanh is better than sigmoid in that its maximum derivative is 1 (versus 0.25 for sigmoid), but it still saturates and can cause vanishing gradients in deep networks. The fact that tanh is zero-centered (outputs range from to ) makes it slightly easier to optimize than sigmoid in practice, since the gradients with respect to downstream weights are not all positive or all negative for a given input.
ReLU Gradient
The ReLU function has derivative:
For positive inputs, ReLU passes the gradient through unchanged (gradient is 1). For negative inputs, ReLU blocks the gradient entirely (gradient is 0). This has two important consequences:
- No vanishing gradient for active neurons: When a neuron is active (output > 0), the gradient passes through without attenuation. A 100-layer ReLU network can potentially propagate gradients all the way back to the first layer without shrinkage, as long as enough neurons remain active.
- Dying ReLU problem: If a neuron consistently outputs negative values (typically due to a large negative bias or unfortunate weight initialization), it permanently stops learning because all gradients through it are zero. This can be detected during training by monitoring the fraction of neurons with zero activations, and mitigated with careful initialization or variants like Leaky ReLU.
The ReLU gradient's binary nature means it is not just non-vanishing for positive inputs: it also cannot explode. A gradient of 1 times 1 is still 1. This stability is a major practical advantage, and it explains why the shift from sigmoid to ReLU activations in the early 2010s dramatically improved the trainability of deep networks.
GELU Gradient
The GELU function (used in modern transformers) has a smooth, data-dependent gradient that avoids both sharp saturation and hard zeros. Its derivative involves the standard normal PDF and CDF, creating a smoother gradient landscape than ReLU. GELU's derivative is positive even for moderately negative inputs, which means neurons rarely die completely, though they do attenuate gradients in the negative regime.
![Line plot of activation function values for sigmoid, tanh, ReLU, and GELU over [-4,4].](https://assets.mbrenndoerfer.com/_optimized/notebooks/backpropagation_files/activation-function-values-1920w.webp)

The derivative plots reveal a key asymmetry. Sigmoid and tanh derivatives peak at 0.25 and 1.0 respectively, then decay toward zero as inputs grow large. ReLU's derivative is a step function: exactly 1 for positive inputs, exactly 0 for negative. GELU interpolates smoothly between the two extremes, with a small but nonzero gradient even for moderately negative inputs. In deep networks, these gradient magnitudes multiply together across layers, so choosing ReLU or GELU over sigmoid was a major practical advance in training deep networks.
To make the vanishing gradient problem concrete, consider a network with 20 layers. The gradient at the first layer has been multiplied by the activation derivative at each intermediate layer. If the average derivative is less than 1 (sigmoid at 0.25, tanh at up to 1 but below 1 for most inputs), the gradient shrinks exponentially with depth:


The left plot confirms the textbook result: sigmoid gradients decay exponentially as they travel toward earlier layers, while ReLU gradients remain comparatively stable. The right plot shows how rapidly this ratio grows with depth for sigmoid, reaching many orders of magnitude even for moderate-depth networks.