⚡ Neural Networks as Function Approximators

In her notes (section 7.6), Martha describes neural networks as what they are mathematically: function approximators that combine simple building blocks. The universal approximation theorem says that a network with a single, wide enough hidden layer can approximate any continuous function on a bounded interval as closely as we want. This notebook shows why, with ReLU neurons and NumPy.

The interactive notebook includes:

  • The building block: a ReLU neuron as a hinged ruler.
  • Adding hinges: piecewise-linear approximations of a curve, and how the error falls as we add neurons.
  • Letting a trained network choose where to put its hinges, and what training does not guarantee.
  • Why depth helps: stacking layers of just 2 neurons multiplies the number of linear pieces.

Want to modify the code and experiment on your own?
Open the notebook in Google Colab

Bibliography