Title: TOWARDS ROBUST, LOCALLY LINEAR DEEP NET-WORKS

Abstract: Deep networks realize complex mappings that are often understood by their locally linear behavior at or around points of interest. For example, we use the derivative of the mapping with respect to its inputs for sensitivity analysis, or to explain (obtain coordinate relevance for) a prediction. One key challenge is that such derivatives are themselves inherently unstable. In this paper, we propose a new learning problem to encourage deep networks to have stable derivatives over larger regions. While the problem is challenging in general, we focus on networks with piecewise linear activation functions. Our algorithm consists of an inference step that identifies a region around a point where linear approximation is provably stable, and an optimization step to expand such regions. We propose a novel relaxation to scale the algorithm to realistic models. We illustrate our method with residual and recurrent networks on image and sequence datasets. 1 

1. INTRODUCTION:

Complex mappings are often characterized by their derivatives at points of interest. Such derivatives with respect to the inputs play key roles across many learning problems, including sensitivity analysis. The associated local linearization is frequently used to obtain explanations for model predictions (Baehrens et al., 2010; Simonyan et al., 2013; Sundararajan et al., 2017; Smilkov et al., 2017) ; explicit first-order local approximations (Rifai et al., 2012; Goodfellow et al., 2015; Wang & Liu, 2016; Koh & Liang, 2017; Alvarez-Melis & Jaakkola, 2018b) ; or used to guide learning through regularization of functional classes controlled by derivatives (Gulrajani et al., 2017; Bellemare et al., 2017; Mroueh et al., 2018) . We emphasize that the derivatives discussed in this paper are with respect to the input coordinates rather than parameters.

The key challenge lies in the fact that derivatives of functions parameterized by deep learning models are not stable in general (Ghorbani et al., 2019) . State-of-the-art deep learning models (He et al., 2016; Huang et al., 2017) are typically over-parametrized (Zhang et al., 2017) , leading to unstable functions as a by-product. The instability is reflected in both the function values (Goodfellow et al., 2015) as well as the derivatives (Ghorbani et al., 2019; Alvarez-Melis & Jaakkola, 2018a) . Due to unstable derivatives, first-order approximations used for explanations therefore also lack robustness (Ghorbani et al., 2019; Alvarez-Melis & Jaakkola, 2018a) .

We note that gradient stability is a notion different from adversarial examples. A stable gradient can be large or small, so long as it remains approximately invariant within a local region. Adversarial examples, on the other hand, are small perturbations of the input that change the predicted output (Goodfellow et al., 2015) . A large local gradient, whether stable or not in our sense, is likely to contribute to finding an adversarial example. Robust estimation techniques used to protect against adversarial examples (e.g., (Madry et al., 2018) ) focus on stable function values rather than stable gradients but can nevertheless indirectly impact (potentially help) gradient stability. A direct extension of robust estimation to ensure gradient stability would involve finding maximally distorted derivatives and require access to approximate Hessians of deep networks.

In this paper, we focus on deep networks with piecewise linear activations to make the problem tractable. The special structure of this class of networks (functional characteristics) allows us to infer lower bounds on the p margin -the maximum radius of p -norm balls around a point where derivatives are provably stable. In particular, we investigate the special case of p = 2 since the lower bound has an analytical solution, and permits us to formulate a regularization problem to maximize it. The resulting objective is, however, rigid and non-smooth, and we further relax the learning problem in a manner resembling (locally) support vector machines (SVM) (Vapnik, 1995; Cortes & Vapnik, 1995) .

Both the inference and learning problems in our setting require evaluating the gradient of each neuron with respect to the inputs, which poses a significant computational challenge. For piecewise linear networks, given D-dimensional data, we propose a novel perturbation algorithm that collects all the exact gradients by means of forward propagating O(D) carefully crafted samples in parallel without any back-propagation. When the GPU memory cannot fit O(D) samples in one batch, we develop an unbiased approximation to the objective with a random subset of such samples.

Empirically, we examine our inference and learning algorithms with fully-connected (FC), residual (ResNet) (He et al., 2016) , and recurrent (RNN) networks on image and time-series datasets with quantitative and qualitative experiments. The main contributions of this work are as follows:

• Inference algorithms that identify input regions of neural networks, with piecewise linear activation functions, that are provably stable. • A novel learning criterion that effectively expand regions of provably stable derivatives.

• Novel perturbation algorithms that scale computation to high dimensional data.

• Empirical evaluation with several types of networks.

2. RELATED WORK:

For tractability reasons, we focus in this paper on neural networks with piecewise linear activation functions, such as ReLU (Glorot et al., 2011) and its variants (Maas et al., 2013; He et al., 2015; Arjovsky et al., 2016) . Since the nonlinear behavior of deep models is mostly governed by the activation function, a neural network defined with affine transformations and piecewise linear activation functions is inherently piecewise linear (Montufar et al., 2014) . For example, FC, convolutional neural networks (CNN) (LeCun et al., 1998) , RNN, and ResNet (He et al., 2016) are all plausible candidates under our consideration. We will call this kind of networks piecewise linear networks throughout the paper.

The proposed approach is based on a mixed integer linear representation of piecewise linear networks, activation pattern (Raghu et al., 2017) , which encodes the active linear piece (integer) of the activation function for each neuron; once an activation pattern is fixed, the network degenerates to a linear model (linear). Thus the feasible set corresponding to an activation pattern in the input space is a natural region where derivatives are provably stable (same linear function). Note the possible degenerate case where neighboring regions (with different activation patterns) nevertheless have the same end-to-end linear coefficients (Serra et al., 2018) . We call the feasible set induced by an activation pattern (Serra et al., 2018) a linear region, and a maximal connected subset of the input space subject to the same derivatives of the network (Montufar et al., 2014) a complete linear region. Activation pattern has been studied in various contexts, such as visualizing neurons (Fischetti & Jo, 2017) , reachability of a specific output value (Lomuscio & Maganti, 2017) , its connection to vector quantization (Balestriero & Baraniuk, 2018) , counting the number of linear regions of piecewise linear networks (Raghu et al., 2017; Montúfar, 2017; Serra et al., 2018) , and adversarial attacks (Cheng et al., 2017; Fischetti & Jo, 2017; Weng et al., 2018) or defense (Wong & Kolter, 2018) . Note the distinction between locally linear regions of the functional mapping and decision regions defined by classes (Wong & Kolter, 2018; Yan et al., 2018; Mirman et al., 2018; Croce et al., 2019) .

Here we elaborate differences between our work and the two most relevant categories above. In contrast to quantifying the number of linear regions as a measure of complexity, we focus on the local linear regions, and try to expand them via learning. The notion of stability we consider differs from adversarial examples. The methods themselves are also different. Finding the exact adversarial example is in general NP-complete (Katz et al., 2017; Sinha et al., 2018) , and mixed integer linear programs that compute the exact adversarial example do not scale (Cheng et al., 2017; Fischetti & Jo, 2017) . Layer-wise relaxations of ReLU activations (Weng et al., 2018; Wong & Kolter, 2018) are more scalable but yield bounds instead exact solutions. Empirically, even relying on relaxations, the defense (learning) methods (Wong & Kolter, 2018; Wong et al., 2018) are still intractable on ImageNet scale images (Deng et al., 2009) . In contrast, our inference algorithm certifies the exact 2 margin around a point subject to its activation pattern by forwarding O(D) samples in parallel. In a high-dimensional setting, where it is computationally challenging to compute the learning objective, we develop an unbiased estimation by a simple sub-sampling procedure, which scales to ResNet (He et al., 2016) on 299 × 299 × 3 dimensional images in practice.

The proposed learning algorithm is based on the inference problem with 2 margins. The derivation is reminiscent of the SVM objective (Vapnik, 1995; Cortes & Vapnik, 1995) , but differs in its purpose; while SVM training seeks to maximize the 2 margin between data points and a linear classifier, our approach instead maximizes the 2 margin of linear regions around each data point. Since there is no label information to guide the learning algorithm for each linear region, the objective is unsupervised and more akin to transductive/semi-supervised SVM (TSVM) (Vapnik & Sterin, 1977; Bennett & Demiriz, 1999) . In the literature, the idea of margin is also extended to nonlinear classifiers in terms of decision boundaries (Elsayed et al., 2018) . Concurrently, Croce et al. (2019) also leverages the (raw) p margin on small networks for adversarial training. In contrast, we develop a smooth relaxation of the p margin and novel perturbation algorithms, which scale the computation to realistic networks, for gradient stability.

The problem we tackle has implications for interpretability and transparency of complex models. The gradient has been a building block for various explanation methods for deep models, including gradient saliency map (Simonyan et al., 2013) and its variants (Springenberg et al., 2014; Sundararajan et al., 2017; Smilkov et al., 2017) , which apply a gradient-based attribution of the prediction to the input with nonlinear post-processings for visualization (e.g., normalizing and clipping by the 99 th percentile (Smilkov et al., 2017; Sundararajan et al., 2017) ). While one of the motivations for this work is the instability of gradient-based explanations (Ghorbani et al., 2019; Alvarez-Melis & Jaakkola, 2018a) , we focus more generally on the fundamental problem of establishing robust derivatives.

3. METHODOLOGY:

To simplify the exposition, the approaches are developed under the notation of FC networks with ReLU activations, which naturally generalizes to other settings. We first introduce notation, and then present our inference and learning algorithms. All the proofs are provided in Appendix A.

3.1. NOTATION:

We consider a neural network θ with M hidden layers and N i neurons in the i th layer, and the corresponding function f θ : R D → R L it represents. We use z i ∈ R Ni and a i ∈ R Ni to denote the vector of (raw) neurons and activated neurons in the i th layer, respectively. We will use x and a 0 interchangeably to represent an input instance from R D = R N0 . With an FC architecture and ReLU activations, each a i and z i are computed with the transformation matrix W i ∈ R Ni×Ni-1 and bias

EQUATION

) where [M ] denotes the set {1, . . . , M }. We use subscript to further denote a specific neuron. To avoid confusion from other instances x ∈ R D , we assert all the neurons z i j are functions of the specific instance denoted by x. The output of the network is a linear transformation of the last hidden layer

f θ (x) = W M +1 a M + b M +1 with W M +1 ∈ R L×N M and b M +1 ∈ R L .

The output can be further processed by a nonlinearity such as softmax for classification problems. However, we focus on the piecewise linear property of neural networks represented by f θ (x), and leverage a generic loss function L(f θ (x), y) to fold such nonlinear mechanism.

We use D to denote the set of training data (x, y), D x to denote the same set without labels y, and B ,p (x) := {x ∈ R D : xx p ≤ } to denote the p -ball around x with radius .

The activation pattern (Raghu et al., 2017) used in this paper is defined as: Definition 1. (Activation Pattern) An activation pattern is a set of indicators for neurons O = {o i ∈ {-1, 1} Ni |i ∈ [M ]} that specifies the following functional constraints:

EQUATION

Each o i j is called an activation indicator. Note that a point on the boundary of a linear region is feasible for multiple activation patterns. The definition fits the property of the activation pattern discussed in §2. We define ∇ x z i j to be the sub-gradient found by back-propagation using

∂a i j /∂z i j := max(o i j , 0), ∀j ∈ [N i ], i ∈ [i -1],

whenever o i j is defined in the context.

3.2. INFERENCE FOR REGIONS WITH STABLE DERIVATIVES:

Although the activation pattern implicitly describes a linear region, it does not yield explicit constraints on the input space, making it hard to develop algorithms directly. Hence, we first derive an explicit characterization of the feasible set on the input space R D with Lemma 2.2 Lemma 2. Given an activation pattern O with any feasible point x, each activation indicator

o i j ∈ O induces a feasible set S i j (x) = {x ∈ R D : o i j [(∇ x z i j ) x + (z i j -(∇ x z i j )

x )] ≥ 0}, and the feasible set of the activation pattern is equivalent to S(x)= ∩ M i=1 ∩ Ni j=1 S i j (x). Remark 3. Lemma 2 characterizes each linear region of f θ as the feasible set S(x) with a set of linear constraints with respect to the input space R D , and thus S(x) is a convex polyhedron.

The aforementioned linear property of an activation pattern equipped with the input space constraints from Lemma 2 yield the definition of ˆ x,p , the p margin of x subject to its activation pattern:

EQUATION

where S(x) can be based on any feasible activation pattern O on x;3 therefore, ∂a i j /∂z i j at z i j = 0 from now on can take 0 or 1 arbitrarily as long as consistency among sub-gradients

{∇ x z i j |j ∈ [N i ], i ∈ [M ]

} is ensured with respect to some feasible activation pattern O. Note that ˆ x,p is a lower bound of the p margin subject to a derivative specification (i.e., a complete linear region).

3.2.1. DIRECTIONAL VERIFICATION, THE CASES p = 1 AND p = ∞:

We first exploit the convexity of S(x) to check the feasibility of a directional perturbation. Proposition 4. (Directional Feasibility) Given a point x, a feasible set S(x) and a unit vector ∆x, if ∃¯ ≥ 0 such that x + ¯ ∆x ∈ S(x), then f θ is linear in {x + ∆x : 0 ≤ ≤ ¯ }.

The feasibility of x + ¯ ∆x ∈ S(x) can be computed by simply checking whether x + ¯ ∆x satisfies the activation pattern O in S(x). Proposition 4 can be applied to the feasibility problem on 1 -balls. Proposition 5. ( 1 -ball Feasibility) Given a point x, a feasible set S(x), and an 1 -ball B ,1 (x) with extreme points x 1 , . . . , x 2D , if

x i ∈ S(x), ∀i ∈ [2D], then f θ is linear in B ,1 (x).

Proposition 5 can be generalized for an ∞ -ball. However, in high dimension D, the number of extreme points of an ∞ -ball is exponential to D, making it intractable. Instead, the number of extreme points of an 1 -ball is only linear to D (+ andfor each dimension). With the above methods to verify feasibility, we can do binary searches to find the certificates of the margins for directional perturbations ˆ x,∆x := max { ≥0:x+ ∆x∈S(x)} and 1 -balls ˆ x,1 . The details are in Appendix B.

3.2.2. THE CASE p = 2:

The feasibility on ˆ x,1 is tractable due to convexity of S(x) and its certification is efficient by a binary search; by further exploiting the polyhedron structure of S(x), ˆ x,2 can be certified analytically. Proposition 6. ( 2 -ball Certificate) Given a point x, ˆ x,2 is the minimum 2 distance between x and the union of hyperplanes

∪ M i=1 ∪ Ni j=1 {x ∈ R D : (∇ x z i j ) x + (z i j -(∇ x z i j ) x) = 0}.

To compute the 2 distance between x and the hyperplane induced by a neuron z i j , we evaluate

|(∇ x z i j ) x + (z i j -(∇ x z i j ) x)|/ ∇ x z i j 2 = |z i j |/ ∇ x z i j 2 . If we denote I as the set of hidden neu- ron indices {(i, j)|i ∈ [M ], j ∈ [N i ]}, then ˆ x,2 can be computed as ˆ x,2 = min (i,j)∈I |z i j |/ ∇ x z i j 2 ,

where all the z i j can be computed by a single forward pass. 4 We will show in §4.1 that all the ∇ x z i j can also be computed efficiently by forward passes in parallel. We refer readers to Figure 1c to see a visualization of the certificates on 2 margins.

3.2.3. THE NUMBER OF COMPLETE LINEAR REGIONS:

The sizes of linear regions are related to their overall number, especially if we consider a bounded input space. Counting the number of linear regions in f θ is, however, intractable due to the combinatorial nature of the activation patterns (Serra et al., 2018) . We argue that counting the number of linear regions on the whole space does not capture the structure of data manifold, and we propose to certify the number of complete linear regions (#CLR) of f θ among the data points D x , which turns out to be efficient to compute given a mild condition. 

3.3. LEARNING: MAXIMIZING THE MARGINS OF STABLE DERIVATIVES:

In this section, we focus on methods aimed at maximizing the 2 margin ˆ x,2 , since it is (sub-)differentiable. We first formulate a regularization problem in the objective to maximize the margin:

min θ (x,y)∈D L(f θ (x), y) -λ min (i,j)∈I |z i j | ∇ x z i j 2 (4)

However, the objective itself is rather rigid due to the inner-minimization and the reciprocal of ∇ x z i j 2 . Qualitatively, such rigid loss surface hinders optimization and may attend infinity. To alleviate the problem, we do a hinge-based relaxation to the distance function similar to SVM.

3.3.1. RELAXATION:

An ideal relaxation of Eq. ( 4) is to disentangle |z i j | and ∇ x z i j 2 for a smoother problem. Our first attempt is to formulate an equivalent problem with special constraints which we can leverage. Lemma 8. If there exists a (global) optimal solution of Eq. (4) that satisfies min (i,j)∈I |z i j | > 0, ∀(x, y) ∈ D, then every optimal solution of Eq. ( 5) is also optimal for Eq. (4).

EQUATION

If the condition in Lemma 8 does not hold, Eq. ( 5) is still a valid upper bound of Eq. ( 4) due to a smaller feasible set. An upper bound of Eq. ( 5) can be obtained consequently due to the constraints:

EQUATION

We then derive a relaxation that solves a smoother problem by relaxing the squared root and reciprocal on the 2 norm as well as the hard constraint with a hinge loss to a soft regularization problem:

EQUATION

where C is a hyper-parameter. The relaxed regularization problem can be regarded as a maximum aggregation of TSVM losses among all the neurons, where a TSVM loss with only unannotated data D x can be written as: which pursues a similar goal to maximize the 2 margin in a linear model scenario, where the margin is computed between a linear hyperplane (the classifier) and the training points.

EQUATION

To visualize the effect of the proposed methods, we make a toy 2D binary classification dataset, and train a 4-layer fully connected network with 1) (vanilla) binary cross-entropy loss L(•, •), 2) distance regularization as in Eq. ( 4), and 3) relaxed regularization as in Eq. ( 7). Implementation details are in Appendix F. The resulting piecewise linear regions and prediction heatmaps along with gradient ∇ x f θ (x) annotations are shown in Figure 1 . The distance regularization enlarges the linear regions around each training point, and the relaxed regularization further generalizes the property to the whole space; the relaxed regularization possesses a smoother prediction boundary, and has a special central region where the gradients are 0 to allow gradients to change directions smoothly.

3.3.2. IMPROVING SPARSE LEARNING SIGNALS:

Since a linear region is shaped by a set of neurons that are "close" to a given a point, a noticeable problem of Eq. ( 7) is that it only focuses on the "closest" neuron, making it hard to scale the effect to large networks. Hence, we make a generalization to the relaxed loss in Eq. ( 7) with a set of neurons that incur high losses to the given point. We denote Î(x, γ) as the set of neurons with top γ percent relaxed loss (TSVM loss) on x. The generalized loss is our final objective for learning RObust Local Linearity (ROLL) and is written as:

EQUATION

A special case of Eq. ( 9) is when γ = 100 (i.e. Î(x, 100) = I), where the nonlinear sorting step effectively disappears. Such simple additive structure without a nonlinear sorting step can stabilize the training process, is simple to parallelize computation, and allows for an approximate learning algorithm as will be developed in §4.2. Besides, taking γ = 100 can induce a strong synergy effect, as all the gradient norms ∇ x z i j 2 2 in Eq. ( 9) between any two layers are highly correlated.

4. COMPUTATION, APPROXIMATE LEARNING, AND COMPATIBILITY:



4.1. PARALLEL COMPUTATION OF GRADIENTS:

The 2 margin ˆ x,2 and the ROLL loss in Eq. ( 9) demands heavy computation on gradient norms. While calling back-propagation |I| times is intractable, we develop a parallel algorithm without calling a single back-propagation by exploiting the functional structure of f θ .

Given an activation pattern, we know that each hidden neuron z i j is also a linear function of x ∈ S(x). We can construct another linear network g θ that is identical to f θ in S(x) based on the same set of parameters but fixed linear activation functions constructed to mimic the behavior of f θ in S(x). Due to the linearity of g θ , the derivatives of all the neurons to an input axis can be computed by forwarding two samples: subtracting the neurons with an one-hot input from the same neurons with a zero input. The procedure can be amortized and parallelized to all the dimensions by feeding To analyze the complexity of the proposed approach, we assume that parallel computation does not incur any overhead and a batch matrix multiplication takes a unit operation. To compute the gradients of all the neurons for a batch of inputs, our perturbation algorithm takes 2M operations, while back-propagation takes M i=1 2iN i operations. The detailed analysis is also in Appendix C.

4.2. APPROXIMATE LEARNING:

Despite the parallelizable computation of ∇ x z i j , it is still challenging to compute the loss for large networks in a high dimension setting, where even calling D + 1 forward passes in parallel as used in §4.1 is infeasible due to memory constraints. Hence we propose an unbiased estimator of the ROLL loss in Eq. ( 9) when Î(x, γ) = I. Note that (i,j)∈I C max(0, 1 -|z i j |) is already computable in one single forward pass. For the sum of gradient norms, we use the following equivalent decoupling:

EQUATION

where the summation inside the expectation in the last equation can be efficiently computed using the procedure in §4.1 and is in general storable within GPU memory. In practice, we can uniformly sample D (1 ≤ D D) input axes to have an unbiased approximation to Eq. ( 10), where computing all the partial derivatives with respect to D axes only requires D + 1 times memory (one hot vectors and a zero vector) than a typical forward pass for x.

4.3. COMPATIBILITY:

The proposed algorithms can be used on all the deep learning models with affine transformations and piecewise linear activation functions by enumerating every neuron that will be imposed an ReLU-like activation function as z i j . They do not immediately generalize to the nonlinearity of maxout/max-pooling (Goodfellow et al., 2013) that also yields a piecewise linear function. We provide an initial step towards doing so in the Appendix E, but we suggest to use an average-pooling or convolution with large strides instead, since they do not induce extra linear constraints as maxpooling and do not in general yield significant difference in performance (Springenberg et al., 2014) .

5. EXPERIMENTS:

In this section, we compare our approach ('ROLL') with a baseline model with the same training procedure except the regularization ('vanilla') in several scenarios. All the reported quantities are computed on a testing set. Experiments are run on single GPU with 12G memory.

5.1. MNIST:

Evaluation Measures: 1) accuracy (ACC), 2) number of complete linear regions (#CLR), and 3) p margins of linear regions ˆ x,p . We compute the margin ˆ x,p for each testing point x with p ∈ {1, 2}, and we evaluate ˆ x,p on 4 different percentiles P 25 , P 50 , P 75 , P 100 among the testing data. Table 2 : Running time for a gradient descent step of FC networks on MNIST dataset. The full setting refers to Eq. ( 9) (γ = 100), and 3-samples refers to approximating Eq. ( 10) with 3 samples. The results are shown in Table 1 . The tuned models have γ = 100, λ = 2, and different C as shown in the table. The condition in Lemma 7 for certifying #CLR is satisfied with tight upper bound and lower bound, so a single number is reported. Given the same performance, the ROLL loss achieves about 10 times larger margins for most of the percentiles than the vanilla loss. By tradingoff 1% accuracy, about 30 times larger margins can be achieved. The Spearman's rank correlation between ˆ x,1 and ˆ x,2 among testing data is at least 0.98 for all the cases. The lower #CLR in our approach than the baseline model reflects the existence of certain larger linear regions that span across different testing points. All the points inside the same linear region in the ROLL model with ACC= 98% have the same label, while there are visually similar digits (e.g., 1 and 7) in the same linear region in the other ROLL model. We do a parameter analysis in Figure 2 with the ACC and P 50 of ˆ x,2 under different C, λ and γ when the other hyper-parameters are fixed. As expected, with increased C and λ, the accuracy decreases with an increased 2 margin. Due to the smoothness of the curves, higher γ values reflect less sensitivity to hyper-parameters C and λ.

To validate the efficiency of the proposed method, we measure the running time for performing a complete mini-batch gradient descent step (starting from the forward pass) on average. We compare 1) the vanilla loss, 2) the full ROLL loss (γ = 100) in Eq. ( 9) computed by back-propagation, 3) the same as 2) but computed by our perturbation algorithm, and 4) the approximate ROLL loss in Eq. ( 10) computed by perturbations. The approximation is computed with 3 = D/256 samples.

The results are shown in Table 2 . The accuracy and 2 margins of the approximate ROLL loss are comparable to the full loss. Overall, our approach is only twice slower than the vanilla loss. The approximate loss is about 9 times faster than the full loss. Compared to back-propagation, our perturbation algorithm achieves about 12 times empirical speed-up. In summary, the computational overhead of our method is minimal compared to the vanilla loss, which is achieved by the perturbation algorithm and the approximate loss. Table 4 : ResNet on Caltech-256. Here ∆(x, x , y) denotes 1 gradient distortion ∇ x f θ (x ) y -∇ x f θ (x) y 1 (the smaller the better for each r percentile P r among the testing data).

Loss P@1 P@5 

EQUATION

5.2. SPEAKER IDENTIFICATION:

We train RNNs for speaker identification on a Japanese Vowel dataset from the UCI machine learning repository (Dheeru & Karra Taniskidou, 2017) with the official training/testing split. 6 The dataset has variable sequence length between 7 and 29 with 12 channels and 9 classes. We implement the network with the state-of-the-art scaled Cayley orthogonal RNN (scoRNN) (Helfrich et al., 2018) , which parameterizes the transition matrix in RNN using orthogonal matrices to prevent gradient vanishing/exploding, with LeakyReLU activation. The implementation details are in Appendix H. The reported models are based on the same criterion as §5.1.

The results are reported in Table 3 . With the same/1% inferior ACC, our approach leads to a model with about 4/20 times larger margins among the percentiles on testing data, compared to the vanilla loss. The Spearman's rank correlation between ˆ x,1 and ˆ x,2 among all the cases are 0.98. We also conduct sensitivity analysis on the derivatives by finding ˆ x,∆x along each coordinate ∆x ∈ ∪ i ∪ 12 j=1

{-e i,j , e i,j } (e i,j k,l = 0, ∀k, l except e i,j i,j = 1), which identifies the stability bounds [ˆ x,-e i,j , ˆ x,e i,j ] at each timestamp i and channel j that guarantees stable derivatives. The visualization using the vanilla and our ROLL model with 98% ACC is in Figure 3 . Qualitatively, the stability bound of the ROLL regularization is consistently larger than the vanilla model.

5.3. CALTECH-256:

We conduct experiments on Caltech-256 (Griffin et al., 2007) , which has 256 classes, each with at least 80 images. We downsize the images to 299 × 299 × 3 and train a 18-layer ResNet (He et al., 2016) with initializing from parameters pre-trained on ImageNet (Deng et al., 2009) . The approximate ROLL loss in Eq. ( 10) is used with 120 random samples on each channel. We randomly select 5 and 15 samples in each class as the validation and testing set, respectively, and put the remaining data into the training set. The implementation details are in Appendix I.

Evaluation Measures: Due to high input dimensionality (D ≈ 270K), computing the certificates ˆ x,1 , ˆ x,2 is computationally challenging without a cluster of GPUs. Hence, we turn to a samplebased approach to evaluate the stability of the gradients f θ (x) y for the ground-truth label in a local region with a goal to reveal the stability across different linear regions. Note that evaluating the gradient of the prediction instead is problematic to compare different models in this case.

Given labeled data (x, y), we evaluate the stability of gradient ∇ x f θ (x) y in terms of expected 1 distortion (over a uniform distribution) and the maximum 1 distortion within the intersection B ,∞ (x) = B ,∞ (x) ∩ X of an ∞ -ball and the domain of images X = [0, 1] 299×299×3 . The 1 gradient distortion is defined as ∆(x, x , y) := ∇ x f θ (x ) y -∇ x f θ (x) y 1 . For a fixed x, we refer to the maximizer ∇ x f θ (x ) y as the adversarial gradient. Computation of the maximum 1 distortion requires optimization, but gradient-based optimization is not applicable since the gradient of the loss involves the Hessian ∇ 2 x f θ (x ) y which is either 0 or ill-defined due to piecewise linearity. Hence, we use a genetic algorithm (Whitley, 1994) for black-box optimization. Implementation details are provided in Appendix J. We use 8000 samples to approximate the expected 1 distortion. Due to computational limits, we only evaluate 1024 random images in the testing set for both maximum and expected 1 gradient distortions. The ∞ -ball radius is set to 8/256.

The results along with precision at 1 and 5 (P@1 and P@5) are presented in Table 4 . The ROLL loss yields more stable gradients than the vanilla loss with marginally superior precisions. Out of 1024 examined examples x, only 40 and 42 gradient-distorted images change prediction labels in the ROLL and vanilla model, respectively. We visualize some examples in Figure 4 with the original and adversarial gradients for each loss. Qualitatively, the ROLL loss yields stable shapes and intensities of gradients, while the vanilla loss does not. More examples with integrated gradient attributions (Sundararajan et al., 2017) are provided in Appendix K.

6. CONCLUSION:

This paper introduces a new learning problem to endow deep learning models with robust local linearity. The central attempt is to construct locally transparent neural networks, where the derivatives faithfully approximate the underlying function and lends itself to be stable tools for further applications. We focus on piecewise linear networks and solve the problem based on a margin principle similar to SVM. Empirically, the proposed ROLL loss expands regions with provably stable derivatives, and further generalize the stable gradient property across linear regions. Proof. The number of different activation patterns is an upper bound since it counts the number of linear regions instead of the number of complete linear regions (a complete linear region can contain multiple linear regions). The number of different Jacobians is a lower bound since it only count the number of different linear coefficients f θ (x) on D x without distinguishing whether they are in the same connected region.

A.6 PROOF OF LEMMA 8 Lemma 8. If there exists a (global) optimal solution of Eq. ( 4) that satisfies min (i,j)∈I |z i j | > 0, ∀(x, y) ∈ D, then every optimal solution of Eq. ( 5) is also optimal for Eq. ( 4).

min θ (x,y)∈D L(f θ (x), y) -λ min (i,j)∈I |z i j | ∇ x z i j 2 , s.t. min (i,j)∈I |z i j | ≥ 1, ∀(x, y) ∈ D.

Proof. The proof is based on constructing a neural network feasible in Eq. ( 5) that has the same loss as the optimal model in Eq. ( 4). Since the optimum in Eq. ( 5) is lower-bounded by the optimum in Eq. ( 4) due to smaller feasible set, a model feasible in Eq. ( 5) and having the same loss as the optimum in Eq. ( 4) implies that it is also optimal in Eq. ( 5).

Given the optimal model f θ in Eq. ( 4) satisfying the constraint min (i,j)∈I |z i j | > 0, ∀(x, y) ∈ D, we construct a model feasible in Eq. ( 5). For i = 1, ..., M , we compute the smallest neuron response δ i j = min (x,y)∈D |z i j | in f θ , and revise its weights by the following rules:

EQUATION

The above rule only scale the neuron value of z i j without changing the value of all the higher layers, so the realized function of f θ does not change. That says, it achieves the same objective value as Eq. ( 4) while being feasible in Eq. ( 5), and thus being an optimum in both Eq. (4) and Eq. ( 5).

Since the other optimal solutions in Eq. ( 5) have the same loss as the constructed network, they are also optimal in Eq. ( 4).

B CERTIFICATE OF DIRECTIONAL MARGIN AND 1 MARGIN:

To certify the directional margin ˆ x,∆x := max { ≥0:x+ ∆x∈S(x)} along a given ∆x, we can do a binary search between a lower bound l and upper bound u . We initialize l 0 = 0 and run a subroutine to exponentially find an arbitrary upper bound u 0 such that x + u 0 ∆x / ∈ S(x). If u 0 does not exist, we have ˆ x,∆x = ∞; otherwise, a binary search is executed by iterating t as

EQUATION

Clearly, x + l t ∆x ∈ S(x), x + u t ∆x / ∈ S(x) always holds, and the gap between l t and u t decreases exponentially fast: u t -l t = 0.5 t ( u 0 -l 0 ), which upper-bounds ˆ x,∆x -l t ≤ u t -l t . In practice, we run the binary search with finite iteration T and return the lower bound l T with an identifiable bound u T -l T from the optimal solution. In our experiments, we run the binary search algorithm until the bound is less than 10 -7 .

If we denote e 1 , . . . , e D as the set of unit vector in each axis (e i i = 1, e i j = 0, ∀j = i), the margin ˆ x,1 for the 1 -ball B ,1 (x) can be certified by 1) computing the set of directional margins for each extreme point direction of an 1 ball {ˆ x,-e 1 , ˆ x,e 1 , . . . , ˆ x,-e D , ˆ x,e D }, and 2) returning the minimum in the set as ˆ x,1 .

C PARALLEL COMPUTATION OF THE GRADIENTS BY LINEARITY:

We denote the corresponding neurons z i j and a i j of f θ in g θ as ẑi j (x) and âi j (x) given x, highlighting its functional relationship with respect to a new input x. The network g θ is constructed with exactly the same weights and biases as f θ but with a well-crafted linear activation function ôi j = max(0, o i j ) ∈ {0, 1}. Note that since o is given, ô is fixed. Then each layer in g θ is represented as:

EQUATION

We note that âi (x), ôi , and ẑi (x) are also functions of x, which we omitted for simplicity. Since the new activation function ô is fixed given x, effectively it applies the same linearity to ẑi j as z i j in S(x) and each ẑi j (x) is linear to x, ∀x ∈ R D . As a direct result of linearity and the equivalence of g θ and f θ (and all the respective ẑi j and z i j ) in S(x), we have to following equality:

EQUATION

)

We then do the following procedure to collect the partial derivatives with respect to an input axis k: 1) feed a zero vector 0 to g θ to get ẑi j (0) and 2) feed a unit vector e k on the axis to get ẑi j (e k ). Then the derivative of each neuron z i j with respect to x k can be computed as

EQUATION

where the first equality comes from the linearity of ẑi j (x) with respect to any x. With the procedure, the derivative of all the neurons to an input dimension can be computed with 2 forward pass, which can be further scaled by computing all the gradients of z i j with respect to all the D dimensions with D + 1 forward pass in parallel. We remark that the implementation is very simple and essentially the same across all the piecewise linear networks.

To analyze the complexity of the proposed approach, we assume that parallel computation does not incur any overhead and a batch matrix multiplication takes a unit operation. In this setting, a typical forward pass up to the last hidden layer takes M operations. To compute the gradients of all the neurons for a batch of inputs, our perturbation algorithm first takes a forward pass to obtain the activation patterns for the batch of inputs, and then takes another forward pass with perturbations to obtain the gradients. Since both forward passes are done up to the last hidden layers, it takes 2M operations in total.

In contrast, back-propagation cannot be parallelized among neurons, so computing the gradients of all the neurons must be done sequentially. For each neuron z i j , it takes 2i operations for backpropagation to compute its gradient (i operations for each of the forward and backward pass). Hence, it takes M i=1 2iN i operations in total for back-propagations to compute the same thing.

D DYNAMIC PROGRAMMING THE GRADIENTS:

We can exploit the chain-rule of Jacobian to do dynamic programming for computing all the gradients of z i j . Note that all the gradients of z i j in the i th layer can be represented by the Jacobian J x z i . Then 1) For the first layer, the Jacobian is trivially J x z 1 = W 1 . 2) We then iterate higher layers with the Jacobian of previous layers by chain rules J x z i = W i J z i-1 a i-1 J x z i-1 , where J x z i-1 and W i are stored and J z i-1 a i-1 is simply the Jacobian of activation function (a diagonal matrix with 0/1 entries for ReLU activations). The dynamic programming approach is efficient for fully connected networks, but is inefficient for convolutional layers, where explicitly representing the convolutional operation in the form of linear transformation (∈ R Ni+1×Ni ) is expensive.

E DERIVATIONS FOR MAXOUT/MAX-POOLING NONLINEARITY:

Here we only make an introductory guide to the derivations for maxout/max-pooling nonlinearity. The goal is to highlight that it is feasible to derive inference and learning methods upon a piecewise 2. (Selection) we sort the samples based on the 1 distance and keep the top 25% samples in the population (denoted as P).

3. (Crossover) we replace the remaining 75% samples with a random linear combination of a pair (c, c ) from P as:

EQUATION

4. (Projection) For all the updated samples c ∈ P, we do an ∞ -projection to the domain B ,∞ (x) ∩ X to ensure the feasibility.

Finally, the sample in P that achieves the maximum 1 distance is returned. We didn't implement mutation in our GA algorithm due to computational reasons. For the readers who are not familiar with GA, we comment that the crossover operator is analogous to a gradient step where the direction is determined by other samples and the step size is determined randomly.

K VISUALIZATION OF ADVERSARIAL GRADIENTS IN CALTECH-256 DATASET:

We visualize the following images:

• Original image.

• Original gradient: the gradient on the original image.

• Adversarial gradient: the maximum 1 distorted gradient in B ,∞ (x) ∩ X .

• Image of adv. gradient: the image that yields adversarial gradient.

• Original int. gradient: the integrated gradient attribution (Sundararajan et al., 2017) on the original image. • Adversarial int. gradient: the integrated gradient attribution (Sundararajan et al., 2017) on the 'image of adv. gradient'. Note that we didn't perform optimization to find the image that yields the maximum distorted integrated gradient.

We follow a common implementation in the literature (Smilkov et al., 2017; Sundararajan et al., 2017) to visualize gradients and integrated gradients by the following procedure:

1. Aggregating derivatives in each channel by summation.

2. Taking absolute value of aggregated derivatives.

3. Normalizing the aggregated derivatives by the 99 th percentile 4. Clipping all the values above 1.

After this, the derivatives are in the range [0, 1] 299×299 , which can be visualized as a gray-scaled image. The original integrated gradient paper visualizes the element-wise product between the grayscaled integrated gradient and the original image, but we only visualize the integrated gradient to highlight its difference in different settings since the underlying images (the inputs) are visually indistinguishable.

We visualize the examples in Caltech-256 dataset that yield the P 25 , P 50 , P 75 , P 100 (P r denotes the r th percentile) of the maximum 1 gradient distortions among the testing data on our ROLL model in Figure 5 and 6, where the captions show the exact values of the maximum 1 gradient distortion for each image. Note that the exact values are slightly different from Table 4 , because each percentile in Table 4 is computed by an interpolation between the closest ranks (as in numpy.percentile), and the figures in Figure 5 and 6 are chosen from the images that are the closest to the percentiles. 

:

Project page: http://people.csail.mit.edu/guanghe/locally_linear.

Similar characterization also appeared in(Balestriero & Baraniuk, 2018) and, concurrently with our work,(Croce et al., 2019).

When x has multiple possible activation patterns O, ˆ x,p is always 0 regardless of the choice of O.

Concurrently, Croce et al. (2019) find that the p margin ˆ x,p can be similarly computed as min (i,j)∈I |z i j |/ ∇xz i j q , where • q is the dual norm of the p-norm.

When the network is FC (or can efficiently be represented as such), one can use a dynamic programming algorithm to compute the gradients(Papernot et al., 2016), which is included in Appendix D.

The parameter is tuned on the testing set and thus the performance should be interpreted as validation.

Figures and Tables:

Figure 1: Toy examples of a synthetic 2D classification task. For each model (regularization type), we show a prediction heatmap (smaller pane) and the corresponding locally linear regions. The boundary of each linear region is plotted with line segments, and each circle shows the 2 margin ˆ x,2 around the training point. The gradient is annotated as arrows with length proportional to its 2 norm.

Figure 2: Parameter analysis on MNIST dataset. P 50 of ˆ x,2 is the median of ˆ x,2 in the testing data.

(a) The 9 th channel of the sequence that yields P50 of ˆ x,2 on the ROLL model. (b) The 9 th channel of the sequence that yields P75 of ˆ x,2 on the ROLL model.

Figure 3: Stability bounds on derivatives on the Japanese Vowel dataset.

Figure 4: Visualization of the examples in Caltech-256 that yield the P 50 (above) and P 75 (below) of the maximum 1 gradient distortions among the testing data on our ROLL model. The adversarial gradient is found by maximizing the distortion ∆(x, x , y) over the ∞ -norm ball with radius 8/256.

PROOF OF LEMMA 7 Lemma 7. (Complete Linear Region Certificate) If every data point x ∈ D x has only one feasible activation pattern denoted as O(x), the number of complete linear regions of f θ among D x is upperbounded by the number of different activation patterns #{O(x)|x ∈ D x }, and lower-bounded by the number of different Jacobians #{J x f θ (x)|x ∈ D x }.

Figure 5: Visualization of the examples in Caltech-256 dataset that yield the P 25 (above) and P 50 (below) of the maximum 1 gradient distortions among the testing data on our ROLL model. For the vanilla model, the maximum 1 gradient distortion ∆(x, x , y) is equal to 893.3 for 'Projector' in Figure 5g and 1199.4 for 'Laptop' in Figure 5q. For the ROLL model, the maximum 1 gradient distortion ∆(x, x , y) is equal to 779.9 for 'Projector' in Figure 5e and 1045.4 for 'Laptop' in Figure 5o.

Figure 6: Visualization of the examples in Caltech-256 dataset that yield the P 75 (above) and P 100(below) of the maximum 1 gradient distortions among the testing data on our ROLL model. For the vanilla model, the maximum 1 gradient distortion ∆(x, x , y) is equal to 1547.1 for 'Bear' in Figure6gand 5473.5 for 'Rainbow' in Figure6q. For the ROLL model, the maximum 1 gradient distortion ∆(x, x , y) is equal to 1367.9 for 'Bear' in Figure6eand 3882.8 for 'Rainbow' in Figure6o.

Here we use #A to denote the cardinality of a set A, and we have Lemma 7. (Complete Linear Region Certificate) If every data point x ∈ D x has only one feasible activation pattern denoted as O(x), the number of complete linear regions of f θ among D x is upperbounded by the number of different activation patterns #{O(x)|x ∈ D x }, and lower-bounded by the number of different Jacobians #{J x f θ (x)|x ∈ D x }.

Table content: <table/>

FC networks on MNIST dataset. #CLR is the number of complete linear regions among the 10K testing points, and ˆ x,p shows the p margin for each r ∈ {25, 50, 75, 100} percentile P r . samples to g θ in parallel. We remark that the algorithm generalizes to all the piecewise linear networks, and refer readers to Appendix C for algorithmic details.5

Table content: <table><tr><td>Loss</td><td>C</td><td colspan="2">ACC #CLR</td><td colspan="2">ˆ x,1(×10</td><td>-4 )</td><td/><td/><td>ˆ x,2(×10 -4 )</td></tr><tr><td/><td/><td/><td>P 25</td><td>P 50</td><td colspan="2">P 75</td><td>P 100</td><td colspan="2">P 25 P 50 P 75 P 100</td></tr><tr><td>Vanilla</td><td/><td colspan="2">98% 10000 22</td><td>53</td><td colspan="2">106</td><td>866</td><td>3</td><td>6</td><td>13</td><td>91</td></tr><tr><td>ROLL</td><td colspan="2">0.25 98%</td><td colspan="5">9986 219 530 1056 6347</td><td>37</td><td>92 182 1070</td></tr><tr><td>ROLL</td><td colspan="2">1.00 97%</td><td colspan="5">8523 665 1593 3175 21825</td><td colspan="2">125 297 604 4345</td></tr><tr><td>D + 1</td><td/><td/><td/><td/><td/><td/><td/><td/></tr></table>

We use a 55, 000/5, 000/10, 000 split of MNIST dataset for training/validation/testing. Experiments are conducted on a 4-layer FC model with ReLU activations. The implementation details are in Appendix G. We report the two models with the largest median ˆ x,2 among validation data given the same and 1% less validation accuracy compared to the baseline model.

Table content: <table><tr><td/><td colspan="4">Vanilla ROLL (full; back-prop) ROLL (full; perturb) ROLL (3-samples; perturb)</td></tr><tr><td>second (×10 -5 )</td><td>129</td><td>31185</td><td>2667</td><td>298</td></tr></table>

RNNs on the Japanese Vowel dataset. ˆ x,p shows the p margin for each r ∈ {25, 50, 75, 100} percentile P r in the testing data (the larger the better).

Table content: <table><tr><td>Loss</td><td>λ</td><td>C ACC</td><td/><td colspan="2">ˆ x,1(×10 -6 )</td><td/><td/><td colspan="2">ˆ x,2(×10 -6 )</td></tr><tr><td/><td/><td/><td>P25</td><td>P50</td><td>P75</td><td>P100</td><td>P25</td><td>P50</td><td>P75</td><td>P100</td></tr><tr><td>Vanilla</td><td/><td>98%</td><td>66</td><td>177</td><td>337</td><td>1322</td><td>23</td><td>61</td><td>113</td><td>438</td></tr><tr><td>ROLL</td><td colspan="2">2 -5 2 4 98%</td><td>264</td><td>562</td><td>1107</td><td>5227</td><td>95</td><td>207</td><td>407</td><td>1809</td></tr><tr><td>ROLL</td><td colspan="6">2 -1 2 2 97% 1284 2898 6086 71235</td><td colspan="4">544 1249 2644 22968</td></tr></table>

Peer review (iclr2019):
 ########## Updated Review ########## The author(s) have presented a very good rebuttal, and I am impressed. My concerns have been addressed and my confusions have been clarified. To reflect this, I am raising my points to 8. It is a good paper, job well done. I enthusiastically recommend acceptance. ################################ A key challenge that presents the deep learning community is that state-of-the-art solutions are oftentimes associated with unstable derivatives, compromising the robustness of the network. In this paper, the author(s) explore the problem of how to train a neural network with stable derivatives by expanding the linear region associated with training samples. The author(s) studied deep networks with piecewise linear activations, which allow them to derive lower bounds on the margin with provably stable derivatives. In the special case of metric, this bound is analytic, albeit rigid and non-smooth. To avoid associated computational issues, the author(s) borrowed an idea from transductive/semi-supervised SVM (TSVM) to derive a relaxed formulation. In general, I find this paper rather interesting and well written. However, I do have a few concerns and confusions as listed below: Major ones: - I would prefer some elaborations on why the relaxation proposed in Eqn (8) serves to encourage the margin of L2 ball? What*s the working mechanism or heuristic behind this relaxation? This is supposedly one of the key techniques used in optimization, yet remains obscure. - On empirical gains, the author(s) claimed that "about 30 times larger margins can be achieved by trading off 1% accuracy." It seems that consistently yields inferior prediction accuracy. In my opinion, the author(s) failed to showcase the practical utility of their solution. A better job should be done to validate the claim `` The problem we tackle has implications to interpretability and transparency of complex models. ** - As always, gradient-based penalties suffer from heavy computational overhead. The final objectives derived in this paper (Eqn (7) & Eqn (9)) seem no exception to this, and perhaps even worse since the gradient is taken wrt each neuron. Could the author(s) provide statistics on empirical wallclock performance? How much drain does this extra gradient penalty impose on the training efficiency? Minor ones: - Just to clarify, does the | - | used in Eqn (9) for |I(x,.gamma)| denote counting measure? - I do not see the necessity of introducing Lemma 7 in the text. Please explain. - Lemma 8, ``... then any optimal solutions for the problem is also optimal for Eqn (4). ** Do you mean ``the following problem** (Eqn (5))?