Study the paper
Deep Residual Learning for Image Recognition
Lessons, visuals, quizzes, flashcards, and resourcesβorganized in teaching order.
Mathematics of Identity Shortcuts and Dimension Matching
Residual Block with Projection Shortcut
Residual Block with Projection Shortcut
Source equation
This equation defines a residual block with a projection shortcut, which is used to match dimensions when the input and output dimensions of a residual block differ.
Sources
S3.E2
π²=β±β(π±,{Wi})+Wsβπ±.π²β±π±subscriptππsubscriptππ π±\mathbf{y}=\mathcal{F}(\mathbf{x},\{W_{i}\})+W_{s}\mathbf{x}. (2)
\mathbf{y}=\mathcal{F}(\mathbf{x},\{W_{i}\})+W_{s}\mathbf{x}Sources
S3.E2
π²=β±β(π±,{Wi})+Wsβπ±.π²β±π±subscriptππsubscriptππ π±\mathbf{y}=\mathcal{F}(\mathbf{x},\{W_{i}\})+W_{s}\mathbf{x}. (2)
\mathbf{y}=\mathcal{F}(\mathbf{x},\{W_{i}\})+W_{s}\mathbf{x}In this formulation, the residual mapping is added to a linear projection of the input . The projection matrix is used to project the channel dimension of the input to match the channel dimension of the output .
Sources
S3.E2
π²=β±β(π±,{Wi})+Wsβπ±.π²β±π±subscriptππsubscriptππ π±\mathbf{y}=\mathcal{F}(\mathbf{x},\{W_{i}\})+W_{s}\mathbf{x}. (2)
\mathbf{y}=\mathcal{F}(\mathbf{x},\{W_{i}\})+W_{s}\mathbf{x}Implementation detail
Illustrative Calculation
Let us consider a simple deterministic example where:
- Input vector (dimension )
- Residual mapping output (dimension )
- Projection matrix (dimension )
We calculate the projected shortcut:
Then, we add the residual mapping output to obtain the final output :
Sources
S3.E2
π²=β±β(π±,{Wi})+Wsβπ±.π²β±π±subscriptππsubscriptππ π±\mathbf{y}=\mathcal{F}(\mathbf{x},\{W_{i}\})+W_{s}\mathbf{x}. (2)
\mathbf{y}=\mathcal{F}(\mathbf{x},\{W_{i}\})+W_{s}\mathbf{x}- Output vector of the residual block Β· [D_{out}]
- Input vector to the residual block Β· [D_{in}]
- Residual mapping function to be learned Β· Function mapping [D_{in}] to [D_{out}]
- Set of weights associated with the residual layers Β· Set of weight matrices
- Linear projection matrix used to match dimensions Β· [D_{out}, D_{in}]