Interactive Lab · Deep Networks & ResNets
To train a network, the error signal has to travel backward through every layer. In a deep plain network it fades a little at each step, and after 20 layers it's a rounding error, so the early layers never learn. That "vanishing gradient" is why deep nets were untrainable for years. Then came one absurdly simple fix: add the input back to the output of each block (out = x + F(x)). Flip the switch and watch the dead signal come back to life.
▶ The playground, watch the gradient flow backward
Add the block's input back to its output: out = x + F(x). The "+x" gives the gradient a shortcut straight to the early layers, an uninterrupted highway that never fades. Click to toggle.
Residual (skip) connections are why we can train networks hundreds of layers deep without gradients vanishing. They unlocked modern computer vision and are baked into every transformer and LLM block. When a deep net won't train, the first question is: does it have residual connections?
The code that's actually running
With skips OFF, switch the activation to ReLU and then sigmoid, watching the first-layer bar. Sigmoid's slope is at most 0.25, so the gradient shrinks by ≥4× every layer, it's dead within a dozen layers. ReLU's slope is 1 for positive inputs, so it fades far more slowly (that's why ReLU alone bought a few more layers of depth). But crank the depth up and even ReLU eventually starves, until you turn skips on, and the highway keeps every layer fed no matter how deep you go.
The takeaway
out = x + F(x) means the gradient has a path with slope exactly 1 all the way down. It can't vanish, so even 100+ layers train.