Improved Bounds on Neural Complexity for Representing Piecewise Linear Functions
Abstract
A deep neural network using rectified linear units represents a continuous piecewise linear (CPWL) function and vice versa.
Recent results in the literature estimated that the number of neurons needed to exactly represent any CPWL function grows exponentially with the number of pieces or exponentially in terms of the factorial of the number of distinct linear components.
Moreover, such growth is amplified linearly with the input dimension.
These existing results seem to indicate that the cost of representing a CPWL function is expensive.
In this paper, we propose much tighter bounds and establish a polynomial time algorithm to find a network satisfying these bounds for any given CPWL function.
We prove that the number of hidden neurons required to exactly represent any CPWL function is at most a quadratic function of the number of pieces.
In contrast to all previous results, this upper bound is invariant to the input dimension.
Besides the number of pieces, we also study the number of distinct linear components in CPWL functions.
When such a number is also given, we prove that the quadratic complexity turns into bilinear, which implies a lower neural complexity because the number of distinct linear components is always not greater than the minimum number of pieces in a
CPWL function.
When the number of pieces is unknown, we prove that, in terms of the number of distinct linear components, the neural complexity of any CPWL function is at most polynomial growth for low-dimensional inputs and a factorial growth for the worst-case scenario, which are significantly better than existing results in the literature.
Introduction
The rectified linear unit (ReLU)
[Fukushima, 1980, Nair and Hinton, 2010] activation has been by far the most widely used nonlinearity and successful building block in deep neural networks (DNNs).
Numerous architectures based on ReLU DNNs have achieved remarkable performance or state-of-the-art accuracy in speech processing [Zeiler et al., 2013, Maas et al., 2013], computer vision [Krizhevsky et al., 2012, Simonyan and Zisserman, 2015,
He et al., 2016], medical image segmentation [Ronneberger et al., 2015], game playing [Mnih et al., 2015, Silver et al., 2016], and natural language processing [Vaswani et al., 2017], just to name a few.
Besides such unprecedented n =n = 2 n =invariant to n
Number of pieces q
N u m b e r
o f h
i dd e n n e u r on s h
Number of distinct linear components k
N u m b e r
o f h
i dd e n n e u r on s h
Theorem 1 and[Hertrich et al., 2021]
[He et al., 2020] empirical success, ReLU DNNs are also probably the most understandable nonlinear deep learning models due to their ability to be “un-rectified”
[Hwang and Heinecke, 2019].
The ability to demystify ReLU DNNs via “un-rectifying ReLUs” dates back to a seminal work by Pascanu et al.
in 2014.
Because each of ReLUs in a hidden layer divides the space of the preceding layer’s output into two half spaces whose ReLU response is affine in one half space and exactly zero in the other, the layer of ReLUs can be replaced by an input-dependent diagonal matrix whose diagonal elements are ones for firing ReLUs and zeros for non-firing ReLUs.
Based on this rationale, Pascanu et al.
[2014] proved that a neural network using ReLUs divides the input space into many linear regions such that the network itself is an affine function within every region.
Two excellent visualizations are shown in Figure 2 in [Hanin and Rolnick, 2019a] and [Hanin and Rolnick, 2019b].
At this point, it is quite evident that any ReLU network exactly represents a CPWL function.
Pascanu et al.
also proved that the maximum number of linear regions for any ReLU network with a single hidden layer is equivalent to the number of connected components induced by arrangements of hyperplanes in general position where each hyperplane corresponds to a ReLU in the hidden layer.
Such a number can be computed in a closed form by Zaslavsky’s Theorem [Zaslavsky, 1975].
Furthermore, they showed that the maximum number of linear regions can be bounded from below by exponential growth in terms of the number of hidden layers, leading to a conclusion that ReLU
DNNs can generate more linear regions than their shallow counterparts.
In the same year, Montúfar et al. improved such a lower bound and gave the first upper bound for the maximum number of linear regions.
These bounds and their assumptions were later improved by [Montúfar, 2017, Raghu et al., 2017, Arora et al., 2018, Serra et al., 2018, Hinz and van de Geer, 2019], just to name a few.
We refer readers to Hinz’s doctoral thesis for a thorough discussion on the upper bound of the number of linear regions.
Because a CPWL function with more pieces can better approximate any given continuous function and a ReLU DNN exactly represents a CPWL function [Arora et al., 2018], a ReLU DNN with more linear regions in general exhibits stronger expressivity.
In summary, this “un-rectifying” perspective provides us a new angle to understand ReLU DNNs, and the results in some ways align with the advance in approximation theory demonstrating the expressivity.
Despite these advancements in linear regions, the complexity of a ReLU DNN that exactly represents a given CPWL function remains largely unexplored.
One can find that this question is the opposite direction of the above-mentioned line of research.
Although Arora et al.
[2018] proved that any
CPWL function can be exactly represented by a ReLU DNN with a bounded depth, any estimates regarding the width or number of neurons of such a network were not given.
The resources required for a ReLU neural network to exactly represent a CPWL function remained unknown until He et al.
[2020] first gave an estimate to the complexity of a ReLU network that realizes any given CPWL function.
They proved that the number of neurons is bounded from above by exponential growth in terms of the product between the number of pieces and the number of distinct linear components of a given CPWL function.
Such an exponential bound also grows linearly with the input dimension.
Because the number of pieces is an upper bound of the number of distinct linear components for any
CPWL function [Tarela and Martinez, 1999, He et al., 2020], the bound grows exponentially with the quadratic number of pieces, which seems to imply that the cost for representing a CPWL function by a ReLU DNN is exceedingly high.
The most recent upper bound can be inferred from a recent work by Hertrich et al.
[2021] although the number of hidden neurons was not directly given.
Hertrich et al.
[2021] proved the first width bound in terms of the number of pieces under the same depth used by Arora et al.
[2018] and He et al.
In particular, they proved that the width of a ReLU network that represents any given CPWL function can be polynomially bounded from above in terms of the number of pieces.
However, the order of such a polynomial is a quadratic function of the input dimension, which can be immensely large for a small number of pieces if the input dimension is large.
This bound grows larger with the input dimension even though the underlying CPWL function is just a one-hidden-layer ReLU network using only one ReLU.
In this paper, we provide improved bounds showing that any CPWL function can be represented by a ReLU DNN whose neural complexity is bounded from above by functions with much slower growth (see Figure 1).
Our results imply that one can exactly realize any given CPWL function by a ReLU network at a much lower cost.
Moreover, in addition to guarantee the existence, we also give a polynomial time algorithm to exactly find a network satisfying our bounds.
To the best of our knowledge, our results regarding the computational resource for a ReLU network, i.e., the number of hidden neurons, are the lowest upper bounds in the existing literature and the algorithm is the first tailored procedure to find a network representation from any given CPWL function.
Key results and main contributions of this paper are highlighted below.
1.1 Key results and contributions
Quadratic bounds.
We prove that any CPWL function with q pieces can be represented by a ReLU network whose number of hidden neurons is bounded from above by a quadratic function of q .
We also give the corresponding upper bounds for the maximum width, i.e., the maximum number of neurons per hidden layer, and the number of layers for such a network.
The maximum width is bounded from above by O ( q 2 ) and the number of layers is bounded from above by a logarithmic function of q , i.e., O (log 2 q ) .
These bounds are invariant to the input dimension.
For any affine function, the upper bounds for the maximum width and the number of hidden neurons are zero.
Further improvements on neural complexity.
When the number of distinct linear components k of any CPWL function is given along with the number of pieces q , the quadratic bounds O ( q 2 ) for the number of hidden neurons and the maximum width turn into bilinear bounds of k and q , i.e.,
O ( kq ) .
Such a change reduces the neural complexity because k ≤ q and q is usually much larger than k .
Still, these bounds are independent of the input dimension.
Finding a network satisfying bilinear bounds.
We establish a polynomial time algorithm that finds a ReLU network representing any given CPWL function.
The network found by the algorithm satisfies the bilinear bounds on the number of hidden neurons and the maximum width, and the logarithmic bound on the number of layers.
Note that such an algorithm also guarantees that one can always reverse-engineer at least one ReLU network from the function it computes.
Compared to the general-purpose reverse-engineering algorithm proposed by Rolnick and Kording [2020], our algorithm specializes in the situation when pieces of a CPWL function are given.
Improved bounds from a perspective of linear components.
When the number of pieces of a
CPWL function is unknown and only the number of linear components k is available, we prove that the number of hidden neurons and maximum width are bounded from above by factorial growth.
More precisely, O ( k · k !) .
The number of layers is bounded from above by linearithmic growth, or O ( k log 2 k ) .
However, if the input dimension n grows sufficiently slower than k , e.g., O (cid:16) √ k (cid:17) , then bounds for the number of hidden neurons and maximum width reduce to polynomial growth functions of order 2 n + 1 ; and the linearithmic growth reduces to O ( n log 2 k ) for the depth.
A new approach to choosing depth.
Instead of scaling the depth of a ReLU network with the input dimension [Arora et al., 2018, He et al., 2020, Hertrich et al., 2021], we reveal that constructing a ReLU network whose depth is scaled with the number of pieces of the given CPWL function is more advantageous.
Such a scaling turns out to be the key to derive better upper bounds.
This insight is provided by the max-min representation of CPWL functions [Tarela et al., 1990].
The importance of this scaling on the depth in ReLU networks has not been well recognized by existing bounds in the literature.
We discuss implications of different representations in Section 4.
Preliminaries
Notation and definitions used in this paper are set up and clarified in this section.
The set { 1 , 2 , · · · , m } is denoted by [ m ] .
I [ condition ] is an indicator function that gives 1 if the condition is true, and 0 otherwise.
The CPWL function is defined by Definition 1 below.
Definition 1.
A function p : R n → R is said to be CPWL if there exists a finite number of closed subsets of R n , say {X i } i ∈ [ m ] , such that (a) R n = (cid:83) i ∈ [ m ] X i ; (b) p is affine on X i , ∀ i ∈ [ m ] .
A family of closed convex subsets of R n satisfying Definition 1 are also referred to as convex regions, affine pieces or simply pieces for a CPWL function in this paper.
Definition 1 follows the definition of CPWL functions by Ovchinnikov [2002].
Notice that there are different definitions in the literature.
For example, Chua and Deng [1988] and Arora et al.
[2018] defined a CPWL function on a finite number of polyhedral regions.
However, their definitions are essentially the same as Definitionbecause any family of closed subsets satisfying Definition 1 can be decomposed into polyhedral regions.
It is possible that some of the closed subsets satisfying Definition 1 are non-convex even though the number of them reaches the minimum (see Figure 2 in [Wang and Sun, 2005]).
The continuity is implied by Definition 1 due to the subsets being closed.
Because the goal of this paper is to bound the complexity of a ReLU DNN that exactly represents any given CPWL function, it is necessary to be able to measure the complexity of a CPWL function.
The complexity of a CPWL function can be described using two quite different perspectives.
One is the number of pieces q , which is the number of closed convex subsets satisfying Definition 1.
Because this number has a minimum and any finite number above the minimum can be a valid m in Definition 1, the bounds become obviously loose when the number of pieces is not the minimum.
Without loss of generality, we are interested in the number q when it is the minimum.
The other is the number of distinct linear components k .
A linear component of a CPWL function is defined in Definition 2.
Definition 2.
An affine function f is said to be a linear component of a CPWL function p if there exists a nonempty subset M ⊆
[ m ] such that f ( x ) = p ( x ) , ∀ x ∈ (cid:83) i
∈M X i where {X i } i ∈ [ m ] is a family of minimum number of closed subsets satisfying Definition 1.
A greater q or k gives a CPWL function more degrees of freedom because a CPWL function allowed to use q + 1 pieces or k + 1 arbitrary linear components can represent any CPWL function with q pieces or k distinct linear components and still have a flexibility to modify existing affine maps or increase the number of distinct affine maps of the CPWL function.
Although increasing them both leads to a CPWL function with a higher flexibility, the speed of upgrading degrees of freedom is different from each other.
Note that a CPWL function with q pieces can never have more than q distinct linear components and a CPWL function with k distinct linear components can easily have more than k minimum number of pieces.
Such a difference in a 1 -dimensional case can be clearly observed from Figure 1 in [Tarela and Martinez, 1999].
Note that it is possible for two disjoint subsets from a minimum number of closed subsets satisfying Definition 1 to share the same linear component.
In other words, a linear component can be reused by multiple pieces.
Hence, increasing k gives much faster growth than increasing q for the complexity and expressivity of CPWL functions.
We define the ReLU activation function in Definition 3.
The ReLU network defined in Definitionis a simple architecture which is usually referred to as a ReLU multi-layer perceptron . Definitiondefines the corresponding number of hidden neurons, depth, and the maximum width.
Definition 3.
The rectified linear unit (ReLU) activation function σ is defined as σ ( x ) = max(0 , x ) .
The ReLU layer or vector-valued rectified linear activation function σ k is defined as
[Equation]
where x = (cid:2) xx· · · x k (cid:3) T .
Definition 4.
Let l be any positive integer.
A function g : R k
→ R k l is said to be an l -layer
ReLU network if there exist weights
W i ∈
R k
i × k
i − 1 and b i ∈
R k i for i ∈
[ l ] such that the input-output relationship of the network satisfies g ( x ) =
h l ( x ) where h 1 ( x ) =
W 1 x + b 1 and h i ( x ) =
W i σ k
i − 1 (cid:0) h
i − 1 ( x ) (cid:1)
+ b i for every i ∈ [ l ] \ [1] .
Definition 5.
The sum (cid:80) L − 1 l =1 k l and the maximum max l ∈ [ L − 1] k l for L > 1 are referred to as the number of hidden neurons and the maximum width of an L -layer ReLU network, respectively.
Any 1 -layer ReLU network is said to have 0 hidden neurons and a maximum width of 0 .
An l -layer ReLU network is said to have depth l and l − 1 hidden layers.
Upper bounds on neural complexity for representing CPWL functions
The correspondence between CPWL functions and ReLU networks was first clearly confirmed by
Theorem 2.1 in [Arora et al., 2018] although a weaker version of the correspondence can be inferred from Proposition 4.1 in [Goodfellow et al., 2013].
Arora et al.
[2018] proved that every ReLU network R n → R exactly represents a CPWL function, and the converse is also true, i.e., every
CPWL function can be exactly represented by a ReLU network.
One of the key steps used by Arora et al.
[2018] to construct a ReLU network from any given CPWL function relies on an important representation result by Wang and Sun [2005], stating that any CPWL function can be represented by a sum of a finite number of max- η -affine functions [Magnani and Boyd, 2009] whose signs may be flipped and η is bounded from above by n + 1 .
The implication of using this representation is later discussed in Section 4.1.
The bound η ≤ n + 1 in the representation allowed Arora et al.
[2018] to further prove that there exists a ReLU DNN with at most
[Equation]
hidden layers to exactly realize any given CPWL function.
However, the computational resource required for a ReLU network to exactly represent any CPWL function had not been available in the literature until the work by He et al.
3.1 Upper bounds in prior work
He et al.
[2020] proved that a CPWL function R n → R with q pieces and k linear components can be represented by a ReLU network whose number of neurons is given by
[Equation]
for k ≥ n + 1 and O (cid:0)
n 2 kq (cid:1) for k < n + 1 .
The number of hidden layers in such a ReLU DNN is also bounded from above by (cid:6) log 2 ( n + 1) (cid:7) , the same as the bound derived by Arora et al.
One of their significant contributions in our view is that they utilize the number of pieces and linear components of a CPWL function to bound the complexity of the equivalent ReLU network.
In general, the number of pieces q is much larger than the number of linear components k for a CPWL function.
He et al.
[2020] also proved the relationship
[Equation]
for any CPWL function.
Note that the bounds in (4) on the number of pieces q and linear components k were first mentioned by Tarela and Martinez [1999] who developed the lattice representation of
CPWL function.
Asymptotically, the bounds proved by He et al.
[2020] are amplified linearly with the input dimension n for any fixed k .
Due to (4), they can be further bounded from above by
O (cid:16) n 2 q 2 +( n +1)( q − n − 1) (cid:17) and O (cid:16) n 2 q 2 (cid:17) in terms of q and n .
On the other hand, in terms of k and n , they can be further bounded from above by O (cid:16) n 2 k · k !+
( n +1)
( k − n − 1) (cid:17) and O (cid:0) n 2 k · k ! (cid:1) .
Because these bounds grow much faster than exponential growth, they seem to suggest that the cost of computing a
CPWL function via a ReLU network is exceptionally high.
Hertrich et al.
[2021] proved that any CPWL function R n → R with q pieces can be represented by a
ReLU network whose maximum width is O (cid:16) q 2 n 2 +3 n +1 (cid:17) under the same number of hidden layers (cid:6) log 2 ( n + 1) (cid:7) .
Hence, the number of hidden neurons must be bounded from above by
[Equation]
Note that we infer this bound by taking the product of the depth and the maximum width.
The bound given by (5) can grow slower than O (cid:16) n 2 q 2 (cid:17) , but it grows faster than O (cid:16) n 2 q 2 (cid:17) if the input dimension n grows sufficiently faster than the number of pieces q .
Bounds expressed in terms of the number of distinct linear components were not given in [Hertrich et al., 2021].
3.2 Improved upper bounds
We show that any CPWL function can be represented by a ReLU network whose number of hidden neurons is bounded by much slower growth functions.
We state our main results in Theorem 1, 2 and 3, and focus on their impact in this subsection.
Each one of them is tailored to a specific complexity measure of the CPWL function.
Their proof sketches are deferred to Section 4.2.
We first focus on the case when the number of linear components is unknown and the complexity of the CPWL is only measured by the number of pieces, a scenario used in [Hertrich et al., 2021].
Theorem 1.
Any CPWL function p : R n → R with q pieces can be represented by a ReLU network whose number of layers l , maximum width w , and number of hidden neurons h satisfy
[Equation]
and
[Equation] [Equation]
Furthermore, Algorithm 1 finds such a network in poly ( n, q ) time.
Algorithm 1 Find a ReLU network that computes a given continuous piecewise linear function
Input: A CPWL function p with pieces {X i } i ∈ [ q ] of R n satisfying Definition 1.
Output: A ReLU network g computing g ( x ) = p ( x ) , ∀ x ∈ R n .
1: f 1 , f 2 , · · · , f k ← run Algorithm 6 to find all distinct linear components of p 2: for i = 1 , 2 , · · · , q do 3:
A i ← ∅ 4: for j = 1 , 2 · · · , k do 5: if f j ( x ) ≥ p ( x ) , ∀ x ∈ X
i then 6:
A i ←
A i (cid:83) { j } 7: end if 8: end for 9: v i ← run Algorithm 2 with { f m } m ∈A i using the minimum type 10: end for 11: v ← run Algorithm 3 with v 1 , v 2 , · · · , v q ▷ Combine q ReLU networks in parallel 12: u ← run Algorithm 2 with (cid:110)(cid:2) ss· · · s q (cid:3) T
(cid:55)→ s m (cid:111) m
∈ [ q ] using the maximum type
: g ← run Algorithm 4 with v and u
▷ Find a ReLU network for the composition u ◦ v
The proof of Theorem 1 is deferred to Appendix B.4 in the supplementary material.
Algorithm 6, 2, 3, and 4 used by Algorithm 1 are deferred to Appendix C in the supplementary material and will be discussed later (before presenting Theorem 2).
Because 2 ⌈ log 2 q ⌉ < 2 q , the upper bound in (8) can be further bounded from above by 6 q 2 + 2 ⌈ log 2 q ⌉ q + 3 q − 2 ⌈ log 2 q ⌉ − 3 , leading to the asymptotic bounds l = O (log 2 q ) , w = O ( q 2 ) , and h = O ( q 2 ) .
Since the bound given by Theorem 5.2 in He et al.
[2020] can be lower bounded by O (cid:16) n 2 q 2 (cid:17) , it grows exponentially faster than our bound of h given in Theorem 1.
On the other hand, the upper bound given by (5) is at least polynomially larger than our bound of h and the order of this polynomial grows quadratically with the input dimension n .
Note that such a polynomial becomes an exponential when the growth in n is not slower than q .
Such differences are illustrated by the figure on the left-hand side of Figure 1.
The bounds in Theoremare independent of the input dimension n .
Hence, one can realize any given CPWL function using a relatively small ReLU network even though n is huge.
In terms of the maximum width, the upper bound given by (7) is at least polynomially smaller than the one given by Hertrich et al.
In contrast to the bound for the number of layers in [Arora et al., 2018, He et al., 2020, Hertrich et al., 2021] that grows logarithmically with the input dimension n , our bound in Theorem 1 grows logarithmically with the number of pieces q .
Therefore, the ReLU network found by Algorithm 1 in general becomes deeper when the CPWL becomes more complex for a fixed input dimension.
On the other hand, the network remains the same depth even for arbitrarily larger n as long as q is fixed.
Taking an affine function for example, a 1 -layer ReLU network with 0 hidden neurons is the solution given by Theorem 1.
However, the bound given by [Arora et al., 2018, He et al., 2020, Hertrich et al., 2021] keeps increasing the depth for a larger n .
Algorithm 1 is a polynomial time algorithm, following from the proof of Theorem 2.
Table 1 in
Appendix C in the supplementary material gives a complexity analysis for Algorithm 1.
Algorithmfinds a ReLU network that computes a max-affine or min-affine function [Magnani and Boyd, 2009].
Algorithm 3 concatenates two given ReLU networks in parallel and returns another ReLU network computing the concatenation of two outputs.
Algorithm 4 finds a ReLU network that represents a composition of two given ReLU networks.
These algorithms are basic manipulations of ReLU networks required in Algorithm 1.
Notice that Algorithm 1 does not need to be given any linear components or completely know the
CPWL function because every distinct linear component can be found by Algorithm 6, which only needs to be given a closed ϵ -ball in the interior of every piece of a CPWL function p and observe the output of p when feeding an input.
Algorithm 6 solves a system of linear equations for every piece of p to find the corresponding linear component.
Every system of linear equations here has a unique solution because the interior of each of pieces is nonempty.
The nonemptyness is guaranteed by Lemma 12(a) in Appendix A in the supplementary material.
The 5th step of Algorithm 1 can be executed by checking the optimization result of the following linear programming problem
[Equation]
The condition in the 5th step can only be true when the optimal value is nonnegative.
Because every piece of p is given to Algorithm 1 , the piece X
i is available for the linear program as a system of linear inequalities.
The objective function is also available since p is affine on X i and all distinct linear components are available from Algorithm 6.
The corresponding linear component of p on X i can be found by first feeding at most n + 1 affinely independent points from the closed ϵ -ball to p and every candidate linear component, and then matching their output values.
Theorem 2 discusses the case when the number of linear components and pieces are both known.
Theorem 2.
Any CPWL function p : R n → R with k linear components and q pieces can be represented by a ReLU network whose number of layers l , maximum width w , and number of hidden neurons h satisfy
[Equation]
[Equation]
and
[Equation]
Furthermore, Algorithm 1 finds such a network in poly ( n, k, q ) time.
1 2 3 4 5 6 7 8 9 10 10101010k
U pp e r bound o f h 1 2 3 4 5 6 7 8 9 10 10101010k U pp e r bound o f h 1 2 3 4 5 6 7 8 9 10 10101010k
U pp e r bound o f h n = 1 n =n = 5 n =
The proof of Theorem 2 is deferred to Appendix B.3 in the supplementary material.
The bounds in
Theorem 2 are in general tighter and always no worse than those in Theorem 1 because q is never less than k but can be much larger than k .
Asymptotically, l = O (log 2 q ) ,
w = O ( kq ) , and h =
O ( kq ) .
The bound given by Theorem 5.2 in He et al.
[2020] increases exponentially faster than the bound of h in Theorem 2.
When the number of linear components is the only complexity measure of the CPWL function, we resort to Theorem 3 below.
Theorem 3.
Any CPWL function p : R n → R with k linear components can be represented by a
ReLU network whose number of layers l , maximum width w , and number of hidden neurons h satisfy
[Equation] [Equation]
(14) and
[Equation]
where
[Equation]
The proof of Theorem 3 is deferred to Appendix B.5 in the supplementary material.
Because ϕ ( n, k ) ≤ k ! , the worst-case asymptotic bounds for l , w and h are l =
O
( k log 2 k ) , w = O ( k · k !) , and
h =
O ( k · k !) , respectively.
However, it holds that (cid:80) ni =0 (cid:0) k 2 − k
i (cid:1) ≤ k 2 n , so the asymptotic bounds are l = O ( n log 2 k ) , w = O (cid:0) k 2 n +1 (cid:1) , and
h =
O (cid:0) k 2 n +1 (cid:1) when n grows sufficiently slower than k .
For example, n = O (cid:16) √ k (cid:17) .
In this case, w and h are bounded from above by a polynomial of order 2 √ k + 1 , which grows slower than factorial growth.
Such an advantage for small n is illustrated by the figure on the left-hand side of Figure 2.
Since the bound given by Theorem 5.2 in [He et al., 2020] can be bounded from below by O (cid:0) n 2 k · k ! (cid:1) , it at the minimum grows exponentially larger than the upper bound of h in Theorem 3.
For sufficiently small n , the relative order of growth is even larger.
The figure on the right-hand side of Figureillustrates such a large difference.
For k = 5 , n 2 k · k ! ≈ 7 . 92 × 10 28 if n = 1 , while our bound of h is less than 3 .
7 × 10 3 for any n .
The difference is extremely large even though k is small under n = 1 .
The middle plot in Figure 2 shows that (5) increases much faster when n becomes larger.
The upper bound of h in Theorem 3 is better than (5) for any n , which can be clearly seen from Figure 2.
Lemma 1.
Let P n,k be the set of all CPWL functions with exactly k distinct linear components such that p : R n → R , ∀ p ∈ P n,k .
Let C n,k ( p ) be the collection of all families of closed convex subsets satisfying Definition 1 for any p ∈ P n,k .
Then,
[Equation]
The proof of Lemma 1 is deferred to Appendix B.1 in the supplementary material.
Clearly, ϕ ( n, k ) is a better upper bound of q compared to the bound q ≤ k !
given by He et al.
When n grows sufficiently slower than k , the bound ϕ ( n, k ) can be exponentially smaller than k ! .
3.3 Limitations
Although the upper bounds in our main results are much better, it is still possible to find a ReLU network whose hidden neurons are fewer than the bounds in Theorem 2 to exactly represent a given
CPWL function.
Tight bounds for the case when n = 1 was first given by Theorem 2.2 in [Arora et al., 2018].
However, it seems more difficult to bound the size of a network from below for a high dimensional input.
To the best of our knowledge, we are not aware of any tight bounds in the literature for the exact ReLU network representation of general CPWL functions using an arbitrary n .
Representations of CPWL functions have different implications on depth
We reveal implications of using different representations of CPWL functions and their impact on constructing ReLU networks.
We first discuss the popular representation used by prior work and the implicit constraint imposed by such a representation.
4.1 Constrained depth
Arora et al.
He et al.
[2020], and Hertrich et al.
[2021] proved the same bound for the number of layers, relying on the following representation of a CPWL function
[Equation] [Equation]
where σ j ∈ { +1 , − 1 } and η ( j ) is a subset of [ J ] such that (cid:12)(cid:12)
η
( j ) (cid:12)(cid:12) ≤ n + 1 for all j ∈
[ J ] .
That is, a sum of a finite number of max- η -affine functions whose signs may be flipped.
(18) was established by Theorem 1 in Wang and Sun [2005] which is essentially the same as Theorem 1 in Wang [2004] that emphasizes on the difference of two convex piecewise linear functions.
This result was also used by Goodfellow et al.
[2013] for the maxout network (Proposition 4.1).
The depth given by (2) does not scale with the complexity of a CPWL function.
This feature directly comes from using a ReLU network to realize each of max- η -affine functions in (18) and concatenating all of them together.
Because the size of η ( j ) is bounded from above by n + 1 , the depth can be made to depend solely on n .
Such a treatment seems to be the only way if one considers a CPWL function represented by (18).
As a result, the ReLU network is forced to use a depth constrained by the input dimension to represent the given CPWL function, which in turn requires more hidden neurons.
Because we do not use (18), our networks are not limited by such an implication.
4.2 Proof sketch for unconstrained depth
We give a proof sketch in this subsection for our main results.
By using a different representation, the depth of a ReLU network is able to be scaled with the complexity measure, i.e., number of pieces, of any given CPWL function to accommodate the high expressivity.
By Theorem 4.2 in [Tarela and Martinez, 1999], any CPWL function p can be represented as
[Equation]
19) for all x ∈ R n where
[Equation] [Equation]
is the set of indices of linear components that have values greater than or equal to p ( x ) for all x ∈ X , and Q is any family of closed convex subsets of R n satisfying Definition 1.
We have used f 1 , f 2 , · · · , f k to denote the k distinct linear components of p .
Notice that Theorem 4.2 in [Tarela and Martinez, 1999] was first stated by Theorem 7 in [Tarela et al., 1990].
Both are essentially the same, but Theorem 4.2 in [Tarela and Martinez, 1999] emphasizes the convexity of each of regions in the domain.
Both theorems are also fundamentally equivalent to Theorem 2.1 in [Ovchinnikov, 2002].
Notice that one of the concluding remarks in [Ovchinnikov, 2002] pointed out that the convexity of the input space is an essential assumption.
The entire space R n satisfies such an assumption.
In addition, Ovchinnikov pointed out that the max-min representation also holds for vector-valued
CPWL functions.
Hence, it is possible to generalize our bounds to vector-valued CPWL functions.
Using the representation in (19) and Lemma 2 below, we are able to prove Theorem 2 by bounding the size of Q and A ( X ) .
Theorem 1 and 3 can be proved by applying Lemma 1 to Theorem 2.
Note that the size |Q| in (19) is the key for the depth of a ReLU network to be able to scale with q .
Lemma 2.
Let m be any positive integer.
Define
[Equation]
and the following sequence for any positive integer k ,
[Equation]
Then, there exists an l ( m )
-layer
ReLU network g : R n → R with r ( m ) hidden neurons and a maximum width of w ( m ) such that g computes the extremum of f 1 ( x ) , f 2 ( x ) , · · · , f m ( x ) , i.e., g ( x ) = max i ∈
[ m ] f i ( x ) or g ( x ) = min i ∈ [ m ] f i ( x ) for all x ∈ R n under any m scalar-valued affine functions f 1 , f 2 , · · · , f m .
Furthermore, Algorithm 2 finds such a network in poly ( m, n ) time.
The proof of Lemma 2 is deferred to Appendix B.2 in the supplementary material.
One can also view l ( m ) , w ( m ) , and r ( m ) as upper bounds for the number of layers, maximum width, and the number of hidden neurons.
Because r ( m ) < 6 m − 3 by Lemma 6, the bound for the number of hidden neurons r ( m ) is tighter than the bound 8 m − 4 given by Lemma D.3 in [Arora et al., 2018] or Lemma 5.4 in [He et al., 2020] (these two lemmas are essentially the same).
The bound for the number of layers remains the same as the one given by Lemma D.3 in [Arora et al., 2018].
By combining
Lemma 2 with Lemma 3, Lemma 4, and Lemma 8, we can easily perform the same job on computing the extremum of multiple scalar-valued ReLU networks as Lemma D.3 does in [Arora et al., 2018].
Lemma 6, 3, 4, and 8 are given in Appendix A in the supplementary material.
Broader impact
Our results guarantee that any CPWL function can be exactly computed by a ReLU neural network at a more manageable cost.
This assurance is crucial because CPWL functions are important tools in many applications.
Such an assurance also relates DNNs closer to CPWL functions and allows researchers and engineers to understand the expressivity of DNNs from a different perspective.
We focus on simple ReLU networks (ReLU multi-layer perceptrons) in this paper, but it may be possible to derive bounds for other activation functions and advanced neural network architectures such as maxout networks
[Goodfellow et al., 2013], residual networks [He et al., 2016], densely connected networks [Huang et al., 2017], and other nonlinear networks [Chen et al., 2021], by making some (possibly mild) assumptions.
Our contributions advance the fundamental understanding of the link between ReLU networks and CPWL functions.
Acknowledgments and disclosure of funding
We would like to thank the anonymous reviewers for their constructive comments and Tai-Hsuan
Chung for answering our mathematical questions.
This work was supported in part by NSF under
Grant CCF-2225617, Grant CCF-2124929, and Grant IIS-
Checklist
For all authors... (a) Do the main claims made in the abstract and introduction accurately reflect the paper’s contributions and scope?
[Yes] The main claims are summarized in Section 1.1.
(b) Did you describe the limitations of your work?
[Yes] See Section 3.3.
(c) Did you discuss any potential negative societal impacts of your work?
[No] This is a theoretical paper and we are not aware of any negative societal impacts.
(d) Have you read the ethics review guidelines and ensured that your paper conforms to them?
[Yes] 2.
If you are including theoretical results... (a) Did you state the full set of assumptions of all theoretical results?
[Yes] All definitions and assumptions are stated or referenced before the results.
(b) Did you include complete proofs of all theoretical results?
[Yes] Appendix B in the supplementary material.
If you ran experiments... (a) Did you include the code, data, and instructions needed to reproduce the main experimental results (either in the supplemental material or as a URL)?
[N/A] (b) Did you specify all the training details (e.g., data splits, hyperparameters, how they were chosen)?
[N/A] (c) Did you report error bars (e.g., with respect to the random seed after running experiments multiple times)?
[N/A] (d) Did you include the total amount of compute and the type of resources used (e.g., type of GPUs, internal cluster, or cloud provider)?
[N/A] 4.
If you are using existing assets (e.g., code, data, models) or curating/releasing new assets... (a) If your work uses existing assets, did you cite the creators?
[N/A] (b) Did you mention the license of the assets?
[N/A] (c) Did you include any new assets either in the supplemental material or as a URL?
[N/A] (d) Did you discuss whether
and how consent was obtained from people whose data you’re using/curating?
[N/A] (e) Did you discuss whether the data you are using/curating contains personally identifiable information or offensive content?
[N/A] 5.
If you used crowdsourcing or conducted research with human subjects... (a) Did you include the full text of instructions given to participants and screenshots, if applicable?
[N/A] (b) Did you describe any potential participant risks, with links to Institutional Review Board (IRB) approvals, if applicable?
[N/A] (c) Did you include the estimated hourly wage paid to participants and the total amount spent on participant compensation?
[N/A]
A Lemmas
Lemma 3.
Let l be any positive integer.
Then, there exists an l -layer ReLU network g with 2 n ( l − 1) hidden neurons and a maximum width of 2 n such that g ( x ) =
x for all x ∈ R n .
Furthermore,
Algorithm 5 finds such a network in poly ( n, l ) time.
Proof.
Appendix B.6.
Definition 6.
Let g ( l,n,w ) denote an l -layer ReLU network g with n hidden neurons and a maximum width bounded from above by w .
Lemma 4.
There exists g ( l 1 + l 2 − 1 ,n 1 + n 2 , max( w 1 ,w 2 ) ) that represents any composition of g ( l 1 ,n 1 ,w 1 ) and g ( l 2 ,n 2 ,w 2 ) .
Algorithm 4 finds such a network computing the composition in poly (cid:0) max( w 1 , w 2 ) , max( l 1 , l 2 ) (cid:1) time.
Proof.
Appendix B.7.
Lemma 5.
The sequence r ( k ) defined by (23) is a strictly increasing sequence.
Proof.
Appendix B.8.
Lemma 6.
For any positive integer k , the sequence r ( k ) defined by (23) satisfies
[Equation] [Equation]
Proof.
Appendix B.
Lemma 7.
Let m 1 and m 2 be the output dimensions of g ( l 1 ,n 1 ,w 1 ) and g ( l 2 ,n 2 ,w 2 ) , respectively.
Define
[Equation] [Equation]
(26) and
[Equation]
(27) where i = arg min k ∈ [2] l k and j = [2] \ { i } .
Then, there exists g ( l,n,w ) such that
[Equation]
for all x ∈ R n .
Proof.
Appendix B.10.
Lemma 8.
Let m 1 , m 2 , · · · , m k be the output dimensions of g ( l 1 ,n 1 ,w 1 ) , g ( l 2 ,n 2 ,w 2 ) , · · · , g ( l k ,n k ,w k ) , respectively.
Define
[Equation]
and
[Equation]
Then, there exists g ( l,n,w ) such that
[Equation]

[Equation]
for all x ∈ R n .
Furthermore, Algorithm 3 finds such a network in poly (cid:16) max
i ∈
[ k ] w i , k, l (cid:17) time.
Proof.
Appendix B.11.
Lemma 9.
Let f 1 , f 2 , · · · , f k be any affine functions such that f i : R n → R for all i ∈
[ k ] .
Define the set of feasible ascending orders as
[Equation]
where S ( k ) is the collection of all permutations of the set [ k ] .
It holds true that
[Equation]
Proof.
Appendix B.12.
Lemma 10.
If Definition 1 is satisfied for a non-affine function, then every nonempty subset has a nonempty intersection with at least one of the other subset(s).
Proof.
Appendix B.13.
Assumption 1.
The number of closed connected subsets satisfying Definition 1 is a minimum.
The interior and frontier (boundary) of a set X are denoted as Int X and Fr X , respectively.
Lemma 11.
Let f i denote the affine function associated with X i for i
∈
[ I ] where {X i } i ∈
[ I ] is a family of closed connected subsets satisfying Assumption 1.
Then, for any i ∈
[ I ] , j ∈
[ I ] such that i ̸
= j and X i (cid:84)
X j ̸ = ∅ ,
(a) f i and f j are different, and { x ∈ R n | f
i
( x ) =
f j ( x ) } ̸ = ∅ .
(b) { x ∈ R n | f i ( x ) =
f j ( x ) } is an affine subspace of R n with dimension n − 1 .
(c) X i (cid:84)
X j ⊆ { x ∈ R n | f i ( x ) =
f j ( x ) } .
(d) x
̸∈ Int X i and x ̸∈ Int X j for all x ∈ X
i (cid:84)
X j .
Proof.
Appendix B.14, B.15, B.16, and B.17.
Lemma 12.
If a family of closed connected subsets {X i } i ∈ [ I ] satisfies Assumption 1, then, for all i ∈
[ I ] ,
(a) Int X i ̸
= ∅ .
(b) Fr X i =
(cid:83)
k ∈
[ I ] \ i X k (cid:84)
X i .
(c) Int X i (cid:84)
Int X j = ∅ for all j ∈ [ I ] such that j ̸ = i .
Proof.
Appendix B.18, B.19, and B.20.
Lemma 13.
Let {X i } i ∈ [ m ] be any finite family of subsets satisfying Assumption 1.
Let {H j } j ∈
k ] be any finite family of affine subspaces of R n with dimension n − 1 .
Then, for i ∈ [ m ] ,
[Equation]
Proof.
Appendix B.21.
Proposition 1.
For any family of closed connected subsets satisfying Definintion 1, all subsets are the largest closed connected subsets if and only if Assumption 1 is satisfied.
Proof.
Appendix B.22.
B Proofs B.1 Proof of Lemma
Proof.
Let the family of closed connected subsets ¯ Q
=
X i } i ∈
[ I ] satisfy Assumption 1 for any p ∈ P n,k .
Let the k distinct linear components of p be f 1 , f 2 , · · · , f k and H lm be the intersection between f l and f m for l ∈ [ k ] , m ∈
[ k ] , l ̸
= m .
Note that every H lm is an affine subspace of R n with dimension n − 1 (a hyperplane) or an empty set.
Because the linear components are distinct, it must be true that k ≤ I by Definition 2.
If p is an affine function, then it follows that k
= min ¯ Q∈C n,k ( p ) (cid:12)(cid:12) ¯ Q (cid:12)(cid:12) =
ϕ ( n, k ) = 1 , the claim holds.
For the non-affine case, we must have k > 1 .
Let R = R n \ H where
[Equation]
Note that H ̸ = ∅ according to Lemma 10 and 11(c).
By Lemma 12(b), the boundary or frontier of X i for i ∈
[ I ] is given by
[Equation]
Because every X i (cid:84) X j for i ∈ [ I ] , j ∈ [ I ] , i ̸
= j is a subset of some H lm for l ∈ [ k ] , m ∈ [ k ] , l ̸
= m by Lemma 11(c), it follows that the boundary of X i , Fr X i , satisfies
[Equation]
38) for i ∈
[ I ] .
The interior of X i , Int X i , is a nonempty subset of R n according to Lemma 12(a).
Furthermore, by Lemma 13,
[Equation]
Now, define
[Equation]
40) for i ∈
[ I ] .
Note that Z i
=
X i (cid:84) R ̸
= ∅ due to (38) and (39).
Let A be any subset of R n and λ ( A ) be the number of connected components of A in R n .
It must be true that
[Equation]
By Lemma 12(c), Int X i (cid:84)
Int X j = ∅ for i ∈
[ I ] , j ∈
[ I ] , i ̸
=
j .
We have
I ≤
[Equation] [Equation]
Notice that (cid:91)
[Equation]
by the property (cid:83) i ∈
[ I ] X i =
R n in Definition 1.
Plugging (43) into (42) leads to
[Equation]
[Equation]
which states that I is bounded from above by the number of connected components of R in R n .
Notice that every component is an open convex set because every component is the intersection of a finite number of open half spaces.
Therefore,
[Equation]
where C ′ n,k ( p ) denotes the collection of all families of closed connected subsets satisfying Definition 1 for any p ∈ P n,k .
Because the ascending order of these k linear components does not change within a connected component of R , λ ( R ) can be bounded from above by the number of feasible ascending orders.
Let S ( k ) be the collection of all permutations of the set [ k ] .
It follows that
[Equation]
Finally, Lemma 9 proves the statement by bounding number of feasible ascending orders.
B.2 Proof of Lemma
Proof.
It suffices to show that
[Equation]
for all x = (cid:2) xx· · · x k (cid:3) T ∈ R k since the composition of affine functions is still affine.
The affine functions can be absorbed into the first layer of the ReLU network g .
We prove the case for taking the maximum of m real numbers since the same procedure below can be applied to prove the case of taking the minimum due to the following identity
[Equation]
Because max( x
[Equation]
, x
[Equation]
) = max
[Equation] [Equation]
max(0 , x
[Equation]
− max(0 , − x 1 ) for any x 1 ∈ R and x 2 ∈ R , it holds true that
[Equation]
even
[Equation]
for x j ∈ R , j ∈ [ k ] where
[Equation]
Let r ( k ) be the number of operations of taking the maximum between a zero and a real number, i.e., max(0 , x ) , x ∈ R for computing the maximum of k real numbers using (49).
One can find r (2) =and r (3) = 8 by expanding all operations in (49).
Because we do not need any maximum operations to compute the maximum over a singleton, we define r (1) = 0 .
For any positive integer k such that k ≥ 2 , we have the recursion
[Equation]
according to (49).
Note that r ( n ) is the number of ReLUs in a ReLU network g that computes the maximum of n real numbers or a max-affine function.
The number of ReLUs here is equivalent to the number of hidden neurons according to Definition 4.
We shall note that the number of ReLU layers is equivalent to the number of hidden layers.
Obviously, we only need a 1 -layer ReLU network with no ReLUs to compute the maximum of a singleton.
Suppose that we aim to compute the maximum of m = 2 n real numbers for any positive integer n .
Then, every time the recursion goes to the next level in (51), the number of variables considered for computing the maximum is halved.
Hence, the number of ReLU layers is n .
When m is not a power of two, i.e., 2 n < m < 2 n +1 , then we can always construct a ReLU network with n + 1 ReLU layers and 2 n +1 input neurons, and set weights connected to the 2 n +1 − m “phantom input neurons” to zeros.
Because ⌈ log 2 m ⌉ = n + 1 for 2 n < m < 2 n +1 , the number of ReLU layers is ⌈ log 2 m ⌉ for any positive integer m .
By Definition 5, we have l ( m ) =
⌈ log 2 m ⌉ + 1 .
By Lemma 5, r ( k ) is a strictly increasing sequence.
Therefore, the maximum width of the network is given by the width of the first hidden layer.
When L = 1 or m = 1 , the width is 0 due to Definition 5.
When L > 1 or m > 1 ,
[Equation]
even
[Equation]
Algorithm 2 directly follows from the above construction.
Its complexity analysis is deferred to Table 2 in Appendix C.
B.3 Proof of Theorem
Proof.
Let f 1 , f 2 , · · · , f k be k distinct linear components of p and Q be any family of closed convex subsets of R n satisfying Definition 1.
By Theorem 4.2 in [Tarela and Martinez, 1999], p can be represented as
[Equation]
for all x ∈ R n where
[Equation]
is the set of indices of linear components that have values greater than or equal to p ( x ) for all x ∈ X .
A thorough discussion of the representation (53) is given in Section 4.2.
According to (53), there are |Q| minima required to be computed where each of them is a minimum of (cid:12)(cid:12)
A ( X ) (cid:12)(cid:12) real numbers.
Then, the value of p can be computed by taking the maximum of the resulting |Q| minima.
We will show that these operations are realizable by a ReLU network.
By Lemma 2, an l ( m ) -layer ReLU network with r ( m ) hidden neurons and a maximum width of w ( m ) can compute the extremum of m real numbers given by m affine functions.
We realize (53) in three steps.
First, we create |Q| ReLU networks where each of them is an l (cid:16) (cid:12) (cid:12) A ( X ) (cid:12) (cid:12) (cid:17) -layer ReLU network with r (cid:16) (cid:12) (cid:12)
A ( X ) (cid:12) (cid:12) (cid:17) hidden neurons and a maximum width of w (cid:16)(cid:12)(cid:12) A ( X ) (cid:12)(cid:12)(cid:17) that computes min i ∈A ( X )
f i ( x ) for X ∈ Q .
Second, we parallelly concatenate these |Q| networks, i.e., put them in parallel and let them share the same input to obtain a ReLU network that takes x and outputs |Q| real numbers.
Finally, we create an l (cid:0) |Q| (cid:1) -layer ReLU network with r (cid:0) |Q| (cid:1) hidden neurons and a maximum width of w (cid:0) |Q| (cid:1) that takes the maximum of |Q| real numbers.
The parallel combination of |Q| networks in the second step can be realized by Lemma 8.
The third step can be fulfilled by Lemma 4.
With the above construction, we can now count the number of layers, the upper bound for the maximum width, and the number of hidden neurons for a ReLU network that realizes p .
The number of layers is given by
[Equation]
The maximum width is bounded from above by
[Equation]
The number of hidden neurons is give by
[Equation]
Because A ( X ) for every X ∈ Q is a subset of [ k ] , it holds that
[Equation]
for all X ∈ Q .
Therefore, the number of layers in (55) can be bounded from above by
[Equation]
where we have used the definition of the function l in Lemma 2.
Again, using (58), the upper bound for the maximum width in (56) can be further bounded from above by
[Equation]
where we have used the definition of the function w in Lemma 2.
Note that the maximum width is zero when the number of layers is one.
Finally, again, using (58), the number of neurons in (57) can be bounded from above by
[Equation]
where we have used Lemma 6 for the upper bound in the fourth line of (61).
Expanding and rearranging terms in (61) lead to (12).
Algorithm 1 directly follows from the above construction.
Its complexity analysis is deferred to Table 1 in Appendix C.
B.4 Proof of Theorem
Proof.
By Lemma 1, the number of distinct linear components k is bounded from above by the number of pieces, i.e., k ≤ q , implying that the bounds in Theorem 2 can be written in terms of q .
Substituting k with q in Theorem 2 proves the claim.
According to Theorem 2, the time complexity of Algorithm 1 is poly ( n, k, q ) .
Using the bound k ≤ q proves the claim for the time complexity.
B.5 Proof of Theorem
Proof.
By Lemma 1, the minimum number of closed convex subsets q of a CPWL function p : R n → R can be bounded from above by ϕ ( n, k ) , i.e.,
[Equation]
Substituting q with ϕ ( n, k ) in Theorem 2 proves the claim.
B.6 Proof of Lemma
Proof.
Obviously, a one-layer ReLU network is an affine function whose weights can be set to fulfill the identify mapping in R n .
We prove the case when the number of layers is more than one in the next paragraph.
We start with a scalar case, and then work on the vector case.
For any x ∈ R , it holds that max(0 , x ) − max(0 , − x ) = x .
In other words, a hidden layer of two
ReLUs with +1 and − 1 weights can represent an identity mapping for any scalar.
For any vector input in R n , we can concatenate such structures of two ReLUs in parallel because the identity mapping can be decomposed into n individual identity mappings from n coordinates.
Therefore, a two-layer ReLU network with 2 n hidden neurons can realize the identity mapping in R n .
Stacking such a hidden layer any number of times gives a deeper network that is still an identity mapping.
Algorithm 5 follows from the above construction.
Its complexity analysis is deferred to Table 5 in Appendix C.
B.7 Proof of Lemma
Proof.
Because a composition of two affine mappings is still affine, the first layer of either one of the two networks can be absorbed into the last layer of the other one if their dimensions are compatible.
The resulting new network still satisfies Definition 4.
The number of layers of the new network is l 1 + l 2 − 1 .
The number of hidden neurons of the new network is n 1 + n 2 .
The maximum width of the new network is at most max( w 1 , w 2 ) .
Algorithm 4 follows from the above construction.
Its complexity analysis is deferred to Table 4 in Appendix C.
B.8 Proof of Lemma
Proof.
For any positive even integer k ≥ 4 , it holds true that
[Equation]
For any positive odd integer k such that k ≥ 3 , we have
[Equation]
which is strictly greater than zero.
Note that (64) is greater than 0 because the equality in (64) can be applied over and over again to reach (63) or the base case r (2) − r (1) = 3 .
B.9 Proof of Lemma
Proof.
By Lemma 5, r ( k ) is a strictly increasing sequence.
Then, it must be true that
[Equation] [Equation]
According to the recursion (23), it holds that
[Equation] [Equation]
B.10 Proof of Lemma
Proof.
Two ReLU networks can be combined in parallel such that the new network shares the same input and the two output vectors from the two ReLU networks are concatenated together.
To see this, we show that the weights of the new network can be found by the following operations.
Let W 1 i and b 1 i be the weights of the i -th layer in g ( l 1 ,n 1 ,w 1 ) , and W 2 i and b 2 i are the weights of the i -th layer in g ( l 2 ,n 2 ,w 2 ) .
Let W i and b i be the weights of the new network.
Now, we find the weights for the new network.
In the first layer, we construct
[Equation]
67) and
[Equation]
For the i -th layer such that 1 < i ≤ min( l 1 , l 2 ) , we use
[Equation]
69) and
[Equation]
If l 1 = l 2 , then the claim is proved.
If l 1 ̸ = l 2 , then we stack a network that implements the identity mapping to the shallower network such that the number of layers of the two networks are the same.
Because the network g ( l i ,n i ,w i ) is shallower than the other network, we append | l 1 − l 2 | hidden layers to g ( l i ,n i ,w i ) such that the procedure in (69) and (70) can be used.
By Lemma 3, there exists an (cid:0) | l 1 − l 2 | + 1 (cid:1) -layer ReLU network g ( | l 1 − l 2 | +1 , 2 m i | l 1 − l 2 | , 2 m i ) with 2 m i | l 1 − l 2 | hidden neurons and a maximum width bounded from above by 2 m i for representing the identity mapping in R m i .
By Lemma 4, there exists a network g ( l i + | l 1 − l 2 | ,n i +
m i | l 1 − l 2 | , max( w i , 2 m i ) ) that represents the composition of g ( | l 1 − l 2 | +1 , 2 m i | l 1 − l 2 | , 2 m i ) and g ( l i ,n i ,w i ) .
Now, (69) and (70) can be used to combine g ( l j ,n j ,w j ) and g ( l i + | l 1 − l 2 | ,n i +2 m i | l 1 − l 2 | , max( w i , 2 m i ) ) in parallel because the number of layers in network g ( l i + | l 1 − l 2 | ,n i +
m i | l 1 − l 2 | , max( w i , 2 m i ) ) is equal to l j according to the fact that l i + | l 1 − l 2 | = max( l 1 , l 2 ) =
l j .
Such a new network has max( l 1 , l 2 ) layers and
[Equation]
hidden neurons.
The maximum width of the new network is at most w j + max( w i , 2 m i ) .
B.11 Proof of Lemma
Proof.
The case k = 1 is trivial.
The case k = 2 is proved by Lemma 7, which gives a tighter bound on the maximum width.
The number of layers and hidden neurons of the claim agree with Lemmawhen k = 2 .
The claim can be proved by following a similar procedure from the proof of Lemma 7.
By Lemma 3, we can stack an identity mapping realized by an ( l − l i + 1) -layer ReLU network with 2 m i ( l − l i ) hidden neurons and a maximum width of 2 m i on the i -th network for all i ∈
[ k ] such that l i < l .
In other words, we increase the number of hidden layers for any network whose number of layers is less than l such that the cascade of the network and the corresponding identity mapping has l layers.
For all i ∈ [ k ] such that l i < l , the extended network has n i +
m i ( l − l i ) hidden neurons and a maximum width at most max( w i , 2 m i ) according to Lemma 4.
Because all the networks now have the same number of layers, we can directly combine them in parallel.
Hence, the resulting new network has max i ∈
[ k ] l i layers and
[Equation]
hidden neurons and a maximum width at most (cid:88)
[Equation]
Algorithm 3 directly follows from the above construction.
Its complexity analysis is deferred to Table 3 in Appendix C.
B.12 Proof of Lemma
Proof.
Because S n f 1 ,f 2 , ··· ,f k is a subset of S ( k ) and (cid:12) (cid:12) S ( k ) (cid:12) (cid:12) =
k ! is the number of permutations of k distinct objects, it follows that
[Equation]
On the other hand, the number of hyperplanes, or affine subspaces of R n with dimension n − 1 , induced by the distinct intersections between any two different affine functions is bounded from above by
[Equation]
Let the arrangement of these hyperplanes be A , and |A| be the number of hyperplanes in the arrangement.
By Zaslavsky’s Theorem [Zaslavsky, 1975], the number of connected components of the set
[Equation]
is bounded from above by
[Equation]
Because there are at most (cid:0) k 2 (cid:1) hyperplanes in R n , it follows that
[Equation]
Combining (74) and (78) proves the claim.
Notice that the ascending order does not change within a connected component.
B.13 Proof of Lemma
Proof.
Let X 1 , X 2 , · · · , X I be a family of subsets satisfying Definition 1 for a non-affine function.
We prove the claim by contradiction.
Suppose that there exists at least one nonempty closed subset, say X i , that is disjoint with every other closed subset X j , j ∈
[ I ] \ i .
It follows that
[Equation]
which implies
[Equation]
Because the union of any finite collection of closed sets is closed, it must be true that (cid:83)
j ∈
[ I ] \ i X j is closed.
Notice that X i is never the whole space R n because the CPWL function is assumed to be non-affine.
(cid:83)
j ∈
[ I ] \ i X j must be nonempty due to Definition 1.
Therefore, both R n \ X i and
R n \ (cid:83) j ∈
[ I ] \ i X j are nonempty and open.
Since R n is connected, it cannot be represented as the union of two disjoint nonempty open subsets.
It follows that the intersection between R n \ X i and R n \ (cid:83) j ∈ [ I ] \ i X j is nonempty.
In other words, there exists an element of R n that is not in X i and (cid:83) j ∈
[ I ] \ i X j , contradicting Definition 1.
B.14 Proof of Lemma 11(a)
Proof.
If the CPWL function is affine, then there are no intersecting closed subsets because the only closed subset satisfying Assumption 1 is R n .
On the other hand, if the CPWL function is non-affine, then there exist at least two intersecting closed subsets according to Lemma 10.
For any two intersecting closed subsets, say X i and X j , we first show that
[Equation]
where f i and f j are the affine functions corresponding to X i and X j .
We prove this statement by contradiction.
Suppose that the intersection is empty, i.e., the linear equation (cid:0) a
i − a j (cid:1) T x + b i − b j = 0 does not have a solution where f i ( x ) = a T i x
+ b i and f j ( x ) =
a T j x + b j for a i , a j ∈ R n and b i , b j ∈ R .
Then, it is necessary that a i = a j and b i ̸ = b j .
In other words, the two affine functions are parallel, implying that every point in X i ∩
X j gives two different values, which cannot be true for a valid function.
Next, we prove that there does not exist an intersection that is R n by contradiction.
Let us assume that there exists at least one intersection that is R n between the affine functions corresponding to two intersecting closed subsets, say X i and X j .
Then, we can always replace X i and X j with their union.
Such a replacement still satisfies Definition 1 but reduces the number of closed (connected) subsets by at least one, contradicting the fact that the number of closed subsets is a minimum.
Because the two affine functions are identical if and only if the intersection is R n , the two affine functions must be different.
B.15 Proof of Lemma 11(b)
Proof.
The claim follows from Lemma 11(a).
Because the two affine functions have nonempty intersection, their intersection must be R n or an affine subspace of R n with dimension n − 1 .
However, the two affine functions must be different, implying that R n is never the intersection.
B.16 Proof of Lemma 11(c)
Proof.
Let any given two intersecting subsets be X i and X j .
The intersection between their corresponding affine functions, say f i and f j , is given by H ij = { x ∈ R n |
f i ( x ) =
f j ( x ) } .
Suppose that there exists a point a ∈ X i (cid:84)
X j such that a ̸∈ H ij , then it follows that f i ( a ) ̸
= f j ( a ) .
Such a result cannot be true for a valid function.
We conclude that
X i (cid:84) X j ⊆ H ij .
B.17 Proof of Lemma 11(d)
Proof.
We prove the statement by contradiction.
Suppose there exists a point c ∈ R n in the intersection of two intersecting closed connected subsets, say X i and X j , such that c is an interior point of X i , then there exists an open ϵ -radius ball B ( c , ϵ )
such that x ∈ X
i , ∀ x ∈ B ( c , ϵ ) for some ϵ > 0 .
By Lemma 11(b), the intersection between the two affine functions corresponding to X i and
X j must be an affine subspace of R n with dimension n − 1 .
Let such an affine subsapce be denoted as H ij and its corresponding linear subspace be denoted as V ( H ij ) .
Then, there exists a nonzero vector d ∈ R n such that α d ⊥ v for all v ∈ V ( H ij ) and any α ̸ = 0 .
Therefore, it follows that α d + a ̸∈ H ij for any a ∈ H ij and any α ̸ = 0 .
According to Lemma 11(c), X i ∩ X j ⊆ H ij , so we have α d + c ̸∈ X i ∩ X j for any α ̸ = 0 .
When α = ϵ 2 ∥ d ∥ 2 or α = − ϵ 2 ∥
d ∥ 2 , α d + c ∈ B ( c , ϵ ) .
However, one of them must satisfy α d + c ̸∈ X i , contradicting the existence of a point in X i ∩
X j that is an interior point of X i .
The same procedure can be applied to prove that there does not exist a point in
X i ∩
X j such that it is an interior point of X j .
We conclude that every element in X i ∩
X j is not an interior point of X i or X j .
B.18 Proof of Lemma 12(a)
Proof.
Let X 1 , X 2 , · · · , X I be a finite number of closed subsets satisfying Assumption 1.
The boundary or frontier of X i is given by
[Equation]
where A denotes the closure of a subset A .
We have used Lemma 11(d) for the equality between the 4 -th and 5 -th line of (82).
Now, we prove that the interior of X i is nonemtpy by contradiction.
Suppose that the interior of X i is empty, then it follows that X
i
=
X i =
Fr X i because the closure of X i is the union of the interior and the boundary of X i .
Combining that with (82), we have
X i =
(cid:83)
k ∈
[ I ] \ i X k (cid:84)
X i .
which implies every element in X i is at least covered by one of the other closed subset X k for some k ∈
[ I ] \ i .
In this case, we can delete X i from X 1 , X 2 , · · · , X I ; and the remaining I − 1 closed subsets still satisfy Definition 1.
Such a valid deletion of X i contradicts the fact that I is the minimum number of closed subsets.
Hence, the interior of X i must be nonempty.
B.19 Proof of Lemma 12(b)
Proof.
The statement is proved by (82) in Lemma 12(a).
B.20 Proof of Lemma 12(c)
Proof.
By Lemma 12(a), the interior of every subset is nonempty.
Next, by Lemma 11(d), every point in the intersection between any two subsets is a boundary point of both subsets.
It follows that the interiors of any two subsets are disjoint.
B.21 Proof of Lemma
Proof.
By Lemma 12(a), the interior of X i is nonempty.
Therefore, there exists an open ϵ -radius ball
B ( c 0 , ϵ ) such that x ∈ X
i , ∀ x ∈ B ( c 0 , ϵ ) for some ϵ > 0 and c 0 ∈
X i .
Let us consider the set
[Equation]
where H + j and H − j are two open half spaces created by H j .
It suffices to show that the nonemptyness of the set in (83) to prove the claim.
If H j and B ( c 0 , ϵ ) do not intersect, then B ( c 0 , ϵ ) completely belongs to H + j or H − j .
Without loss of generality, we can remove all j such that H j does not intersect
B ( c 0 , ϵ ) and assume there are k affine subspaces of R n with dimension n − 1 intersecting B ( c 0 , ϵ ) .
Let us sequentially carry out the intersection in (83).
Every time before the operation of the j -th intersection between B ( c j − 1 , ϵ 2 j − 1 ) and (cid:16) H + j (cid:83) H − j (cid:17) , there exists an open ϵ 2 j -radius ball B ( c j , ϵ 2 j ) for some c j ∈ B ( c j − 1 , ϵ 2 j − 1 ) such that it does not intersect with H j .
Therefore, at the end of the sequential process, there exists an open ball that does not intersect any of these k affine subspaces of R n with dimension n − 1 .
The set in (83) is nonempty, implying (35) holds true.
B.22 Proof of Proposition
Proof.
We prove the claim by contraposition.
If the number of closed connected subsets is not a minimum, i.e., Assumption 1 is not satisfied, then such a number can be decreased by merging some of the intersecting closed connected subsets that have the same corresponding affine functions.
Therefore, there exist at least two closed connected subsets that can be made larger.
On the other hand, if the closed connected subsets, say X 1 , X 2 , · · · , X I , have at least one of subsets that can be made larger, then there exist at least two intersecting closed connected subsets, say X i and X j , from X 1 , X 2 , · · · , X
I such that their corresponding affine functions are the same.
Otherwise, any closed connected subset cannot be made larger than itself.
Therefore, X i and X j can be replaced with X i ∪ X j and these I − 1 closed connected subsets still satisfy Definition 1, implying that I is not the minimum.
C Algorithms and time complexities
[Table]
Algorithm 2 (see Table 2).
[Table]
Algorithm 3 (see Table 3).
[Table]
Algorithm 2 (see Table 2).
[Table]
Algorithm 4 (see Table 4).
A ←   − 1  − 1  , B ← (cid:2) 1 1 − 1 (cid:3) , C ← (cid:20) 1 − 1 (cid:21)
▷ Constant matrices 2: Ψ ( Y , Z )
← (cid:20) Y
Z (cid:21)
▷ A function a block
Y and
3: Φ ( Y , s ) ←  
Y (1) · · ·
Y (2) · · · ...
· · · Y ( s )  
4: l ← ⌈ log 2 m ⌉ + 1 , k 0 ← n, k l ← 1 , c 0 ← m
5: for i = 1 , 2 , · · · , l − 1 do 6: if c i − 1 is even then 7: c i ← c i − 18: k i ← 3 c
i ▷ Output dimension of the i -th layer 9: else 10: c
i ← c
i − 1 + 11: k i ← 3 c
i −▷ Output dimension of the i -th layer 12: end if 13: end for 14: W 1 ← (cid:2) ∇ f∇ f· · · ∇ f m (cid:3) T , b 1 ← (cid:2) f 1 (0)
f 2 (0) · · · f m (0) (cid:3) T 15: if l > 1 then ▷ Find the weights of input and output layers, if any 16: if c 0 is even then 17:
W 1 ← Φ ( A , c 1 ) W 1 , b 1 ← Φ ( A , c 1 ) b18: else 19:
W 1 ← Ψ (cid:0) Φ ( A , c 1 − 1) , C (cid:1) W 1 , b 1 ← Ψ (cid:0) Φ ( A , c 1 − 1) , C (cid:1) b20: end if 21:
W l ← B , b l ← 0 k l 22: end if 23: if l > 2 then ▷ Find the weights of remaining layers, if any 24: for i = 2 , 3 , · · · , l − 1 do 25: if c i − 1 is even then 26:
T ← Φ ( A , c i ) 27: else 28:
T ← Ψ (cid:0) Φ ( A , c i − 1) , C (cid:1) 29: end if 30: if c i − 2 is even then 31:
W i ← TΦ ( B , c
i − 1 ) 32: else 33:
W i ← TΨ (cid:0) Φ ( B , c
i − 1 − 1) , C T (cid:1) 34: end if 35: b i ← 0 k
i 36: end for 37: end if 38: if type of extremum is the minimum then 39:
W 1 ← − W 1 , b 1 ← − b40:
W l ← − W l , b l ← − b l 41: end if ▷ See Table 2 in Appendix C for complexity analysis
Algorithm 3 Find a ReLU network that concatenates a number of given ReLU networks
Input
Output
  g 1 (
) g 2 ( x ) .
g k ( x )   , ∀ x ∈ R n .
1: l ← max j ∈ [ k ] l j 2: W 1 ←  
W
W...
W k  , b 1 ←   bb...
b k  ▷ Weights of the input layer 3: for j = 1 , 2 , · · · , k do 4: if l j < l then ▷ Append an identity mapping network to the network if it is shallower 5: m ← output dimsion of g j 6: g cj ← run Algorithm 5 with an input dimension m and a number of layers l − l j +7: g ′ j ← run Algorithm 4 with g j and g cj 8: { W ji , b ji } li =1 ← weights of g ′ j 9: end if 10: end for 11: for i = 2 , 3 , · · · , l do ▷ Find the remaining weights 12:
W i ←  
W 1 i · · ·
W 2 i · · · ...
· · · W ki   , b
i ←   b
i b 2 i ...
b ki   13: end for ▷ See Table 3 in Appendix C for complexity analysis
Algorithm 4 Find a ReLU network computing a composition of two given ReLU networks
Input: Weights g g denoted by { W i b i l 1 i =
{ W 2 i b 2 i } l
=
2: for i
· · · , l do 3: if i < l 1 then ▷
The first l 1 − 1 layers are identical to the corresponding layers in g4:
W
i ← W 1 i , b i ← b 1 i 5: else if i = l 1 then ▷ A composition of affine functions is still an affine function 6:
W
[Equation]
7: else ▷
The last l 2 − 1 layers are identical to the corresponding layers in g8:
W
[Equation]
←
[Equation] [Equation]
9: end if 10: end for ▷ See Table 4 in Appendix C for complexity analysis
Algorithm 5 Find a ReLU network that computes an identity mapping for a given depth
1: A ← (cid:20)−(cid:21) , B ← (cid:2) 1 − 1 (cid:3) , C ← (cid:20)−− (cid:21) ▷ Constant matrices 2: Φ ( Y , s ) =
 
Y (1) · · ·
Y (2) · · · ...
· · · Y ( s ) 
 ▷ A
3: k 0 ← n k l ← n b l ← 0 n 4: for i =
l
1 do 5: k
← n
6: b i ← 0 k i 7: end for 8: if l = 1 then ▷ Find the weights of input and output layers, if any 9:
W 1 ← I n × n
An identity matrix 10: else 11:
W 1 ← Φ ( A , k 0 ) 12:
W l ← Φ ( B , k l ) 13: end if 14: if l > 2 then ▷ Find the weights of hidden layers, if any 15: for i = 2 , 3 , · · · , l − 1 do 16:
W i ← Φ ( C , n ) 17: end for 18: end if ▷ See Table 5 in Appendix C for complexity analysis
Algorithm 6 Find all distinct linear components of a CPWL function
Input: An unknown CPWL function p whose output can be observed by feeding input from R n to the function.
A center c i and radius ϵ i > 0 of any closed ϵ i -radius ball B ( c i , ϵ i ) such that
B ( c i , ϵ i ) ⊂
X i for i = 1 , 2 , · · · , q where {X i } i ∈ [ q ] are all pieces of p .
Output: All distinct linear components of p , denoted by F .
1: F ← ∅ ▷ Initialize the set of all distinct linear components 2: for i = 1 , 2 , · · · , q do 3: x 0 ← c i
▷ select the center of B ( c i , ϵ i ) 4: y
← p ( x 0 ) 5: (cid:2) ss· · · s n (cid:3) ← ϵ i
I n × n ▷ scale the standard basis of R n 6:
S ← (cid:2) ss· · · s n (cid:3) 7: z ←   p
[Equation]
p
[Equation]
p
[Equation]
x
[Equation]
−
[Equation]
  8: a ← S − T z ▷ Find the linear map by solving a system of linear equations 9: b ← y 0 − a T x▷ Find the translation 10: f ← x (cid:55)→ a T x + b ▷ The affine map on X i 11: if f ̸∈ F then ▷ Only add the affine map f to the set F if f is distinct to all elements of F 12:
F ← F (cid:83) { f } 13: end if 14: end for ▷ See Table 6 in Appendix C for complexity analysis
[Table]
Let d 1 be the maximum dimension of Y and Z .
[Table]
Let d 2 be the maximum dimension of Y .
[Table] [Table]
[Table] [Table]
[Table] [Table]
[Table] [Table]
[Table] [Table]
[Table]
inequality
[Table] [Table]
[Table] [Table]
[Table] [Table]
[Table] [Table]
[Table] [Table]
[Table] [Table]
[Table]
Assign a vector whose length is
[Table]
most (cid:6) 3 m 2 (cid:7)
[Table]
[Table] [Table]
[Table]
Check the binary data type.
[Table]
Reverse the sign of W
[Table]
and
[Table] [Table]
Reverse the sign of a constant matrix.
[Table]
[Table] [Table]
[Table]
a block diagonal matrix from Y ∈ R d 1 × d 2 and s ∈ N .
O ( n )
Assign two constant scalars and one constant vector of length n .
O ( l )
Repeat Line 5 to line 6 l times.
O (1)
Assign a scalar.
O ( n )
Assign a vector whose length k
i is equal to 2 n .
O (1)
Check a scalar equality.
O ( n 2 )
Assign a 2 n -by- n matrix.
O ( n 2 )
Assign a 2 n -by- n block diagonal matrix.
O ( n 2 )
Assign an n -by- 2 n block diagonal matrix.
O (1)
Check a scalar inequality.
O ( l )
Repeat Line 16 l − 2 times.
O ( n 2 )
Assign a 2 n -by- 2 n block diagonal matrix.
[Table]
D Open source implementation and run time of Algorithm
We implement Algorithm 1 in Python.
Figure 3 shows that the run time of the algorithm is greatly affected by the number of pieces q .
Code is available at https://github.com/kjason/CPWL2ReLUNetwork.
[Figure]
ond s ) n =n =n =