The mechanism
Residual connections add a block’s output to a continuing representation. This lets each block contribute an update and provides a direct route through a deep computation graph. Normalization controls aspects of numerical scale; LayerNorm uses the mean and variance over specified feature dimensions, while other normalizers differ. Placement before or after sublayers matters. Neither operation creates persistent autobiographical memory: the stream is an intermediate activation for the current computation.
A residual addition passes an input directly to the output alongside a learned transformation, creating an identity term in the derivative. Normalization modifies feature scale before or after a sublayer according to the declared architecture. RMS normalization does not subtract the mean, and its learned gain and epsilon conventions must be stated. The lifecycle variant uses pre-RMS normalization with fixed gain one and epsilon 1e-5; it is not exactly the original Transformer normalization placement.
- Normalize the features at the architecture’s chosen location.
- Compute the block’s transformation.
- Add the compatible result to the continuing representation.
- Trace the identity branch separately from the sublayer branch.
- Compute mean square over the declared feature axis, with epsilon placed explicitly.
- Compare actual activation and gradient values rather than assuming a residual guarantees stable learning.
Science and assumptions
Normalization and a direct gradient route
LayerNorm subtracts the feature mean and divides by the square root of variance plus stabilizer, then applies learned scale and shift. Separately, an identity residual add has Jacobian equal to the identity plus the transformation Jacobian.
Normalization and residual addition are separate relations, not a claim that every architecture uses this combined block. Model coordinates are usually represented as dimensionless numbers.
Symbols and units
- x
- Input representation over the normalized feature set
real d-coordinate vector
- μ
- Mean of x over those features
same coordinate units as x
- σ²
- Population variance over those features
squared coordinate units
- ε
- Positive normalization stabilizer
same units as σ²
- γ
- Learned elementwise output scale
output-coordinate units
- β
- Learned elementwise output shift
output-coordinate units
- y
- Residual-block output
same shape and coordinate units as x
- F(x)
- Residual transformation with matching output shape
same shape and coordinate units as x
- I
- Identity Jacobian for the skip path
dimensionless d × d matrix
- J_F(x)
- Jacobian of F with respect to x
dimensionless d × d matrix
- ⊙
- Elementwise multiplication
operator
LayerNorm measures the mean and variance of one representation across its normalized features, then applies learned scale and shift. Separately, a residual add supplies an identity term in the Jacobian, giving gradients a direct path alongside the learned transformation. Neither guarantees that all deep networks train stably.
Assumptions The residual equation describes an identity skip with matching shapes; F may include normalization. LayerNorm uses population variance over the chosen features. RMSNorm omits mean subtraction, and pre-norm versus post-norm changes the full block Jacobian.
Activation scale and gradient flow · worked relation
Distinguish an identity gradient path from normalization’s scale transformation.
Symbols and units
- x_i
- Input feature
dimensionless
- d
- Features normalized together
features
- epsilon
- Positive stabilizer in mean-square units
dimensionless squared
- f
- Residual sublayer
function
- y
- Residual output
dimensionless
For y=x+f(x), local derivative is 1+f′(x); if f′(x)=−0.2 the total is 0.8. For vector [3,4], RMS without epsilon is sqrt((9+16)/2)=sqrt12.5=3.535534, giving normalized values [0.848528,1.131371]. Their mean is not zero. The core’s positive epsilon changes these numbers slightly and prevents division by zero.
Assumptions Fixed gain one; epsilon zero only for the explicitly labeled hand calculation. Core epsilon is 1e-5, so exact scale invariance is qualified.
Engineering example
Synthetic vector [1, 3] has mean 2 and population variance 1. With unit scale, zero shift and ε = 0.00001, LayerNorm gives approximately [−0.999995, 0.999995]. Separately, adding an update [0.5, −0.5] to the original vector gives [1.5, 2.5]; the two operations do different work.
For y=x+f(x), local derivative is 1+f′(x); if f′(x)=−0.2 the total is 0.8. For vector [3,4], RMS without epsilon is sqrt((9+16)/2)=sqrt12.5=3.535534, giving normalized values [0.848528,1.131371]. Their mean is not zero. The core’s positive epsilon changes these numbers slightly and prevents division by zero.
Distinctions and tradeoffs
Residual streams carry current activations; they are not persistent personal memory.
Normalization and residual placement affect stability. Low precision requires care with accumulation and numerical ranges.
These operations make very deep learned transformations practical.
Specifications and interfaces
- Residual add
- x + f(x)
Both operands must have compatible shapes.
- LayerNorm
- (x − μ) / √(σ² + ε)
Usually includes learned affine parameters.
Interfaces
- Earlier layer Input
- Activation vector
- Later layer Output
- Updated activation vector
Check your understanding
What travels through a residual connection?
- An intermediate numerical representation
- An archive of all training documents
- Coolant
Answer and reasoning
An intermediate numerical representation
It carries activations through the computation graph.
Does RMS normalization force the output mean to zero?
- Yes, for every input.
- Only when residual paths are absent.
- No; it rescales by root mean square without subtracting the mean.
Answer and reasoning
No; it rescales by root mean square without subtracting the mean.
No; it rescales by root mean square without subtracting the mean. Fixed gain one; epsilon zero only for the explicitly labeled hand calculation. Core epsilon is 1e-5, so exact scale invariance is qualified.
Historical context
2016 · Layer normalization removes dependence on batch statistics
Ba, Kiros, and Hinton proposed normalization within a training example, with the same normalization computation at training and inference. This became useful for sequence models with varying batch conditions.
Evidence and scope
The example uses the linked LayerNorm definition over two features. RMSNorm, pre/post-normalization placement and learned parameters differ; the residual operands must have matching shapes, and neither operation guarantees stable training.
Mode: executable residual and RMS paths. Fixed gain one; epsilon zero only for the explicitly labeled hand calculation. Core epsilon is 1e-5, so exact scale invariance is qualified. Numerical examples are authored calculations, except explicitly identified automated core fixtures. Primary sources support the scoped mechanism; no human specialist review or learner outcome is implied.
Use the execution investigation for the shared tensor-to-memory-to-result thread; no current standalone calculator models this lesson’s full mechanism.