Skip to content

Residual network

Residual networks add learned corrections to shortcuts. Trace a scalar block and its gradient, understand projection and activation order, and avoid guarantees about financial generalisation.

A residual network is a neural network built from blocks that add a learned transformation to a shortcut carrying the block's input. This lets a deep model refine an existing representation instead of requiring each block to reconstruct it. For a quant researcher building a deep encoder for order-book observations or volatility surfaces, the immediate benefit is an architectural way to ease optimisation; forecasting value still has to be established on later data.

Learn a correction to the input

For an input vector or tensor xx, the simplest identity-shortcut block computes

y=x+F(x;θ).y=x+F(x;\theta).

The residual branch FF contains trainable layers with parameters θ\theta. If a desired block mapping is H(x)H(x), the branch is asked to learn H(x)−xH(x)-x. When F(x)=0F(x)=0, this basic block passes xx through unchanged. Here “residual” means a correction relative to the input, rather than an observed-minus-predicted regression error.

He and colleagues introduced the ResNet family to address degradation: deeper plain networks could have higher training error than shallower counterparts. That is an optimisation problem, distinct from overfitting. Their 2015 paper, §§1 and 3, motivates the residual parameterisation and tests it on image-recognition tasks.

The addition is element by element. Both branches must have matching shapes; concatenation would append features and is a different operation. When channels or resolution change, a common repair is a learned projection shortcut:

y=P(x)+F(x;θ).y=P(x)+F(x;\theta).
In a convolutional neural network, this can be a 1×11\times1 convolution with an appropriate stride and output-channel count. The shortcut then has parameters and is no longer the identity map. See He et al., §3.2.

Follow the value, then the gradient

Take a synthetic, dimensionless scalar block with fixed branch F(x)=0.25x−1F(x)=0.25x-1. At x=2x=2, the branch produces −0.5-0.5 and the addition gives y=1.5y=1.5. These values illustrate the computation; they are not fitted financial estimates.

Synthetic input 2 follows an identity shortcut and residual branch F(x) equals 0.25x minus 1, producing minus 0.5. Addition gives output 1.5. For loss half y squared, shortcut and branch gradient contributions are 1.5 and 0.375, summing to 1.875.
Synthetic input 2 follows an identity shortcut and residual branch F(x) equals 0.25x minus 1, producing minus 0.5. Addition gives output 1.5. For loss half y squared, shortcut and branch gradient contributions are 1.5 and 0.375, summing to 1.875.
Original scalar forward and backward calculation. Parameters are fixed by hand; all quantities are dimensionless. The diagram shows addition before any optional output activation.

For a differentiable scalar branch, the block derivative is

dydx=1+F′(x)=1.25.\frac{dy}{dx}=1+F'(x)=1.25.
With loss function L=12y2L=\tfrac12 y^2, the chain rule gives
dLdx=dLdydydx=1.5(1+0.25)=1.875.\frac{dL}{dx} =\frac{dL}{dy}\frac{dy}{dx} =1.5(1+0.25) =1.875.
The two paths contribute 1.51.5 and 0.3750.375. This derivative concerns the block's input; updating a trainable parameter requires its own loss derivative. In the vector case, the block Jacobian is I+JF(x)I+J_F(x), where II is the identity matrix and JFJ_F is the branch Jacobian. The 2016 identity-mapping paper, §2, analyses the direct forward and backward paths created by identity shortcuts.
A direct path does not guarantee a nonzero total gradient. Set F(x)=−x+3F(x)=-x+3: the basic block is constantly 33, so its input derivative is 1−1=01-1=0. Even with L=12y2L=\tfrac12y^2 and nonzero upstream derivative dL/dy=3dL/dy=3, the total dL/dxdL/dx is zero. Nor does the identity summand guarantee good conditioning or prevent exploding gradients across a whole network.

The activation's position changes the block

The displayed equation describes the addition itself. The original ResNet units apply a ReLU after that addition, so a full post-activation unit outputs ReLU⁡(x+F(x))\operatorname{ReLU}(x+F(x)). Negative sums are clamped to zero and their local derivatives are zero. Even F=0F=0 then gives ReLU⁡(x)\operatorname{ReLU}(x), rather than the identity for every possible input.
Full pre-activation units move normalisation and ReLU before the branch's weight layers and leave the sum without an immediate post-addition ReLU. This preserves a cleaner identity route across compatible blocks. He et al. compare these orderings in the 2016 paper, §4 and Figure 4. “Residual connection” alone therefore does not specify the activation order or the shortcut used at shape changes.

Use depth as a research choice

A residual architecture can improve trainability without demonstrating better predictions outside the training sample. There is no universal layer count at which shortcuts become necessary, and image-benchmark results do not establish an advantage on a financial dataset. Compare the complete training procedure with a simpler baseline under the same evaluation rules.

For a forecasting encoder, every residual branch still needs to respect the prediction cutoff. Adding an identity path does not repair a branch that uses future observations. Keep preprocessing, parameter fitting and architecture selection within their eligible data windows, then evaluate on later observations; shortcuts do not remove look-ahead bias or protect against distribution shift.
For tensor-shape tracking and a worked convolutional residual block, see SelfMadeQuant's CNN Building Blocks, Receptive Fields, and Residual Design Patterns. The preview is public; the full lesson requires membership.

Sources

Last updated
  • residual networks
  • resnet
  • deep learning
  • skip connections
  • gradient flow
← Back to the glossaryBack to top ↑