Residual Connections & Skip Connections
Why identity shortcuts solve the degradation problem: formal analysis of gradient flow in deep networks, the unraveled view of ResNets as exponential ensembles, and the dynamical systems interpretation of residual blocks.
Prerequisites
Table of Contents
- Learning Objectives
- Notation
- Core Intuition
- The Degradation Problem
- The Residual Learning Framework
- Gradient Flow Analysis
- The Unraveled View
- Dynamical Systems Interpretation
- Dense Connections (DenseNet)
- Common Pitfalls
- Summary
- Exercises
Learning Objectives
- Explain the degradation problem and why adding layers can increase training error.
- Derive how skip connections create direct gradient pathways.
- Prove that a ResNet with blocks can be viewed as an ensemble of paths.
- Interpret residual blocks as Euler discretization of an ODE.
- Analyze the effect of residual connections on the loss landscape.
Notation
- — hidden state at layer
- — residual function (nonlinear transformation at block )
- — total number of residual blocks
Core Intuition
A plain network of depth requires gradients to traverse nonlinear layers. Each layer's Jacobian can shrink or amplify gradients. A residual connection adds the identity: . This creates a "gradient highway" — the identity path carries gradients directly, regardless of what happens in .
Residual / Skip Connections
The Degradation Problem
Observation (He et al., 2015). Training error of a 56-layer plain network is higher than a 20-layer network — not due to overfitting (training error, not just test error, degrades).
Why? The deeper network has strictly more representational capacity. It could learn the identity for the extra layers. But optimization fails: the gradient signal is too weak or chaotic to find good solutions when traversing many composed nonlinearities.
The Residual Learning Framework
Instead of learning directly, learn the residual :
Key insight: If the optimal function is close to identity, learning a small is easier than learning from scratch. The skip connection provides the "default" identity mapping.
Gradient Flow Analysis
For a ResNet with blocks, the output is:
The gradient of the loss with respect to an intermediate layer:
Using the chain rule through residual blocks:
Expanding the product:
The leading term ensures the gradient never vanishes — even if all , the gradient flows directly through the identity.
The Unraveled View
Theorem (Veit et al., 2016). A ResNet with blocks is equivalent to an ensemble of paths of different lengths.
Proof. Expanding (2) recursively:
Each subset defines a path that passes through blocks in and skips the rest. There are such paths. Most effective paths have length (binomial distribution peaks).
Implication: ResNets exhibit graceful degradation — removing individual blocks has small effect because most paths remain intact.
Dynamical Systems Interpretation
The update is an Euler discretization of the ODE:
with step size . This perspective leads to:
- Neural ODEs (Chen et al., 2018): use adaptive ODE solvers instead of fixed layers.
- Depth as continuous time: deeper networks = longer integration time.
- Stability analysis: if , the system is contractive and stable.
Dense Connections (DenseNet)
DenseNet concatenates all previous features:
Every layer has direct access to all earlier features. This maximizes information flow but increases memory ( features at the final layer).
Common Pitfalls
Pitfall 1. Expecting skip connections to help shallow networks. The benefit is primarily for deep networks () where gradient degradation is significant.
Pitfall 2. Adding skip connections with dimension mismatch. When , use a linear projection: .
Pitfall 3. Not initializing residual blocks near zero. For very deep networks, if outputs are large at initialization, the sum in (2) grows as causing instability.
Summary
- Skip connections solve the degradation problem by providing identity shortcuts.
- The gradient contains a direct term — it never vanishes regardless of depth.
- ResNets can be viewed as ensembles of paths — inherently robust.
- The ODE interpretation connects depth to continuous dynamics.
- Residual connections smooth the loss landscape, making optimization easier.
Exercises
Exercise 1. For a plain network , show that the gradient is . How does this differ from equation (4)?
Exercise 2. Prove that a ResNet with blocks has unique paths from input to output.
Exercise 3. For the ODE with positive definite , show the solution is contractive: .
Exercise 4. Show that Pre-Norm ResNets have gradient norm for all .
Exercise 5. Compute the memory cost of DenseNet vs ResNet with blocks and hidden dimension .