Identity Mappings in Deep Residual Networks
- Publication
- ECCV 2016Conference
- First submitted to arXiv
- arXiv:1603.05027
Cite this paper · BibTeX
The citation identifies the linked source version. It cites the original paper and its authors.
@misc{classiccnnsresnetv22016,
title = {{Identity Mappings in Deep Residual Networks}},
author = {Kaiming He and Xiangyu Zhang and Shaoqing Ren and Jian Sun},
year = {2016},
eprint = {1603.05027},
archivePrefix = {arXiv},
url = {https://arxiv.org/abs/1603.05027}
}
ResNet made 152-layer networks trainable and won ILSVRC 2015. On CIFAR-10, though, the original paper's 1202-layer ResNet had an error rate of 7.93%, actually worse than the 110-layer network's 6.61%.
Residual connections let networks go deeper, but at a thousand layers, a new problem showed up.
In March 2016, the original team, Kaiming He, Xiangyu Zhang, Shaoqing Ren, and Jian Sun, released this paper. This time they went back and wrote out the propagation formulas of the residual unit, used them to work out how the signal could flow most smoothly, and redesigned the residual unit accordingly. After the change, a 1001-layer ResNet reached 4.62% error on CIFAR-10.
This new version later came to be commonly called ResNet v2, or the pre-activation ResNet.
Defining the Problem
First, write the original residual unit in general form. The input to the -th unit is :
is the residual function, for example two convolutions; is the operation on the shortcut; is the operation after the addition. In the original ResNet, is an identity mapping and is ReLU.

The curves on the right put the problem in plain view. At the same 1001 layers, the original design's loss falls very slowly early in training and ends at a test error of 7.61%; the modified design's loss falls quickly from the start and ends at 4.92%.
The two units on the left use exactly the same components; only the order differs. In the original, ReLU comes after the addition, sitting on the shortcut path; the new design moves both BN and ReLU in front of the weight layers and does nothing after the addition. As a result, the gray shortcut passes through no operation at all, from start to finish.
Why does this matter? The authors' argument starts by treating both and as identity mappings.
Solving the Problem
Two Identity Mappings
If is also an identity mapping, , and the equation above becomes:
Unrolling all the way to a deeper unit :
By this equation, any deep feature equals some shallower feature plus the outputs of all the residual functions in between. Compare an ordinary network, where is the result of a chain of matrix multiplications, roughly (ignoring BN and ReLU). One adds; the other multiplies.
The same goes for backpropagation. With loss , by the chain rule:
The 1 in the parentheses delivers straight to the shallower without passing through any weight layer. The other term does pass through weight layers, but it's unlikely to be exactly for every sample in a mini-batch and cancel the whole parenthesis out. So even when the weights are very small, the gradient won't vanish.
Both of these nice properties require the shortcut to be an identity mapping, and the after-addition to be an identity mapping too. In terms of the figure, the gray arrow must carry no operation other than the addition.
The authors then check this in two parts, first changing the shortcut and then the after-addition .
What If the Shortcut Carries Something Extra?
The simplest way to break it is to multiply the shortcut by a constant , that is, . Unrolling the same way, the backpropagation equation becomes:
absorbs those constants. The original 1 has turned into a product of 's. In a very deep network, if every is greater than 1, this term explodes exponentially; if every is less than 1, it vanishes exponentially, and the gradient has to go through the weight layers instead.
Take ResNet-110, which has 54 residual units. When the residual functions are small, the gradient reaching the first layer is almost exactly . looks like only a 10% discount, yet after 54 units only three thousandths remain; shrinks it to . With more complex shortcuts such as gates or convolutions, the product becomes one of each shortcut's derivatives, which can block the signal just the same.
The authors then compare several kinds of shortcut in practice, on ResNet-110 for CIFAR-10:

| Shortcut | Coefficient on the shortcut | Coefficient on the branch | Error |
|---|---|---|---|
| (a) Original identity shortcut | 1 | 1 | 6.61% |
| (b) Constant scaling | 0 | 1 | fail (a plain network) |
| (b) Constant scaling | 0.5 | 1 | fail |
| (b) Constant scaling | 0.5 | 0.5 | 12.35% |
| (c) Exclusive gating, initialized to | 8.70% | ||
| (c) Exclusive gating, initialized to 0 through | fail | ||
| (d) Shortcut-only gating, initialized to 0 | 1 | 12.86% | |
| (d) Shortcut-only gating, initialized to | 1 | 6.91% | |
| (e) convolutional shortcut | conv | 1 | 12.22% |
| (f) Dropout shortcut | dropout 0.5 | 1 | fail |
Let's go through these shortcuts one by one.
- Constant scaling by 0.5: without scaling the branch, it fails to train; with the branch also multiplied by 0.5 (like a Highway network with its gates frozen), it converges, but the error is 12.35%, nearly twice the baseline.
- Exclusive gating is the Highway Networks approach. The initial value of the gate bias is critical: the authors searched between 0 and , and even the best value, , reaches only 8.70%.
- With shortcut-only gating, an initial bias of makes close to 1, so the shortcut is nearly an identity mapping, and its 6.91% is also the closest to the baseline.
- convolutional shortcuts worked well on the original 34-layer ResNet (option C in the ResNet paper), but stacked over 54 units they give 12.22%. The authors saw something similar with ResNet-101 on ImageNet.
- A dropout shortcut statistically amounts to multiplying the shortcut by an expected value of 0.5, so it blocks the signal just like constant scaling.
Gates and convolutions both add parameters, so in theory they should be more expressive; with shortcut-only gating or convolutions, the solution space even contains the identity shortcut, which they would only need to learn. Yet their training error is higher. So the degradation comes from optimization and has nothing to do with expressiveness.
Where Should the After-Addition ReLU Go?
In the previous experiments, the after-addition was still ReLU, so the derivation held only approximately. Next up is .
The only way to make an identity mapping is to rearrange where ReLU and BN go. The authors tried these arrangements:

| Arrangement | ResNet-110 | ResNet-164 |
|---|---|---|
| (a) Original residual unit | 6.61% | 5.93% |
| (b) BN after addition | 8.17% | 6.50% |
| (c) ReLU before addition | 7.84% | 6.14% |
| (d) ReLU-only pre-activation | 6.71% | 5.91% |
| (e) Full pre-activation | 6.37% | 5.46% |
(b) BN after addition is an experiment in the opposite direction: now includes both BN and ReLU. The result is clearly worse. BN now alters the signal on the shortcut, and the loss has a hard time coming down early in training.
(c) ReLU before the addition is the most direct way to make an identity mapping, and it also made things worse. The problem is that with ReLU at the end of the branch, the residual function's output can never be negative. Intuitively, a “residual” should be able to go either way; if it can only be positive, every added unit raises the signal's mean another notch. The full pre-activation's residuals are both positive and negative, so the mean stays near 0.
A Different Angle: Pre-Activation
The remaining two arrangements come from a shift in perspective.
In the original design, the after-addition activation affects both paths of the next unit:
If this activation acts only on the residual branch, with the shortcut bypassing it, we get:
Changing notation, this is . Nothing comes after the addition, so has become an identity mapping; what used to be “the previous unit's output activation” has become “the next unit's input activation.”

Going from (b) to (c) in the figure just redraws the unit boundaries. The authors also point out that this before/after distinction only means something in branched structures with additions; an ordinary -layer network has activations, and it makes no difference whether you call them pre-activations or post-activations.
Following this idea, (d) in Figure 4 moves only ReLU to the front, with results about the same as the original design; the authors suspect that this ReLU, not paired with BN, doesn't get BN's benefits. (e) moves both BN and ReLU in front of the weight layers, and the results clearly improve. This is the unit the paper proposes.
Discussion
The Deeper, the Wider the Gap
| Dataset | Network | Original unit | Pre-activation |
|---|---|---|---|
| CIFAR-10 | ResNet-110 (one layer per unit) | 9.90% | 8.91% |
| CIFAR-10 | ResNet-110 | 6.61% | 6.37% |
| CIFAR-10 | ResNet-164 | 5.93% | 5.46% |
| CIFAR-10 | ResNet-1001 | 7.61% | 4.92% |
| CIFAR-100 | ResNet-164 | 25.16% | 24.33% |
| CIFAR-100 | ResNet-1001 | 27.82% | 22.71% |
Pre-activation is better in every case, and the deeper the network, the bigger the gap. At 1001 layers, CIFAR-10 error falls from 7.61% to 4.92%, and CIFAR-100 error from 27.82% to 22.71%.
The authors attribute the gains to two things.
First, easier optimization. This is most visible at 1001 layers (Figure 1, right). When is ReLU, negative signals get truncated; with many units, the earlier formulas stop being a good approximation. The 164-layer network is affected much less: its curve suffers a little early in training and quickly recovers. Monitoring the network's responses, the authors found that after some training the weights adjust so that is mostly above 0, and ReLU rarely truncates anything; is already non-negative after the previous ReLU, so drops below 0 only when is strongly negative. At a thousand layers, truncation happens far more often.
Second, less overfitting. The pre-activation version converges to a slightly higher training loss but a lower test error. The authors suspect this is BN's regularizing effect: in the original unit, the BN-normalized signal is immediately added to the shortcut, so what actually enters the next weight layer is unnormalized; in the pre-activation version, the input to every weight layer goes through BN first.
Comparison with Other Methods
On CIFAR, the authors' ResNet-1001 reaches 4.92% on CIFAR-10 (median of five runs), and 4.62% with the mini-batch size changed to 64; on CIFAR-100 it reaches 22.71%. They stress that these results come without specially tailoring the width or filter sizes and without regularization such as dropout, which is very effective on small datasets; all they rely on is “going deeper.”
On ImageNet, the authors first note an evaluation detail. The original ResNet was trained with the shorter side scaled to between 256 and 480, yet tested on crops from images with a shorter side of 256, which works against ResNet. So this time they take a single crop from images with a shorter side of 320. ResNet is fully convolutional and can take larger inputs directly, and this size is also close to Inception-v3's 299.
| Method | Augmentation | Top-1 error | Top-5 error |
|---|---|---|---|
| ResNet-152, original unit | scale | 21.3% | 5.5% |
| ResNet-152, pre-activation | scale | 21.1% | 5.5% |
| ResNet-200, original unit | scale | 21.8% | 6.0% |
| ResNet-200, pre-activation | scale | 20.7% | 5.3% |
| ResNet-200, pre-activation | scale + aspect ratio | 20.1% | 4.8% |
| Inception-v3 | scale + aspect ratio | 21.2% | 5.6% |
Switching ResNet-152 to pre-activation improves it only from 21.3% to 21.1%, because it had no obvious generalization problem to begin with. ResNet-200 is a different story. With the original unit, its error is 21.8%, worse than ResNet-152, yet its training error is lower than ResNet-152's, which means it's overfitting. With pre-activation it gets 20.7%, better than both versions of ResNet-152.
The authors also finished a “BN after addition” version of ResNet-101 on ImageNet, with a single-crop error of 24.6%/7.5%, worse than the original's 23.6%/7.1% and consistent with the CIFAR results.
As for computational cost, model complexity grows linearly with depth, so 1001 layers cost about ten times as much as 100 layers. ResNet-1001 on CIFAR takes about 27 hours to train on two GPUs; ResNet-200 on ImageNet takes about three weeks on eight GPUs.
Conclusion
Keeping the shortcut clean is this paper's conclusion. Don't multiply the shortcut by constants, don't add gates, don't put convolutions or dropout on it; and don't follow the addition with ReLU or BN either. That way, in both forward and backward propagation, the signal can travel directly from any unit to any other.
In practice, the change is small, just moving BN and ReLU forward in the residual branch and doing nothing after the addition. If you're training a very deep ResNet, or your model has started to overfit, try the pre-activation version first; for shallower networks, the two make little difference.
The principle of “put nothing on the shortcut” came up again a few years later in Transformers; Pre-LN moves LayerNorm off the shortcut, and the warm-up stage can be dropped.