Neural networks and rational functions
Matus Telgarsky
Overview
Significant effort has been invested in characterizing the functions that can be efficiently approximated by neural networks. The goal of the present work is to characterize neural networks more finely by finding a class of functions which is not only well-approximated by neural networks, but also well-approximates neural networks.
The function class investigated here is the class of rational functions: functions represented as the ratio of two polynomials, where the denominator is a strictly positive polynomial. For simplicity, the neural networks are taken to always use ReLU activation ; for a review of neural networks and their terminology, the reader is directed to Section 1.4. For the sake of brevity, a network with ReLU activations is simply called a ReLU network.
The main theorem here states that ReLU networks and rational functions approximate each other well in the sense that -approximating one class with the other requires a representation whose size is polynomial in , rather than being polynomial in .
Perhaps the main wrinkle is the appearance of when approximating neural networks by rational functions. The following theorem shows that this dependence is tight.
Note that this statement implies the desired difficulty of approximation, since a gap in the above integral () distance implies a gap in the earlier uniform distance (), and furthermore an -degree rational function necessarily has total terms in its numerator and denominator.
As a final piece of the story, note that the conversion between rational functions and ReLU networks is more seamless if instead one converts to rational networks, meaning neural networks where each activation function is a rational function.
Combining Theorem 1.2 and Section 1.1 yields an intriguing corollary.
The hard-to-approximate function is a rational network which has a description of size . Despite this, attempting to approximate it with a rational function of the usual form requires a description of size . Said another way: even for rational functions, there is a benefit to a neural network representation!
2 Auxiliary results
The first thing to stress is that Theorem 1.1 is impossible with polynomials: namely, while it is true that ReLU networks can efficiently approximate polynomials (Yarotsky, 2016; Safran & Shamir, 2016; Liang & Srikant, 2017), on the other hand polynomials require degree , rather than , to approximate a single ReLU, or equivalently the absolute value function (Petrushev & Popov, 1987, Chapter 4, Page 73).
Another point of interest is the depth needed when converting a rational function to a ReLU network. Theorem 1.1 is impossible if the depth is : specifically, it is impossible to approximate the degree 1 rational function with size but depth .
Lastly, the implementation of division in a ReLU network requires a few steps, arguably the most interesting being a “continuous switch statement”, which computes reciprocals differently based on the magnitude of the input. The ability to compute switch statements appears to be a fairly foundational operation available to neural networks and rational functions (Petrushev & Popov, 1987, Theorem 5.2), but is not available to polynomials (since otherwise they could approximate the ReLU).
3 Related work
The results of the present work follow a long line of work on the representation power of neural networks and related functions. The ability of ReLU networks to fit continuous functions was no doubt proved many times, but it appears the earliest reference is to Lebesgue (Newman, 1964, Page 1), though of course results of this type are usually given much more contemporary attribution (Cybenko, 1989). More recently, it has been shown that certain function classes only admit succinct representations with many layers (Telgarsky, 2015). This has been followed by proofs showing the possibility for a depth 3 function to require exponentially many nodes when rewritten with 2 layers (Eldan & Shamir, 2016). There are also a variety of other result giving the ability of ReLU networks to approximate various function classes (Cohen et al., 2016; Poggio et al., 2017).
Most recently, a variety of works pointed out neural networks can approximate polynomials, and thus smooth functions essentially by Taylor’s theorem (Yarotsky, 2016; Safran & Shamir, 2016; Liang & Srikant, 2017). This somewhat motivates this present work, since polynomials can not in turn approximate neural networks with a dependence : they require degree even for a single ReLU.
Rational functions are extensively studied in the classical approximation theory literature (Lorentz et al., 1996; Petrushev & Popov, 1987). This literature draws close connections between rational functions and splines (piecewise polynomial functions), a connection which has been used in the machine learning literature to draw further connections to neural networks (Williamson & Bartlett, 1991). It is in this approximation theory literature that one can find the following astonishing fact: not only is it possible to approximate the absolute value function (and thus the ReLU) over to accuracy with a rational function of degree (Newman, 1964), but moreover the optimal rate is known (Petrushev & Popov, 1987; Zolotarev, 1877)! These results form the basis of those results here which show that rational functions can approximate ReLU networks. (Approximation theory results also provide other functions (and types of neural networks) which rational functions can approximate well, but the present work will stick to the ReLU for simplicity.)
An ICML reviewer revealed prior work which was embarrassingly overlooked by the author: it has been known, since decades ago (Beame et al., 1986), that neural networks using threshold nonlinearities (i.e., the map ) can approximate division, and moreover the proof is similar to the proof of part 1 of Theorem 1.1! Moreover, other work on threshold networks invoked Newman polynomials to prove lower bound about linear threshold networks (Paturi & Saks, 1994). Together this suggests that not only the connections between rational functions and neural networks are tight (and somewhat known/unsurprising), but also that threshold networks and ReLU networks have perhaps more similarities than what is suggested by the differing VC dimension bounds, approximation results, and algorithmic results (Goel et al., 2017).
4 Further notation
Here is a brief description of the sorts of neural networks used in this work. Neural networks represent computation as a directed graph, where nodes consume the outputs of their parents, apply a computation to them, and pass the resulting value onward. In the present work, nodes take their parents’ outputs and compute , where is a vector, is a scalar, and ; another popular choice of nonlineary is the sigmoid . The graphs in the present work are acyclic and connected with a single node lacking children designated as the univariate output, but the literature contains many variations on all of these choices.
Approximating ReLU networks with rational functions
This section will develop the proofs of part 2 of Theorem 1.1, Theorem 1.2, Section 1.1, and Section 1.1.
The starting point is a seminal result in the theory of rational functions (Zolotarev, 1877; Newman, 1964): there exists a rational function of degree which can approximate the absolute value function along to accuracy . This in turn gives a way to approximate the ReLU, since
The construction here uses the Newman polynomials (Newman, 1964): given an integer , define
The Newman polynomials , , and are depicted in Figure 3. Typical polynomials in approximation theory, for instance the Chebyshev polynomials, have very active oscillations; in comparison, the Newman polynomials look a little funny, lying close to 0 over . The seminal result of Newman (1964) is that
Thanks to this bound and eq. 2.1, it follows that the ReLU can be approximated to accuracy by rational functions of degree .
(Some basics on Newman polynomials, as needed in the present work, can be found in Section A.1.)
2 Proof of Section 1.1
Now that a single ReLU can be easily converted to a rational function, the next task is to replace every ReLU in a ReLU network with a rational function, and compute the approximation error. This is precisely the statement of Section 1.1.
The proof of Section 1.1 is an induction on layers, with full details relegated to the appendix. The key computation, however, is as follows. Let denote a rational approximation to . Fix a layer , and let denote the multi-valued mapping computed by layer , and let denote the mapping obtained by replacing each in with . Fix any node in layer , and let denote its output as a function of the input. Then
For the first term , note since is -Lipschitz and by Hölder’s inequality that
meaning this term has been reduced to the inductive hypothesis since . For the second term , if can be shown to lie in (which is another easy induction), then is just the error between and on the same input.
3 Proof of part 2 of Theorem 1.1
It is now easy to find a rational function that approximates a neural network, and to then bound its size. The first step, via Section 1.1, is to replace each with a rational function of low degree (this last bit using Newman polynomials). The second step is to inductively collapse the network into a single rational function. The reason for the dependence on the number of nodes is that, unlike polynomials, summing rational functions involves an increase in degree:
4 Proof of Theorem 1.2
The final interesting bit is to show that the dependence on in part 2 of Theorem 1.1 (where is the number of nodes and is the number of layers) is tight.
The -fold composition is a piecewise affine function with regularly spaced peaks (Telgarsky, 2015). This function was demonstrated to be inapproximable by shallow networks of subexponential size, and now it can be shown to be a hard case for rational approximation as well.
Consider the horizontal line through . The function will cross this line times. Now consider a rational function . The set of points where corresponds to points where . A poor estimate for the number of zeros is simply the degree of , however, since is univariate, a stronger tool becomes available: by Descartes’ rule of signs, the number of zeros in is upper bounded by the number of terms in .
Approximating rational functions with ReLU networks
This section will develop the proof of part 1 of Theorem 1.1, as well as the tightness result in Section 1.2
To establish part 1 of Theorem 1.1, the first step is to approximate polynomials with ReLU networks, and the second is to then approximate the division operation.
The representation of polynomials will be based upon constructions due to Yarotsky (2016). The starting point is the following approximation of the squaring function.
Let any be given. There exists , represented as a ReLU network with nodes and layers, such that and .
Yarotsky’s proof is beautiful and deserves mention. The approximation of is the function , defined as
where is the triangle map from Section 2. For every , is a convex, piecewise-affine interpolation between points along the graph of ; going from to does not adjust any of these interpolation points, but adds a new set of interpolation points.
Once squaring is in place, multiplication comes via the polarization identity .
Let any and be given. There exists , represented by a ReLU network with nodes and layers, with
Next, it follows that ReLU networks can efficiently approximate exponentiation thanks to repeated squaring.
Let and positive integer be given. There exists , represented by a ReLU network with nodes and layers, with
With multiplication and exponentiation, a representation result for polynomials follows.
Let be given. Let denote a polynomial with monomials, each with degree and scalar coefficient within . Then there exists a function computed by a network of size , which satisfies .
The remainder of the proof now focuses on the division operation. Since multiplication has been handled, it suffices to compute a single reciprocal.
Let and nonnegative integer be given. There exists a ReLU network , of size and depth such that
This proof relies on two tricks. The first is to observe, for , that
Thanks to the earlier development of exponentiation, truncating this summation gives an expression easily approximate by a neural network as follows.
Unfortunately, Section 3.1 differs from the desired statement Section 3.1: inverting inputs lying within requires nodes rather than !
To obtain a good estimate with only terms of the summation, it is necessary for the input to be bounded below by a positive constant (not depending on ). This leads to the second trick (which was also used by Beame et al. (1986)!).
Consider, for positive constant , the expression
If is small, choosing a larger will cause this summation to converge more quickly. Thus, to compute accurately over a wide range of inputs, the solution here is to multiplex approximations of the truncated sum for many choices of . In order to only rely on the value of one of them, it is possible to encode a large “switch” style statement in a neural network. Notably, rational functions can also representat switch statements (Petrushev & Popov, 1987, Theorem 5.2), however polynomials can not (otherwise they could approximate the ReLU more efficiently, seeing as it is a switch statement of 0 (a degree 0 polynomial) and (a degree 1 polynomial).
2 Proof of Section 1.2
It remains to show that shallow networks have a hard time approximating the reciprocal map .
This proof uses the same scheme as various proofs in (Telgarsky, 2016), which was also followed in more recent works (Yarotsky, 2016; Safran & Shamir, 2016): the idea is to first upper bound the number of affine pieces in ReLU networks of a certain size, and then to point out that each linear segment must make substantial error on a curved function, namely .
The proof is fairly brute force, and thus relegated to the appendices.
Summary of figures
Throughout this work, a number of figures were presented to show not only the astonishing approximation properties of rational functions, but also the higher fidelity approximation achieved by both ReLU networks and rational functions as compared with polynomials. Of course, this is only a qualitative demonstration, but still lends some intuition.
In all these demonstrations, rational functions and polynomials have degree 9 unless otherwise marked. ReLU networks have two hidden layers each with 3 nodes. This is not exactly apples to apples (e.g., the rational function has twice as many parameters as the polynomial), but still reasonable as most of the approximation literature fixes polynomial and rational degrees in comparisons.
Figure 1 shows the ability of all three classes to approximate a truncated reciprocal. Both rational functions and ReLU networks have the ability to form “switch statements” that let them approximate different functions on different intervals with low complexity (Petrushev & Popov, 1987, Theorem 5.2). Polynomials lack this ability; they can not even approximate the ReLU well, despite it being low degree polynomials on two separate intervals.
Figure 2 shows that rational functions can fit the threshold function errily well; the particular rational function used here is based on using Newman polynomials to approximate (Newman, 1964).
Figure 3 shows Newman polynomials , , . As discussed in the text, they are unlike orthogonal polynomials, and are used in all rational function approximations except Figure 1, which used a least squares fit.
Figure 4 shows that rational functions (via the Newman polynomials) fit very well, whereas polynomials have trouble. These errors degrade sharply after recursing, namely when approximating as in Figure 6.
Figure 5 shows how polynomials and rational functions fit the ReLU, where the ReLU representation, based on Newman polynomials, is the one used in the proofs here. Despite the apparent slow convergence of polynomials in this regime, the polynomial fit is still quite respectable.
Open problems
There are many next steps for this and related results.
Can rational functions, or some other approximating class, be used to more tightly bound the generalization properties of neural networks? Notably, the VC dimension of sigmoid networks uses a conversion to polynomials (Anthony & Bartlett, 1999).
Can rational functions, or some other approximating class, be used to design algorithms for training neural networks? It does not seem easy to design reasonable algorithms for minimization over rational functions; if this is fundamental and moreover in contrast with neural networks, it suggests an algorithmic benefit of neural networks.
Can rational functions, or some other approximating class, give a sufficiently refined complexity estimate of neural networks which can then be turned into a regularization scheme for neural networks?
Acknowledgements
The author thanks Adam Klivans and Suvrit Sra for stimulating conversations. Adam Klivans and the author both thank Almare Gelato Italiano, in downtown Berkeley, for necessitating further stimulating conversations, but now on the topic of health and exercise. Lastly, the author thanks the University of Illinois, Urbana-Champaign, and the Simons Institute in Berkeley, for financial support during this work.
References
Appendix A Deferred material from Section 2
This section collects technical material omitted from Section 2. The first step is to fill in some missing details regarding Newman polynomials.
Define the Newman polynomial (Newman, 1964)
Define , the Newman approximation to , as
If , then . Otherwise , and note for any that
means ,
means .
Together, , and
Since when , thus .
Lastly, the case follows from the case since is even.
where the last step was proved by Newman (Lorentz et al., 1996, Theorem 7.3.1).
If , then along .
A.2 Remaining deferred proofs
The details of converting a ReLU network into a rational network are as follows.
This construction will use the Newman-based approximation to with degree . By Section A.1, this degree suffices to guarantee and for .
First note, by induction on layers, that the output of every node has absolute value at most 1. The base case is the inputs themselves, and thus the statement holds by the assumption . In the inductive step, consider any node , where is the multivariate input to this node. By the inductive hypothesis, , thus
Next, collapsing a rational network down into a single rational function is proved as follows.
Throughout this proof, let denote the rational activation function at each node, and write where and are polynomials of degree at most . The proof establishes, by induction on layers, that the nodes of layer compute rational functions of degree at most . The base case is layer , where each node computes a rational function of degree . For the case of layer , fix any node, and denote its computation by , where and is a rational function of degree at most . Note
the map is rational of degree . Let and denote its numerator and denominator. Since is univariate, its numerator and denominator have the form and . Thus, using the fact that ,
The proof of part 2 of Theorem 1.1 now follows by combining Sections 1.1, A.1 and A.2.
The last piece is a slighly more detailed account of Theorem 1.2.
Define the target function , which as in (Telgarsky, 2015) has regular-spaced crossings of 0 along $2k\leq 2$ nodes.
Next consider the rational function . As in the text, it is necessary to count the zeros of (the case is trivial). Writing , equivalently this means the zeros of . Since and together have terms, by Descartes’ rule of signs, crosses at most times along . Therefore, following a similar calculation to the proof in (Telgarsky, 2016, Proof of Theorem 1.1),
Appendix B Deferred material from Section 3
To start, the lemmas due to Yarotsky are slightly adjusted to clip the range to $$.
Inspecting Yarotsky’s proof, the construction provides with and . To provide the desired , it suffices to define . ∎
First suppose , let be as in Section 3.1 at resolution , and define via the polarization identity (as in Yarotsky’s proof):
(where appears since has domain ). Since ,
Now consider the case , and set . Then implies
The full details for the proof of fast exponentiation are as follows.
This proof constructs a network implementing the russian peasant algorithm for exponentiation:
Set .
For (the bits of from left to right):
Set .
If , set .
The two lines in the inner loop will use the squaring function from Section 3.1 and the multiplication function from Section 3.1, each with accuracy where . At the end, the network returns to ensure the output lies in $\mathcal{O}(\ln(y))\mathcal{O}(\ln(1/(c\epsilon)))=\mathcal{O}(\ln(y/\epsilon))\mathcal{O}(\ln(y/\epsilon)^{2})$.
It remains to show that the network computes a function which satisfies
Let denote the integer corresponding to the first bits of when read left-to-right; it will be shown by induction (on the bits of from left to right) that, at the end of the th invocation of the loop,
This suffices to establish the claim since then .
For the base case, consider ; then as desired. For the inductive step, let denote at the end of the previous iteration, whereby the inductive hypothesis grants
The error after the approximate squaring step can be upper bounded as
The reverse inequality is proved analogously, thus
If the bit in this iteration is 0, then and the proof for this loop iteration is complete. Otherwise , and
The proof of the reverse inequality is analogous, which establishes the desired error bound on for this loop iteration. ∎
Using the preceding exponentiation lemma, the proof of polynomial approximation is as follows.
It will be shown momentarily that a single monomial term can be approximating to accuracy with a network of size . This implies the result by summing monomials comprising a polynomial, along with their errors.
For a single monomial, here are two constructions.
One approach is to product together individual variables (and lastly multiple by a fixed scalar coefficient), with no concern of the multiplicities of individual variables. To this end, let with denote coordinates of the input variable so that is the desired multinomial. Let denote multiplication with error as provided by Section 3.1. The network will compute , where is the scalar coefficient on the monomial, and is recursively defined as
The base case is immediate since . For the inductive step,
and the reverse inequality is proved analogously.
Alternatively, the network uses the fast exponentiation routine from Section 3.1, and then multiplies together the terms for individual coordinates. In particular, the exponentiation for each coordinate with accuracy requires a network of size . By an analysis similar to the preceding construction, multiplying such networks will result in a network approximating the monomial with error and size .
Next, the proof that ReLU networks can efficiently compute reciprocals, namely Section 3.1. As stated in the text, it is first necessary to establish Section 3.1, which gives computes reciprocals at a choice of magnitude, and then Section 3.1, which combines these circuits across scales.
For each , define the function
The functions have the following properties.
Each can be represented by a ReLU network with three nodes in 2 layers.
For any , there exists so that implies and implies . Indeed, it suffices to let be the smallest element of . satisfying .
For any , .
The family thus forms a partition of unity over , moreover with the property that at most two elements, necessarily consecutive, are nonzero at any point in the interval.
By construction, is a ReLU network with layers and nodes.
It remains to check the approximation properties of . Let be given, and set . Then
By construction, is a ReLU network with nodes and layers.
For the approximation property of , let be given, and note
Putting the pieces together gives the proof of the second part of the main theorem.
Define , and use Sections 3.1, 3.1 and 3.1 to choose ReLU network approximations and to and at resolution , as well as ReLU network for multiplication along and to approximate along , again at resolution . The desired network will compute the function , defined as
Combining the size bounds from the preceding lemmas, itself has size bound
Before verifying the approximation guarantee upon , it is necessary to verify that the inputs to and are of the correct magnitude, so that Sections 3.1 and 3.1 may be applied. Note firstly that , since implies . Thus , and so both arguments to within the definition of are within $$. Consequently, the approximation guarantees of Sections 3.1, 3.1 and 3.1 all hold, whereby
The proof of the reverse inequality is analogous. ∎
B.2 Proof of Section 1.2
Let denote this final partition of , and let denote the corresponding interval lengths. Let index the subcollection of intervals with length at least , meaning . Then
Consider now any interval with endpoints . Since , then satisfies . In order to control the difference between and along , consider two cases: either along this interval, or along this interval (these are the only two cases due to the subdivisions above).
If , then can be taken to be a tangent to at some point along the interval (otherwise, the distance can always be only decreased by moving up to be a tangent). Consequently, for some , and by convexity and since over this interval,
On the other hand, if , then passes above the secant line between and . The area between and is at least the area between and , and this latter area is bounded above by a triangle of width and height
Combining this with , the triangle has area at least .
Combining these two cases and summing across the intervals of (where implies ),