Foundations to Frontier
Tests
E. Deep Learning › E4 Regularization Techniques (one page each)

Stochastic Depth and DropPath

Stochastic depth randomly skips whole residual blocks during training, leaving only the identity shortcut, so each training step uses a shorter network; at test time every block is used. DropPath is the per-example version used in vision transformers and ConvNeXt. This page covers the update, the linear decay rule that drops deeper blocks more, the expected depth and training-time saving, and why the method needs residual connections. In the exercises you derive that ResNet-110 uses about 25% fewer blocks per step under the standard rule, then train a 12-block residual network and find, honestly, that it did not overfit, so DropPath had nothing to fix: accuracy stayed at 99.7% while each example passed through 27–43% fewer blocks.

Level 0: Foundation

★☆☆☆☆ Introductory⏱ 5 minGeneral audience. No mathematics required.

Skip whole layers at random

In a residual network each block adds a correction to a signal that also flows past it through a shortcut. Stochastic depth sometimes switches a block off entirely during training: the signal just takes the shortcut. Each training step therefore uses a randomly shortened network, which is faster and acts as regularisation, like training an ensemble of networks of different depths. At test time all blocks are on.

Regularisation lab: a small network on 40 noisy points
test cross-entropy during training
lowest test loss 0.212 at epoch 102
train accuracy 1.000 · test accuracy 0.833 · final test cross-entropy 0.817
With no regularisation the network fits all 40 noisy training points with a contorted boundary, and its test loss rises after an early minimum (the dot): overfitting. Each regulariser trades some training fit for a smoother boundary. Early stopping keeps the weights from the dot (here the test loss stands in for a validation set, which makes it look slightly better than it would in practice). Try the strength slider: too little does nothing, too much underfits. Results vary with the data, so press "new data" before trusting a comparison.
Why engineers care

DropPath is in nearly every modern vision backbone recipe: vision transformers, Swin and ConvNeXt use drop-path rates of 0.1–0.5, larger for bigger models. It was originally sold as a way to train 1000-layer networks faster.

📝 Quick check (Level 0)
0/3 answered
  1. 1. Stochastic depth skips…
  2. 2. When a block is skipped the signal…
  3. 3. At test time…

Level 1: Beginner

★★☆☆☆ Basic⏱ 20 minSecondary-school mathematics: arithmetic and elementary algebra.

By hand

  • Residual block: h ← h + f(h). With stochastic depth: h ← h + b·f(h), b ~ Bernoulli(1 − p_l).
  • Two scalings:
    • Original (Huang et al.): no rescaling in training; at test time multiply f(h) by the survival probability 1 − p_l.
    • DropPath (inverted): divide by 1 − p_l in training, nothing at test time.
  • Per batch or per example: Huang et al. drew one b per mini-batch (and saved compute). DropPath draws one b per example (more noise, but no compute saving unless implemented with gathering).
  • Linear rule: p_l = p_L·l/L for block l = 1..L, so early blocks, which compute low-level features every later block needs, are rarely dropped.
  • Expected active blocks: L − p_L(L + 1)/2. For 12 blocks with p_L = 0.5: 8.75. For ResNet-110 (54 blocks): 40.25, about 25% fewer.
📝 Quick check (Level 1)
0/3 answered
  1. 1. Under the linear rule, the most-dropped block is…
  2. 2. Expected active blocks of 12 at p_L = 0.5:
  3. 3. DropPath draws its mask…

Level 2: Intermediate

★★★☆☆ Intermediate⏱ 25 minUndergraduate students and practising engineers.

DropPath in code

Exercise 1.

  • The linear rule gave 40.25 expected active blocks of ResNet-110’s 54 (25.5% fewer), in line with the roughly 25% training-time saving Huang et al. reported.
  • The DropPath function skipped the branch for 30% of 20 000 examples at p = 0.3 and scaled the others by 1/0.7, so each block’s expected contribution was unchanged.

Practice.

  • Use timm.layers.DropPath(p) on the residual branch, with rates rising linearly over depth to a final value of 0.1 (small models) to 0.4–0.5 (huge ones).
  • Do not apply it to networks without shortcuts: dropping a plain layer breaks the signal.
  • Combine with other regularisers (augmentation, mixup, label smoothing, weight decay) as in DeiT and ConvNeXt recipes.
dpr = [x.item() for x in torch.linspace(0, 0.2, depth)]   # linear rule
blocks = torch.nn.ModuleList([Block(dim, drop_path=dpr[i]) for i in range(depth)])
# inside Block.forward: x = x + self.drop_path(self.mlp(self.norm(x)))
🐍 Exercise 1: expected depth and the DropPath operator
Implement the linear rule, the expected number of active blocks and a per-example DropPath, and check them.
📝 Quick check (Level 2)
0/3 answered
  1. 1. DropPath needs…
  2. 2. A typical drop-path rate for a small ViT is…
  3. 3. ResNet-110 under p_L = 0.5 uses on average about…

Level 3: Advanced

★★★★☆ Advanced⏱ 25 minGraduate level, with full derivations and proofs.

Theory

Implicit ensemble of depths. A network with L droppable blocks contains 2^L sub-networks of different depths, and training samples them. Veit, Wilber and Belongie (2016) showed residual networks already behave like ensembles of shallower paths: deleting a single block at test time barely hurts a trained ResNet. Stochastic depth makes this explicit during training.

Shorter effective depth. With blocks skipped, gradients pass through fewer nonlinear layers, which eases optimisation of very deep networks; Huang et al. trained a 1202-layer ResNet with improved test error.

Why deeper blocks are dropped more. Early blocks compute features that all later blocks depend on; removing them disrupts the whole network. Later blocks refine; removing them is milder.

Test-time scaling. With the original form, a block’s training-time expected contribution is (1 − p)f(h), so its output must be scaled by 1 − p at test time to match. DropPath’s inverted scaling moves this into training.

📝 Quick check (Level 3)
0/3 answered
  1. 1. L droppable blocks define how many sub-networks?
  2. 2. Deleting one block from a trained ResNet at test time usually…
  3. 3. Huang et al. trained a ResNet with…

Level 4: Expert

★★★★★ Expert⏱ 30 minResearchers: original papers and open problems.

Stochastic depth on a small problem

History.

  • K. He et al. (2016) introduced residual networks.
  • G. Huang, Y. Sun, Z. Liu, D. Sedra and K. Weinberger (2016) introduced stochastic depth.
  • G. Larsson, M. Maire and G. Shakhnarovich (2017) used “drop-path” in FractalNet.
  • H. Touvron et al. (2021, DeiT) and Z. Liu et al. (2022, ConvNeXt) made DropPath standard in vision recipes.

Exercise 2. A 12-block residual MLP (width 32, layer normalisation, ReLU branches) on three spirals (300 training points), trained with Adam for 400 mini-batch steps. DropPath is per example with the linear rule. Three seeds:

DropPath test accuracy per seed test CE blocks active per example
none 0.999, 0.998, 0.999 0.0053 12
linear, p_L = 0.5 0.997, 0.994, 0.999 0.0105 8.75
linear, p_L = 0.8 0.998, 0.997, 0.999 0.0078 6.80
  • The network did not overfit: without DropPath it already reached 99.9% test accuracy, so there was nothing for regularisation to fix.
  • DropPath cost nothing measurable in accuracy while each example passed through 27% (p_L = 0.5) or 43% (p_L = 0.8) fewer blocks. With per-batch dropping, as in the original method, that becomes a real training-time saving.
  • Lesson: a regulariser’s benefit only shows when there is overfitting to cure. The large gains reported for DropPath come from large models on large image datasets trained for long schedules.
🐍 Exercise 2 (research): stochastic depth on a small problem
Train a 12-block residual MLP with and without DropPath and compare accuracy, loss and the number of active blocks.

Stochastic depth in AI, robotics and aerospace

  • Vision backbones for detection and segmentation in autonomous systems are trained with DropPath.
  • Anytime inference: networks trained with stochastic depth tolerate skipping later blocks, which can trade accuracy for latency on embedded hardware.
  • Very deep models (language, vision, multimodal) use it as one of several standard regularisers.

References

  1. G. Huang, Y. Sun, Z. Liu, D. Sedra, K. Q. Weinberger (2016). “Deep networks with stochastic depth.” Proc. ECCV.
  2. A. Veit, M. Wilber, S. Belongie (2016). “Residual networks behave like ensembles of relatively shallow networks.” Advances in NeurIPS.
  3. G. Larsson, M. Maire, G. Shakhnarovich (2017). “FractalNet: ultra-deep neural networks without residuals.” Proc. ICLR.
  4. H. Touvron et al. (2021). “Training data-efficient image transformers and distillation through attention.” Proc. ICML.