T OWARDS R OBUST , L OCALLY L INEAR D EEP N ETWORKS
A BSTRACT
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 identiﬁes 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.
I NTRODUCTION
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 ﬁrst-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 reﬂected 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, ﬁrst-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 ﬁnding 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 ﬁnding 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 (cid:96) p margin — the maximum radius of (cid:96) 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 signiﬁcant 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 ﬁt 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.
R ELATED W ORK
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 deﬁned with afﬁne 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 ﬁxed, 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 coefﬁcients (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 speciﬁc 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´ufar, 2017;
Serra et al., 2018), and adversarial attacks (Cheng et al., 2017; Fischetti & Jo, 2017; Weng et al., 2018) or defense (Wong & Kolter, 2018).
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 certiﬁes the exact (cid:96)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 (cid:96) 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 (cid:96) 2 margin between data points and a linear classiﬁer, our approach instead maximizes the (cid:96) 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 classiﬁers in terms of decision boundaries (Elsayed et al., 2018).
Concurrently, Croce et al.
(2019) also leverages the (raw) (cid:96) p margin on small networks for adversarial training.
In contrast, we develop a smooth relaxation of the (cid:96) 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.
M ETHODOLOGY
To simplify the exposition, the approaches are developed under the notation of FC networks with
ReLU activations, which naturally generalizes to other settings.
We ﬁrst introduce notation, and then present our inference and learning algorithms.
All the proofs are provided in Appendix A.
3. N OTATION
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 N i and a i ∈ R N i to denote the vector of (raw) neurons and activated neurons in the i th layer, respectively.
We will use x and ainterchangeably to represent an input instance from R D = R N 0 .
With an FC architecture and ReLU activations, each a i and z i are computed with the transformation matrix W i ∈ R N i × N i − 1 and bias vector b i ∈ R N i as
[Equation]
where [ M ] denotes the set { 1 , . .
, M } .
We use subscript to further denote a speciﬁc neuron.
To avoid confusion from other instances ¯ x ∈ R D , we assert all the neurons z ij are functions of the speciﬁc 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 classiﬁcation 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 (cid:15),p ( x ) := { ¯ x ∈ R D : (cid:107) ¯ x − x (cid:107) p ≤ (cid:15) } to denote the (cid:96) p -ball around x with radius (cid:15) .
The activation pattern (Raghu et al., 2017) used in this paper is deﬁned as:
Deﬁnition 1.
(Activation Pattern)
An activation pattern is a set of indicators for neurons O
=
{ o i ∈ {− 1 , 1 } N i | i ∈
[ M ] } that speciﬁes the following functional constraints:
[Equation]
Each o ij is called an activation indicator.
Note that a point on the boundary of a linear region is feasible for multiple activation patterns.
The deﬁnition ﬁts the property of the activation pattern discussed in § 2.
We deﬁne ∇ x z ij to be the sub-gradient found by back-propagation using ∂ a i (cid:48) j (cid:48) /∂
z i (cid:48) j (cid:48) :
= max( o i (cid:48) j (cid:48) , 0) , ∀ j (cid:48) ∈
[ N i (cid:48) ] , i (cid:48) ∈
[ i − 1] , whenever o i (cid:48)
j (cid:48) is deﬁned in the context.
3. I NFERENCE FOR R EGIONS WITH S TABLE D ERIVATIVES
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 ﬁrst derive an explicit characterization of the feasible set on the input space R D with Lemma 2.
Lemma 2.
Given an activation pattern O with any feasible point x , each activation indicator o ij ∈
O induces a feasible set S ij ( x ) =
{ ¯ x ∈ R D : o ij [( ∇ x z ij ) (cid:62) ¯ x + ( z ij − ( ∇ x z ij ) (cid:62) x ) ] ≥ 0 } , and the feasible set of the activation pattern is equivalent to S ( x )=
∩ Mi =1 ∩ N i j =1 S ij ( 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 deﬁnition of ˆ (cid:15) x ,p , the (cid:96) p margin of x subject to its activation pattern: ˆ (cid:15) x ,p := max (cid:15)
[Equation]
where S ( x ) can be based on any feasible activation pattern O on x ; 3 therefore, ∂ a ij /∂ z ij at z ij =from now on can take 0 or 1 arbitrarily as long as consistency among sub-gradients {∇ x z ij | j ∈ [ N i ] ,
i ∈
[ M ] } is ensured with respect to some feasible activation pattern O .
Note that ˆ (cid:15) x ,p is a lower bound of the (cid:96) p margin subject to a derivative speciﬁcation (i.e., a complete linear region).
3.2. D IRECTIONAL V ERIFICATION , THE C ASES p = 1 AND p = ∞
We ﬁrst 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 ∃ ¯ (cid:15) ≥ 0 such that x + ¯ (cid:15) ∆ x ∈ S ( x ) , then f θ is linear in { x + (cid:15) ∆ x : 0 ≤ (cid:15) ≤ ¯ (cid:15) } .
The feasibility of x + ¯ (cid:15) ∆ x ∈ S ( x ) can be computed by simply checking whether x + ¯ (cid:15) ∆ x satisﬁes the activation pattern O in S ( x ) .
Proposition 4 can be applied to the feasibility problem on (cid:96) 1 -balls.
Proposition 5.
( (cid:96) 1 -ball Feasibility)
Given a point x , a feasible set S ( x ) , and an (cid:96) 1 -ball B (cid:15), 1 ( x ) with extreme points x 1 , . . .
, x 2 D , if x i ∈ S ( x ) , ∀ i ∈ [2 D ] , then f θ is linear in B (cid:15), 1 ( x ) .
Proposition 5 can be generalized for an (cid:96) ∞ -ball.
However, in high dimension D , the number of extreme points of an (cid:96) ∞ -ball is exponential to D , making it intractable.
Instead, the number of extreme points of an (cid:96) 1 -ball is only linear to D ( + (cid:15) and − (cid:15) for each dimension).
With the above methods to verify feasibility, we can do binary searches to ﬁnd the certiﬁcates of the margins for directional perturbations ˆ (cid:15) x , ∆ x := max { (cid:15) ≥ 0: x + (cid:15) ∆ x ∈ S ( x ) } (cid:15) and (cid:96) 1 -balls ˆ (cid:15) x , 1 .
The details are in Appendix B.
3.2. T HE CASE p =
The feasibility on ˆ (cid:15) x , 1 is tractable due to convexity of S ( x ) and its certiﬁcation is efﬁcient by a binary search; by further exploiting the polyhedron structure of S ( x ) , ˆ (cid:15) x , 2 can be certiﬁed analytically.
Proposition 6.
( (cid:96) 2 -ball Certiﬁcate)
Given a point x , ˆ (cid:15) x , 2 is the minimum (cid:96) 2 distance between x and the union of hyperplanes ∪ Mi =1 ∪ N i j =1 { ¯ x ∈ R D : ( ∇ x z ij ) (cid:62) ¯ x + ( z ij − ( ∇ x z ij ) (cid:62) x ) = 0 } .
To compute the (cid:96) 2 distance between x and the hyperplane induced by a neuron z i j , we evaluate | ( ∇ x z ij ) (cid:62) x
+ ( z ij − ( ∇ x z ij ) (cid:62) x ) | / (cid:107)∇ x z ij (cid:107) 2 = | z ij | / (cid:107)∇ x z ij (cid:107) 2 .
If we denote I as the set of hidden neuron indices { ( i, j ) | i ∈
[ M ] , j ∈
[ N i ] } , then ˆ (cid:15) x , 2 can be computed as ˆ (cid:15) x , 2 = min ( i,j ) ∈I | z ij | / (cid:107)∇ x z ij (cid:107) 2 , When has , ˆ (cid:15) x ,p is always 0 regardless of the choice of O . where all the z ij can be computed by a single forward pass.
4 We will show in § 4.1 that all the ∇ x z ij can also be computed efﬁciently by forward passes in parallel.
We refer readers to Figure 1c to see a visualization of the certiﬁcates on (cid:96) 2 margins.
3.2. T HE N UMBER OF C OMPLETE L INEAR R EGIONS
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 efﬁcient to compute given a mild condition.
Here we use # A to denote the cardinality of a set A , and we have
Lemma 7.
(Complete Linear Region Certiﬁcate)
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 } .
3. L EARNING : M AXIMIZING THE M ARGINS OF S TABLE D ERIVATIVES
In this section, we focus on methods aimed at maximizing the (cid:96) 2 margin ˆ (cid:15) x , 2 , since it is (sub- )differentiable.
We ﬁrst formulate a regularization problem in the objective to maximize the margin: min θ (cid:88) ( x , y ) ∈D (cid:20)
L ( f θ ( x ) , y ) − λ min ( i,j ) ∈I | z ij | (cid:107)∇ x z ij (cid:107)
[Equation]
However, the objective itself is rather rigid due to the inner-minimization and the reciprocal of (cid:107)∇ x z ij (cid:107) 2 .
Qualitatively, such rigid loss surface hinders optimization and may attend inﬁnity.
To alleviate the problem, we do a hinge-based relaxation to the distance function similar to SVM.
3.3. R ELAXATION
An ideal relaxation of Eq.
(4) is to disentangle | z ij | and (cid:107)∇ x z ij (cid:107) 2 for a smoother problem.
Our ﬁrst 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 satisﬁes min ( i,j ) ∈I
| z ij | > 0 , ∀ ( x , y ) ∈ D , then every optimal solution of Eq.
(5) is also optimal for Eq.
min
[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 (cid:96) 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:
[Equation]
[Equation] [Equation] [Figure] which pursues a similar goal to maximize the (cid:96) 2 margin in a linear model scenario, where the margin is computed between a linear hyperplane (the classiﬁer) and the training points.
To visualize the effect of the proposed methods, we make a toy 2D binary classiﬁcation 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.
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. I MPROVING S PARSE L EARNING S IGNALS
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 ˆ
I ( x , γ ) as the set of neurons with top γ percent relaxed loss (TSVM loss) on x .
The generalized loss is our ﬁnal objective for learning RObust Local
Linearity (R OLL ) and is written as:
[Equation]
A special case of Eq.
(9) is when γ = 100 (i.e. ˆ I ( 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 (cid:107)∇ x z ij (cid:107) 22 in Eq.
(9) between any two layers are highly correlated.
C OMPUTATION , A PPROXIMATE L EARNING , AND C OMPATIBILITY 4. P ARALLEL C OMPUTATION OF G RADIENTS
The (cid:96) 2 margin ˆ (cid:15) x , 2 and the R OLL 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 ij 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 ﬁxed 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
[Table]
D + 1 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.
To analyze the complexity of the proposed approach
[Table]
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 2 M operations, while back-propagation takes (cid:80) Mi
=1 2 iN i operations.
The detailed analysis is also in Appendix C.
A PPROXIMATE L EARNING
Despite the parallelizable computation of ∇ x z ij [Table] 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 R OLL loss in Eq.
(9) when ˆ I ( x , γ ) =
I .
Note that (cid:80) ( i,j ) ∈I C max(0 , 1 − | z ij | ) 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 efﬁciently computed using the procedure in § 4.1 and is in general storable within GPU memory.
In practice, we can uniformly sample D (cid:48) ( 1 ≤ D (cid:48) (cid:28) D ) input axes to have an unbiased approximation to Eq.
(10), where computing all the partial derivatives with respect to D (cid:48) axes only requires D (cid:48)
+ 1 times memory
(one hot vectors and a zero vector) than a typical forward pass for x .
4. C OMPATIBILITY
The proposed algorithms can be used on all the deep learning models with afﬁne transformations and piecewise linear activation functions by enumerating every neuron that will be imposed an
ReLU-like activation function as z ij .
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 signiﬁcant difference in performance (Springenberg et al., 2014).
E XPERIMENTS
In this section, we compare our approach (‘R OLL ’) 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 12 G memory.
5. MNIST
Evaluation Measures: 1) accuracy (ACC), 2) number of complete linear regions (#CLR), and 3) (cid:96) p margins of linear regions ˆ (cid:15) x ,p .
We compute the margin ˆ (cid:15) x ,p for each testing point x with p ∈ { 1 , 2 } , and we evaluate ˆ (cid:15) x ,p on 4 different percentiles P 25 , P 50 , P 75 , P 100 among the testing data. [Figure] [Table] [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 ˆ (cid:15) x , 2 among validation data given the same and 1% less validation accuracy compared to the baseline model.
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 satisﬁed with tight upper bound and lower bound, so a single number is reported.
Given the same performance, the R OLL 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 ˆ (cid:15) x , 1 and ˆ (cid:15) x , 2 among testing data is at least 0.98 for all the cases.
The lower #CLR in our approach than the baseline model reﬂects the existence of certain larger linear regions that span across different testing points.
All the points inside the same linear region in the R OLL 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 R OLL model.
We do a parameter analysis in Figure 2 with the ACC and
P 50 of ˆ (cid:15) x , 2 under different C, λ and γ when the other hyper-parameters are ﬁxed.
As expected, with increased C and λ , the accuracy decreases with an increased (cid:96) 2 margin.
Due to the smoothness of the curves, higher γ values reﬂect less sensitivity to hyper-parameters C and λ .
To validate the efﬁciency 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 R OLL loss ( γ = 100 ) in Eq.
(9) computed by back-propagation, 3) the same as 2) but computed by our perturbation algorithm, and 4) the approximate R OLL 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 (cid:96) 2 margins of the approximate R OLL 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. x ,p [Table] [Figure]
[Table]
5. S PEAKER I DENTIFICATION
We train RNNs for speaker identiﬁcation on a Japanese Vowel dataset from the UCI machine learning repository (Dheeru & Karra Taniskidou, 2017) with the ofﬁcial training/testing split.
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 ˆ (cid:15) x , 1 and ˆ (cid:15) x , 2 among all the cases are 0 .
We also conduct sensitivity analysis on the derivatives by ﬁnding ˆ (cid:15) x , ∆ x along each coordinate ∆ x ∈ ∪ i ∪ 12 j = {− e i,j , e i,j } ( e i,jk,l = 0 , ∀ k, l except e i,ji,j = 1 ), which identiﬁes the stability bounds [ˆ (cid:15) x , − e i,j , ˆ (cid:15) x , e i,j ] at each timestamp i and channel j that guarantees stable derivatives.
The visualization using the vanilla and our R OLL model with 98% ACC is in Figure 3.
Qualitatively, the stability bound of the
R OLL regularization is consistently larger than the vanilla model.
5. C ALTECH -
We conduct experiments on Caltech-256 (Grifﬁn 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 R OLL 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 ≈ 270 K ), computing the certiﬁcates ˆ (cid:15) x , 1 , ˆ (cid:15) 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 (cid:96) 1 distortion (over a uniform distribution) and the maximum (cid:96) 1 distortion within the intersection ¯
B (cid:15), ∞ ( x ) = B (cid:15), ∞ ( x ) ∩ X of an (cid:96) ∞ -ball and the domain of images
X = [0 , 1] 299 × 299 × 3 .
The (cid:96)gradient distortion is deﬁned as ∆( x , x (cid:48) , y ) :
= (cid:107)∇ x (cid:48)
f θ ( x (cid:48) )
y − ∇ x f θ ( x ) y (cid:107) 1 .
For a ﬁxed x , we refer to [Figure] the maximizer ∇ x (cid:48)
f θ ( x (cid:48) )
y as the adversarial gradient .
Computation of the maximum (cid:96) 1 distortion requires optimization, but gradient-based optimization is not applicable since the gradient of the loss involves the Hessian ∇ 2 x (cid:48)
f θ ( x (cid:48) )
y which is either 0 or ill-deﬁned 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 (cid:96) 1 distortion.
Due to computational limits, we only evaluate 1024 random images in the testing set for both maximum and expected (cid:96) 1 gradient distortions.
The (cid:96) ∞ -ball radius (cid:15) 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 R OLL 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 R OLL and vanilla model, respectively.
We visualize some examples in Figure 4 with the original and adversarial gradients for each loss.
Qualitatively, the R OLL 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.
C ONCLUSION
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 R OLL loss expands regions with provably stable derivatives, and further generalize the stable gradient property across linear regions.
A CKNOWLEDGMENTS
The authors acknowledge support for this work by a grant from Siemens Corporation, thank the anonymous reviewers for their helpful comments, and thank Hao He and Yonglong Tian for helpful discussions.
A P ROOFS A. P ROOF OF L EMMA
Lemma 2.
Given an activation pattern O with any feasible point x , each activation indicator o ij ∈
O induces a feasible set S ij ( x ) =
{ ¯ x ∈ R D : o ij [( ∇ x z ij ) (cid:62) ¯ x + ( z ij − ( ∇ x z ij ) (cid:62) x ) ] ≥ 0 } , and the feasible set of the activation pattern is equivalent to S ( x )=
∩ Mi =1 ∩ N i j =1 S ij ( x ) .
Proof.
For j ∈ [ N 1 ] , we have ∇ x z 1 j = W 1 j, : , ( z 1 j − ( ∇ x z 1 j ) (cid:62) x ) =
b 1 j .
If ¯ x is feasible to the ﬁxed activation pattern o 1 j , it is equivalent to that ¯ x satisﬁes the linear constraint
[Equation]
in the ﬁrst layer.
Assume ¯ x has satisﬁed all the constraints before layer i > 1 .
We know if all the previous layers follows the ﬁxed activation indicators, it is equivalent to rewrite each
[Equation] [Equation]
Then for j ∈ [ N i ] , it is clear that z ij is a ﬁxed linear function of x with linear weights equal to ∇ x z ij by construction.
If ¯ x is also feasible to the ﬁxed activation indicator o ij , it is equivalent to that ¯ x also satisﬁes the linear constraint
[Equation]
[Equation]
The proof follows by induction.
A. P ROOF OF P ROPOSITION
Proposition 4.
(Directional Feasibility)
Given a point x , a feasible set S ( x ) and a unit vector ∆ x , if ∃ ¯ (cid:15) ≥ 0 such that x + ¯ (cid:15) ∆ x ∈ S ( x ) , then f θ is linear in { x + (cid:15) ∆ x : 0 ≤ (cid:15) ≤ ¯ (cid:15) } .
Proof.
Since S ( x ) is a convex set and x , x + ¯ (cid:15) ∆ x ∈ S ( x ) , { x + (cid:15)
∆ x : 0 ≤ (cid:15) ≤ ¯ (cid:15) } ⊆ S ( x ) .
A. P ROOF OF P ROPOSITION
Proposition 5.
( (cid:96) 1 -ball Feasibility)
Given a point x , a feasible set S ( x ) , and an (cid:96) 1 -ball B (cid:15), 1 ( x ) with extreme points x 1 , . . .
, x 2 D , if x i ∈ S ( x ) , ∀ i ∈ [2 D ] , then f θ is linear in B (cid:15), 1 ( x ) .
Proof.
S ( x ) is a convex set and x i ∈ S ( x ) , ∀ i ∈ [2 D ] .
Hence, ∀ x (cid:48) ∈ B (cid:15), 1 ( x ) , we know x (cid:48) is a convex combination of x 1 , . . .
, x 2 D , which implies x (cid:48) ∈ S ( x ) .
A. P ROOF OF P ROPOSITION
Proposition 6.
( (cid:96) 2 -ball Certiﬁcate)
Given a point x , ˆ (cid:15) x , 2 is the minimum (cid:96) 2 distance between x and the union of hyperplanes ∪ M i =1 ∪ N i j =1 { ¯ x ∈ R D : ( ∇ x z i j ) (cid:62) ¯ x
+ ( z i j − ( ∇ x z i j ) (cid:62) x ) = 0 } .
Proof.
Since S ( x ) is a convex polyhedron and x ∈ S ( x ) , B (cid:15),
2 ( x ) ⊆ S ( x ) is equivalent to the statement: the hyperplanes induced from the linear constraints in S ( x ) are away from x for at least (cid:15) in (cid:96) 2 distance.
Accordingly, the minimizing (cid:96) 2 distance between x and the hyperplanes is the maximizing distance that satisﬁes B (cid:15), 2 ( x ) ⊆ S ( x ) .
A. P ROOF OF L EMMA
Lemma 7.
(Complete Linear Region Certiﬁcate)
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 } .
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 coefﬁcients f θ ( x ) on D x without distinguishing whether they are in the same connected region.
A. P ROOF OF L EMMA
Lemma 8.
If there exists a (global) optimal solution of Eq.
(4) that satisﬁes min ( i,j ) ∈I
| z ij | > 0 , ∀ ( x , y ) ∈ D , then every optimal solution of Eq.
(5) is also optimal for Eq.
[Equation]
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.
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.
Given the optimal model f θ in Eq.
(4) satisfying the constraint min ( i,j ) ∈I
| z ij | > 0 , ∀ ( x , y ) ∈ D , we construct a model feasible in Eq.
For i = 1 , ..., M , we compute the smallest neuron response δ ij = min ( x , y ) ∈D | z ij | in f θ , and revise its weights by the following rules:
[Equation]
The above rule only scale the neuron value of z ij 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.
Since the other optimal solutions in Eq.
(5) have the same loss as the constructed network, they are also optimal in Eq.
B C ERTIFICATE OF D IRECTIONAL M ARGIN AND (cid:96) 1 M ARGIN
To certify the directional margin ˆ (cid:15) x , ∆ x := max { (cid:15) ≥ 0:
x + (cid:15) ∆ x ∈ S ( x ) } (cid:15) along a given ∆ x , we can do a binary search between a lower bound (cid:15) l and upper bound (cid:15) u .
We initialize (cid:15) l 0 = 0 and run a subroutine to exponentially ﬁnd an arbitrary upper bound (cid:15) u 0 such that x + (cid:15) u 0 ∆ x / ∈ S ( x ) .
If (cid:15) u 0 does not exist, we have ˆ (cid:15) x , ∆ x = ∞ ; otherwise, a binary search is executed by iterating t as (cid:26) (cid:15) lt +1 :
= 0 .
5( (cid:15) lt + (cid:15) ut ) , (cid:15)
[Equation]
if
[Equation] [Equation]
(cid:15)
[Equation] [Equation]
( (cid:15)
[Equation]
, otherwise (15)
Clearly, x + (cid:15) lt ∆ x ∈ S ( x ) , x + (cid:15) ut
∆ x / ∈ S ( x ) always holds, and the gap between (cid:15)
lt and (cid:15) ut decreases exponentially fast: (cid:15) ut − (cid:15) lt = 0 .
5 t ( (cid:15) u 0 − (cid:15) l 0 ) , which upper-bounds ˆ (cid:15) x , ∆ x − (cid:15) lt ≤ (cid:15) ut − (cid:15) lt .
In practice, we run the binary search with ﬁnite iteration T and return the lower bound (cid:15) lT with an identiﬁable bound (cid:15) u T − (cid:15) 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 ii = 1 , e ij = 0 , ∀ j (cid:54) = i ), the margin ˆ (cid:15) x , 1 for the (cid:96) 1 -ball B (cid:15), 1 ( x ) can be certiﬁed by 1) computing the set of directional margins for each extreme point direction of an (cid:96) 1 ball { ˆ (cid:15) x , − e 1 , ˆ (cid:15) x , e 1 , . . .
, ˆ (cid:15) x , − e D , ˆ (cid:15) x , e D } , and 2) returning the minimum in the set as ˆ (cid:15) x , 1 .
C P ARALLEL C OMPUTATION OF THE G RADIENTS BY L INEARITY
We denote the corresponding neurons z ij and a ij of f θ in g θ as ˆ z ij (ˆ x ) and ˆ a ij (ˆ 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 ˆ o ij = max(0 , o ij ) ∈ { 0 , 1 } .
Note that since o is given, ˆ o is ﬁxed.
Then each layer in g θ is represented as:
[Equation]
We note that ˆ a i (ˆ x ) , ˆ o i , and ˆ z i (ˆ x ) are also functions of x , which we omitted for simplicity.
Since the new activation function ˆ o is ﬁxed given x , effectively it applies the same linearity to ˆ z ij as z ij in S ( x ) and each ˆ z ij (ˆ 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 ˆ z ij and z ij ) 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 ˆ z ij ( 0 ) and 2) feed a unit vector e k on the axis to get ˆ z ij ( e k ) .
Then the derivative of each neuron z ij with respect to x k can be computed as
[Equation]
where the ﬁrst equality comes from the linearity of ˆ z ij (ˆ 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 ij 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 ﬁrst 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 2 M 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 ij , it takes 2 i operations for backpropagation to compute its gradient ( i operations for each of the forward and backward pass).
Hence, it takes (cid:80) M i =1 2 iN i operations in total for back-propagations to compute the same thing.
D D YNAMIC P ROGRAMMING THE G RADIENTS
We can exploit the chain-rule of Jacobian to do dynamic programming for computing all the gradients of z ij .
Note that all the gradients of z ij in the i th layer can be represented by the Jacobian J x z i .
Then
1) For the ﬁrst 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 /entries for ReLU activations).
The dynamic programming approach is efﬁcient for fully connected networks, but is inefﬁcient for convolutional layers, where explicitly representing the convolutional operation in the form of linear transformation ( ∈ R N i +
× N i ) is expensive.
E D ERIVATIONS FOR M AXOUT /M AX - POOLING N ONLINEARITY
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 linear network with max-pooling nonlinearity, but we do not suggest to use it since a max-pooling neuron would induce new linear constraints; instead, we suggest to use convolution with large strides or average-pooling which do not incur any constraint.
For simplicity, we assume the target network has a single nonlinearity, which maps N neurons tooutput by the maximum
[Equation]
Then we can deﬁne the corresponding activation pattern
o
= o 11 ∈
[ N ] as which input is selected:
[Equation]
It is clear to see once an activation pattern is ﬁxed, the network again degenerates to a linear model, as the nonlinearity in the max-pooling effectively disappears.
Such activation pattern induces a feasible set in the input space where derivatives are guaranteed to be stable, but such representation may have a similar degenerate case where two activation patterns yield the same linear coefﬁcients.
The feasible set S ( x ) of a feasible activation pattern O = { o 11 } at x can be derived as:
[Equation]
To check its correctness, we know that Eq.
(21) is equivalent to
[Equation]
where the linear constraints are evident, and the feasible set is thus again a convex polyhedron.
As a result, all the inference and learning algorithms can be applied with the linear constraints.
Clearly, for each max-pooling neuron with N inputs, it will induce N − 1 linear constraints.
F I MPLEMENTATION D ETAILS ON THE T OY D ATASET
The FC model consists of M = 4 fully-connected hidden layers, where each hidden layer hasneurons.
The input dimension D is 2 and the output dimension L is 1 .
The loss function L ( f θ ( x ) , y ) is sigmoid cross entropy.
We train the model for 5000 epochs with Adam (Kingma & Ba, 2015) optimizer, and select the model among epochs based on the training loss.
We ﬁx C = 5 , and increase λ ∈ { 10 − 2 , . .
. , 10 2 } for both the distance regularization and relaxed regularization problems until the resulting classiﬁer is not perfect.
The tuned λ in both cases are 1 .
G I MPLEMENTATION D ETAILS ON MNIST D ATASET
The data are normalized with µ = 0 .
1307 and σ = 0 .
We ﬁrst compute the margin ˆ (cid:15) x ,p in the normalized data, and report the scaled margin σ ˆ (cid:15) x ,p in the table, which reﬂects the actual margin in the original data space since
[Equation]
[Equation]
so the reported margin should be perceived in the data space of X = [0 , 1] 28 × 28 .
We compute the exact R OLL loss during training (i.e., approximate learning is not used).
The FC model consists of M = 4 fully-connected hidden layers, where each hidden layer has 300 neurons.
The activation function is ReLU.
The loss function L ( f θ ( x ) , y ) is a cross-entropy loss with soft-max performed on f θ ( x ) .
The number of epochs is 20, and the model is chosen from the best validation loss from all the epochs.
We use stochastic gradient descent with Nesterov momentum.
The learning rate is 0 .
01 , the momentum is 0 . 5 , and the batch size is 64 .
Tuning: We do a grid search on λ, C, γ , with λ ∈ { 2 − 3 , . . .
, 2 2 } , C ∈ { 2 − 2 , . . .
, 2 3 } , γ ∈ { max , 25 , 50 , 75 , 100 } ( max refers to Eq.
(7)), and report the models with the largest validation ˆ (cid:15) 2 , 50 given the same and 1% less validation accuracy compared to the baseline model (the vanilla loss).
H I MPLEMENTATION D ETAILS ON THE J APANESE V OWEL D ATASET
The data are not normalized.
We compute the exact R OLL loss during training (i.e., approximate learning is not used).
The representation is learned with a single layer scoRNN, where the state embedding from the last timestamp for each sequence is treated as the representation along with a fully-connected layer to produce a prediction as f θ ( x ) .
We use LeakyReLU as the activation functions in scoRNN.
The dimension of hidden neurons in scoRNN is set to 512 .
The loss function L ( f θ ( x ) , y ) is a cross-entropy loss with soft-max performed on f θ ( x ) .
We use AMSGrad optimizer (Reddi et al., 2018).
The learning rate is 0 . 001 , and the batch size is 32 (sequences).
Tuning: We do a grid search on λ ∈ { 2 − 6 , . . .
, 2 3 } , C ∈ { 2 − 5 , . . .
, 2 7 } , and set γ = 100 .
The models with the largest testing ˆ (cid:15) 2 , 50 given the same and 1% less testing accuracy compared to the baseline model (the vanilla loss) are reported.
(We do not have validation data in this dataset, so the performance should be interpreted as validation.)
I I MPLEMENTATION D ETAILS ON C ALTECH -256 D ATASET
The data are normalized with µ = [0 . 485 , 0 .
456 , 0 . 406] , and σ = [0 . 225 , 0 . 225 , 0 .
225] (25) along each channel.
We train models on the normalized images, and establish a bijective mapping between the normalized distance and the distance in the original space with the trick introduced in Appendix G.
The bijection is applied to our sample-based approach to compute E x (cid:48) ∼ Unif ( B 8 / 256 , ∞ ( x ) ∩X )
[∆( x , x (cid:48) , y )] and max x (cid:48) ∈B 8 / 256 , ∞ ( x ) ∩X
[∆( x , x (cid:48) , y )] that we ensure the perturbed space is consistent with X
= [0 , 1] 299 × 299 × 3 and B 8 / 256 , ∞ ( x ) in the original space.
We download the pre-trained ResNet-18 (He et al., 2016) from PyTorch (Paszke et al., 2017), and we revise the model architecture as follows: 1) we replace the max-pooling after the ﬁrst convolutional layer with average-pooling to reduce the number of linear constraints (because max-pooling induces additional linear constraints on activation pattern, while average-pooling does not), and 2) we enlarge the receptive ﬁeld of the last pooling layer such that the output will be 512 dimension, since ResNet-18 is originally used for smaller images in ImageNet data (most implementations use 224 × 224 × 3 dimensional images for ImageNet while our data has even higher dimension 299 × 299 × 3 ).
We train the model with stochastic gradient descent with Nesterov momentum for 20 epochs.
The initial learning rate is 0 .
005 , which is adjusted to 0 .
after the ﬁrst 10 epochs.
The momentum is 0 .
The batch size is 32 .
The model achieving the best validation loss among the 20 epochs is selected.
Tuning: Since the training is computationally demanding, we ﬁrst ﬁx C = 8 , use only 18 samples ( 6 per channel) for approximate learning, and tune λ ∈ { 10 − 6 , 10 − 5 , . . .
} until the model yields signiﬁcantly inferior validation accuracy than the vanilla model.
Afterwards, we ﬁx λ to the highest plausible value ( λ = 0 . 001 ) and try to increase C ∈ { 8 , 80 , . . . } , but we found that C
= 8 is already the highest plausible value.
Finally, we train a model with 360 random samples ( 120 per channel) for approximate learning to improve the quality of approximation.
J I MPLEMENTATION D ETAILS OF THE G ENETIC A LGORITHM
We implement a genetic algorithm (GA)
(Whitley, 1994) with 4800 populations P and 30 epochs.
Initially, we ﬁrst uniformly sample 4800 samples (called chromosome in GA literature) in the domain B (cid:15), ∞ ( x ) ∩ X for P .
In each epoch,
∀ c ∈ P ,
we
evaluate the (cid:96) 1 distance of its gradient from that of the target x :
[Equation]
(Selection)
we sort the samples based on the (cid:96) 1 distance and keep the top 25% samples in the population (denoted as ˆ P ).
(Crossover) we replace the remaining 75% samples with a random linear combination of a pair ( c , c (cid:48) ) from ˆ P as:
[Equation]
(Projection)
For all the updated samples c ∈ P , we do an (cid:96) ∞ -projection to the domain B (cid:15), ∞ ( x ) ∩
X to ensure the feasibility.
Finally, the sample in P that achieves the maximum (cid:96) 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 V ISUALIZATION OF A DVERSARIAL G RADIENTS IN C ALTECHDATASET
We visualize the following images:
• Original image.
• Original gradient: the gradient on the original image.
• Adversarial gradient: the maximum (cid:96) 1 distorted gradient in B (cid:15), ∞ ( 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 ﬁnd 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:
Aggregating derivatives in each channel by summation.
Taking absolute value of aggregated derivatives.
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 (cid:96) 1 gradient distortions among the testing data on our R OLL model in
Figure 5 and 6, where the captions show the exact values of the maximum (cid:96) 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 ﬁgures in Figure 5 and 6 are chosen from the images that are the closest to the percentiles.
[Figure] [Figure]