Layers, depth, and universal approximation

Part 0, Neural networks from absolute zero

Learning objectives

  • Write a layer of neurons as a sum of switches, and a second layer as switches of those sums
  • State what the universal approximation theorem promises and what it leaves out
  • Compare networks by width and by depth at equal parameter count on the Marmousi2 column
  • Read a training curve and say which part of a profile a network learns first

Many Switches

A layer of neurons adds switches together, each with its own place and sharpness, and a second layer switches sums of switches. With enough neurons a network can follow any continuous profile as closely as you like: that is the universal approximation theorem. It says such a network exists, not how many neurons it needs, nor that training finds it. On the Marmousi2 column, after 3000 Adam steps, two layers of 4 tanh neurons (33 parameters) miss by 108 m/s RMS, two of 16 (321) by 106 m/s and two of 64 (4353) by 90 m/s, while one layer of 107 (322 parameters, as many as two of 16) misses by 133 m/s. Width buys little here, depth helps, and every one of them rounds off the slow layer near 1100 m.

Width Depth And The ColumnInteractive figure, enable JavaScript to interact.

A Layer Is a Sum

Section 0.1's neuron was one switch. A layer of mm of them on the same input, added by the output layer, is

v(z)=V0(k+βˆ‘j=1majtanh⁑(wj z/L+bj)),v(z) = V_0\Big(k + \sum_{j=1}^{m} a_j \tanh(w_j\,z/L + b_j)\Big),

mm steps of heights aja_j at depths βˆ’bjL/wj-b_j L/w_j, as sharp as wjw_j is large. A second layer feeds mm such sums through tanh⁑\tanh again before the output, so each of its neurons is a switch of a profile, not of depth. Cybenko (1989) proved that sums of this kind, with one hidden layer of any continuous sigmoidal function, can uniformly approximate any continuous function on a bounded domain. The proof gives no number of neurons and no way to find the weights.

Four Networks on the Column

The book trained four networks on the column at its 176 depths every 10 m, each from its own seed's random start (Glorot's rule, Section 0.8), by Adam for 3000 steps: two layers of 4, of 16 and of 64 tanh neurons, and one layer of 107. The figure replays them from their stored checkpoints at 0, 300, 1000 and 3000 steps and scores each against the column every 5 m. It is the same column as Section 0.1's, the window at x = 3600 m of the Marmousi2 model, a 2D acoustic, constant-density slice of a synthetic model, not field data; the networks and their settings are the book's own.

Width

From 33 to 321 to 4353 parameters the error falls from 108 to 106 to 90 m/s: more than a hundred times the parameters for a sixth less error. Each network's worst miss, 408, 420 and 386 m/s, is at 1100 m, where the column drops from 1917 m/s into its slow layer: a narrow notch that every width rounds off. The theorem is not broken; 3000 steps of training are not enough to put a sharp enough switch there.

Depth

One layer of 107 neurons has 322 parameters, two layers of 16 have 321. After the same 3000 steps the single layer misses by 133 m/s and the two layers by 106 m/s. The second layer reuses the first layer's switches: each of its 16 neurons bends a sum the first layer made, so the same number of parameters makes more bends. This is one comparison on one profile, not a law, but it is the reason PINNs are usually several layers deep rather than one layer wide.

What Training Learns First

Before training, two layers of 16 are their seed's random start, 2388 m/s from the column. By step 300 they have the trend, 319 m/s; the remaining 2700 steps go into the bends. The coarse shape comes first and the sharp detail last, in every network here: Section 0.9 measures this spectral bias, and Part 2 is about fixing it.

What Comes Next

Section 0.3 keeps two layers of 16 and changes the activation, and asks what a wave equation needs of it.

References

  • Cybenko, G. (1989). Approximation by superpositions of a sigmoidal function. Mathematics of Control, Signals and Systems, 2, 303-314. doi:10.1007/BF02551274.

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