Understanding ResNets: How Residual Connections Improve Backpropagation

·

3 min read

Deep learning has been at the forefront of recent advancements in artificial intelligence, with Convolutional Neural Networks (CNNs) leading the way in image recognition tasks. However, as we try to make our networks deeper to capture more complex patterns, we run into a couple of key problems: vanishing and exploding gradients. The ResNet (Residual Network) architecture, introduced by He et al. in 2015, effectively addresses these issues using a simple but powerful concept known as residual connections or skip connections.

Vanishing and Exploding Gradients

The backpropagation algorithm, which is used to train neural networks, works by calculating the gradient of the loss function with respect to the network's parameters and then adjusting the parameters in a direction that reduces the loss. However, when networks become very deep, the gradients can become exceedingly small (vanish) or exceedingly large (explode) during this process. This makes the network hard to train, as the updates to the parameters either become insignificantly small or uncontrollably large.

Enter ResNet: The Power of Residual Connections

ResNet tackles this problem by introducing a concept called residual learning. Instead of trying to learn an underlying mapping directly, the layers in ResNet learn the residual, or difference, between the current learned representation and the target.

Specifically, a ResNet is composed of several stacked "Residual Blocks". In each block, the input is passed through a series of layers (like convolution and batch normalization) and then added to the output of these layers. This operation forms a 'shortcut' or 'skip connection', allowing the input of the block to be added to the output of the layers in the block.

Mathematically, if we denote the desired underlying mapping as H(x), traditional networks would try to learn this H(x) directly. Instead, ResNets try to learn the residual, or F(x) = H(x) - x, and then compute the original mapping as H(x) = F(x) + x.

How Does This Help With Backpropagation?

The main advantage of residual connections comes during backpropagation. As we noted, backpropagation works by propagating the error gradient back through the network. In a ResNet, when the error is backpropagated, the gradient can flow directly through the shortcut connections, unimpeded by any layers.

This direct path makes it easier for the gradient to reach the earlier layers without vanishing, even in very deep networks. This happens because, due to the addition operation in the residual block, at least one path exists where the gradient is neither multiplied by a weight matrix (which could cause it to vanish) nor does it go through an activation function (which could also cause it to vanish).

Conclusion

ResNets, with their clever use of residual connections, have significantly improved the training process of deep neural networks, allowing us to train networks with depths that were previously thought to be impractical. ResNets have achieved state-of-the-art performance in various tasks and have paved the way for even more sophisticated deep learning architectures. Through residual learning, ResNets have given us a powerful tool to combat the vanishing and exploding gradient problems and have pushed the boundaries of what is possible with deep learning.