The Universal Approximation Theorem: A Beginner‘s Guide
The universal approximation theorem is one of the most important theoretical results in the field of artificial neural networks. In a nutshell, the theorem states that a feedforward neural network with a single hidden layer can approximate any continuous function to an arbitrary degree of accuracy, given enough hidden units and under mild assumptions on the activation function.
This is a powerful result that demonstrates the theoretical flexibility and expressiveness of neural networks as function approximators. It helps explain why neural networks have been so successful at a wide variety of machine learning tasks across domains like computer vision, natural language processing, robotics, and more.
Intuition and Examples
Let‘s unpack what the theorem is saying with some examples and intuition. Suppose you have some data generated by an unknown continuous process, like the prices of a stock over time or the temperatures at different locations. If you want to model this data, one approach is to find a mathematical function that maps the inputs (e.g. time or location) to the outputs (price or temperature).
The universal approximation theorem says that a neural network with even just one hidden layer can represent any such function, as long as it‘s continuous. This is true regardless of the shape of the function – whether it‘s linear, polynomial, exponential, trigonometric, or some complicated combination thereof. Given enough hidden units and the right weights, a neural network can fit curves and surfaces to the data points with arbitrary precision.
For a visual example, consider the following continuous function in two dimensions:

According to the universal approximation theorem, a neural network with a single hidden layer can approximate this function to any desired level of accuracy. Here‘s what the approximations might look like with an increasing number of hidden units:

As the number of hidden units grows, the neural network approximation (shown in red) gets closer and closer to the true function (shown in blue). With enough hidden units, the two curves would be virtually indistinguishable.
The Role of Activation Functions
The universal approximation theorem makes some assumptions about the activation function used in the neural network. The activation function is the nonlinearity applied at each node that allows the network to model non-linear relationships.
Common activation functions like the sigmoid, tanh, and ReLU have been proven to satisfy the theorem‘s assumptions:
- Sigmoid: φ(x) = 1 / (1 + exp(-x))
- Tanh: φ(x) = (exp(x) – exp(-x)) / (exp(x) + exp(-x))
- ReLU: φ(x) = max(0, x)
Other less commonly used activation functions like the cos and sin have also been shown to provide universal approximation.
Intuitively, what these activation functions have in common is that they introduce non-linearity and allow the neural network to model more complex relationships than a purely linear model. The proof of the theorem relies on the ability to closely approximate non-linear functions using a large number of these non-linear building blocks.
Interestingly, the universal approximation theorem does not hold for neural networks with certain activation functions. For example, a single hidden layer network with a linear activation function is equivalent to linear regression and thus cannot model arbitrary non-linear functions. So the non-linearity of the activation function is key.
Historical Development and Extensions
The first proof of the universal approximation theorem was given by George Cybenko in 1989 for single hidden layer neural networks with sigmoid activation functions. The result was later extended by Kurt Hornik in 1991 to show that the theorem holds for any bounded, non-constant activation function.
These early proofs showed the existence of universal approximator neural networks but did not give a constructive method for finding them or specify how many hidden units would be required for a given function or accuracy level. They also only applied to neural networks with a single hidden layer.
Since then, there have been many generalization and refinement of the universal approximation theorem:
-
In 1993, Leshno et al. showed that the theorem holds under even milder assumptions on the activation function – it need only be locally bounded, piecewise continuous, and not a polynomial.
-
Other researchers showed that universal approximation also holds for neural networks with multiple hidden layers. In fact, deeper networks can provide exponentially more efficient approximations than single hidden layer networks for certain classes of functions.
-
More recently, several authors have derived upper bounds on the size of the hidden layer required for a given degree of approximation accuracy. For example, Harvey et al. (2017) showed that a neural network with a single ReLU hidden layer requires at most O(ε^(-d/2)) units to approximate a Sobolev function on a d-dimensional unit cube to accuracy ε. However, the required number of units can still grow exponentially with the dimension d.
-
The theorem has also been generalized to other neural network architectures like recurrent neural networks (RNNs) and convolutional neural networks (CNNs), showing that they also have universal approximation capabilities.
Empirical Results and Limitations
While the universal approximation theorem provides a strong theoretical foundation for the use of neural networks, it‘s important to keep in mind its limitations and how it translates to practice.
First, the theorem only states the existence of a neural network approximator for any given continuous function – it doesn‘t tell us how to find that network. In practice, training a neural network with gradient descent and backpropagation can be challenging and requires careful choice of architecture, optimizer, initialization, and other hyperparameters. There‘s no guarantee that a given training procedure will converge to a good approximation, even if one theoretically exists.
Second, the theorem provides an upper bound on the size of the network required for a given level of approximation, but this bound can be quite loose in practice. The number of hidden units required can grow exponentially with the input dimension, making it infeasible to actually construct a network large enough to achieve a desired accuracy. This is related to the "curse of dimensionality".
That said, there is a wealth of empirical evidence showing that neural networks can learn very good approximations to a wide variety of functions in practice. Some examples:
- Rippel et al. (2015) showed that a neural network with a single hidden layer can learn pixel-wise approximations of natural images with high accuracy.
- Li et al. (2019) demonstrated that neural networks can approximate solutions to high-dimensional partial differential equations in physics with much better accuracy and efficiency than traditional numerical methods.
- Neural networks have achieved state-of-the-art results on benchmarks in areas like image classification, machine translation, speech recognition, protein folding, and much more – demonstrating their ability to learn highly complex, non-linear functions from data.
So while the universal approximation theorem provides a valuable theoretical guarantee, the empirical performance of neural networks in practice is what has driven their widespread adoption and success.
Societal Implications and Future Directions
The universal approximation capabilities of neural networks have significant implications for society and raise important questions as AI systems become more prevalent and powerful.
On one hand, universal approximation suggests that AI systems have the potential to automate and optimize a wide range of functions in areas like healthcare, education, transportation, science, and more. Neural networks could be used to model complex systems, make accurate predictions, and discover new solutions that might be difficult for humans to find.
On the other hand, the opacity and potential biases of neural networks raise concerns about fairness, accountability, and safety when applied to high-stakes domains. If a neural network is approximating a decision function that affects people‘s lives (e.g. loan approvals or medical diagnoses), it‘s important to ensure that it does so in an equitable and transparent way.
There are also risks associated with the unintended consequences or adversarial misuse of AI systems that are able to approximate arbitrary functions. Research on AI safety aims to ensure that highly capable systems remain aligned with human values and interests.
From a theoretical perspective, there are many open questions and active areas of research related to the universal approximation theorem:
- What are the fundamental limits of neural network approximation for different function classes and architectures? Tighter bounds on the size of networks required could help guide the design of efficient and effective models.
- How can we characterize the learnability and sample complexity of neural network approximation? The universal approximation theorem says nothing about how much training data and compute are required to achieve a good approximation in practice.
- Are there alternative function classes or architectures that provide better approximation capabilities than standard neural networks? Could hybrid models that combine neural networks with other types of approximators (e.g. Fourier series or wavelets) offer advantages?
- What role does approximation play in the generalization and robustness of neural networks? Can we develop training methods that favor finding approximations that are stable and generalize well to unseen data?
Answering these questions could lead to important theoretical and practical advances in our understanding and use of neural networks.
Conclusion
The universal approximation theorem is a foundational result in neural network theory that has deep implications for artificial intelligence and machine learning. By showing that even a single hidden layer network can approximate any continuous function, the theorem helps explain the power and flexibility of neural networks as general-purpose function approximators.
The theorem has been refined and generalized in many ways since its introduction, and there is strong empirical evidence that neural networks can learn very effective approximations across a range of domains in practice. At the same time, the theorem has limitations and there remain many open questions about the actual realizability and learnability of these approximations.
As AI systems become more prevalent and impactful in society, it‘s important for practitioners to be aware of theoretical results like the universal approximation theorem. A solid grasp of the capabilities and limits of our models can help us use them in a responsible and beneficial way while inspiring further research to expand the frontiers of what‘s possible.