A residual neural network (also referred to as a residual network or ResNet)[1] is a deep learning architecture in which the weight layers learn residual functions with reference to the layer inputs. It was developed in 2015 for image recognition and won that year's ImageNet Large Scale Visual Recognition Challenge (ILSVRC).[2] [3]
As a point of terminology, "residual connection" or "skip connection" refers to the specific architectural motif of where
f
The residual connection stabilizes the training and convergence of deep neural networks with hundreds of layers, and is a common motif in deep neural networks, such as Transformer models (e.g., BERT and GPT models such as ChatGPT), the AlphaGo Zero system, the AlphaStar system, and the AlphaFold system.
In a multi-layer neural network model, consider a subnetwork with a certain number of stacked layers (e.g., 2 or 3). Denote the underlying function performed by this subnetwork as , where is the input to the subnetwork. Residual learning re-parameterizes this subnetwork and lets the parameter layers represent a "residual function" . The output of this subnetwork is then represented as:
The operation of "" is implemented via a "skip connection" that performs an identity mapping to connect the input of the subnetwork with its output. This connection is referred to as a "residual connection" in later work. The function is often represented by matrix multiplication interlaced with activation functions and normalization operations (e.g., batch normalization or layer normalization). As a whole, one of these subnetworks is referred to as a "residual block". A deep residual network is constructed by simply stacking these blocks together.
Importantly, the underlying principle of residual blocks is also the principle of the original LSTM cell, a recurrent neural network that predicts an output at time
t+1
If the function
F
F:\Rn\to\Rm
n ≠ m
P
P(x)=Mx
M
m x n
The introduction of identity mappings facilitates signal propagation in both forward and backward paths, as described below.[7]
If the output of the -th residual block is the input to the -th residual block (assuming no activation function between blocks), then the -th input is:
Applying this formulation recursively, e.g.,
yields the general relationship:
where is the index of a residual block and is the index of some earlier block. This formulation suggests that there is always a signal that is directly sent from a shallower block to a deeper block .
The residual learning formulation provides the added benefit of addressing the vanishing gradient problem to some extent. However, it is crucial to acknowledge that the vanishing gradient issue is not the root cause of the degradation problem, which is tackled through the use of normalization layers. To observe the effect of residual blocks on backpropagation, consider the partial derivative of a loss function with respect to some residual block input . Using the equation above from forward propagation for a later residual block
L>\ell
This formulation suggests that the gradient computation of a shallower layer, , always has a later term that is directly added. Even if the gradients of the terms are small, the total gradient resists vanishing thanks to the added term .
A Basic Block is the simplest building block studied in the original ResNet. This block consists of two sequential 3x3 convolutional layers and a residual connection. The input and output dimensions of both layers are equal.
A Bottleneck Block consists of three sequential convolutional layers and a residual connection. The first layer in this block is a 1x1 convolution for dimension reduction, e.g., to 1/4 of the input dimension; the second layer performs a 3x3 convolution; the last layer is another 1x1 convolution for dimension restoration. The models of ResNet-50, ResNet-101, and ResNet-152 in are all based on Bottleneck Blocks.
The Pre-activation Residual Block applies the activation functions (e.g., non-linearity and normalization) before applying the residual function . Formally, the computation of a Pre-activation Residual Block can be written as:
where can be any non-linearity activation (e.g., ReLU) or normalization (e.g., LayerNorm) operation. This design reduces the number of non-identity mappings between Residual Blocks. This design was used to train models with 200 to over 1000 layers.
Since GPT-2, the Transformer Blocks have been dominantly implemented as Pre-activation Blocks. This is often referred to as "pre-normalization" in the literature of Transformer models.[8]
All Transformer architectures include residual connections. Indeed, very deep Transformer models cannot be successfully trained without Residual Connections.[9]
The original Residual Network paper made no claim on being inspired by biological systems. But later research has related ResNet to biologically-plausible algorithms.[10] [11]
A study published in Science in 2023[12] disclosed the complete connectome of an insect brain (of a fruit fly larva). This study discovered "multilayer shortcuts" that resemble the skip connections in artificial neural networks, including ResNets.
In 1961, Frank Rosenblatt described a three-layer multilayer perceptron (MLP) model with skip connections.[13] The model was referred to as a "cross-coupled system", and the skip connections were forms of cross-coupled connections.
During late 1980s, "skip-layer" connections were sometimes used in neural networks. Examples include.[14] [15] An 1988 paper[16] trained a fully connected feedforward network where each layer residually connects to all subsequent layers, like the later DenseNet (2016).
Sepp Hochreiter discovered the vanishing gradient problem in 1991[17] and argued that it explained why the then-prevalent forms of recurrent neural networks did not work for long sequences. He and Schrmidhuber later designed the long short-term memory (LSTM, 1997)[18] to solve this problem, which has a "cell state"
ct
In 2014, the state of the art was training “very deep neural network” with 20 to 30 layers. The research team attempted to train deeper ones by empirically testing various tricks for training deeper networks until they discovered the deep residual network architecture.[21]
DenseNet (2016)[22] connects the output of each layer to the input to each subsequent layer:
Neural networks with Stochastic Depth[23] were made possible given the Residual Network architectures. This training procedure randomly drops a subset of layers and lets the signal propagate through the identity skip connection. Also known as "DropPath", this is an effective regularization method for training large and deep models, such as the Vision Transformer (ViT).