B OUNDING AND C OUNTING L INEAR R EGIONS OF
D EEP N EURAL N ETWORKS
Anonymous authors
Paper under double-blind review
A BSTRACT
In this paper we study the representational power of deep neural networks (DNN) that belong to the family of piecewise-linear (PWL) functions, based on PWL activation units such as rectiﬁer or maxout.
We investigate the complexity of such networks by studying the number of linear regions of the PWL function.
Typically, a PWL function from a DNN can be seen as a large family of linear functions acting on millions of such regions.
We directly build upon the work of Mont´ufar et al.
(2014), Mont´ufar (2017) and Raghu et al.
(2017) by reﬁning the upper and lower bounds on the number of linear regions for rectiﬁed and maxout networks.
In addition to achieving tighter bounds, we also develop a novel method to perform exact enumeration or counting of the number of linear regions with a mixed-integer linear formulation that maps the input space to output.
We use this new capability to visualize how the number of linear regions change while training
DNNs.
I NTRODUCTION
We have witnessed an unprecedented success of deep learning algorithms in computer vision, speech, and other domains (Krizhevsky et al., 2012; Ciresan et al., 2012; Goodfellow et al., 2013;
Hinton et al., 2012).
While the popular deep learning architectures such as AlexNet (Krizhevsky et al., 2012), GoogleNet (Szegedy et al., 2015), and residual networks (He et al., 2016) have shown record beating performance on various image recognition tasks, empirical results still govern the design of network architecture in terms of depth and activation functions.
Two important practical considerations that are part of most successful architectures are greater depth and the use of PWL activation functions such as rectiﬁed linear units (ReLUs).
Due to the large gap between theory and practice, many researchers have been looking at the theoretical modeling of the representational power of DNNs (Cybenko, 1989; Anthony & Bartlett, 1999; Pascanu et al., 2014; Mont´ufar et al., 2014; Bianchini & Scarselli, 2014; Eldan & Shamir, 2016; Telgarsky, 2015; Mhaskar et al., 2016;
Raghu et al., 2017; Mont ´ ufar, 2017).
Any continuous function can be approximated to arbitrary accuracy using a single hidden layer of sigmoid activation functions (Cybenko, 1989).
This does not imply that shallow networks are sufﬁcient to model all problems in practice.
Typically, shallow networks require exponentially more number of neurons to model functions that can be modeled using much fewer activation functions in deeper ones (Delalleau & Bengio, 2011).
There have been a wide variety of activation functions such as threshold ( f ( z ) =
( z > 0) ), logistic ( f ( z )
= 1 / (1 + exp( − e )) ), hyperbolic tangent ( f ( z ) =
tanh( z ) ), rectiﬁed linear units (ReLUs f ( z ) = max { 0 , z } ), and maxouts ( f ( z 1 , z 2 , . . .
, z k ) =
max { z 1 , z 2 , . . .
, z k } ).
The activation functions offer different modeling capabilities.
For example, sigmoid networks are shown to be more expressive than similar-sized threshold networks (Maass et al., 1994).
It was recently shown that ReLUs are more expressive than similar-sized threshold networks by deriving transformations from one network to another (Pan & Srikumar, 2016).
The complexity of neural networks belonging to the family of PWL functions can be analyzed by looking at how the network can partition the input space to an exponential number of linear response regions (Pascanu et al., 2014; Mont´ufar et al., 2014).
The basic idea of a PWL function is simple: we can divide the input space into several regions and we have individual linear functions for each of these regions.
Functions partitioning the input space to a larger number of linear regions are considered to be more complex ones, or in other words, possess better representational power.
In the case of ReLUs, it was shown that deep networks separate their input space into exponentially more linear response regions than their shallow counterparts despite using the same number of activation functions (Pascanu et al., 2014).
The results were later extended and improved (Mont´ufar et al., 2014; Raghu et al., 2017; Mont´ufar, 2017; Arora et al., 2016).
In particular, Mont´ufar et al.
(2014) shows both upper and lower bounds on the maximal number of linear regions for a ReLU DNN and a single layer maxout network, and a lower bound for a maxout DNN.
Furthermore, Raghu et al.
(2017) and Mont´ufar (2017) improve the upper bound for a ReLU DNN.
This upper bound asymptotically matches the lower bound from Mont´ufar et al.
(2014) when the number of layers and input dimension are constant and all layers have the same width.
Finally, Arora et al.
(2016) improves the lower bound by providing a family of ReLU DNN S with an exponential number of regions given ﬁxed size and depth.
In this work, we directly improve on the results of Mont´ufar et al.
(Pascanu et al., 2014; Mont´ufar et al., 2014; Mont´ufar, 2017) and Raghu et al.
(Raghu et al., 2017) in better understanding the representational power of DNNs employing PWL activation functions.
N OTATIONS AND BACKGROUND
We will only consider feedforward neural networks in this paper.
Let us assume that the network has n 0 input variables given by x = { x 1 , x 2 , . . .
, x n 0 } , and m output variables given by y = { y 1 , y 2 , . . .
, y m } .
Each hidden layer l = { 1 , 2 , . . .
, L } has n l hidden neurons whose activations are given by h l = { h l 1 , h l 2 , . .
, h ln l } .
Let W l be the n l × n l − 1 matrix where each row corresponds to the weights of a neuron of layer l .
Let b l be the bias vector used to obtain the activation functions of neurons in layer l .
Based on the ReLU( x ) = max { 0 , x } activation function, the activations of the hidden neurons and the outputs are given below:
[Equation]
As considered in Pascanu et al.
(2014), the output layer is a linear layer that computes the linear combination of the activations from the previous layer without any ReLUs.
We can treat the DNN as a piecewise linear (PWL) function F : R n 0 → R m that maps the input x in R n 0 to y in R m .
This paper primarily deals with investigating the bounds on the linear regions of this PWL function.
There are two subtly different deﬁnitions for linear regions in the literature and we will formally deﬁne them.
Deﬁnition 1.
Given a PWL function F : R n 0 → R m , a linear region is deﬁned as a maximal connected subset of the input space R n 0 , on which F is linear (Pascanu et al., 2014; Mont´ufar et al., 2014).
Activation Pattern: Let us consider an input vector x = { x 1 , x 2 , . . .
, x n 0 } .
For every layer l we deﬁne an activation set S l ⊆ { 1 , 2 , . . . , n l } such that e ∈ S l if and only if the ReLU e is active, that is, h le > 0 .
We aggregate these activation sets into a set S =
( S 1 , . . .
, S l ) , which we call an activation pattern.
Note that we may consider activation patterns up to a layer l ≤ L .
Activation patterns were previously deﬁned in terms of strings (Raghu et al., 2017; Mont´ufar, 2017).
We say that an input x corresponds to an activation pattern S in a DNN if feeding x to the DNN results in the activations in S .
Deﬁnition 2.
Given a PWL function F : R n 0 → R m represented by a DNN, a linear region is the set of input vectors x that corresponds to an activation pattern S in the DNN.
We prefer to look at linear regions as activation patterns and we interchangeably refer to S as an activation pattern or a region.
Deﬁnitions 1 and 2 are essentially the same, except in a few degenerate cases.
There could be scenarios where two different activation patterns may correspond to two adjacent regions with the same linear function.
In this case, Deﬁnition 1 will produce only one linear region whereas Deﬁnition 2 will yield two linear regions.
This has no effect on the bounds that we derive in this paper.
In Fig.
1(a)
we show a simple ReLU DNN with two inputs { x 1 , x 2 } and 3 hidden layers.
The activation units { a, b, c, d, e, f } in the hidden layers can be thought of as hyperplanes that each divide the space in two.
On one side of the hyperplane, the unit outputs a positive value.
For all points on the other side of the hyperplane including itself, the unit outputs 0.
One may wonder: into how many regions do n hyperplanes split a space?
Zaslavsky (1975) shows that an arrangement of n hyperplanes divides a d -dimensional space into at most (cid:80) ds =0 (cid:0) ns (cid:1) regions, a bound that is attained when they are in general position.
The term general position basically means that a small perturbation of the hyperplanes does not change the number of regions.
This corresponds to the exact maximal number of regions of a single layer DNN with n ReLUs and input dimension d .
In Figs. 1(b)–(g), we provide a visualization of how ReLUs partition the input space.
Figs. 1(e), (f), and (g) show the hyperplanes corresponding to the ReLUs at layers l = 1 , 2 , and 3 respectively.
Figs. 1(b), (c), and (d) consider these same hyperplanes in the input space x .
In Fig. 1(b), as per
Zaslavsky (1975), the 2D input space is partitioned into 4 regions ( (cid:0) 20 (cid:1) + (cid:0) 21 (cid:1) + (cid:0) 22 (cid:1) = 4 ).
In Figs.
1(c) and (d), we add the hyperplanes from the second and third layers respectively, which are affected by the transformations applied in the earlier hidden layers.
The regions are further partitioned as we consider additional layers.
Fig.
1 also highlights that activation boundaries behave like hyperplanes when inside a region and may bend whenever they intersect with a boundary from a previous layer.
This has also been pointed out by Raghu et al.
In particular, they cannot appear twice in the same region as they are deﬁned by a single hyperplane if we ﬁx the region.
Moreover, these boundaries do not need to be connected, as illustrated in Fig.
Main Contributions
We summarize the main contributions of this paper below:
• We achieve tighter upper and lower bounds on the maximal number of linear regions of the PWL function corresponding to a DNN that employs ReLUs.
As a special case, we present the exact maximal number of regions when the input dimension is one.
We ad- ditionally provide the ﬁrst upper bound on the number of linear regions for multi-layer maxout networks (See Sections 3 and 4).
• We show for ReLUs that the exact maximal number of linear regions of shallow networks is larger than that of deep networks if the input dimension exceeds the number of neurons.
This result is particularly interesting, since it cannot be inferred from the bounds derived in prior work.
• We use a mixed-integer linear formulation to show that exact counting of the linear regions is indeed possible.
For the ﬁrst time, we show the exact counting of the number of linear regions for several small-sized DNNs during the training process.
This new capability can be used to evaluate the tightness of the bounds and potentially analyze the correlation between validation accuracy and the number of linear regions.
It also provides new insights as to how the linear regions vary during the training process (See Section 5 and 6).
T IGHTER BOUNDS FOR RECTIFIER NETWORKS
Mont´ufar et al.
(2014) derive an upper bound of 2 N for N hidden units, which can be obtained by mapping linear regions to activation patterns.
Raghu et al.
(2017) improves this result by deriving an asymptotic upper bound of O ( n Ln 0 ) to the maximal number of regions, assuming n l = n for all layers l and n
= O (1) .
Mont´ufar (2017) further tightens the upper bound to (cid:81)
Ll =1 (cid:80) d l j =0 (cid:0) n l j (cid:1) , where d l = min { n 0 , n 1 , . .
. , n l } .
Moreover, Mont´ufar et al.
(2014) prove a lower bound of (cid:16)(cid:81)
L − 1 l =1 (cid:98) n l /n
(cid:99) n 0 (cid:17) (cid:80) n 0 j =0 (cid:0) n L j (cid:1) when n ≥ n 0 , or asymptotically Ω(( n/n 0 )
( L − 1) n 0 n n 0 ) .
Arora et al.
(2016) present a lower bound of 2 (cid:80) n 0 − 1 j =0 (cid:0) m − 1 j (cid:1) w L − 1 where 2 m = n 1 and w = n l for all l = 2 , . . .
, L .
By choosing m and w appropriately, this lower bound is Ω( s n 0 ) where s is the total size of the network.
We derive both upper and lower bounds that improve upon these previous results.
3. A N UPPER BOUND ON THE NUMBER OF LINEAR REGIONS
In this section, we prove the following upper bound on the number of regions.
Theorem 1.
Consider a deep rectiﬁer network with L layers, n l rectiﬁed linear units at each layer l , and an input of dimension n 0 .
The maximal number of regions of this neural network is at most (cid:88) ( j 1 ,...,j L ) ∈ J
L (cid:89) l = (cid:18) n l j l (cid:19) where J = { ( j 1 , . . .
, j L ) ∈
Z L : 0 ≤ j l ≤ min { n 0 , n 1 − j 1 , . . . , n l − 1 − j l − 1 , n l } ∀ l = 1 , . . . , L } .
This bound is tight when L = 1 .
Note that this is a stronger upper bound than the one that appeared in Mont´ufar (2017), which can be derived from this bound by relaxing the terms n l − j l to n l and factoring the expression.
When n 0 = O (1) and all layers have the same width n , this expression has the same best known asymptotic bound O ( n Ln 0 ) ﬁrst presented in Raghu et al.
Two insights can be extracted from the above expression:
Bottleneck effect.
The bound is sensitive to the positioning of layers that are small relative to the others, a property we call the bottleneck effect.
If we subtract a neuron from one of two layers with the same width, choosing the one closer to the input layer will lead to a larger (or equal) decrease in the bound.
This occurs because each index j l is essentially limited by the widths of the current and previous layers, n 0 , n 1 , . . . , n l .
In other words, smaller widths in the ﬁrst few layers of the network imply a bottleneck on the bound.
In particular for a 2-layer network, we show in Appendix A that if the input dimension is sufﬁciently large to not create its own bottleneck, then moving a neuron from the ﬁrst layer to the second layer strictly decreases the bound, as it tightens a bottleneck.
Figure 3a illustrates this behavior.
For the solid line, we keep the total size of the network the same but shift from a small-to-large network (i.e., smaller width near the input layer and larger width near the output layer) to a large-to-small network in terms of width.
We see that the bound monotonically increases as we reduce the bottleneck.
If we add a layer of constant width at the end, represented by the dashed line, the bound decreases when the layers before the last become too small and create a bottleneck for the last layer.
While this is a property of the upper bound rather than one of the exact maximal number of regions, we observe in Section 6 that empirical results for the number of regions of a trained network exhibit a behavior that resembles the bound as the width of the layers vary.
Deep vs shallow for large input dimensions.
In several applications such as imaging, the input dimension can be very large.
Mont ´ ufar et al.
(2014) show that if the input dimension n 0 is constant, then the number of regions of deep networks is asymptotically larger than that of shallow (single-layer) networks.
We complement this picture by establishing that if the input dimension is large, then shallow networks can attain more regions than deep networks.
More precisely, we compare a deep network with L layers of equal width n and a shallow network with one layer of width Ln .
In Appendix A, we show using Theorem 1 that if the input dimension n 0 exceeds the size of the network Ln , then the ratio between the exact maximal number of regions of the deep and of the shallow network goes to zero as L approaches inﬁnity.
We also show in Appendix A that in a 2-layer network, if the input dimension n 0 is larger than both widths n 1 and n 2 , then turning it into a shallow network with a layer of n 1 + n ReLUs increases the exact maximal number of regions.
Figure 3b illustrates this behavior.
As we increase the number of layers while keeping the total size of the network constant, the bound plateaus at a value lower than the exact maximal number of regions for shallow networks.
Moreover, the number of layers that yields the highest bound decreases as we increase the input dimension n 0 .
It is important to note that this property cannot be inferred from previous upper bounds derived in prior work, since they are at least 2 N when n 0 ≥ max { n 1 , . . .
, n L } , where N is the total number of neurons.
We remark that asymptotically both deep and shallow networks can attain exponentially many regions when the input dimension is at least n (see Appendix B).
[Figure]
We now build towards the proof of Theorem 1.
For a given activation set S l and a matrix W with n l rows, let σ S l ( W ) be the operation that zeroes out the rows of W that are inactive according to S l .
This represents the effect of the ReLUs.
For a region S at layer l − 1 , deﬁne ¯ W l S :=
W l σ S l − 1 ( W l − 1 ) · · · σ S 1 ( W 1 ) .
Each region S at layer l − 1 may be partitioned by a set of hyperplanes deﬁned by the neurons of layer l .
When viewed in the input space, these hyperplanes are the rows of ¯ W l S x
+ b = 0 for some b .
To verify this, note that, if we recursively substitute out the hidden variables h l − 1 , . .
, h 1 from the original hyperplane W l h l − 1 + b l = 0 following S , the resulting weight matrix applied to x is ¯ W l S .
Finally, we deﬁne the dimension of a region S at layer l − 1 as dim( S ) :
= rank( σ S l − 1 ( W l − 1 ) · · · σ S 1 ( W 1 )) .
This can be interpreted as the dimension of the space corresponding to S that W l effectively partitions.
The proof of Theorem 1 focuses on the dimension of each region S .
A key observation is that once it falls to a certain value, the regions contained in S cannot recover to a higher dimension.
Zaslavsky (1975) showed that the maximal number of regions in R d induced by an arrangement of m hyperplanes is at most (cid:80) dj
=0 (cid:0) mj (cid:1) .
Moreover, this value is attained if and only if the hyperplanes are in general position.
The lemma below tightens this bound for a special case where the hyperplanes may not be in general position.
Lemma 2.
Consider m hyperplanes in R d deﬁned by the rows of Wx + b = 0 .
Then the number of regions induced by the hyperplanes is at most (cid:80) rank( W ) j = [Equation]
The proof is given in Appendix C.
Its key idea is that it sufﬁces to count regions within the row space of W .
The next lemma brings Lemma 2 into our context.
Lemma 3.
The number of regions induced by the n l neurons at layer l within a certain region S is at most (cid:80) min { n l , dim( S [Equation] } j = [Equation]
Proof.
The hyperplanes in a region S of the input space are given by the rows of ¯ W l S x
+ b = 0 for some b .
By the deﬁnition of ¯ W l S , the rank of ¯ W l S is upper bounded by min { rank( W l ) , rank( σ S l − 1 ( W l − 1 ) · · · σ S 1 ( W 1 )) }
= min { rank( W l ) , dim( S ) } .
That is, rank( ¯ W l S ) ≤ min { n l , dim( S ) } .
Applying Lemma 2 yields the result.
In the next lemma, we show that the dimension of a region S can be bounded recursively in terms of the dimension of the region containing S and the number of activated neurons deﬁning S .
Lemma 4.
Let S be a region at layer l and S (cid:48) be the region at layer l − 1 that contains it.
Then dim( S ) ≤ min {| S l | , dim( S (cid:48) ) } .
Proof.
dim( S ) = rank( σ S l ( W l ) · · · σ S 1 ( W 1 )) ≤ min { rank( σ S l ( W l )) , rank( σ S l − 1 ( W l − 1 ) · · · σ S 1 ( W 1 )) ≤ min {| S l | , dim( S (cid:48) ) } .
The last inequality comes from the fact that the zeroed out rows do not count towards the rank of the matrix.
In the remainder of the proof of Theorem 1, we combine Lemmas 3 and 4 to construct a recurrence
R ( l, d ) that bounds the number of regions within a given region of dimension d .
Simplifying this recurrence yields the expression in Theorem 1.
We formalize this idea and complete the proof of
Theorem 1 in Appendix D.
As a side note, Theorem 1 can be further tightened if the weight matrices are known to have small rank.
The bound from Lemma 3 can be rewritten as (cid:80) min { rank( W l ) , dim( S ) } j = (cid:0) n l j (cid:1) if we do not relax rank( W l ) to n l in the proof.
The term rank( W l ) follows through the proof of Theorem 1 and the index set J in the theorem becomes { ( j 1 , . .
, j L ) ∈
Z L : 0 ≤ j l ≤ min { n 0 , n 1 − j 1 , . . . , n l − 1 − j l − 1 , rank( W l ) } ∀ l ≥ 1 } .
A key insight from Lemmas 3 and 4 is that the dimensions of the regions are non-increasing as we move through the layers partitioning it.
In other words, if at any layer the dimension of a region becomes small, then that region will not be able to be further partitioned into a large number of regions.
For instance, if the dimension of a region falls to zero, then that region will never be further partitioned.
This suggests that if we want to have many regions, we need to keep dimensions high.
We use this idea in the next section to construct a DNN with many regions.
3. T HE CASE OF DIMENSION ONE
If the input dimension n 0 is equal to 1 and n l = n for all layers l , the upper bound presented in the previous section reduces to ( n + 1) L .
On the other hand, the lower bound given by Mont´ufar et al.
(2014) becomes n L − 1 ( n + 1) .
It is then natural to ask: are either of these bounds tight?
The answer is that the upper bound is tight in the case of n 0 = 1 , assuming there are sufﬁciently many neurons.
Theorem 5.
Consider a deep rectiﬁer network with L layers, n l ≥ 3 rectiﬁed linear units at each layer l , and an input of dimension 1.
The maximal number of regions of this neural network is exactly (cid:81)
Ll =1 ( n l + 1) .
The expression above is a simpliﬁed form of the upper bound from Theorem 1 in the case n 0 = 1 .
The proof of this theorem in Appendix E has a construction with n + 1 regions that replicate themselves as we add layers, instead of n as in Mont ´ ufar et al.
That is motivated by an insight from the previous section: in order to obtain more regions, we want the dimension of every region to be as large as possible.
When n 0 = 1 , we want all regions to have dimension one.
This intuition leads to a new construction with one additional region that can be replicated with other strategies.
3. A LOWER BOUND ON THE MAXIMAL NUMBER OF LINEAR REGIONS
Both the lower bound from Mont´ufar et al.
(2014) and from Arora et al.
(2016) can be slightly improved, since their approaches are based on extending a 1-dimensional construction similar to the one in Section 3.2.
We do both since they are not directly comparable: the former bound is in terms of the number of neurons in each layer and the latter is in terms of the total size of the network.
Theorem 6.
The maximal number of linear regions induced by a rectiﬁer network with n 0 input units and L hidden layers with n l ≥ 3 n 0 for all l is lower bounded by
[Equation]
The proof of this theorem is in Appendix F. For comparison, the differences between the lower bound theorem (Theorem 5) from Mont´ufar et al.
and the above theorem is the replacement of the condition n l ≥ n 0 by the more restrictive n l ≥ 3 n 0 , and of (cid:98) n l /n
(cid:99) by (cid:98) n l /n
(cid:99)
+ 1 .
Theorem 7.
For any values of m ≥ 1 and w ≥ 2 , there exists a rectiﬁer network with n 0 input units and L hidden layers of size 2 m + w ( L − 1) that has 2 (cid:80) n 0 − 1 j =0 (cid:0) m − 1 j (cid:1) ( w + 1)
L − 1 linear regions.
The proof of this theorem is in Appendix G.
The differences between Theorem 2.11(i) from Arora et al.
and the above theorem is the replacement of w by w + 1 .
They construct a 2 m -width layer with many regions and use a one-dimensional construction for the remaining layers.
A N UPPER BOUND ON THE NUMBER OF LINEAR REGIONS FOR MAXOUT NETWORKS
We now consider a deep neural network composed of maxout units.
Given weights W lj for j = 1 , . . .
, k , the output of a rank- k maxout layer l is given by
[Equation]
In terms of bounding number of regions, a major difference between the next result for maxout units and the previous one for ReLUs is that reductions in dimensionality due to inactive neurons with zeroed output become a particular case now.
Nevertheless, using techniques similar to the ones from Section 3.1, the following theorem can be shown (see Appendix H for the proof).
Theorem 8.
Consider a deep neural network with L layers, n l rank- k maxout units at each layer l , and an input of dimension n 0 .
The maximal number of regions of this neural network is at most
[Equation]
where d l = min { n 0 , n 1 , . .
. , n l } .
Asymptotically, if n l = n for all l = 1 , . . .
, L , n ≥ n 0 , and n 0 =
O (1) , then the maximal number of regions is at most O (( k 2 n ) Ln 0 ) .
E XACT COUNTING OF LINEAR REGIONS
If the input space x ∈ R n 0 is bounded by minimum and maximum values along each dimension, or else if x corresponds to a polytope more generally, then we can deﬁne a mixed-integer linear formulation mapping polyhedral regions of x to the output space y ∈ R m .
The assumption that x is bounded and polyhedral is natural in most applications, where each value x i has known lower and upper bounds (e.g., the value can vary from 0 to 1 for image pixels).
Among other things, we can use this formulation to count the number of linear regions.
In the formulation that follows, we use continuous variables to represent the input x , which we can also denote as h 0 , the output of each neuron i in layer l as h li , and the output y as h L +1 .
To simplify the representation, we lift this formulation to a space that also contains the output of a complementary set of neurons, each of which is active when the corresponding neuron is not.
Namely, for each neuron i in layer l we also have a variable h li :
= max { 0 , − W li h l − 1 − b li } .
We use binary variables of the form z li to denote if each neuron i in layer l is active or else if the complement of such neuron is.
Finally, we assume M to be a sufﬁciently large constant.
For a given neuron i in layer l , the following set of constraints maps the input to the output:
[Equation]
Theorem 9.
Provided that | w li h l − 1 j + b li | ≤ M for any possible value of h l − 1 , a formulation with the set of constraints (1) for each neuron of a rectiﬁer network is such that a feasible solution with a ﬁxed value for x yields the output y of the neural network.
The proof for the statement above is given in Appendix I. More details on the procedure for exact counting are in Appendix J.
In addition, we show the theory for unrestricted inputs and a mixedinteger formulation for maxout networks in Appendices K and L, respectively.
These results have important consequences.
First, they allow us to tap into the literature of mixedinteger representability (Jeroslow, 1987) and disjunctive programming (Balas, 1979) to understand what can be modeled on rectiﬁer networks with a ﬁnite number of neurons and layers.
To the best of our knowledge, that has not been discussed before.
Second, they imply that we can use mixedinteger optimization solvers to analyze the ( x , y ) mapping of a trained neural network.
For example,
Cheng et al.
(2017) use another mixed-integer formulation to generate adversarial examples of a
DNN.
That is technically feasible due to the linear proportion between the size of the neural network and that of the mixed-integer formulation.
Compared to Cheng et al.
, we show in Appendix I that formulation (1) can be implemented with further reﬁnements on the value of the M constants.
E XPERIMENTS
We perform two different experiments for region counting using small-sized networks with ReLU activation units on the MNIST benchmark dataset (LeCun et al., 1998).
In the ﬁrst experiment, we generate rectiﬁer networks with 1 to 4 hidden layers having 10 neurons each, with ﬁnal test error between 6 and 8%.
The training was carried out for 20 epochs or training steps [Figure] and we count the number of linear regions during each training step.
For those networks, we count the number of linear regions within 0 ≤ x ≤ 1 in which a single neuron is active in the output layer, hence partitioning these regions in terms of the digits that they classify.
In Fig.
4, we show how the number of regions classifying each digit progresses during training.
Some digits have zero linear regions in the beginning, which explains why they begin later in the plot.
The total number of such regions per training step is presented in Fig.
5(a) and error measures are found in Appendix M. Overall, we observe that the number of linear regions jumps orders of magnitude are varies more widely for each added layer.
Furthermore, there is an initial jump in the number of linear regions classifying each digit that seems proportional to the number of layers.
[Figure]
[Figure]
u t
[Figure]
t n
[Figure]
u r o n
[Figure]
In the second experiment, we train rectiﬁer networks with two hidden layers summing up toneurons.
We train a network for each width conﬁguration under the same conditions as above, with the test error in half of them ranging from 5 to 6%.
In this case, we count all linear regions within 0 ≤ x ≤ 1 , hence not restricting by activation in output layer as before.
The number of linear regions of these networks are plotted in Fig. 5(b), along with the upper bound from Theorem 1 and the upper bounds from Mont´ufar et al.
(2014) and Mont´ufar (2017).
Error measures of both experiments can be found in Appendix M and runtimes for counting the linear regions in Appendix N.
D ISCUSSION
The representational power of a DNN can be studied by observing the number of linear regions of the PWL function that the DNN represents.
In this work, we improve on the upper and lower bounds on the linear regions for rectiﬁed networks derived in prior work (Mont´ufar et al., 2014; Raghu et al., 2017; Mont´ufar, 2017; Arora et al., 2016) and introduce a ﬁrst upper bound for multi-layer maxout networks.
We obtain several valuable insights from our extensions.
Our ReLU upper bound indicates that small widths in early layers cause a bottleneck effect on the number of regions.
If we reduce the width of an early layer, the dimensions of the linear regions become irrecoverably smaller throughout the network and the regions will not be able to be partitioned as much.
Moreover, the dimensions of the linear regions are not only driven by width, but also the number of activated ReLUs corresponding to the region.
This intuition allowed us to create a 1-dimensional construction with the maximal number of regions by eliminating a zero-dimensional bottleneck.
An unexpected and useful consequence of our result is that shallow networks can attain more linear regions when the input dimensions exceed the number of neurons of the DNN.
In addition to achieving tighter bounds, we use a mixed-integer linear formulation that maps the input space to the output to show the exact counting of the number of linear regions for several small-sized DNNs during the training process.
In the ﬁrst experiment, we observed that the number of linear regions correctly classifying each digit of the MNIST benchmark increases and vary in proportion to the depth of the network during the ﬁrst training epochs.
In the second experiment, we count the total number of linear regions as we vary the width of two layers with a ﬁxed number of neurons, and we experimentally validate the bottleneck effect by observing that the results follow a similar pattern to the upper bound that we show.
Our current results suggest new avenues for future research.
First, we believe that the study of linear regions may eventually lead to insights in how to design better DNNs in practice, for example by further validating the bottleneck effect found in this study.
Other properties of the bounds may turn into actionable insights if conﬁrmed as these bounds get sufﬁciently close to the actual number of regions.
For example, the plots in Appendix O show that there are particular network depths that maximize our ReLU upper bound for a given input dimension and number of neurons.
In a sense, the number of neurons is a proxy to the computational resources available.
We also believe that analyzing the shape of the linear regions is a promising idea for future work, which could provide further insight in how to design DNNs.
Another important line of research is to understand the exact relation between the number of linear regions and accuracy, which may also involve the potential for overﬁtting.
We conjecture that the network training is not likely to generalize well if there are so many regions that each point can be singled out in a different region, in particular if regions with similar labels are unlikely to be compositionally related.
Second, applying exact counting to larger networks would depend on more efﬁcient algorithms or on using approximations instead.
In any case, the exact counting at a smaller scale can assess the quality of the current bounds and possibly derive insights for tighter bounds in future work, hence leading to insights that could be scaled up.
Appendices
Most of the proofs for theorems and lemmas associated with the upper and lower bounds on the linear regions are provided below.
The theory for mixed-integer formulation for exact counting in the case of maxouts and unrestricted inputs are also provided below.
A A NALYSIS OF THE BOUND FROM T HEOREM
In this section, we present properties of the upper bound for the number of regions of a rectiﬁer network from Theorem 1.
Denote the bound by B ( n 0 , n 1 , . .
. , n L ) , where n 0 is the input dimension and n 1 , . .
. , n L are the widths of layers 1 through L of the network.
That is,
[Equation]
Instead of expressing J as in Theorem 1, we rearrange it to a more convenient form for the proofs in this section:
[Equation]
Note that whenever we assume n 0 ≥ max { n 1 , . . . , n l } , then the bound inequality for n 0 becomes redundant and can be removed.
Some of the results have implications in terms of the exact maximal number of regions.
We denote it by R ( n 0 , n 1 , . . . , n L ) , following the same notation above.
Moreover, the following lemma is useful throughout the section.
Lemma 10.
[Equation]
Proof.
The result comes from taking a generalization of Vandermonde’s identity and adding the summation of j from 0 to k as above.
We ﬁrst examine some properties related to 2-layer networks.
The proposition below characterizes the bound when L = 2 for large input dimensions.
Proposition 11.
Consider a 2-layer network with widths n 1 , n 2 and input dimension n 0 ≥ n 1 and n 0 ≥ n 2 .
Then
[Equation]
If n 0 < n 1 or n 0 < n 2 , the above holds with inequality:
[Equation]
Proof.
If n 0 ≥ n 1 and n 0 ≥ n 2 , the bound inequalities for n 0 in the index set J become redundant.
By applying Lemma 10, we obtain
[Equation]
If n 0 < n 1 or n 0 < n 2 , then its index set J is contained by the one above, and thus the ﬁrst equal sign above becomes a less-or-equal sign.
Recall that the expression on the right-hand side of Proposition 11 is equal to the maximal number of regions of a single-layer network with n 1 + n 2 ReLUs and input dimension n 1 , as discussed in
Section 2.
Hence, the proposition implies that for large input dimensions, a two-layer network has no more regions than a single-layer network with the same number of neurons, as formalized below.
Corollary 12.
Consider a 2-layer network with widths n 1 , n 2 ≥ 1 and input dimension n 0 ≥ nand n 0 ≥ n 2 .
Then R ( n 0 , n 1 , n 2 ) ≤ R ( n 0 , n 1 + n 2 ) .
Moreover, this inequality is strict when n 0 > n 1 .
Proof.
This is a direct consequence of Proposition 11:
[Equation]
Note that if n 0 > n 1 , then the second inequality can be turned into a strict inequality.
The next corollary illustrates the bottleneck effect for two layers.
It states that for large input dimensions, moving a neuron from the second layer to the ﬁrst strictly increases the bound.
Corollary 13.
Consider a 2-layer network with widths n 1 , n 2 and input dimension n 0 ≥ n 1 +and n 0 ≥ n 2 + 1 .
Then B ( n 0 , n 1 + 1 , n 2 ) > B ( n 0 , n 1 , n 2 + 1) .
Proof.
By Proposition 11,
[Equation]
The assumption that n 0 must be large is required for the above proposition; otherwise, the input itself may create a bottleneck with respect to the second layer as we decrease its size.
Note that the bottleneck affects all subsequent layers, not only the layer immediately after it.
However, it is not true that moving neurons to earlier layers always increases the bound.
For instance, with three layers, B (4 , 3 , 2 , 1) = 47 > 46 = B (4 , 4 , 1 , 1) .
In the remainder of this section, we consider deep networks of equal widths n .
The next proposition can be viewed as an extension of Proposition 11 for multiple layers.
It states that for a network with widths and input dimension n and at least 4 layers, if we halve the number of layers and redistribute the neurons so that the widths become 2 n , then the bound increases.
In other words, if we assume the bound to be close to the maximal number of regions, it suggests that making a deep network shallower allows for more regions when the input dimension is equal to the width.
Proposition 14.
Consider a 2 L -layer network with equal widths n and input dimension n 0 = n .
Then
[Equation]
This inequality is met with equality when L = 1 and strict inequality when L ≥ 2 .
Proof.
When n 0 = n , the inequalities j l ≤ min { n 0 , 2 n − j 1 , . . . , 2 n − j l − 1 , 2 n } appearing in J (in the form presented in Theorem 1) can be simpliﬁed to j l ≤ n .
Therefore, using Lemma 10, the bound on the right-hand side becomes
[Equation]
(cid:125)
L times )
=
n (cid:88)
j 1 = n (cid:88)
j 2 = . . .
n (cid:88)
j L =
L (cid:89) l = (cid:18) 2 n j l (cid:19) =   n (cid:88)
j = (cid:18) 2 n j (cid:19) 

L =   n (cid:88) j 1 = n − j 1 (cid:88)
j 2 = (cid:18) n j(cid:19)(cid:18) n j(cid:19) 

L ≥ (cid:88) ( j 1 ,...,j 2 L ) ∈
J 2 L (cid:89) l
= (cid:18) n j l (cid:19) =
B ( n, n, . . . , n (cid:124) (cid:123)(cid:122) (cid:125)
L times ) .
where J above is the index set from Theorem 1 applied to n 0 = n l = n for all l = 1 , . .
, 2 L .
Note that we can turn the inequality into equality when L = 1 (also becoming a consequence of
Proposition 11) and into strict inequality when L ≥ 2 .
Next, we provide an upper bound that is independent of n 0 .
Proposition 15.
Consider an L -layer network with equal widths n and any input dimension n 0 ≥ 0 .
[Equation]
Proof.
Since we are deriving an upper bound, we can assume n 0 ≥ n , as the bound is nondecreasing on n 0 .
We ﬁrst assume that L is even.
We relax some of the constraints of the index set J from
Theorem 1 and apply Vandermonde’s identity on each pair:
[Equation]
The bound on (cid:0) 2 nn (cid:1) is a direct application of Stirling’s approximation (Stirling, 1730).
If L is odd, then we can write
[Equation]
where the last inequality is analogous to the even case.
Hence, the result follows.
Corollary 16.
Consider an L -layer network with equal widths n and any input dimension n 0 ≥ 0 .
[Equation]
Proof.
By Proposition 15 and Theorem
[Equation]
the ratio between R ( n 0 , n, . . . , n ) and 2 Ln is at most (cid:113) 12 + 1 2 √ πn L √ 2 .
Since the base of the ﬁrst term is less than 1 for all n ≥ 1 and √ 2 is a constant, the ratio goes to 0 as L goes to inﬁnity.
In particular, Corollary 16 implies that if n 0 exceeds the total size of the network, that is, n 0 ≥ Ln , then lim L →∞ R ( n 0 ,n,...,n ) R ( n 0 ,Ln )
= 0 .
In other words, the ratio between the maximal number of regions of a deep network and a shallow network goes to zero as L goes to inﬁnity.
B E XPONENTIAL MAXIMAL NUMBER OF REGIONS WHEN INPUT DIMENSION IS LARGE
Proposition 17. Consider an L -layer rectiﬁer network with equal widths n and input dimension n 0 ≥ n/ 3 . Then the maximal number of regions is Ω(2 23 Ln ) .
Proof.
It sufﬁces to show that a lower bound such as the one from Theorem 6 grows exponentially large.
{+For simplicity, we consider the lower bound ( (cid:81) Ll =
+}
( (cid:98) n l /n 0 (cid:99) + 1)) n 0 , which is the bound obtained before the last tightening step in the proof of Theorem 6 (see Appendix F).
{+Note that replacing n 0 in the above expression by a value n (cid:48) 
+}
smaller than the input dimension still yields a valid lower bound.
This holds because increasing the input dimension of a network from n (cid:48)to n 0 cannot decrease its maximal number of regions.
{+Choose n (cid:48) 
+}
= (cid:98) n/ 3 (cid:99) , which satisﬁes n (cid:48) 0 ≤ n 0 and the condition n ≥ 3 n (cid:48) 0 of Theorem 6.
The lower bound can be expressed as ( (cid:98) n/ (cid:98) n/ 3 (cid:99)(cid:99)
+ 1) L (cid:98) n/ 3 (cid:99) ≥
4 L (cid:98) n/ 3 (cid:99) .
This implies that the maximal number of regions is Ω(2 23 Ln ) .
C P ROOF OF L EMMA
Lemma 2. Consider m hyperplanes in R d deﬁned by the rows of Wx + b = 0 .
Then the number of regions induced by the hyperplanes is at most (cid:80) rank( W ) j =
[Equation]
Proof.
Consider the row space R ( W ) of W , which is a subspace of R d of dimension rank( W ) .
We show that the number of regions N R d in R d is equal to the number of regions N R ( W ) in R ( W ) induced by Wx
+ b = 0 restricted to R ( W ) .
This sufﬁces to prove the lemma since R ( W ) has at most (cid:80) rank( W ) j = (cid:0) mj (cid:1) regions according to Zaslavsky’s theorem.
Since R ( W ) is a subspace of R d , it directly follows that N R ( W ) ≤ N R d .
To show the converse, we apply the orthogonal decomposition theorem from linear algebra: any point ¯ x ∈ R d can be expressed uniquely as ¯
x = ˆ x + y , where ˆ x ∈ R ( W ) and y ∈ R ( W ) ⊥ .
Here, R ( W ) ⊥ =
Ker ( W ) :
= { y ∈ R
d : Wy = 0 } , and thus W ¯ x =
W ˆ x + Wy = W ˆ x .
This means ¯ x and ˆ x lie on the same side of each hyperplane of Wx = b and thus belong to the same region.
In other words, given any ¯ x ∈ R d , its region is the same one that ˆ x ∈ R ( W ) lies in.
Therefore, N R d ≤ N R ( W ) .
Hence, N R d = N R ( W ) and the result follows.
D P ROOF OF T HEOREM
Theorem 1. Consider a deep rectiﬁer network with L layers, n l rectiﬁed linear units at each layer l , and an input of dimension n 0 .
The maximal number of regions of this neural network is at most
[Equation]
where J = { ( j 1 , . .
, j L ) ∈
Z L : 0 ≤ j l ≤ min { n 0 , n 1 − j 1 , . . . , n l − 1 − j l − 1 , n l } ∀ l = 1 , . . . , L } .
This bound is tight when L = 1 .
Proof.
As illustrated in Figure 1, the partitioning can be viewed as a sequential process: at each layer, we partition the regions obtained from the previous layer.
When viewed in the input space, each region S obtained at layer l − 1 is potentially partitioned by n l hyperplanes given by the rows of ¯ W l S + b = 0 for some bias b .
Some of these hyperplanes may fall outside the interior of S and do not partition the region.
With this process in mind, we recursively bound the number of subregions within a region.
More precisely, we construct a recurrence R ( l, d ) to be an upper bound to the maximal number of regions obtained from partitioning a region of dimension d with layers l, l + 1 , . . .
, L .
The base case of the recurrence is given by Lemma 3:
R ( L, d ) =
(cid:80)
[Equation]
n L ,
[Equation]
[Equation]
= (cid:0) n L j (cid:1) .
Based on Lemma 4, we can write the recurrence by grouping together regions with the same activation set size | S l | , as follows:
R ( l, d ) =
(cid:80) n l j =
N n l ,d,j R ( l + 1 , min { j, d } ) for all l = 1 , . . .
, L − 1 .
Here, N n l ,d,j represents the maximum number of regions with | S l | =
j obtained by partitioning a space of dimension d with n l hyperplanes.
We bound this value next.
For each j , there are at most (cid:0) n l j (cid:1) regions with | S l | =
j , as they can be viewed as subsets of n l neurons of size j .
In total, Lemma 3 states that there are at most (cid:80) min { n l ,d } j = (cid:0) n l j (cid:1) regions.
If we allow these regions to have the highest | S l | possible, for each j from 0 to min { n l , d } we have at most (cid:0) n l n l − j (cid:1) =
(cid:0) n l j (cid:1) regions with | S l | = n l − j .
Therefore, we can write the recurrence as
[Equation]
if l = L . The recurrence R (1 , n 0 ) can be unpacked to
[Equation]
j
[Table] = [Table]
(cid:18)
n
[Table]
j [Table] [Table] (cid:18)
n [Table] j
[Table]
(cid:19)
[Table]
min { [Table] [Table] (cid:88)
j L = [Table] (cid:18) n
[Table]
j L (cid:19) where d l = min { n 0 , n 1 − j 1 , . . . , n l − 1 − j l − 1 } .
This can be made more compact, resulting in the ﬁnal expression.
The bound is tight when L = 1 since it becomes (cid:80) min { n 0 ,n 1 } j = (cid:0) n 1 j (cid:1) , which is the maximal number of regions of a single-layer network.
E P ROOF OF T HEOREM
Theorem 5. Consider a deep rectiﬁer network with L layers, n l ≥ 3 rectiﬁed linear units at each layer l , and an input of dimension 1.
The maximal number of regions of this neural network is exactly (cid:81)
Ll =1 ( n l + 1) .
Proof.
Section 3 provides us with a helpful insight to construct an example with a large number of regions.
It tells us that we want regions to have large dimension in general.
In particular, regions of dimension zero cannot be further partitioned.
This suggests that the one-dimensional construction from Mont´ufar et al.
(2014) can be improved, as it contains n regions of dimension one and 1 region of dimension zero.
This is because all ReLUs point to the same direction as depicted in Fig.
6, leaving one region with an empty activation pattern.
Our construction essentially increases the dimension of this region from zero to one.
This is done by shifting the neurons forward and ﬂipping the direction of the third neuron, as illustrated in Fig.
We assume n ≥ 3 .
We review the intuition behind the construction strategy from Mont´ufar et al.
They construct a linear function ˜
h : R → R with a zigzag pattern from [0 , 1] to [0 , 1] that is composed of n
ReLUs.
More precisely, ˜ h ( x ) =
(1 , − 1 , 1 , . .
. , ± 1) (cid:62) ( h 1 ( x ) , h 2 ( x ) , . .
, h n ( x )) , where h i ( x ) for i = 1 , . . . , n are ReLUs.
This linear function can be absorbed in the preactivation function of the next layer.
The zigzag pattern allows it to replicate in each slope a scaled copy of the function in the domain [0 , 1] .
Fig.
7 shows an example of this effect.
Essentially, when we compose ˜ h with itself, each linear piece in [ t 1 , t 2 ] such that ˜ h ( t 1 )
=
and ˜ h
( t 2 )
= 1 maps the entire function ˜ h to the interval [ t 1 , t 2 ] , and each piece such that ˜ h ( t 1 )
= 1 and ˜ h
( t 2 )
= 2 does the same in a backward manner.
In our construction, we want to use n ReLUs to create n + 1 regions instead of n .
In other words, we want the construct this zigzag pattern with n + 1 slopes.
In order to do that, we take two steps to give ourselves more freedom.
First, observe that we only need each linear piece to go from zero to one or one to zero; that is, the construction works independently of the length of each piece.
Therefore, we turn the breakpoints into parameters t 1 , t 2 , . . . , t n , where 0 < t 1 < t 2 < . . .
< t n < 1 .
Second, we add sign and bias parameters to the function ˜ h .
That is, ˜ h
( x ) = ( s 1 , s 2 , . . .
, s n ) (cid:62) ( h 1 ( x ) , h 2 ( x ) , . . .
, h n ( x ))
+ d , where s i ∈ {− 1 , +1 } and d are parameters to be set.
Here, h i ( x ) = max { 0 , ˜
w i x + ˜ b i } since it is a ReLU.
We deﬁne w i =
s i ˜ w i and b i
=
s i ˜
b i , which are the weights and biases we seek in each interval to form the zigzag pattern.
The parameters s i are needed because the signs of ˜ w i cannot be arbitrary: it must match the directions the ReLUs point towards.
In particular, we need a positive slope ( ˜ w i > 0 ) if we want i to point right, and a negative slope ( ˜ w i < 0 ) if we want i to point left.
Hence, without loss of generality, we do not need to consider the s i ’s any further since they will be directly deﬁned from the signs of the w i ’s and the directions.
More precisely, s i =
if w i ≥ 0 and s i
= −otherwise for i
= 1 , 2 , 4 , . .
. , n , and s 3 =
− 1 if w 3 ≥ 0 and s 3 = 1 otherwise.
To summarize, our parameters are the weights w i and biases b i for each ReLU, a global bias d , and the breakpoints 0 < t 1 < . . .
< t n < 1 .
Our goal is to ﬁnd values for these parameters such that each piece in the function ˜ h with domain in [0 , 1] is linear from zero to one or one to zero.
More precisely, if the domain is [ s, t ] , we want each linear piece to be either 1 t − s x − s t − s or − 1 t − s x + t t − s , which deﬁne linear functions from zero to one and from one to zero respectively.
Since we want a zigzag pattern, the former should happen for the interval [ t i , t i − 1 ] when i is odd and the latter should happen when i is even.
There is one more set of parameters that we will ﬁx.
Each ReLU corresponds to a hyperplane, or a point in dimension one.
In fact, these points are the breakpoints t 1 , . . . , t n .
They have directions that deﬁne for which inputs the neuron is activated.
For instance, if a neuron h i points to the right, then the neuron h i ( x ) outputs zero if x ≤ t
i and the linear function
w i x
+ b i if x > t i .
As previously discussed, in our construction all neurons point right except for the third neuron h 3 , which points left.
This is to ensure that the region before t 1 has one activated neuron instead of zero, which would happen if all neurons pointed left.
However, although ensuring every region has dimension one is necessary to reach the bound, not every set of directions yields valid weights.
These directions are chosen so that they admit valid weights.
The directions of the neurons tells us which neurons are activated in each region.
From left to right, we start with h 3 activated, then we activate h 1 and h 2 as we move forward, we deactivate h 3 , and ﬁnally we activate h 4 , . .
, h n in sequence.
This yields the following system of equations, where t n +1 is deﬁned as 1 for simplicity:
[Equation]
if i is odd
[Equation]
if i is even
[Equation]
for all i = 5 , . . .
, n +
It is left to show that there exists a solution to this system of linear equations such that 0 < t 1 < . . .
< t n < 1 .
First, note that all of the biases b 1 , . . .
, b n , d can be written in terms of t 1 , . . . , t n .
Note that if we subtract ( R 4 ) from ( R 3 ) , we can express b 3 in terms of the t i variables.
The remaining equations become triangular, and therefore given any values for t
i ’s we can back-substitute the remaining bias variables.
The same subtraction yields w 3 in terms of t i ’s.
However, both ( R 1 ) and ( R 3 ) − ( R 4 ) deﬁne w 3 in terms of the t i variables, so they must be the same:
[Equation]
If we ﬁnd values for t i ’s satisfying this equation and 0 < t 1 < . . .
< t n < 1 , all other weights can be obtained by back-substitution since eliminating w 3 yields a triangular set of equations.
In particular, the following values are valid: t 1 = 1 2 n +1 and t i
=
i − 1 2 n +1 for all i
= 2 , . .
. , n .
The remaining weights and biases can be obtained as described above, which completes the desired construction.
As an example, a construction with four units is depicted in Fig.
Its breakpoints are t 1 = 19 , t 2 = 39 , t 3 = 59 , and t 4 = 79 .
Its ReLUs are h 1 ( x ) = max { 0 , − 272 x + 32 } , h 2 ( x ) = max { 0 , 9 x − 3 } ,
h 3 ( x ) = max { 0 , 9 x − 5 } , and h 4 ( x ) = max { 0 , 9 x } .
Finally, ˜ h ( x ) =
( − 1 , 1 , − 1 , 1) (cid:62) ( h 1 ( x ) , h 2 ( x ) , h 3 ( x ) , h 4 ( x ))
+ 5 .
F P ROOF OF T HEOREM
Theorem 6. The maximal number of linear regions induced by a rectiﬁer network with n 0 input units and L hidden layers with n l ≥ 3 n 0 for all l is lower bounded by
[Equation]
(cid:18)(cid:22) n
[Equation]
(cid:19)
[Equation]
(cid:88)
[Equation]
(cid:18)
n
[Equation]
j (cid:19) .
Proof.
We follow the proof of Theorem 5 from (Mont´ufar et al., 2014) except that we use a different 1-dimensional construction.
The main idea of the proof is to organize the network into n 0 independent networks with input dimension 1 each and apply the 1-dimensional construction to each individual network.
In particular, for each layer l we assign (cid:98) n l /n 0 (cid:99) ReLUs to each network, ignoring any remainder units.
In (Mont´ufar et al., 2014), each of these networks have at least (cid:81) Ll =1 (cid:98) n l /n
(cid:99) regions.
We instead use Theorem 5 to attain (cid:81) Ll
=1 ( (cid:98) n l /n 0 (cid:99) + 1) regions in each network.
Since the networks are independent from each other, the number of activation patterns of the compound network is the product of the number of activation patterns of each of the n 0 networks.
Hence, the same holds for the number of regions.
Therefore, the number of regions of this network is at least ( (cid:81)
Ll =
( (cid:98) n l /n 0 (cid:99) + 1))
n 0 .
In addition, we can replace the last layer by a function representing an arrangement of n L hyperplanes in general position that partitions (0 , 1) n 0 into (cid:80) n 0 j =0 (cid:0) n L j (cid:1) regions.
This yields the lower bound of (cid:81) L − 1 l =1 ( (cid:98) n l /n
(cid:99) + 1) n 0 (cid:80) n 0 j =0 (cid:0) n L j (cid:1) .
G P ROOF OF T HEOREM
Theorem 7. For any values of m ≥ 1 and w ≥ 2 , there exists a rectiﬁer network with n 0 input units and L hidden layers of size 2 m + w ( L − 1) that has 2 (cid:80) n 0 − 1 j =0 (cid:0) m − 1 j (cid:1) ( w + 1)
L − 1 linear regions.
Proof.
Theorem 6.1 and Lemma 6.2 in Arora et al.
(2016) imply that for any m ≥ 1 , we can construct a layer representing a function from R n to R with 2 m ReLUs that has 2 (cid:80) n 0 − 1 j =0 (cid:0)
m − 1 j (cid:1) regions. Consider the network where this layer is the ﬁrst one and the remaining layers are the onedimensional layers from Theorem 5, each of size w .
Then this network has size 2 m + w ( L − 1) and 2 (cid:80) n 0 − 1 j =0 (cid:0) m − 1 j (cid:1) ( w + 1) L − 1 regions.
H P ROOF OF T HEOREM
Theorem 8.
Consider a deep neural network with L layers, n l rank- k maxout units at each layer l , and an input of dimension n 0 .
The maximal number of regions of this neural network is at most
[Equation]
where d l = min { n 0 , n 1 , . .
. , n l } .
Asymptotically, if n l = n for all l = 1 , . . .
, L , n ≥ n 0 , and n 0 =
O (1) , then the maximal number of regions is at most O (( k 2 n ) Ln 0 ) .
Proof.
We denote by W lj the n l × n l − 1 matrix where the rows are given by the j -th weight vectors of each rank- k maxout unit at layer l , for j = 1 , . . .
, k .
Similarly, b lj is the vector composed of the j -th biases at layer l .
In the case of maxout, an activation pattern S
= ( S 1 , . . .
, S l ) is such that S l is a vector that maps from layer- l neurons to { 1 , . . .
, k } .
We say that the activation of a neuron is j if w j x + b j attains the maximum among all of its functions; that is, w j x + b j ≥ w j (cid:48) x
+ b j (cid:48) for all j (cid:48)
= 1 , . . .
j .
In the case of ties, we assume the function with lowest index is considered as its activation.
Similarly to the ReLU case, denote by φ S l : R n l × n l − 1 × k
→ R n l × n l − 1 the operator that selects the rows of W l 1 , . .
, W lk that correspond to the activations in S l .
More precisely, φ S l ( W l 1 , . . .
, W lk ) is a matrix W such that its i -th row is the i -th row of W lj , where j is the neuron i ’s activation in S l .
This essentially applies the maxout effect on the weight matrices given an activation pattern.
Mont´ufar et al.
(2014) provides an upper bound of (cid:80) n 0 j =0 (cid:0) k 2 nj (cid:1) for the number of regions for a single rank- k maxout layer with n neurons.
The reasoning is as follows.
For a single maxout unit, there is one region per linear function.
The boundaries between the regions are composed by pieces that are each contained in a hyperplane.
Each piece is part of the boundary of at least two regions and conversely each pair of regions corresponds to at most one piece.
Extending these pieces into hyperplanes cannot decrease the number of regions.
Therefore, if we now consider n maxout units in a single layer, we can have at most the number of regions of an arrangement of k 2 n hyperplanes.
In the results below we replace k 2 by (cid:0) k 2 (cid:1) , as only pairs of distinct functions need to be considered.
We need to deﬁne more precisely these (cid:0) k 2 (cid:1) n hyperplanes in order to apply a strategy similar to the one from the Section 3.1.
In a single layer setting, they are given by w j x + b j = w j (cid:48)
+ b j (cid:48) for each distinct pair j, j (cid:48) within a neuron.
In order to extend this to multiple layers, consider a (cid:0) k 2 (cid:1) n l × n l −matrix ˆ W l where its rows are given by w j − w j (cid:48) for every distinct pair j, j (cid:48) within a neuron i and for every neuron i = 1 , . . . , n l .
Given a region S , we can now write the weight matrix corresponding to the hyperplanes described above: ˆ W l S :
=
ˆ W l φ S l − 1 ( W l − 1, . .
, W l − 1 k ) · · · φ S 1 ( W 11 , . . .
, W 1 k ) .
In other words, the hyperplanes that extend the boundary pieces within region S are given by the rows of ˆ W l S x
+ b = 0 for some bias b .
A main difference between the maxout case and the ReLU case is that the maxout operator φ does not guarantee reductions in rank, unlike the ReLU operator σ .
We show the analogous of Lemmafor the maxout case.
However, we fully relax the rank.
Lemma 18.
The number of regions induced by the n l neurons at layer l within a certain region S is at most (cid:80) d
l j =0 (cid:0) k
( k − 1)n l [Equation] (cid:1) , where d l = min { n 0 , n 1 , . . . , n l } .
Proof.
For a ﬁxed region S , an upper bound is given by the number of regions of the hyperplane arrangement corresponding to ˆ W l S x
+ b = 0 for some bias b .
The rank of ˆ W l S is upper bounded by
[Equation]
Applying Lemma 2 yields the result.
Since we can consider the partitioning of regions independently from each other, Lemma 18 implies that the maximal number of regions of a rank- k maxout network is at most (cid:81)
Ll =1 (cid:80) d l j =0 (cid:0) k
[Equation]
k − 1) [Equation] where d l = min { n 0 , n 1 , . . . , n l } .
I P ROOF OF T HEOREM
Theorem 9. Provided that | w li h l − 1 j + b li | ≤ M for any possible value of h l − 1 , a formulation with the set of constraints (1) for each neuron of a rectiﬁer network is such that a feasible solution with a ﬁxed value for x yields the output y of the neural network.
Proof.
For ease of explanation, we expand the set of constraints (1) as follows:
[Equation]
li ) (4) h li ≥(5) h li ≥(6)
z li ∈ { 0 , 1 } (7)
It sufﬁces to prove that the constraints for each neuron map the input to the output in the same way that the neural network would.
If W li h l − 1 + b li > 0 , it follows that h li − h li > 0 according to (2).
Since both variables are non-negative due to (5) and (6) whereas one is non-positive due to (3), (4), and (7), then z li = 1 and h li = max (cid:8) 0 , W li h l − 1 + b li (cid:9) .
If W li h l − 1 + b li < 0 , then it similarly follows that h li − h li < 0 , z li = 0 , and thus h li = min (cid:8) 0 , W li h l − 1 j + b li (cid:9) .
If (cid:80) j W li h l − 1 j + b li = 0 , then either h li = 0 or h li =
due to constraints (5) to (7) whereas (2) implies that h li = 0 or h li = 0 , respectively.
In this case, the value of z li is arbitrary but irrelevant.
J E XACT COUNTING FOR RECTIFIER NETWORKS USING A MIXED - INTEGER FORMULATION
A systematic method to count these solutions is the one-tree approach (Danna et al., 2007), which resumes the search after an optimal solution has been found using the same branch-and-bound tree.
That method can also be applied to near-optimal solutions by revisiting nodes pruned when solving for an optimal solution.
Note that in constraints (1), the variables z li can be either 0 or 1 when they lie on the activation boundary, whereas we want to consider a neuron active only when its output is strictly positive.
This discrepancy may cause double-counting when activation boundaries overlap.
We can address that by deﬁning an objective function that maximizes the minimum output f of an active neuron, which is positive in non-degenerate cases.
The formulation is as follows:
[Equation]
[Equation]
Corollary 19.
The number of z assignments of (8) yielding a positive objective function value corresponds to the number of linear regions of the neural network.
Proof.
Implicit in the discussion above.
Corollary 20.
If the input X is a polytope, then ( x, y ) is mixed-integer representable.
Proof.
Immediate from the existence of a mixed-integer formulation mapping x to y , which is correct as long as the input is bounded and therefore a sufﬁciently large M exists.
In practice, the value of constant M should be chosen to be as small as possible, which also implies choosing different values on different places to make the formulation tighter and more stable numerically (Camm et al., 1990).
For the constraints set (1), it sufﬁces to choose M to be as large as either h li or ¯ h li can be given the bounds on the input.
Hence, we can respectively replace M with H li and ¯ H li in the constraints involving those variables.
If we are given lower and upper bounds for X , which we can use for H 0 and ¯ H 0 , then we can deﬁne subsequent bounds as follows:
[Equation]
For the constraint involving f in formulation (8), we should choose a slightly larger value than H li for correctness because some neurons may never be active within the input bounds.
K C OUNTING LINEAR REGIONS OF R E LU S WITH UNRESTRICTED INPUTS
More generally, we can represent linear regions as a disjunctive program (Balas, 1979), which consist of a union of polyhedra.
Disjunctive programs are used in the integer programming literature to generate cutting planes by lift-and-project (Balas et al., 1993).
In what follows, we assume that a neuron can be either active or inactive when the output lies on the activation hyperplane.
For each active neuron, we can use the following constraints to map input to output:
[Equation]
For each inactive neuron, we use the following constraint:
[Equation]
Theorem 21.
The set of linear regions of a rectiﬁer network is a union of polyhedra.
Proof.
First, the activation set S l for each level l deﬁnes the following mapping:
[Equation]
Consequently, we can project the variables sets h 1 , . .
, h L +1 out of each of those terms by FourierMotzkin elimination (Fourier, 1826), thereby yielding a polyhedron for each combination of active sets across the layers.
Note that the result above is similar in essence to Theorem 2 of Raghu et al.
Corollary 22.
If X is unrestricted, then the number of linear regions can be counted using (8) if M is large enough.
Proof.
To count regions, we only need one point x from each linear region.
Since the number of linear regions is ﬁnite, then it sufﬁces if M is large enough to correctly map a single point in each region.
Conversely, each infeasible linear region either corresponds to empty sets of (13) or else to a polyhedron P such that { ( h 1 , . .
, h L +1 ) ∈ P | h li > 0 ∀ l ∈ { 1 , . . .
, L + 1 } , i ∈ S l (cid:9) is empty, and neither case would yield a solution for the z -projection of (8).
L M IXED - INTEGER REPRESENTABILITY OF MAXOUT UNITS
In what follows, we assume that we are given a neuron i in level l with output h li .
For that neuron, we denote the vector of weights as w li 1 , . . .
, w lik .
Thus, the neuron output corresponds to
[Equation]
Hence, we can connect inputs to outputs for that given neuron as follows:
[Equation]
The formulation above generalizes that for ReLUs with some small modiﬁcations.
First, we are computing the output of each term with constraint (14).
The output of the neuron is lower bounded by that of each term with constraint (15).
Finally, we have a binary variable z lim per term of each neuron, which denotes which neuron is active.
Constraint (18) enforces that only one variable is at one per neuron, whereas constraint (16) equates the output of the neuron with the active term.
Each constant M should be chosen in a way that the other terms can vary freely, hence effectively disabling the constraint when the corresponding binary variable is at zero.
M A CCURACY AND ERROR MEASURES OF THE SAMPLE NETWORKS
Figure 8 shows the error during training for different conﬁgurations in the ﬁrst experiment. Figureshows the errors after training for different conﬁgurations in the second experiment.
In both, we observe some relation between accuracy and the order of magnitude of the linear regions, which suggest that linear regions represent a reasonable proxy to the representational power of DNNs.
[Figure]
i n i
[Figure] [Table]
[Figure]
[Table]
[Figure]
[Table] [Figure]
[Figure]
N R UNTIMES FOR COUNTING THE LINEAR REGIONS
Table 1 reports the runtimes to count different conﬁgurations of networks on each experiment.
[Table]
O U PPER BOUND BY VARYING THE TOTAL NUMBER OF NEURONS
Figure 10a shows that the upper bound from Theorem 1 can only be maximized if more layers are added as the number of neurons increase.
In contrast, Figure 10b shows that the smallest depth preserving such growth is better because there is a secondary, although still exponential, effect that starts shrinks the bound if the number of layers is too large for the total number of neurons
[Table]
[Figure]
b
[Figure]