The Computational Complexity of Training ReLU(s)

Pasin Manurangsi, Daniel Reichman

Our Results

We prove both hardness results as well as algorithmic results for training a single ReLU as well as depth-2 ReLUs with kk units. In terms of hardness, we prove NP-hardness results for the ReLU training problem showing that this problem is hard even for a single ReLU, not only to solve exactly but also to approximate (Section 2). In Section 3, we prove that, in contrast to the case of single ReLU, training 2 ReLUs is NP-hard even in the realizable caseFor completeness we provide a proof in Appendix B that training a single ReLU can be done in polynomial time in the realizable case.. We remark that this latter result also yields, as an immediate corollary, NP-hardness for training networks considered in [BDL18]. Our proof is shorter and arguably simpler than the proof appearing in [BDL18] altough their result also applies to the case of k>2k>2 whereas ours hardness result only applies when k=2k=2.

On the algorithmic side, we show, in Section 4, that depth-2 ReLUs can be properly (agnostically) learned in time 2(k/ϵ)O(1)nO(1)2^{(k/\epsilon)^{O(1)}}n^{O(1)} provided that the inputs and weights of the units belong to the unit ball (see Section 4 for precise learning-theoretic definitions). To the best of our knowledge, only improper learning algorithms were known before [GKKT17]. The insight here is very simple: standard generalization bounds (similar to those used in [GKKT17]) imply that it suffices to consider only (k/ε)O(1)(k/\varepsilon)^{O(1)} samples. We then observe that the algorithm of [ABMM18] runs in exponential time in the number of samples. Putting these together immediately results in the proper learning algorithm.

We additionally show that, when the coefficients αj\alpha_{j}’s are all positive, they can be reliably properly learned (see Subsection 4.5 for more details) in similar running time. For the reliable model, we need to also take the advantage of the biases to ensure that there are few false positives. We remark here that Goel et al. [GKKT17] did not allow bias in their ReLUs and hence our algorithm for the reliable model would still be improper for their setting; nevertheless, our output (ReLUs with biases) is still arguably simpler than that of [GKKT17] (which is a “clipped” of a low degree polynomial). We note that, similar to [GKKT17], our algorithms work also for more general loss functions, as long as they are convex and Ok(1)O_{k}(1)-Lipschitz; we only focus on the squared loss for the simplicity of presentation.

Our lower bounds and algorithms contribute to the quest to understand how neural networks can be trained efficiently despite NP-hardness results. Specifically, while we prove NP-hardness results for training ReLUs, our learning results (paralleling those of [GKKT17] for improper learning) show that efficient trainingA proper learning algorithm immediately yields a polynomial time training algorithm with ε\varepsilon additive error for any constant ε>0\varepsilon>0 (i.e., an additive PTAS). (up to small additive errors) is possible when weights and inputs of bounded norms are concerned. The exponential dependency of our algorithms on k/ϵk/\epsilon makes them impractical, and we believe it is of interest to find faster algorithms for properly learning ReLUS.

Hardness of Training a Single ReLU

We start by showing NP-hardness of training a single ReLU:

ReLU training problem for a neural network consisting of a single ReLU is NP-hard.

For the simplicity of exposition, we will assume in all our hardness proofs (in this section and Section 3) that the biases are equal to zero. In Appendix A, we explain how our proofs can be easily extended to handle non-zero biases.

We reduce the set cover problem to the training ReLU problem. Recall that, in the set cover problem, we are given a set U={1,…,N}U=\{1,\ldots,N\} along with a family S={S1,…,SM}\mathcal{S}=\{S_{1},\ldots,S_{M}\} of MM subsets of UU. Our goal is to determine if one can choose kk subsets from S\mathcal{S} whose union equals S\mathcal{S}. Set cover is well known to be NP-hard.

We consider a ReLU with n=M+2n=M+2 variables. For each Si∈SS_{i}\in\mathcal{S}, we have a variable wSiw_{S_{i}}. We also have two dummy variables w1w_{1} and wϵw_{\epsilon}. Let α1=1\alpha_{1}=1 and ϵ=0.01/m2\epsilon=0.01/m^{2}.

We introduce the following training points. First, for each i∈Ui\in U, add an (M+2)(M+2)-dimensional vector having 11 for the coordinate corresponding to the dummy variable w1w_{1}, 11 in all coordinates that correspond to a subset in SS containing ii and to all other coordinates. We label this vector by . This labeled data point corresponds to the constraint

Second, for every j∈[M]j\in[M], add an (M+2)(M+2)-dimensional vector having 11 in the SjS_{j}-th location, 11 in the coordinate corresponding to wϵw_{\epsilon} and for all other coordinates. We label it by ϵ\epsilon. This corresponds to

We then add a vector having 11 in the coordinate corresponding to w1w_{1} and elsewhere. We label these vectors by 11. This corresponds to

We also add (k+1)(k+1) vectors having 11 in the coordinate corresponding to wϵw_{\epsilon} and elsewhere. We label these vectors by ϵ\epsilon. These vectors correspond to (k+1)(k+1) copies of the constraint

Finally, we set the target error to be ϵ2k\epsilon^{2}k where kk is the target value in the set cover instance. Clearly, this reduction runs in polynomial time.

We now prove the correctness of this reduction.

(YES Case) Assume that there is a set cover of size kk consisting of the subsets Sj1,…,SjkS_{j_{1}},\ldots,S_{j_{k}} in S\mathcal{S}. Assigning wSj1=wSj2=…=wSjk=−1,w1=1w_{S_{j_{1}}}=w_{S_{j_{2}}}=\ldots=w_{S_{j_{k}}}=-1,w_{1}=1, wϵ=ϵw_{\epsilon}=\epsilon and to all other variables results in an error of ϵ2⋅k\epsilon^{2}\cdot k. This is because exactly kk of the constraints from (3) are violated and each violated constraint contributes ϵ2\epsilon^{2} to the squared error. All other constraints are satisfied.

(NO Case) Suppose contrapositively that there is a weight vector w\mathbf{w} that results in an error of at most ϵ2k\epsilon^{2}k. First, observe that w1≥0.9w_{1}\geq 0.9; otherwise, the squared error from (4) is more than (0.1)2≥ϵ2k(0.1)^{2}\geq\epsilon^{2}k. Observe also that wϵ≤0.2/mw_{\epsilon}\leq 0.2/m; otherwise, the squared error from (5) must be more than (0.2/m−ϵ)2≥(0.1/m)2>ϵ2k(0.2/m-\epsilon)^{2}\geq(0.1/m)^{2}>\epsilon^{2}k. Moreover, notice that wϵw_{\epsilon} must be non-negative, since otherwise the (k+1)(k+1) copies of (5) must incur total error of (k+1)ϵ2>ϵ2k(k+1)\epsilon^{2}>\epsilon^{2}k.

Our main observation is that the family S<−wϵ={Sj:wSj<−wϵ}\mathcal{S}_{<-w_{\epsilon}}=\{S_{j}:w_{S_{j}}<-w_{\epsilon}\} is a set cover. The reason is as follows: if there is an element i∈Ui\in U that is not covered by S<−wϵ\mathcal{S}_{<-w_{\epsilon}}, then ∑i∈SjwSj≥−wϵ⋅m≥−0.2\sum_{i\in S_{j}}w_{S_{j}}\geq-w_{\epsilon}\cdot m\geq-0.2, which means that the corresponding constraint (2) for ii will incur already a squared error of at least (0.7)2>ϵ2k(0.7)^{2}>\epsilon^{2}k (recall that kk is no larger than mm). Thus, the observation follows.

The last step of the proof is to show that the family S<−wε\mathcal{S}_{<-w_{\varepsilon}} contains at most kk subsets. To see that this is the case, observe that, for every Sj∈S<−wεS_{j}\in\mathcal{S}_{<-w_{\varepsilon}}, we have [wϵ+wSj]+=0[w_{\epsilon}+w_{S_{j}}]_{+}=0, meaning that the corresponding constraint (3) incurs a squared error of ϵ2\epsilon^{2}. Since the total squared error is at most ϵ2k\epsilon^{2}k, we can immediately concludes that at most kk subsets belong to S<−wε\mathcal{S}_{<-w_{\varepsilon}}.

Thus, S<−wε\mathcal{S}_{<-w_{\varepsilon}} is a set cover with at most kk subsets, which completes the NO case of the proof. ∎

We remark that the above proof (and also that of Theorem 2 below) also works for the case where α1\alpha_{1} is treated as an unknown. This is because, if α1=−1\alpha_{1}=-1, then the error incurred in (4) (resp. in (8) below) already exceeds the target error. Thus, it must be that α1=+1\alpha_{1}=+1.

The reduction above coupled with the fact that set cover is hard to approximate within a factor O(log⁡∣U∣)O(\log|U|) [Fei98] immediately implies that the problem of approximating the minimum training error to within a factor of O(log⁡(nm))O(\log(nm)) is also hard. In this subsection, we will substantially improve this inapproximability ratio to an almost polynomial (i.e. (nm)1/polylog⁡log⁡(nm)(nm)^{1/\text{poly}\log\log(nm)}) factor:

Given an instance of the single ReLU training problem, it is NP-hard to approximate the minimum squared error to within a factor of (nm)1/(log⁡log⁡(nm))O(1)(nm)^{1/(\log\log(nm))^{O(1)}}.

To prove Theorem 2, we will reduce from the Minimum Monotone Circuit Satisfiability problem, which is formally defined below.

A monotone circuit is a circuit where each gate is either an OR or an AND gate. We use ∣C∣|C| to denote the number of wires in the circuit.

In the Minimum Monotone Circuit Satisfiabilityi (MMCSi) problem, we are given a monotone circuit of depth ii, and the objective is to assign as few Trues as possible to the input wires while ensuring that the circuit is satisfied (i.e. output wire is evaluated to True).

For any monotone circuit CC, we use OPT⁡\textscMMCS(C)\operatorname{OPT}_{\textsc{MMCS}}(C) to denote the optimum of the MMCS problem on CC, i.e., the smallest number of input wires need to be set to True so that CC is satisfied.

The hardness of approximating MMCS has long been studied (e.g. [ABMP01, DS04]). By now, this problem is known to be NP-hard to approximate to within a factor of ∣C∣1/(log⁡log⁡∣C∣)O(1)|C|^{1/(\log\log|C|)^{O(1)}}:

\textscMMCS3\textsc{MMCS}_{3} is NP-hard to approximate to within ∣C∣1/(log⁡log⁡∣C∣)O(1)|C|^{1/(\log\log|C|)^{O(1)}} factor.

Dummy Variable Constraint. We add the following constraint

Input Wire Constraint. For each input wire ii, we add the constraint

Output Wire Constraint. For the output wire oo, we add the constraint

OR Gate Constraint. For each OR gate with input wires i1,…,iki_{1},\dots,i_{k} and output wire jj, we add the constraint

AND Gate Constraint. For each AND gate with input wires i1,…,iki_{1},\dots,i_{k} and output wire jj, we add the following kk constraints:

We will now show that the minimum squared training error is exactly OPT⁡\textscMMCS(C)⋅ε2\operatorname{OPT}_{\textsc{MMCS}}(C)\cdot\varepsilon^{2}. First, we will show that the error is at most OPT⁡\textscMMCS(C)⋅ε2\operatorname{OPT}_{\textsc{MMCS}}(C)\cdot\varepsilon^{2}. Suppose that ϕ\phi is an assignment to CC with OPT⁡\textscMMCS(C)\operatorname{OPT}_{\textsc{MMCS}}(C) Trues that satisfies the circuit. We assign wϵ=ϵw_{\epsilon}=\epsilon, and, for each wire jj, we assign wjw_{j} to be 1 if the wire jj is evaluated to be True on input ϕ\phi and 0 otherwise. It is clear that every constraint is satisfied except the input wire constraints (7) for the wires that are assigned to True by ϕ\phi. There are exactly OPT⁡\textscMMCS(C)\operatorname{OPT}_{\textsc{MMCS}}(C) such wires, and each contributes ε2\varepsilon^{2} to the error; as a result, the training error of such weights is exactly OPT⁡\textscMMCS(C)⋅ε2\operatorname{OPT}_{\textsc{MMCS}}(C)\cdot\varepsilon^{2}.

Next, we will show that the minimum squared training error is at least OPT⁡\textscMMCS(C)⋅ε2\operatorname{OPT}_{\textsc{MMCS}}(C)\cdot\varepsilon^{2}. Suppose for the sake of contradiction that the minimum error δ\delta is less than OPT⁡\textscMMCS(C)⋅ε2\operatorname{OPT}_{\textsc{MMCS}}(C)\cdot\varepsilon^{2}. Observe that, from OPT⁡\textscMMCS(C)≤∣C∣\operatorname{OPT}_{\textsc{MMCS}}(C)\leq|C| and from our choice of ε\varepsilon, we have

Consider an assignment ϕ\phi that assigns each input wire ii to be True iff wi≥wϵw_{i}\geq w_{\epsilon}. The following proposition bounds the weight of every False wire.

For any wire jj at height hh that is evaluated to False on ϕ\phi, wj≤(2∣C∣)h⋅(ε+δ)w_{j}\leq(2|C|)^{h}\cdot(\varepsilon+\sqrt{\delta}).

Note that we define the height recursively by first letting the heights of all input wires be zero and then let the height of the output wire of each gate GG be one plus the maximum of the heights among all input wires of GG. The proof of this proposition, which is based on a simple induction, is deferred to Appendix C.

Now, consider the output wire oo. We claim that oo must be evaluated to True on ϕ\phi. Otherwise, Proposition 5 ensures that wow_{o} is at most

where the second inequality comes from our choice of ε\varepsilon. This would mean that the squared error incurred in (8) is at least 0.81>δ0.81>\delta. Thus, it must be that ϕ\phi satisfies CC.

Moreover, since ϕ\phi assigns each input wire ii to be True iff wi≥wϵw_{i}\geq w_{\epsilon}, each input wire that is assigned True incurs a squared error of ε2\varepsilon^{2} from (7). Thus, the number of input wires assigned True is at most δε2<OPT⁡\textscMMCS(C)\frac{\delta}{\varepsilon^{2}}<\operatorname{OPT}_{\textsc{MMCS}}(C), which is a contradiction as we argued that ϕ\phi satisfies CC. ∎

Observe that, in both Theorem 4 and Theorem 1, the target squared error tends to zero as the dimension tends to infinity. However, this is not an issue: if the norms of the sample vectors are not required to be bounded, then we can simply multiply them by any factor to make the error arbitrarily large. On the other hand, our learning algorithm below implies that, when the norms of samples and weights of ReLUs are bounded, we can approximate the minimum training error for kk ReLUs up to an additive error of ϵ\epsilon in time 2(k/ε)O(1)⋅poly(n)2^{(k/\varepsilon)^{O(1)}}\cdot poly(n).

NP-hardness of Training Two ReLUs

We next prove that, for two ReLUs, not only the training problem is NP-hard, but it is NP-hard to even determine whether the samples are realizable. (We remark that this also rules out any multiplicative approximation for the training problem with two ReLUs.) This is in contrast with the single ReLU case, where the realizable case is easy to solve (see Appendix B).

It is NP-hard to determine, given labeled samples of a network consisting of two ReLUs, whether it is possible to assign weights to the units such that the training error is .

We reduce from the 3SAT problem. Recall that, in the 3SAT problem, we are given 3CNF formulas with MM clauses on NN Boolean variables X1,…,XNX_{1},\dots,X_{N} and we would like to determine whether there exists an assignment that satisfies the formula.

The reduction proceeds as follows. Let n=N+1n=N+1 and m=2N+M+1m=2N+M+1. We view the nn-th coordinate of each sample as a coefficient of dummy variables which we will refer to as v1v^{1} (=wn1=w^{1}_{n}) and v2v^{2} (=wn2=w^{2}_{n}). Moreover, let α1=α2=1\alpha_{1}=\alpha_{2}=1.

The first sample has only one non-zero coordinate corresponding to vv which is set to one and has label 44, i.e., this corresponds to

Next, for every variable XiX_{i}, we add constraints

Finally, for each clause Cj=(b1∨b2∨b3)C_{j}=(b_{1}\vee b_{2}\vee b_{3}), we add a constraint as follows. For p=1,2,3p=1,2,3, let XipX_{i_{p}} denote the variable corresponding to the literal bpb_{p}; moreover, let npn_{p} be +1 if the literal is positive and -1 otherwise. We then add the following constraint for this clause:

The reduction clearly runs in polynomial time. Next, we argue the correctness of the reduction.

(YES Case) We will start with the YES case. Suppose that the formula is satisfiable. That is, there exists an assignment ϕ:[N]→{0,1}\phi:[N]\to\{0,1\} that satisfies all clauses. Set v1=1,v2=3v^{1}=1,v^{2}=3 and, for every i∈[N]i\in[N], wi1=2ϕ(i)−1w^{1}_{i}=2\phi(i)-1 and wi2=1−2ϕ(i)w^{2}_{i}=1-2\phi(i). It is easy to verify that all constraints are satisfied, i.e., that the samples are realizable by a sum of two ReLUs with boolean weights.

We remark that, once again, the hardness in Theorem 6 applies even to the case where α1,α2\alpha_{1},\alpha_{2} are treated as unknowns. Specifically, (13) and (14) already enforce both α1\alpha_{1} and α2\alpha_{2} to be positive.

Learning ReLUs

Another model we consider is the reliable agnostic learning model; in the real-valued setting, this model was first defined in [GKKT17], based on the model of [KKM12] for the standard PAC learning model. Informally speaking, reliability puts more emphasis on false positives, i.e., (x,y)(\mathbf{x},y) supported on D\mathcal{D} such that y=0y=0 but h(x)>0h(\mathbf{x})>0. The additional requirement is that such false positives should only happen with probability ≤ε\leq\varepsilon. (For motivations of the model, see e.g. [GKKT17].)

where L=0(h;D)=Pr⁡(x,y)∼D[h(x)>0∧y=0]\mathcal{L}_{=0}(h;\mathcal{D})=\Pr_{(\mathbf{x},y)\sim\mathcal{D}}[h(\mathbf{x})>0\wedge y=0] is the probability of false positive, and C+(D)={c∈C∣L=0(c;D)=0}\mathcal{C}^{+}(\mathcal{D})=\{c\in\mathcal{C}\mid\mathcal{L}_{=0}(c;\mathcal{D})=0\} denote all functions in the concept class that (with probability 1) do not admit any false positives. Similar to before, we say that A\mathcal{A} is proper if h∈Ch\in\mathcal{C}.

Before we move on, we remark that, in the reliable model, the error L(h;D)\mathcal{L}(h;\mathcal{D}) is only compared to L(c;D)\mathcal{L}(c;\mathcal{D}) for cc that does not admit any false positives, unlike in the (non-reliable) agnostic learning model where all c∈Cc\in\mathcal{C} are considered. In other words, the fact that a concept class C\mathcal{C} is reliably agnostically learnable does not necessarily imply that it is agnostically learnable. It is also not hard to verify that the fact that a concept class C\mathcal{C} is agnostically learnable does not imply that it is reliably agnostically learnable.

We now proceed to state our results. The concept classes we consider are the classes of sums of kk ReLUs, where each weight vector has norm at most one, and the distribution D\mathcal{D} is allowed to be any distribution on the unit ball. More specifically, the class ReLU(n,k)(n,k), which represent the sums of kk ReLUs, is defined as follows:

Let ReLU(n,k)(n,k) denote the class {\textscreluw1,…,wkb1,…,bk∣w1,…,wk∈Bn,b1,…,bk∈}\{\textsc{relu}_{\mathbf{w}^{1},\dots,\mathbf{w}^{k}}^{b_{1},\dots,b_{k}}\mid\mathbf{w}^{1},\dots,\mathbf{w}^{k}\in\mathcal{B}^{n},b_{1},\dots,b_{k}\in\}.

We show that, for any fixed number of ReLUs kk and error parameter ε>0\varepsilon>0, the class above can be efficiently agnostically properly learned (both reliably and non-reliably), as stated below.

Observe that both Theorems consider learning the sum of kk ReLUs, i.e., when α1=⋯=αk=1\alpha_{1}=\cdots=\alpha_{k}=1. For Theorem 7, the same result holds for arbitrary coefficients (with a similar proof). This theorem can be further generalized to the case where the coefficients α1,…,αk\alpha_{1},\dots,\alpha_{k} are unknowns with only 2k2^{k} multiplicative overhead to the running time, by enumerating all α1,…,αk∈{±1}\alpha_{1},\dots,\alpha_{k}\in\{\pm 1\}. On the other hand, it is unclear how to extend the algorithm in Theorem 8 to work for negative coefficients; however, we note that it is not even clear whether “reliable” makes sense in this case, since the predicted values can take negative values.

Our results above should be compared to those of [GKKT17] who showed similar results, except that their algorithm is improper: their output is a (“clipped” of) low-degree polynomial, as opposed to sums of ReLUs (which our algorithm outputs). While our algorithm is advantageous to theirs in this sense, theirs is fasterWe do not attempt to optimize our running time, for the sake of simplicity. Nevertheless, it is clear that our approach cannot go beyond 2O(k2/ε2)⋅(n/δ)O(1)2^{O(k^{2}/\varepsilon^{2})}\cdot(n/\delta)^{O(1)} time, which is still slower than the algorithms of [GKKT17]. and extends to a larger class of networks.

Our proof is simple. It first applies generalization bounds (similar to [GKKT17]) which implies that it suffices to take (k/ε)O(1)(k/\varepsilon)^{O(1)} samples and solve (even approximately) the training problem on these samples. Hence, by invoking the algorithm from Arora et al.’s work [ABMM18] (see Lemma 12), we immediately get Theorem 7.

To ensure the reliability guarantee (Theorem 8), we do not immediately output the minimizer hh from Arora et al.’s algorithm. Rather, we “shift” the biases by subtracting them with a small number. By doing so, for any x\mathbf{x} such that y=0y=0 and h(x)h(\mathbf{x}) is non-zero but not too large, the modified hypothesis makes sure that (x,y)(\mathbf{x},y) is not a false positive (see (19) below). This is a difference between our proof and the one used in [GKKT17] where all biases are assumed to be zero and hence they need to “clip” their hypothesis instead. This is also where we need the positivity of αj\alpha_{j}’s; if αj\alpha_{j}’s are allowed to be negative, it could be that h(x)h(\mathbf{x}) is small but it remains non-zero after bias shifts.

2 Generalization Bounds

Before we get to our proofs, we state the necessary generalization bounds; these are exactly the same as those used in [GKKT17]. (See Section 2.5 there.)

where Rm(F)\mathcal{R}_{m}(\mathcal{F}) is the Rademacher complexity of F\mathcal{F}.

Let X⊆Bn\mathcal{X}\subseteq\mathcal{B}^{n} and W={x↦<x,w>∣∥w∥2≤1}\mathcal{W}=\{\mathbf{x}\mapsto\left<\mathbf{x},\mathbf{w}\right>\mid\|w\|_{2}\leq 1\}. Then, Rm(W)≤1m\mathcal{R}_{m}(\mathcal{W})\leq\sqrt{\frac{1}{m}}.

3 Arora et al.’s Training Algorithm

Another ingredient is the algorithm of [ABMM18], which runs in time mO(kn)m^{O(kn)} and output the optimal training error (to within arbitrarily small accuracy). We observe that, for m≪nm\ll n, the running time becomes 2km⋅poly(n,m,k)2^{km}\cdot poly(n,m,k) which is even faster:

Since the result stated here is slightly different than the version in [ABMM18], we sketch its proof in Appendix D.

4 Properly Learning ReLUs

We now proceed to prove Theorem 7. When we invoke the algorithm from Lemma 12, we will ignore the accuracy parameter β\beta and pretend that the algorithm output an actual optimal solution. This is with out loss of generality as in the applications below we can always set β\beta sufficiently small such that it becomes negligible. We only choose to ignore it because the proof is much cleaner this way.

First, let us describe the algorithm. Given samples S={(xi,yi)}i∈[m]S=\{(\mathbf{x}_{i},y_{i})\}_{i\in[m]} whereIf there are more than mm samples, just consider mm of them.

we use the algorithm in Lemma 12 to solve for w1,…,wk,b1,…,bk\mathbf{w}_{1},\dots,\mathbf{w}_{k},b_{1},\dots,b_{k} that minimizes the training error. Then, output the hypothesis h=\textscreluw1,…,wkb1,…,bkh=\textsc{relu}_{\mathbf{w}_{1},\dots,\mathbf{w}_{k}}^{b_{1},\dots,b_{k}}.

Clearly, the algorithm is a proper learning algorithm (i.e. h∈h\in ReLUα1,…,αk(n,k){}_{\alpha_{1},\dots,\alpha_{k}}(n,k)). Furthermore, it runs in time 2kmpoly(n,m)=2O(k5/ε2)poly(n,1/δ)2^{km}poly(n,m)=2^{O(k^{5}/\varepsilon^{2})}poly(n,1/\delta).

Thus, we are left to bound the error L(h;D)\mathcal{L}(h;\mathcal{D}). Observe that, from Theorems 10 and 11, we have Rm(ReLU(n,1))≤2m\mathcal{R}_{m}(\text{ReLU}(n,1))\leq\frac{2}{\sqrt{m}}. Hence, from Fact 1, we have Rm(ReLU(n,k))≤2km\mathcal{R}_{m}(\text{ReLU}(n,k))\leq\frac{2k}{\sqrt{m}}. Since the squared loss function is (4k)(4k)-Lipschitz and (4k2)(4k^{2})-bounded in [0,2k]2[0,2k]^{2}, Theorem 9 implies that the following holds for all f∈ReLU(n,k)f\in\text{ReLU}(n,k) with probability at least 1−δ1-\delta:

For any c∈ReLU(n,k)c\in\text{ReLU}(n,k), since hh minimizes the training error,

5 Properly Reliably Learning ReLUs

Again, we start with our algorithm. Given samples S={(xi,yi)}i∈[m]S=\{(\mathbf{x}_{i},y_{i})\}_{i\in[m]} where

We use the algorithm from Lemma 12 to solve for w1,…,wk,b1,…,bk\mathbf{w}_{1},\dots,\mathbf{w}_{k},b_{1},\dots,b_{k} that minimizes the training error for the mm samples subject to the additional constraints that, for every sample xi\mathbf{x}_{i} with yi=0y_{i}=0, we have ∑j=1k[<wj,xi>+bj]+=0\sum_{j=1}^{k}[\left<\mathbf{w}_{j},\mathbf{x}_{i}\right>+b_{j}]_{+}=0. Then, let bj′=max⁡{−1,bj−γ}b^{\prime}_{j}=\max\{-1,b_{j}-\gamma\} for all j=1,…,kj=1,\dots,k where γ=ε12k2\gamma=\frac{\varepsilon}{12k^{2}} and output the hypothesis hshifted=\textscreluw1,…,wkb1′,…,bk′h_{\text{shifted}}=\textsc{relu}_{\mathbf{w}_{1},\dots,\mathbf{w}_{k}}^{b^{\prime}_{1},\dots,b^{\prime}_{k}}.

This is clearly a proper learning algorithm and runs in 2kmpoly(nm)=2O(k7/ε4)poly(n/δ)2^{km}poly(nm)=2^{O(k^{7}/\varepsilon^{4})}poly(n/\delta) time.

Thus, we are left to bound the loss. To do so, first recall (from the proof of Theorem 7) that Rm(ReLU(n,k))≤2km\mathcal{R}_{m}(\text{ReLU}(n,k))\leq\frac{2k}{\sqrt{m}}. Recall also that, for reliable learning, we need to bound two losses:

For convenience, let h=\textscreluw1,…,wkb1,…,bkh=\textsc{relu}_{\mathbf{w}_{1},\dots,\mathbf{w}_{k}}^{b_{1},\dots,b_{k}} be the minimizer before bias shifts.

Observe that, if h(x)≤γh(\mathbf{x})\leq\gamma, then the bias shifts ensure that hshifted(x)=0h_{\text{shifted}}(\mathbf{x})=0; this is because h(x)≤γh(\mathbf{x})\leq\gamma implies that <wj,x>+bj≤γ\left<\mathbf{w}_{j},\mathbf{x}\right>+b_{j}\leq\gamma for all j∈[k]j\in[k], which means that <wj,x>+bj′≤0\left<\mathbf{w}_{j},\mathbf{x}\right>+b^{\prime}_{j}\leq 0. (Note that this is the place where we need positivity of αj\alpha_{j}’s.) As a result, we have

Combining (19) and (18), we can conclude that the following holds with probability 1−δ/21-\delta/2:

where the last inequality also comes from the fact that h(xi)=0h(\mathbf{x}_{i})=0 for all ii with yi=0y_{i}=0, i.e., L^γ-cont(h;S)=0\hat{\mathcal{L}}_{\gamma\text{-cont}}(h;S)=0.

Bounding ℒℒ\mathcal{L}.

Notice that, for any x∈Bn\mathbf{x}\in\mathcal{B}^{n}, ∣h(x)−hshifted(x)∣≤k⋅γ|h(\mathbf{x})-h_{\text{shifted}}(\mathbf{x})|\leq k\cdot\gamma. Since the squared loss function is (4k)(4k)-Lipschitz in the domain [0,2k]2[0,2k]^{2}, it holds that

Finally, let cc be any function in ReLU(n,k)(n,k) such that c(x)=0c(\mathbf{x})=0 for all (x,y)(\mathbf{x},y) in the support of D\mathcal{D} such that y=0y=0. From how hh is computed, we must have

By combining the above bounds, the following holds with probability 1−δ/21-\delta/2:

which, together with (20), completes our proof. ∎

Acknowledgments

We are indebted to Adam Klivans for useful comments on an preliminary version of this work and for his suggestion to study the bounded norm case. We thank Amir Globerson and Amit Daniely for helpful discussions. We thank an anonymous reviewer for pointing out an error in a previous version of this work.

References

Appendix A Dealing with Biases In NP-hardness Proofs

As stated earlier, the proofs for NP-hardness results in the main body of the paper assumes that the biases b1,⋯ ,bkb_{1},\cdots,b_{k} are all zeros. However, all NP-hardness results apply even for unknown b1,…,bkb_{1},\dots,b_{k}, with little to no change. We elaborate on this below.

For Theorem 1, the same reduction establishes NP-hardness result when there is a bias variable b1b_{1} in the ReLU. In the YES case, we can simply set b1b_{1} to . In the NO case, we can get an assignment with the same squared error and no bias by replacing wϵw_{\epsilon} by wϵ−b1w_{\epsilon}-b_{1} and w1w_{1} by w1−b1w_{1}-b_{1}, and thereafter use the same arguments as in the proof of Theorem 1.

A.2 NP-hardness of Training Two ReLUs

For Theorem 6, we need to add two dummy variables vdummy1v^{1}_{\text{dummy}} and vdummy2v^{2}_{\text{dummy}}, and add the following constraints

The YES case proceeds the same as before, by additionally setting vdummy1=1,vdummy2=−1v^{1}_{\text{dummy}}=1,v^{2}_{\text{dummy}}=-1 and b1=b2=0b_{1}=b_{2}=0. In the NO case, these constraints force b1b_{1} and b2b_{2} to both be zero. The rest of the proof remains unchanged.

A.3 NP-hardness of Approximating Training Error of a Single ReLU

For Theorem 2, we add a dummy variable vdummyv_{\text{dummy}}, and add the following constraints:

Again, it is simple to see that the minimum training error is at most is at most OPT⁡\textscMMCS(C)⋅ε2\operatorname{OPT}_{\textsc{MMCS}}(C)\cdot\varepsilon^{2}, by additionally setting vdummy=1v_{\text{dummy}}=1 and b1=0b_{1}=0.

The other direction of the proof (i.e. that the minimum training error is at least OPT⁡\textscMMCS(C)⋅ε2\operatorname{OPT}_{\textsc{MMCS}}(C)\cdot\varepsilon^{2}) is more delicate. First, one needs to observe that ∣b1∣|b_{1}| cannot be more than 2δ2\sqrt{\delta}; otherwise, one of the three additional constraints must contribute to more than δ\delta to the training error. Then, we can once again use induction as before to prove a statement similar to Proposition 5, except that the bound will now be (2∣C∣)h⋅(ε+3δ)(2|C|)^{h}\cdot(\varepsilon+3\sqrt{\delta}). The rest of the proof proceeds as before. Once again, we will be able to conclude that ϕ\phi assign less than OPT⁡\textscMMCS(C)\operatorname{OPT}_{\textsc{MMCS}}(C) input wires to True but satisfies the circuit, which is a contradiction.

Appendix B Training a Single ReLU in the Realizable Case

Here we demonstrate that training a single ReLU in the realizable case can be done in polynomial time using linear programming. The key observation is the following.

Consider a system Λ\Lambda of mm equalities of the form [⟨vi,x⟩]+=ci[\langle{\mathbf{v}_{i}},{\mathbf{x}}\rangle]_{+}=c_{i} where vi\mathbf{v}_{i} are fixed nn-dimensional vectors and x\mathbf{x} is an nn-dimensional vector composed of the variables x1,…,xnx_{1},\ldots,x_{n}. Then there is a polynomial time algorithm in n,mn,m and the binary representation of the numbers in vi,civ_{i},c_{i} to determine if Λ\Lambda is feasible, and, in the feasible case, output an assignment to the xix_{i}’s satisfying all equalities in Λ\Lambda.

We show how to transform each equality to a linear equality or inequality. Consider [⟨vi,x⟩]+=ci[\langle{\mathbf{v}_{i}},{\mathbf{x}}\rangle]_{+}=c_{i}. If ci<0c_{i}<0 then the inequality is not satisfied by any assignment and Λ\Lambda has no solution. If ci>0c_{i}>0 then replace the equality by ⟨vi,x⟩=ci\langle{\mathbf{v}_{i}},{\mathbf{x}}\rangle=c_{i}. If ci=0c_{i}=0 then replace the equality by ⟨vi,x⟩≤0\langle{\mathbf{v}_{i}},{\mathbf{x}}\rangle\leq 0. Since transforming the equalities to linear (in)equalities can be done in polynomial time and as we can decide whether a system of linear inequalities over the reals is satisfiable in polynomial time using linear programing, the claimed statement follows. ∎

Recall a training sample {(xi,yi)}i∈[m]\{(\mathbf{x}_{i},y_{i})\}_{i\in[m]} of a single ReLU is called realizable if there exists a choice of weights wi,i∈[n]w_{i},i\in[n] and a bias bb such that [⟨xi,w⟩+b]+=yi[\langle{\mathbf{x}_{i}},{\mathbf{w}}\rangle+b]_{+}=y_{i} for all i∈[m]i\in[m]. Hence, the above lemma immediately implies that the training problem for a single ReLU can be solved in polynomial time for realizable samples.

Appendix C Missing proof of Proposition 5

Recall that we have the following constraints in our training sample:

Dummy Variable Constraint. We add the following constraint

OR Gate Constraint. For each OR gate with input wires i1,…,iki_{1},\dots,i_{k} and output wire jj, we add the constraint

AND Gate Constraint. For each AND gate with input wires i1,…,iki_{1},\dots,i_{k} and output wire jj, we add the following kk constraints:

We will prove by induction on the height hh.

Base Case. Consider any input wire ii (of height 0) that is assigned False by ϕ\phi. By definition of ϕ\phi, we have wi<wϵw_{i}<w_{\epsilon}. Note that wϵw_{\epsilon} must be at most ε+δ\varepsilon+\sqrt{\delta}, as otherwise the squared error incurred in (24) is already more than δ\delta. Thus, we have wi≤ε+δw_{i}\leq\varepsilon+\sqrt{\delta} as claimed.

jj is an output of an OR gate. Let i1,…,iki_{1},\dots,i_{k} be the inputs of the gate. Since jj is evaluated to False, i1,…,iki_{1},\dots,i_{k} must all be evaluated to False. From our inductive hypothesis, we have wi1,…,wik≤(2∣C∣)h−1⋅(ε+δ)w_{i_{1}},\dots,w_{i_{k}}\leq(2|C|)^{h-1}\cdot(\varepsilon+\sqrt{\delta}). Now, observe that wjw_{j} can be at most δ+wi1+⋯+wik\sqrt{\delta}+w_{i_{1}}+\cdots+w_{i_{k}}, as otherwise the squared error incurred in (25) would be more than δ\delta. As a result, we have

jj is an output of an AND gate. Let i1,…,iki_{1},\dots,i_{k} be the inputs of the gate. Since jj is evaluated to False, at least one of i1,…,iki_{1},\dots,i_{k} must all be evaluated to False. Let ii be one such wire. Observe that wjw_{j} can be at most δ+wi\sqrt{\delta}+w_{i}, as otherwise the squared error incurred in (26) would be more than δ\delta. Hence, we have

where the second inequality comes from the inductive hypothesis.

In both cases, we have wj<(2∣C∣)h⋅(ε+δ)w_{j}<(2|C|)^{h}\cdot(\varepsilon+\sqrt{\delta}), which concludes the proof of Proposition 5. ∎

Appendix D The Running Time of Arora et al.’s Algorithm

[ABMM18] gives a simple algorithm that runs in time nO(km)n^{O(km)} and outputs the optimal training error (to within arbitrarily small accuracy). Below, we observe that their algorithm also yields an 2km⋅poly(n,m,k)2^{km}\cdot poly(n,m,k) time algorithm; we use this running time guarantee for agnostically learning depth-2 networks of ReLUs. Before we proceed to the statement and the proof of the algorithm, we remark that, our NP-hardness proof for 2 ReLUs in fact also implies that, assuming the Exponential Time Hypothesis (ETH) [IP01, IPZ01]ETH states that 3SAT with nn variables and m=O(n)m=O(n) clauses cannot be solved in 2o(n)2^{o(n)} time., the training problem for 2 ReLUs cannot be done in 2o(m)2^{o(m)} time. Hence, the dependency mm in the exponent is tight in this sense.

up to an additive error of δ\delta. We assume the bit complexity of every number appearing in the coordinates of the xix_{i}’s and yiy_{i}’s is at most CC. Furthermore, there is an algorithm with the same running time up to polynomial factors that finds w1,…,wk∈Bn,b1,…,bk∈\mathbf{w}_{1},\dots,\mathbf{w}_{k}\in\mathcal{B}^{n},b_{1},\dots,b_{k}\in subjects to an additional constraint that ∑j∈[k][<wj,xj>+bj]+=0\sum_{j\in[k]}[\left<\mathbf{w}_{j},\mathbf{x}_{j}\right>+b_{j}]_{+}=0 for all ii such that yi=0y_{i}=0.

For each ReLU term [<wj,xi>+bj]+[\left<\mathbf{w}_{j},\mathbf{x}_{i}\right>+b_{j}]_{+} guess whether it equals or <wj,xi>+bj\left<\mathbf{w}_{j},\mathbf{x}_{i}\right>+b_{j} and replace the term in the error function accordingly. Furthermore, if the guess [<wj,xi>+bj]+=0[\left<\mathbf{w}_{j},\mathbf{x}_{i}\right>+b_{j}]_{+}=0 was made then add the linear constraint <wj,xi>+bj≤0\left<\mathbf{w}_{j},\mathbf{x}_{i}\right>+b_{j}\leq 0. Else, add the linear constraint <wj,xi>+bj≥0\left<\mathbf{w}_{j},\mathbf{x}_{i}\right>+b_{j}\geq 0. Finally add the constraints −1≤bi≤1,∥wi∥2≤1-1\leq b_{i}\leq 1,\|\mathbf{w}_{i}\|_{2}\leq 1 for all 1≤i≤k1\leq i\leq k. After all guesses are made we get a convex quadratically constrained quadratic program (QCQP). It is well known that such a convex optimization problem can be solved in time polynomial in n,m,1/δ,Cn,m,1/\delta,C using a separation oracles and the ellipsoid algorithm (see for example, [B+15], section 2.1). Since the number of guesses is at most (2m)k(2^{m})^{k}, the claim follows. For the second part of the lemma, simply substitute the constraint ∑j∈[k][<wj,xi>+bj]+=0\sum_{j\in[k]}[\left<\mathbf{w}_{j},\mathbf{x}_{i}\right>+b_{j}]_{+}=0 according to the guesses made and add the resulting linear constraint. The claim follows. ∎