Bring the mental model from Scaled Dot-Product Attention & Transformer Layers; this page will reuse it instead of restarting from zero.
Attention & Transformers
Residual Connections & Skip Connections
Why deep networks can keep useful features alive: each layer learns a correction to the identity instead of rewriting the whole representation from scratch.
Concept Structure
Residual Connections & Skip Connections
Start with the picture, metaphor, or geometric mechanism.
Make the objects explicit and connect them with notation.
Mirror the equations with runnable implementation details.
Manipulate the mechanism and watch the idea respond.
Learning map
Residual Connections & Skip ConnectionsConceptual Bridge
What should feel connected as you move through this page.
Why deep networks can keep useful features alive: each layer learns a correction to the identity instead of rewriting the whole representation from scratch.
The next edge should feel earned: use the demo prediction here before following Layer Normalization & RMSNorm.
01
Intuition
Build the mental picture first so the rest of the page has something to attach to.
Without a skip connection, a deep layer has to reinvent the whole representation it receives.
That is a hard optimization problem. If the best thing a layer could do is "mostly keep what already works, and add a small correction," a plain stack has no easy way to express that.
Residual connections make that easy. Instead of asking a layer to learn a full map , we ask it to learn a delta:
Now the safe default is clear:
- if the layer has nothing useful to add, it can make ,
- if it has a useful feature, it writes that feature on top of the existing state,
- the block provides an additive identity path for the current representation, even though later normalization, nonlinearities, finite precision, and downstream updates can still change or overwrite information.
In transformers, this becomes the residual stream mental model: attention and MLP blocks both read the current state, write an update, and pass the shared stream onward.
02
Math
Translate the story into symbols, assumptions, and a derivation you can inspect.
Let be the input to a block and let be the learned update. A residual block outputs
The Jacobian of this mapping is
where is the identity matrix and is the Jacobian of .
That identity term matters for optimization. Across many layers,
so backpropagation multiplies matrices of the form . Even if the learned part is small or noisy, there is still a direct gradient path through the identity.
For a pre-norm transformer layer, a common pattern is
This says each sublayer writes an update into a shared stream rather than replacing the stream entirely.
03
Code
Keep the implementation aligned with the notation so the algorithm is legible.
import numpy as np
rs = np.random.RandomState(0)
d = 128
x0 = rs.randn(d)
def run(depth=40, residual=True, alpha=0.2):
h = x0.copy()
norms = []
for _ in range(depth):
W = rs.randn(d, d) / np.sqrt(d)
update = np.tanh(W @ h)
h = h + alpha * update if residual else update
norms.append(np.linalg.norm(h))
return norms
plain = run(residual=False)
resid = run(residual=True)
print("plain layer-1/layer-40:", round(plain[0], 3), round(plain[-1], 3))
print("resid layer-1/layer-40:", round(resid[0], 3), round(resid[-1], 3))
Residual connections do not magically solve every instability, but they give optimization a much safer default: keep the current representation unless there is a good reason to change it.
04
Interactive Demo
Use direct manipulation to connect the explanation to a moving system.
No interactive demo yet for this concept. A strong next step would be a residual-stream sandbox that toggles skip connections on and off, then shows signal norms and gradient flow across depth.
No live visualization is registered for this concept yet.
The page still supports explanatory demo notes above; when a viz.tsx exists, it will render here without changing the route.
After The First Pass
Turn the concept into an inspected object.
Once the invariant is visible in the intuition, math, code, and demo, use these panels to inspect the mechanism visually, check source support, practice the idea, and attach a grounded research question.
Mechanism Storyboard
See the idea move before the page explains it
Why deep networks can keep useful features alive: each layer learns a correction to the identity instead of rewriting the whole representation from scratch.
Start with the picture, metaphor, or geometric mechanism.
Before reading further, choose the kind of change Residual Connections & Skip Connections should make visible.
Visual Inquiry
Make the image answer a mathematical question
Why deep networks can keep useful features alive: each layer learns a correction to the identity instead of rewriting the whole representation from scratch.
Which visible object should carry the first intuition?
Pick the cue that should make Residual Connections & Skip Connections easier to reason about before the page gives the answer.
Claim Review
Why deep networks can keep useful features alive: each layer learns a correction to the identity instead of rewriting the whole representation from scratch.
Source IDs and witness objects are attached for review; they are not proof by themselves.
Add source metadata before claiming support.
Use equation, code, and demo objects to check whether the source support is operational.
Source support candidates
No structured source note is attached yet.
Practice Loop
Try the idea before it explains itself
Why deep networks can keep useful features alive: each layer learns a correction to the identity instead of rewriting the whole representation from scratch.
Before touching the demo, predict one visible change that should happen in Residual Connections & Skip Connections.
Reveal when your model needs a nudge.
Reveal when your model needs a nudge.
Reveal when your model needs a nudge.
A concrete answer is on the canvas.
The answer names why the claim should hold.
It touches the page context or a neighboring idea.
Research Room
Attach the question to an exact object
Pick the concept, equation, source, code witness, claim, misconception, or demo state before asking for help. The handoff stays grounded to that object.Open the draft below to save one note and next action in this browser.
Residual Connections & Skip Connections
What is the smallest example that makes Residual Connections & Skip Connections click without losing the math?
Local action draftNo local draft saved yetExpand only when ready to capture one local next action
This draft stays locally in this browser for concept:attention-transformers/residual-connections.
- Definition, prerequisite, and contrast concept links
- The equation or code witness that makes the concept operational
- One demo state that shows the invariant instead of a slogan
- The learner can state the mechanism in their own words
- The learner can name the prerequisite that would repair confusion
- The learner can predict how the mechanism changes under one perturbation
I am working in Continuous Function's research reading room. Object: concept - Residual Connections & Skip Connections Object key: concept:attention-transformers/residual-connections Context: Attention & Transformers Anchor id: concept/concept-notebook/attention-transformers/residual-connections Open question: What is the smallest example that makes Residual Connections & Skip Connections click without losing the math? Evidence to inspect: - Definition, prerequisite, and contrast concept links - The equation or code witness that makes the concept operational - One demo state that shows the invariant instead of a slogan What would resolve this: - The learner can state the mechanism in their own words - The learner can name the prerequisite that would repair confusion - The learner can predict how the mechanism changes under one perturbation Answer as a careful research tutor: stay source-grounded, separate verified evidence from assumptions, name the relevant math objects, and end with one next action.
concept/concept-notebook/attention-transformers/residual-connections
concept:attention-transformers/residual-connections