A terrain with millions of dimensions cannot be viewed directly. Instead, one draws slices centered on the trained weights θ∗ along one or two randomly chosen directions (Li et al. 2018, Eq. 1).
- Draw a random direction δ with the same shape as the weights θ∗ (for 2D, δ and η) from a normal distribution.
- Scale the direction to match the magnitude of the weights (filter normalization). For each j-th filter in layer i, set the norm of the direction equal to the norm of the weights.
di,j←∥di,j∥di,j∥θi,j∥
- Vary the distance from the center α (for 2D, α and β) in small steps, compute the loss, and plot it as a curve or contour map.
f(α)=L(θ∗+αδ),f(α,β)=L(θ∗+αδ+βη)
Without the scaling in step 2, as noted in the ⚠️ of the previous section, valleys can look sharp or flat merely because of differences in weight scale, making models impossible to compare. Filter normalization can also be applied to fully connected layers (the weights producing one output unit are treated as one filter).
Using this method, Li et al. drew the landscapes of image classification models on CIFAR-10 and showed the following.
- Residual connections make the terrain smoother: when the residual connections were removed from ResNet, the terrain changed abruptly with depth from nearly convex (a single bowl) to a highly bumpy shape. ResNets with residual connections did not show this change even when made deeper.
- Widening makes valleys flatter: models with more filters per layer had less noticeable bumps and flatter valleys.
- Terrain smoothness and error rate change together: models whose terrain became bumpy also had much worse error rates on test data.
| Layers | With residual connections | Without residual connections |
|---|
| 20 layers | 7.37% | 8.18% |
| 56 layers | 5.89% | 13.31% |
| 110 layers | 5.79% | 16.44% |
(Error rates on the CIFAR-10 test data. Table 2 of Li et al. 2018. The 56-layer model without residual connections reaches 10.83% when the learning rate is lowered to 0.01.)