Gradient

Courses

∇\nabla∇The maths behind AI0/72
π\piπMaths0/84
⋆\star⋆AI for everyone0/10
Γ\GammaΓGame theory0/49
py\texttt{py}pyPython for AI0/15
y^\hat{y}y^​Build your own AI0/15
All courses

Tuition

My tuitionOlympiad trackCompetitions

Practice

ProjectsAsk a questionTrain on a GPUExplorationsMaths StoriesUnsolved problemsPlaygroundScience labsMock testsOlympiad

Reference

GlossaryBlogDiscoveries
Glossary › Residual connection

What is residual connection?

Adding a sub-layer's output to its input instead of replacing it. This gives gradients a direct path through deep networks.

Where it is taught

The transformer block. Attention moves information between tokens. Add an MLP, two normalisations and two shortcut connections, and you have the unit that a GPT repeats again and again.

What the lesson leaves you with

  • A block is attention then an MLP, each wrapped in a residual connection with layer normalisation.
  • Residual connections give gradients a direct path, so very deep stacks can be trained.
  • Size is set by the dimension, the number of blocks and the number of heads. The design does not change.
Open the lesson

Questions

What is residual connection?
Adding a sub-layer's output to its input instead of replacing it. This gives gradients a direct path through deep networks.
Where is residual connection used in AI?
Attention moves information between tokens. Add an MLP, two normalisations and two shortcut connections, and you have the unit that a GPT repeats again and again.
What is the key idea to remember about residual connection?
A block is attention then an MLP, each wrapped in a residual connection with layer normalisation.
Where can I learn residual connection step by step?
In the lesson “The transformer block” in Gradient’s course on the maths behind AI, with interactive diagrams and questions.

See it in 3D on the blog

  • Sigmoid or ReLU: which activation function?3 min
  • How does attention work in transformers?3 min

Related terms

  • Attention
  • Attention head
  • Autoregressive
  • Byte-pair encoding
  • Causal mask
  • Context length