Loss functions and the loss landscape

Part 0, Neural networks from absolute zero

Learning objectives

  • Write a network's mean-squared loss on the column and read it as an RMS error in m/s
  • Read a loss surface over two parameters: its minimum, its valley and its plateaus
  • Say why the gradient all but vanishes on a plateau where a neuron's switch has left the data
  • Read the two curvatures at a minimum and their ratio, the valley's aspect

The Ground Training Walks On

Training moves a network's parameters downhill on its loss, so the loss over the parameters is the ground training walks on. Even one neuron's is no bowl. Over the weight and bias of Section 0.1's trained neuron on the Marmousi2 column, its output layer held, the loss is a narrow curved valley where the switch sits inside the column, between two flat plateaus where it does not: there the neuron reads a constant and the slope all but vanishes, 4.8Γ—10βˆ’84.8 \times 10^{-8} on the lower plateau. The valley's floor is the trained neuron, 211 m/s RMS, and at it the loss curves 413 times less along the valley than across it.

The Loss Of One NeuronInteractive figure, enable JavaScript to interact.

The Loss

The neuron is fitted at 176 depths ziz_i of the column, every 10 m to 1750 m, with xi=zi/Lx_i = z_i/L and the targets ci=vi/V0c_i = v_i/V_0 (LL = 1800 m, V0V_0 = 1500 m/s). Its loss is the mean of the squared misses,

L(w,b)=1Nβˆ‘i=1N(a tanh⁑(w xi+b)+kβˆ’ci)2,L(w, b) = \frac1N \sum_{i=1}^{N} \big(a\,\tanh(w\,x_i + b) + k - c_i\big)^2,

and V0LV_0\sqrt{L} is the RMS error in m/s the figure prints. Holding the output layer at the trained a=0.62a = 0.62 and k=1.69k = 1.69 leaves two parameters, so the loss can be drawn: the book's build computed it at 81 weights from βˆ’4-4 to 16 and 73 biases from βˆ’14-14 to 4, every 0.25, with the same kernel that trained the neuron. The column is the window at x = 3600 m of the Marmousi2 model, a 2D acoustic, constant-density slice of a synthetic model, not field data; the grid and the held output layer are the book's own choices.

A Valley and Two Plateaus

The two dashed lines in plate (a) are where the switch βˆ’b/w-b/w crosses the surface (b=0b = 0) and the column's last depth (b=βˆ’0.97 wb = -0.97\,w). Between them, for a rising neuron, the switch is in the column and the loss changes fast as it moves: that is the valley, curved because the switch's depth is a ratio. Beyond them the switch has left the data. Above the surface the neuron is on at every depth and the loss is 1520 m/s RMS; below the column it is off at every depth and the loss is 843 m/s. Either way it reads a constant, moving ww or bb changes almost nothing, and the slope is tiny: 1.9Γ—10βˆ’41.9 \times 10^{-4} and 4.8Γ—10βˆ’84.8 \times 10^{-8} at the probe's first weight, 6, with the bias at the top and the bottom of the figure. Goodfellow, Bengio and Courville (2016) give the same reason for avoiding sigmoidal hidden units: they saturate across most of their domain, and that makes gradient-based learning very difficult.

The Minimum and Its Curvatures

The minimum is the trained neuron, w=5.88w = 5.88, b=βˆ’4.19b = -4.19, 211 m/s RMS; the probe starts beside it on the grid, at w=6w = 6, b=βˆ’4.25b = -4.25, 212 m/s. From there walk along the valley, doubling ww and bb together so the switch stays at 1275 m, and the loss rises only to 248 m/s; raise the bias by one instead and the switch moves to 975 m and the loss to 476 m/s. Near the minimum the loss is close to a quadratic whose Hessian has two eigenvalues, the curvatures across and along the valley: 0.28 and 0.00069, a ratio of 413, computed by the build from the kernel's gradient. Li et al. (2017) note that training neural networks relies on finding good minimisers of highly non-convex loss functions, and draw such surfaces for large networks; one neuron already shows their parts.

What It Means for a PINN

A PINN's loss adds a residual term to the data term, each with its own valleys and plateaus, over thousands of parameters. Part 3 is about the trouble that causes: terms whose slopes differ by orders of magnitude, and regions where a term's gradient vanishes.

What Comes Next

Section 0.5 puts gradient descent on this surface and writes every step out.

References

  • Goodfellow, I., Bengio, Y. and Courville, A. (2016). Deep Learning, Chapter 6, Deep feedforward networks. MIT Press.
  • Li, H., Xu, Z., Taylor, G., Studer, C. and Goldstein, T. (2017). Visualizing the loss landscape of neural nets. arXiv:1712.09913.

This page is prerendered for SEO and accessibility. The interactive widgets above hydrate on JavaScript load.