3.1.11 · D1Neural Network Fundamentals

Foundations — Vanishing and exploding gradients

1,812 words8 min readBack to topic

This page assumes you have seen none of the notation in the parent note. We build every symbol from the ground up, in the order the story needs them. By the end, the equation should read like a plain English sentence.


0 — What a layer is, drawn

Before any symbol: a neural network is a stack of layers. Each layer takes a list of numbers, mixes them, bends them, and hands the result to the next layer. "Deep" just means many layers stacked.

Figure — Vanishing and exploding gradients

Why we need this: the whole topic is about what happens as a signal travels from layer back to layer . Without a way to number layers we cannot even ask "how many multiplications happened."


1 — Vectors, and the symbol

Inside a layer, the numbers travel in a bunch. A vector is just an ordered list of numbers, like . Picture it as several parallel wires, each carrying one number.


2 — The weighted sum, and the symbols , ,

Each neuron takes the previous layer's numbers, multiplies each by an importance factor, adds them up, and adds a constant. That is a weighted sum.

Figure — Vanishing and exploding gradients

Why we need separately from : the multiplication that causes vanishing/exploding happens partly through and partly through the bending we apply to . We must name the number before bending to talk about both.

The tool used here is matrix multiplication — not ordinary multiplication — precisely because a layer takes many inputs to many outputs at once. A matrix is the compact way to write "every output is a weighted combination of every input." See Weight Initialization for how the size of the numbers in is chosen.


3 — The activation function and its slope

After the weighted sum we bend the value with a function called (Greek "sigma"). Bending is what lets a network learn curves, not just straight lines.

Figure — Vanishing and exploding gradients

The tool here is the derivative, chosen because backpropagation literally asks "rate of change of output per change of input" at every neuron — and that is the definition of a derivative. More on choices in Activation Functions.


4 — The loss and the gradient

The network's mistake is measured by a single number, the loss. Training means shrinking it.

Why we need this: "the gradient vanishes" means is nearly all zeros — layer 1 has no direction to move, so it stops learning. Everything ties back to Gradient Descent, which steps the weights along this gradient.


5 — The error signal and the chain rule

Backprop does not recompute everything from scratch at each layer. It carries a running quantity backward.

Figure — Vanishing and exploding gradients

Each backward step multiplies by a and a . Two multipliers, one per link. See Backpropagation for the full derivation of this recursion.


6 — Products, norms, and the gain

Going from layer all the way to layer 1 chains such steps. Multiplying factors is the source of all the trouble.

The tool here is the exponential : whenever the same factor is applied repeatedly, the result is that factor raised to a power. That is why a tiny per-layer bias (say or ) becomes astronomically small or large over many layers. Fixes like Batch Normalization and Residual Networks (ResNet) exist purely to pin near ; LSTM and GRU do the same for recurrent nets.


Prerequisite map

Layer index l and depth L

Weighted sum z = W a + b

Vectors a and matrices W

Activation sigma and slope sigma prime

Error signal delta per layer

Loss L and gradient grad

Chain rule = multiply along path

Product of L minus 1 factors

Norm and per layer gain gamma

Vanishing and exploding gradients


Equipment checklist

What does the superscript in mean?
A layer label (layer number ), not a power.
What is a vector, in one phrase?
An ordered list of numbers — picture parallel wires each carrying one value.
What does the matrix store?
How strongly each input feeds each output neuron — a table of weights.
Difference between and ?
is the weighted sum before bending; is after the activation.
What does measure and why does it matter?
The slope of the activation at ; if it's near 0 (a flat part), the backward signal dies there.
What is the loss ?
One number scoring how wrong the network is; training shrinks it.
What does being near zero mean?
Layer 1's gradient vanished — it has no direction to update and stops learning.
What is ?
The loss's sensitivity to layer 's pre-activation, .
Why does a product of factors appear in backprop?
The chain rule multiplies each layer's effect along the path from loss to layer 1.
What does do?
Multiplies matching entries element-wise (each neuron scales only its own error).
Why the exponent in ?
Propagating from layer to layer 1 crosses links, each contributing one factor .
What single value must stay near 1 for stable training?
The per-layer gain .