Sigmoid Towers in One Dimension

Steep sigmoids act like steps, two steps make a tower, and enough towers trace any curve: the idea behind universal approximation.

Deep Learning- Fundamentals to Advanced Concepts

For perceptrons we asked what a network can represent. Now the same question for sigmoid neurons, this time with real numbers and approximate answers: given an unknown function f(x)f(x), can a network of sigmoids produce output close to f(x)f(x)?

A sigmoid can act like a step

Recall from the first lesson of this module that for a single input σ(wx+b)\sigma(wx + b) is centred where wx+b=0wx + b = 0. Increasing ww makes the S steeper. For a very large ww it is almost vertical:

σ(k (x−a))  ≈  {0x<a1x>a(k large)\sigma\bigl(k\,(x - a)\bigr) \;\approx\; \begin{cases} 0 & x < a \\ 1 & x > a \end{cases} \qquad (k \text{ large})

So a sigmoid neuron with weight kk and bias −ka-ka is a step at the position x=ax = a. We can place the step wherever we like by choosing bb, and make its edge as sharp as we like by choosing ww.

Try it yourself
Sigmoid versus step simulator →

Increase the weight until the sigmoid turns into a step.

Two steps make a tower

Take two such steps, one at aa and one at cc, with a<ca < c, and subtract them:

σ(k(x−a))−σ(k(x−c))\sigma\bigl(k(x - a)\bigr) - \sigma\bigl(k(x - c)\bigr)
  • For x<ax < a: both steps are 0, so the difference is 0.
  • For a<x<ca < x < c: the first step is 1 and the second is still 0, so the difference is 1.
  • For x>cx > c: both are 1, so the difference is 0 again.

The result is a flat-topped tower of height 1 between aa and cc, zero elsewhere. Multiplying it by a number hh makes the tower height hh.

Left: two sigmoid steps and their difference forming a tower. Right: ten towers added together closely following a sine-like curve.
Left: two steps subtracted give a tower. Right: ten towers with heights read off the target curve.

Many towers trace any curve

Now take a target function f(x)f(x) that we want to approximate. Cut the xx axis into small intervals. Over each interval build a tower as above, and set its height to the value of ff at the middle of the interval. Add all the towers.

The sum is a staircase that follows ff. The thinner the towers, the closer the staircase hugs the curve, so we can approximate ff to any desired accuracy by using enough of them.

The network that does this is small in structure:

  • Input: xx.
  • Hidden layer: two sigmoid neurons per tower, one for each edge.
  • Output: a neuron that adds them, with weight +hi+h_i on the left edge of tower ii and −hi-h_i on the right edge.

The heights are the output weights, and the positions of the edges are set by the hidden biases.

What we have shown, and what we have not

This construction is the core of the universal approximation theorem: for any reasonable function there is a sigmoid network that approximates it as closely as you like, provided it is allowed enough neurons.

Be careful about what it says:

  • It is about existence. It tells us a good network exists, and how to build one in principle. It does not say gradient descent will find it.
  • It is expensive. Ten towers cost 20 hidden neurons. To double the resolution you double the towers. The networks we use in practice are far more economical, and later lessons explain how.
  • The edges are not perfect. With finite ww the step has a slope, so each tower has slightly sloped sides. More sharpness means larger weights.
EasyUniversal approximation

How many hidden sigmoid neurons does this construction need for 10 towers in one dimension?

MediumUniversal approximation

In the tower network, what sets a tower's width and what sets its height?

MediumUniversal approximation

What does the universal approximation theorem guarantee, and what does it not guarantee?