liveBook · Manning

Residual connection

As explained in Deep Learning with R, Third Edition

A residual connection is a neural-network connection that adds or otherwise passes an earlier representation to a later layer.

A residual connection adds a block’s input to its output, creating an information shortcut around noisy or destructive layers. It helps deep networks preserve information and propagate gradients when ordinary layer chains suffer from vanishing gradients. section 9.2

A residual block in R/Keras

inputs <- keras_input(shape = c(32, 32, 3)) x <- inputs |> layer_conv_2d(32, 3, activation = "relu") residual <- x x <- x |> layer_conv_2d(64, 3, activation = "relu", padding = "same") residual <- residual |> layer_conv_2d(64, 1) x <- layer_add(list(x, residual)) The 1 × 1 convolution projects the shortcut from 32 to 64 channels so both paths can be added. section 9.2

The pattern stores the incoming representation, processes a copy through the target block, then combines both paths with addition. If the block changes spatial size through max pooling, the shortcut uses a 1 × 1 convolution with matching strides.

Use residual connections with these practical checks:

  • Match the input and output shapes before addition. section 9.2
  • Use a 1 × 1 convolution to change channel count or downsample the shortcut. section 9.2
  • Stack blocks to build deeper hierarchical models; residual paths make deeper optimization more feasible. section 9.1

How Deep Learning with R, Third Edition covers it

How deep it goes
Explains the shortcut mechanism, shape-matching projections, pooling case, and a reusable stacked-block implementation.
Examples
Uses R/Keras pseudocode, channel-changing blocks, pooling blocks, and a three-block convolutional model.
What it assumes
Assumes basic neural-network layers and convolutional models while motivating the design from vanishing gradients.
What you can do after
Build residual convolutional blocks with shape-compatible shortcuts and stack them into deeper image-classification models.
How it connects
Connects residual connections to vanishing gradients, backpropagation, convolutional layers, ReLU, dropout, max pooling, and ResNet.

Also explained in

Compare how 12 books explain residual connection →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Deep Learning with R, Third Edition. The section links point to the parts of the book it draws on.