Depth-Width Tradeoffs in Approximating Natural Functions with Neural Networks
Itay Safran, Ohad Shamir
Introduction
Deep learning, in the form of artificial neural networks, has seen a dramatic resurgence in the past recent years, achieving great performance improvements in various fields of artificial intelligence such as computer vision and speech recognition. While empirically successful, our theoretical understanding of deep learning is still limited at best.
An emerging line of recent works has studied the expressive power of neural networks: What functions can and cannot be represented by networks of a given architecture (see related work section below). A particular focus has been the trade-off between the network’s width and depth: On the one hand, it is well-known that large enough networks of depth can already approximate any continuous target function on to arbitrary accuracy (Cybenko, 1989; Hornik, 1991). On the other hand, it has long been evident that deeper networks tend to perform better than shallow ones, a phenomenon supported by the intuition that depth, providing compositional expressibility, is necessary for efficiently representing some functions. Indeed, recent empirical evidence suggests that even at large depths, deeper networks can offer benefits over shallower networks (He et al., 2015).
To demonstrate the power of depth in neural networks, a clean and precise approach is to prove the existence of functions which can be expressed (or well-approximated) by moderately-sized networks of a given depth, yet cannot be approximated well by shallower networks, even if their size is much larger. However, the mere existence of such functions is not enough: Ideally, we would like to show such depth separation results using natural, interpretable functions, of the type we may expect neural networks to successfully train on. Proving that depth is necessary for such functions can give us a clearer and more useful insight into what various neural network architectures can and cannot express in practice.
In this paper, we provide several contributions to this emerging line of work. We focus on standard, vanilla feedforward networks (using some fixed activation function, such as the popular ReLU), and measure expressiveness directly in terms of approximation error, defined as the expected squared loss with respect to some distribution over the input domain. In this setting, we show the following:
We show that this depth/width trade-off can also be observed experimentally: Specifically, that the indicator of a unit ball can be learned quite well using a 3-layer network, using standard backpropagation, but learning the same function with a 2-layer network (even if much larger) is significantly more difficult. Our theoretical result indicates that this gap in performance is due to approximation error issues. This experiment also highlights the fact that our separation result is for a natural function that is not just well-approximated by some 3-layer network, but can also be learned well from data using standard methods.
Finally, we prove that any member of a wide family of non-linear and twice-differentiable functions (including for instance in $\epsilon\mathcal{O}(\text{poly}(\log(1/\epsilon)))\Omega(\text{poly}(1/\epsilon))$. We note that a similar result appeared online concurrently and independently of ours in Yarotsky (2016); Liang & Srikant (2016), but the setting is a bit different (see related work below for more details).
A noteworthy paper in the same setting as ours is Telgarsky (2016), which proves a separation result between the expressivity of ReLU networks of depth and depth (for any ). This holds even for one-dimensional functions, where a depth network is shown to realize a saw-tooth function with oscillations, whereas any network of depth would require a width super-polynomial in to approximate it by more than a constant. In fact, we ourselves rely on this construction in the proofs of our results in Sec. 5. On the flip side, in our paper we focus on separation in terms of the accuracy or dimension, rather than a parameter . Moreover, the construction there relies on a highly oscillatory function, with Lipschitz constant exponential in almost everywhere. In contrast, in our paper we focus on simpler functions, of the type that are likely to be learnable from data using standard methods.
Our separation results in Sec. 5 (for smooth non-linear functions) are closely related to those of Yarotsky (2016); Liang & Srikant (2016), which appeared online concurrently and independently of our work, and the proof ideas are quite similar. However, these papers focused on bounds rather than bounds. Moreover, Yarotsky (2016) considers a class of functions different than ours in their positive results, and Liang & Srikant (2016) consider networks employing a mix of ReLU and threshold activations, whereas we consider a purely ReLU network.
Another relevant and insightful work is Poggio et al. (2016), which considers width vs. depth and provide general results on expressibility of functions with a compositional nature. However, the focus there is on worse-case approximation over general classes of functions, rather than separation results in terms of specific functions as we do here, and the details and setting is somewhat orthogonal to ours.
Preliminaries
for some parameters and -dimensional vectors . Similarly, a 3-layer ReLU network has the form
for some parameters .
We note that the assumptions from Eldan & Shamir (2016) are very mild, and apply to all standard activation functions, including ReLU, sigmoid and threshold.
Let and be a non-singular matrix and vector respectively, to be determined later. We begin by performing a change of variables, , , which yields
In particular, let us choose the distribution defined as , where is the (continuous) distribution used in the main result of Eldan & Shamir (2016) (note that is indeed a distribution, since , which by the change of variables , equals ). Plugging the definition of in Eq. (1), and using the fact that , we get
we get by Eq. (4) and the triangle inequality that
The proof of the theorem appears in Subsection 6.1.
In this subsection, we empirically demonstrate that indicator functions of balls are indeed easier to learn with a 3-layer network, compared to a 2-layer network (even if the 2-layer network is significantly larger). This indicates that the depth/width trade-off for indicators of balls, predicted by our theory, can indeed be observed experimentally. Moreover, it highlights the fact that our separation result is for simple natural functions, that can be learned reasonably well from data using standard methods.
We trained ReLU networks on this dataset:
One 3-layer network, with a first hidden layer of size , a second hidden layer of size , and a linear output neuron.
Four 2-layer networks, with hidden layer of sizes and , and a linear output neuron.
The results are presented in Fig. 1. As can be clearly seen, the 3-layer network achieves significantly better performance than the 2-layer networks. This is true even though some of these networks are significantly larger and with more parameters (for example, the 2-layer, width 800 network has ~80K parameters, vs. ~10K parameters for the 3-layer network). This gap in performance is the exact opposite of what might be expected based on parameter counting alone. Moreover, increasing the width of the 2-layer networks exhibits diminishing returns: The performance improvement in doubling the width from 100 to 200 is much larger than doubling the width from 200 to 400 or 400 to 800. This indicates that one would need a much larger 2-layer network to match the 3-layer, width 100 network’s performance. Thus, we conclude that the network’s depth indeed plays a crucial role, and that 3-layer networks are inherently more suitable to express indicator functions of the type we studied.
Having considered functions depending on the norm, we now turn to consider functions depending on the norm. Focusing on ReLU networks, we will show a certain separation result holding for any non-linear function, which depends on the input only via its 1-norm .
Then there exists a distribution over , such that if a 2-layer ReLU network satisfies
Intuitively, the proof relies on showing that any good -layer approximation of must capture the non-linear behavior of close to “most” points satisfying . However, a -layer ReLU network is piecewise linear, with non-linearities only at the union of the hyperplanes . This implies that “most” points s.t. must be -close to a hyperplane . However, the geometry of the ball is such that the neighborhood of any single hyperplane can only cover a “small” portion of that ball, yet we need to cover most of the ball. Using this and an appropriate construction, we show that required number of hyperplanes is at least , as long as (and if is smaller than that, we can simply use one neuron/hyperplane for each of the facets of the ball, and get a covering using neurons/hyperplanes). The formal proof appears in Subsection 6.2.
We note that the bound in Thm. 3 is of a weaker nature than the bound in the previous section, in that the lower bound is only polynomial rather than exponential (albeit w.r.t. different problem parameters: vs. ). Nevertheless, we believe this does point out that balls also pose a geometric difficulty for 2-layer networks, and conjecture that our lower bound can be considerably improved: Indeed, at the moment we do not know how to approximate a function such as with 2-layer networks to better than constant accuracy, using less than neurons.
In this section, we establish a depth separation result for approximating continuously twice-differentiable () functions using ReLU neural networks. Unlike the previous results in this paper, the separation is for depths which can be larger than 3, depending on the required approximation error. Also, the results will all be with respect to the uniform distribution over . As mentioned earlier, the results and techniques in this section are closely related to the independent results of Yarotsky (2016); Liang & Srikant (2016), but our emphasis is on rather than approximation bounds, and we focus on somewhat different network architectures and function classes.
Clearly, not all functions are difficult to approximate (e.g. a linear function can be expressed exactly with a 2-layer network). Instead, we consider functions which have a certain degree of non-linearity, in the sense that its Hessians are non-zero along some direction, on a significant portion of the domain. Formally, we make the following definition:
In words, is the measure (w.r.t. the uniform distribution on ) of the largest connected set in the domain of , where at any point, has curvature at least along some fixed direction . The “prototypical” functions we are interested in is when is lower bounded by a constant (e.g. it is if is strongly convex). We stress that our results in this section will hold equally well by considering the condition as well, however for the sake of simplicity we focus on the former condition appearing in Def. 1. Our goal is to show a depth separation result inidividually for any such function (that is, for any such function, there is a gap in the attainable error between deeper and shallower networks, even if the shallow network is considerably larger).
As usual, we start with an inapproximability result. Specifically, we prove the following lower bound on the attainable approximation error of , using a ReLU neural network of a given depth and width:
The theorem conveys a key tradeoff between depth and width when approximating a function using ReLU networks: The error cannot decay faster than polynomially in the width , yet the bound deteriorates exponentially in the depth . As we show later on, this deterioration does not stem from the looseness in the bound: For well-behaved , it is indeed possible to construct ReLU networks, where the approximation error decays exponentially with depth.
The proof of Thm. 4 appears in Subsection 6.3, and is based on a series of intermediate results. First, we show that any strictly curved function (in a sense similar to Definition 1) cannot be well-approximated in an sense by piecewise linear functions, unless the number of linear regions is large. To that end, we first establish some necessary tools based on Legendre polynomials. We then prove a result specific to the one-dimensional case, including an explicit lower bound if the target function is quadratic (Thm. 9) or strongly convex or concave (Thm. 10). We then expand the construction to get an error lower bound in general dimension , depending on the number of linear regions in the approximating piecewise-linear function. Finally, we note that any ReLU network induces a piecewise-linear function, and bound the number of linear regions induced by a ReLU network of a given width and depth (using a lemma borrowed from Telgarsky (2016)). Combining this with the previous lower bound yields Thm. 4.
We now turn to complement this lower bound with an approximability result, showing that with more depth, a wide family of functions to which Thm. 4 applies can be approximated with exponentially high accuracy. Specifically, we consider functions which can be approximated using a moderate number of multiplications and additions, where the values of intermediate computations are bounded (for example, a special case is any function approximable by a moderately-sized Boolean circuit, or a polynomial).
The key result to show this is the following, which implies that the multiplication of two (bounded-size) numbers can be approximated by a ReLU network, with error decaying exponentially with depth:
The idea of the construction is that depth allows us to compute highly-oscillating functions, which can extract high-order bits from the binary representation of the inputs. Given these bits, one can compute the product by a procedure resembling long multiplication, as shown in Fig. 2, and formally proven as follows:
We begin by observing that by using a simple linear change of variables on , we may assume without loss of generality that , as we can just rescale to the interval , and then map it back to its original domain , where the error will multiply by a factor of . Then by requiring accuracy instead of , the result will follow.
The key behind the proof is that performing bit-wise operations on the first bits of yields an estimation of the product to accuracy . Let be the binary representation of where is the bit of , then
Requiring that , it suffices to show the existence of a network which approximates the function to accuracy , where . This way both approximations will be at most , resulting in the desired accuracy of .
Before specifying the architecture which extracts the bit of , we first describe the last 2 layers of the network. Let the penultimate layer comprise of neurons, each receiving both and as input, and having the set of weights . Thus, the output of the neuron in the penultimate layer is
We now specify the architecture which extracts the first most significant bits of . In Telgarsky (2016), the author demonstrates how the composition of the function
with itself times, , yields a highly oscillatory triangle wave function in the domain . Furthermore, we observe that , and thus . Now, a linear shift of the input of by , and composing the output with
We stress that choosing such that the network approximates the bit-wise product to accuracy will require to be of magnitude , but this poses no problem as representing such a number requires bits, which is also the magnitude of the size of the network, as suggested by the following analysis.
Next, we compute the size of the network required to implement the above approximation. To compute only two neurons are required, therefore can be computed using layers with neurons in each, and finally composing this with requires a subsequent layer with more neurons. To implement the bit extractor we therefore require a network of size . Using dummy neurons to propagate the bit for , the architecture extracting the most significant bits of will be of size . Adding the final component performing the multiplication estimation will require more layers of width and respectively, and an increase of the width by to propagate to the penultimate layer, resulting in a network of size . ∎
Repeating these arguments, we see that any function which can be approximated by a bounded number of operations involving additions and multiplications, can also be approximated well by moderately-sized networks. This is formalized in the following theorem, which provides an approximation error upper bound (in the sense, which is stronger than for upper bounds):
As discussed in Sec. 2, this type of approximation bound implies an approximation bound with respect to any distribution. The proof of the theorem appears in Subsection 6.4.
Combining Thm. 4 and Thm. 6, we can state the following corollary, which formally shows how depth can be exponentially more valuable than width as a function of the target accuracy :
Suppose , where and . Then approximating to accuracy in the norm using a fixed depth ReLU network requires width at least , whereas there exists a ReLU network of depth and width at most which approximates to accuracy in the infinity norm, where is a polynomial depending solely on .
The lower bound follows immediately from Thm. 4. For the upper bound, observe that Thm. 6 implies an approximation by a network of width and depth at most
which by the assumption of Corollary 1, can be bounded by
for some polynomial which depends solely on . ∎
This research is supported in part by an FP7 Marie Curie CIG grant, Israel Science Foundation grant 425/13, and the Intel ICRI-CI Institute. We would like to thank Shai Shalev-Shwartz for some illuminating discussions, Eran Amar for his valuable help with the experiment, and Lv Xianzhang for spotting a mistake in a previous version of Sec. 3.
References
Proofs
This proof bears resemblance to the proof provided in Eldan & Shamir (2016)[Lemma 10], albeit once approximating , the following construction takes a slightly different route. For completeness, we also state assumption 1 from Eldan & Shamir (2016):
As discussed in Eldan & Shamir (2016), this assumption is satisfied by ReLU, sigmoid, threshold, and more generally all standard activation functions we are familiar with.
which is constant outside , as well as the function
and where the width parameter is at most . Consequently, the function
can be expressed in the form where , yielding an approximation satisfying
We now invoke assumption 1 again to approximate the -Lipschitz function
for appropriate scalars and vectors , and where is at most . It is now left to bound the approximation error obtained by . We have
Beginning with the second summand, define for any ,
Since is continuous, there exists such that
Combining both Eq. (10) and Eq. (11) we compute
where the equality is since both functions are equal outside of , the first inequality is since the difference between the two functions on is at most , and the last inequality is due to Eq. (9). Moving to the first summand in Eq. (8), we have
where the third inequality is due to Eq. (7) and being -Lipschitz and the last inequality due to Eq. (6). Letting and which also entails , the above is upper bounded by , which when combined with Eq. (12) and plugged in Eq. (8) implies the lemma. ∎
2 Proof of Thm. 3
Consider an input distribution of the form
where is drawn from a certain distribution on the unit sphere to be specified later, and is uniformly distributed on .
be a 2-layer ReLU network of width , such that with respect to the distribution above,
where in the first inequality we used the fact that for all , and in the second inequality we used a union bound. Combining these inequalities with Eq. (13), we get that
As a result, to prove the theorem, it is enough to construct a distribution for on the on the unit ball, such that for any ,
where is a parameter dependent on to be determined later. It is easily verified that independent of , hence lies on the hyperplane containing the facet of the ball on which resides. Calling this facet , we define to have the same distribution as , conditioned on .
To see this, let , and note that the left hand side equals
Therefore, to prove Eq. (15), it is enough to prove that for any . As shown earlier, lies on the hyperplane containing , the facet of the ball in which resides. Thus, can be outside , only if at least one of its coordinates has a different sign than . By definition of , this can only happen if . The probability of this event (over the random draw of ) equals
Since for all , the event on the right hand side can only occur if for some . Recalling that each has a standard Gaussian distribution, this probability can be upper bounded by
where we used a union bound and a standard Gaussian tail bound. Thus, by picking
we can ensure that the probability is at most , hence proving that and validating Eq. (15).
With Eq. (15) in hand, we now turn to upper bound
By the equation above, we have that conditioned on , the distribution of is Gaussian with mean and variance
By Hoeffding’s inequality, we have that for any ,
This means that with probability at least over the choice of , the distribution of (conditioned on ) is Gaussian with mean bounded in absolute value by , and variance of at least . To continue, we utilize the following lemma:
Since the probability can only increase if we replace the mean by , we will assume without loss of generality that .
By definition of a Gaussian distribution, and using the easily-verified fact that for all , the probability equals
A simple case analysis reveals that the denominator is at leastIf , then we get . If , we get . If , we get . , from which the result follows. ∎
Using this lemma and the previous observations, we get that with probability at least over the choice of ,
Letting be the event that is such that this inequality is satisfied (and noting that its probability of non-occurence is at most ), we get overall that
Recalling Eq. (15) and the definition of , we get that
Picking , we get the bound
This justifies Eq. (14), from which the result follows.
3 Proof of Thm. 4
The proof rests largely on the following key result:
Before proving Thm. 7, let us explain how we can use it to prove Thm. 4. To that end, we use the result in Telgarsky (2016, Lemma 3.2), of which the following is an immediate corollary:
Let denote the family of ReLU neural networks receiving input of dimension and having depth and maximal width . Then
Combining this corollary with Thm. 7, the result follows. The remainder of this subsection will be devoted to proving Thm. 7.
Let denote the Legendre Polynomial given by Rodrigues’ formula:
These polynomials are useful for the following analysis since they obey the orthogonality relationship
The shifted Legendre polynomials obey the orthogonality relationship
A generalization of Parseval’s identity yields
A function is -strongly convex if for all and ,
A function is -strongly concave, if is -strongly convex.
3.2 One-dimensional Lower Bounds
We begin by proving two useful lemmas; the first will allow us to compute the error of a linear approximation of one-dimensional functions on arbitrary intervals, and the second will allow us to infer bounds on the entire domain of approximation, from the lower bounds we have on small intervals where the approximating function is linear.
Where in the second equality we used the orthogonality relationship from Eq. (17), and the generalized Parseval’s identity from Eq. (18). ∎
Now, recall Hölder’s sum inequality which states that for any satisfying we have
Plugging the inequality from Eq. (21) with in Eq. (20) yields
Our first lower bound for approximation using piece-wise linear functions is for non-linear target functions of the simplest kind. Namely, we obtain lower bounds on quadratic functions.
If is the family of piece-wise linear functions with at most linear segments in the interval , then for any quadratic function , we have
Note that for quadratic functions, the optimal error is dependent solely on the length of the interval. Using Lemma 3 with we get
For non-quadratic functions, however, we now show that a lower bound can be derived under the assumption of strong convexity (or strong concavity) in .
We first stress that an analogous assumption to -strong convexity would be that is -strongly concave, since the same bound can be derived under concavity by simply applying the theorem to the additive inverse of , and observing that the additive inverse of any piece-wise linear approximation of is in itself, of course, a piece-wise linear function. For this reason from now on we shall use the convexity assumption, but will also refer without loss of generality to concave functions.
We now integrate by parts twice, taking the anti-derivative of the polynomial to obtain
But since and since due to strong convexity, we have that
Plugging this inequality in Eq. (24) yields
and by using the strong convexity of again, we get that
First, observe that if is -strongly convex on , then is -strongly convex on since ,
Now, we use the change of variables ,
where the inequality follows from an application of Thm. 10. Back to the theorem statement, if then the bound trivially holds, therefore assume such that . Since is strongly convex on a set of measure , the theorem follows by applying the inequality from Eq. (6.3.2). ∎
3.3 Multi-dimensional Lower Bounds
We now move to generalize the bounds in the previous subsection to general dimension . Namely, we can now turn to proving Thm. 7.
Analogously to the proof of Thm. 11, we identify a neighborhood of in which the restriction of to a line in a certain direction is non-linear. We then integrate along all lines in that direction and use the result of Thm. 11 to establish the lower bound.
We now integrate the approximation error on in the neighborhood along the direction . Compute
where in the second inequality we used Thm. 11 and in the third inequality we used Jensen‘s inequality with respect to the convex function . ∎
4 Proof of Thm. 6
and for multiplication we compute the product error estimation
From this, we see that at each stage the error grows by at most a multiplicative factor of . After operations, and with an initial estimation error of , we have that the error is bounded by . Choosing to guarantee approximation , we have from Thm. 5 that each operation will require at most
depth for some universal . Composing the networks performing each operation, we arrive at a total network width and depth of at most
Now, our target function is approximated to accuracy by a function which our network approximates to the same accuracy , for a total approximation error of the target function by our network of .