Residual Connections (ResNet)
A residual connection is a structure that adds the input of a network layer directly to that layer's output, that is, the output equals the layer transformation result plus the original input. It is the core design of ResNet (deep residual network), which solved the difficulty of training deep networks and made feedforward networks of hundreds or even thousands of layers truly usable in engineering.
Core Principles
In traditional stacked networks, each layer is required to learn the desired mapping directly. As layers deepen, gradients must be multiplied back layer by layer; as long as the Jacobian spectrum of most layers is small, gradients decay exponentially and training nearly stalls. At the same time, optimizing an identity mapping is numerically nontrivial, and the training error of a deep network may actually be higher than that of a shallow one. The residual structure changes what the network must learn from a complete mapping to a residual, that is, the difference between output and input. If some layers need to do nothing, they only need to learn the residual as zero, and the identity mapping becomes naturally easy to express; this is the motivation for residual learning.
From another angle, the residual connection opens an identity path beside the main path, and during backpropagation gradients can return directly to shallow layers along this path, equivalent to providing a low-impedance highway for gradients and alleviating vanishing gradients. This structure also makes the loss surface smoother with fewer jumps, reducing sensitivity to initialization and learning rate.
Key Points
Basic module: two or three convolutional layers, each followed by batch normalization and an activation function, with the output then added element-wise to the input before activation. The key to the order is activation after the addition, so that the residual branch output is not truncated by the activation function into the non-negative range.
Dimension matching: when the channel count or spatial size of input and output differ, they cannot be added directly; usually a stride-2 convolution or a 1x1 convolution projects the input to the same shape, and this projection is called the shortcut projection. Another approach uses projection only where channels change and keeps identity elsewhere, reducing parameters.
Bottleneck structure: deep networks commonly use a bottleneck module of "1x1 dimension reduction, 3x3 convolution, 1x1 dimension increase," greatly reducing the channel count of the 3x3 convolution and thus the computation. ResNet versions of fifty layers and above all adopt this design.
Pre-activation variant: moving normalization and activation before the convolution keeps the identity path completely clean with no operation at all; measurements show it is easier to optimize in very deep networks and better suited to transfer learning. In practice, the weights of many frameworks originate from pre-activation versions.
On the cost side: residual connections add a small amount of addition and memory usage, because the post-addition activation must be retained during backpropagation, and memory is often the first wall hit when training deep backbones; but they do not reduce inference computation or total parameters. In addition, stacking multiple residual branches may cause activation values to grow with depth, so normalization is needed after the addition or at the branch end, otherwise deep output values become uncontrolled.
Common Misconceptions
First, believing a residual connection is shortcut learning and that adding it always helps. If the residual branch output scale is large, the addition destroys the activation value range, and reasonable initialization and normalization must cooperate. Second, treating it as a purely parallel branch and ignoring that shapes must be aligned before addition. Third, believing residuals allow unlimited depth, when in fact ultra-deep networks still need pre-activation, appropriate initialization, and learning rate warmup to converge stably.
Application Scenarios
Image classification backbones, object detection, semantic segmentation, acoustic models for speech recognition, denoising networks in diffusion models, submodules of each Transformer layer, graph neural networks, and medical image analysis.