Datasets:
Upload folder using huggingface_hub (part 10)
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
Files changed (50)
- md/train/rJxgknCcK7/rJxgknCcK7.mdAdded+317
- md/train/rJxpuoCqtQ/rJxpuoCqtQ.mdAdded+479
- md/train/rJxt0JHKvS/rJxt0JHKvS.mdAdded+475
- md/train/rJzIBfZAb/rJzIBfZAb.mdAdded+398
- md/train/rJzLciCqKm/rJzLciCqKm.mdAdded+572
- md/train/rYhBGWYm6AU/rYhBGWYm6AU.mdAdded+223
- md/train/rbdKZJxDWWx/rbdKZJxDWWx.mdAdded+214
- md/train/rcQdycl0zyk/rcQdycl0zyk.mdAdded+344
- md/train/rdT5GV-LnZU/rdT5GV-LnZU.mdAdded+529
- md/train/rh0vIXw6i33/rh0vIXw6i33.mdAdded+396
- md/train/rk49Mg-CW/rk49Mg-CW.mdAdded+267
- md/train/rk4Fz2e0b/rk4Fz2e0b.mdAdded+281
- md/train/rk4Qso0cKm/rk4Qso0cKm.mdAdded+340
- md/train/rk5UYassf/rk5UYassf.mdAdded+160
- md/train/rk5upnsxe/rk5upnsxe.mdAdded+327
- md/train/rk6H0ZbRb/rk6H0ZbRb.mdAdded+334
- md/train/rk6cfpRjZ/rk6cfpRjZ.mdAdded+239
- md/train/rk6qdGgCZ/rk6qdGgCZ.mdAdded+252
- md/train/rk8wKk-R-/rk8wKk-R-.mdAdded
- md/train/rk9eAFcxg/rk9eAFcxg.mdAdded
- md/train/rkA1f3NpZ/rkA1f3NpZ.mdAdded
- md/train/rkE3y85ee/rkE3y85ee.mdAdded
- md/train/rkE8pVcle/rkE8pVcle.mdAdded
- md/train/rkEFLFqee/rkEFLFqee.mdAdded
- md/train/rkEfPeZRb/rkEfPeZRb.mdAdded
- md/train/rkFBJv9gg/rkFBJv9gg.mdAdded
- md/train/rkGG6s0qKQ/rkGG6s0qKQ.mdAdded
- md/train/rkGZuJb0b/rkGZuJb0b.mdAdded
- md/train/rkGabzZgl/rkGabzZgl.mdAdded
- md/train/rkHVZWZAZ/rkHVZWZAZ.mdAdded
- md/train/rkKCdAdgx/rkKCdAdgx.mdAdded
- md/train/rkMW1hRqKX/rkMW1hRqKX.mdAdded
- md/train/rkQkBnJAb/rkQkBnJAb.mdAdded
- md/train/rkQu4Wb0Z/rkQu4Wb0Z.mdAdded
- md/train/rkRwGg-0Z/rkRwGg-0Z.mdAdded
- md/train/rkTBjG-AZ/rkTBjG-AZ.mdAdded
- md/train/rkTS8lZAb/rkTS8lZAb.mdAdded
- md/train/rkWN3g-AZ/rkWN3g-AZ.mdAdded
- md/train/rkYTTf-AZ/rkYTTf-AZ.mdAdded
- md/train/rkZB1XbRZ/rkZB1XbRZ.mdAdded
- md/train/rkZvSe-RZ/rkZvSe-RZ.mdAdded
- md/train/rkZzY-lCb/rkZzY-lCb.mdAdded
- md/train/rkaSvlnoG/rkaSvlnoG.mdAdded
- md/train/rkaT3zWCZ/rkaT3zWCZ.mdAdded
- md/train/rkaqxm-0b/rkaqxm-0b.mdAdded
- md/train/rkcQFMZRb/rkcQFMZRb.mdAdded
- md/train/rkcya1ZAW/rkcya1ZAW.mdAdded
- md/train/rkdU7tCaZ/rkdU7tCaZ.mdAdded
- md/train/rke3TJrtPS/rke3TJrtPS.mdAdded
- md/train/rke41hC5Km/rke41hC5Km.mdAdded
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317# FFJORD: FREE-FORM CONTINUOUS DYNAMICS FOR SCALABLE REVERSIBLE GENERATIVE MODELS
Will Grathwohl∗†‡ , Ricky T. Q. Chen∗†, Jesse Bettencourt†, Ilya Sutskever‡ , David Duvenaud†
# ABSTRACT
Reversible generative models map points from a simple distribution to a complex distribution through an easily invertible neural network. Likelihood-based training of these models requires restricting their architectures to allow cheap computation of Jacobian determinants. Alternatively, the Jacobian trace can be used if the transformation is specified by an ordinary differential equation. In this paper, we use Hutchinson’s trace estimator to give a scalable unbiased estimate of the logdensity. The result is a continuous-time invertible generative model with unbiased density estimation and one-pass sampling, while allowing unrestricted neural network architectures. We demonstrate our approach on high-dimensional density estimation, image generation, and variational inference, improving the state-ofthe-art among exact likelihood methods with efficient sampling.
# 1 INTRODUCTION
Reversible generative models use cheaply invertible neural networks to transform samples from a fixed base distribution. Examples include NICE (Dinh et al., 2014), Real NVP (Dinh et al., 2017), and Glow (Kingma & Dhariwal, 2018). These models are easy to sample from, and can be trained by maximum likelihood using the change of variables formula. However, this requires placing awkward restrictions on their architectures, such as partitioning dimensions or using rank one weight matrices, in order to avoid an $\mathcal { O } ( D ^ { 3 } )$ cost determinant computation.
Recently, Chen et al. (2018) introduced continuous normalizing flows (CNF), defining the mapping from latent variables to data using ordinary differential equations (ODE). In their model, the likelihood can be computed using trace operations costing only $\mathcal { O } ( D ^ { 2 } )$ . This allows a more flexible, but still restricted, family of network architectures to be used.
Extending this work, we introduce an unbiased stochastic estimator of the likelihood that has $\mathcal { O } ( D )$ time cost, allowing completely unrestricted architectures. Furthermore, we have implemented GPU-based adaptive ODE solvers to train and evaluate these models on modern hardware. We call our approach Free-form Jacobian of
 Figure 1: FFJORD transforms a simple base distribution at $t _ { 0 }$ into the target distribution at $t _ { 1 }$ by integrating over learned continuous dynamics.
Reversible Dynamics (FFJORD). Figure 1 shows FFJORD smoothly transforming a Gaussian distribution into a multi-modal distribution.
# 2 BACKGROUND: GENERATIVE MODELS AND CHANGE OF VARIABLES
In contrast to directly parameterizing a normalized distribution (e.g. Oord et al. (2016); Germain et al. (2015)), the change of variables formula allows one to specify a complex normalized distribution $p _ { \mathbf { x } } ( \mathbf { x } )$ implicitly by warping a normalized base distribution $p _ { \mathbf { z } } ( \mathbf { z } )$ through an invertible function $f : \mathbb { R } ^ { D } \overset { \cdot } { } \mathbb { R } ^ { D }$ . Given a random variable $\mathbf { z } \sim p _ { \mathbf { z } } ( \mathbf { z } )$ the log density of ${ \bf x } = f ( { \bf z } )$ follows
$$\log p _ { \mathbf { x } } ( \mathbf { x } ) = \log p _ { \mathbf { z } } ( \mathbf { z } ) - \log \operatorname* { d e t } \left| \frac { \partial f ( \mathbf { z } ) } { \partial \mathbf { z } } \right|$$
where $\partial f ( \mathbf { z } ) / \partial \mathbf { z }$ is the Jacobian of $f$ . In general, computing the log determinant has a time cost of $\mathcal { O } ( D ^ { 3 } )$ . Much work has gone into developing restricted neural network architectures which make computing the Jacobian’s determinant more tractable. These approaches broadly fall into three categories:
Normalizing flows. By restricting the functional form of $f$ , various determinant identities can be exploited (Rezende & Mohamed, 2015; Berg et al., 2018). These models cannot be trained as generative models from data because they do not have a tractable inverse $f ^ { - 1 }$ . However, they are useful for specifying approximate posteriors for variational inference (Kingma & Welling, 2014).
Autoregressive transformations. By using an autoregressive model and specifying an ordering of the dimensions, the Jacobian of $f$ is enforced to be lower triangular (Kingma et al., 2016; Oliva et al., 2018). These models excel at density estimation for tabular datasets (Papamakarios et al., 2017), but require $D$ sequential evaluations of $f$ to invert, which is prohibitive when $D$ is large.
Partitioned transformations. Partitioning the dimensions and using affine transformations makes the determinant of the Jacobian cheap to compute, and the inverse $\breve { f } ^ { - 1 }$ computable with the same cost as $f$ (Dinh et al., 2014; 2017). This method allows the use of convolutional architectures, excelling at density estimation for image data (Dinh et al., 2017; Kingma & Dhariwal, 2018).
Throughout this work, we refer to reversible generative models as those which use the change of variables to transform a base distribution to the model distribution while maintaining both efficient density estimation and efficient sampling capabilities using a single pass of the model.
# 2.1 OTHER GENERATIVE MODELS
There exist several approaches to generative modeling approaches which do not use the change of variables equation for training. Generative adversarial networks (GANs) (Goodfellow et al., 2014) use large, unrestricted neural networks to transform samples from a fixed base distribution. Lacking a closed-form likelihood, an auxiliary discriminator model must be trained to estimate divergences or density ratios in order to provide a training signal. Autoregressive models (Germain et al., 2015; Oord et al., 2016) directly specify the joint distribution $p ( \mathbf { x } )$ as a sequence of explicit conditional distributions using the product rule. These models require at least $\mathcal { O } ( D )$ evaluations to sample from. Variational autoencoders (VAEs) (Kingma & Welling, 2014) use an unrestricted architecture to explicitly specify the conditional likelihood $p ( x | z )$ , but can only efficiently provide a stochastic lower bound on the marginal likelihood $p ( x )$ .
# 2.2 CONTINUOUS NORMALIZING FLOWS
Chen et al. (2018) define a generative model for data $\mathbf { x } \in \mathbb { R } ^ { D }$ similar to those based on (1), but replace the warping function with an integral of continuous-time dynamics. The generative process first samples from a base distribution ${ \bf z } _ { 0 } \sim p _ { z _ { 0 } } ( { \bf z } _ { 0 } )$ . Then, given an ODE whose dynamics are defined by the parametric function $\partial \mathbf { z } ( t ) / \partial t = f ( \mathbf { z } ( t ) , t ; \theta )$ , we solve the initial value problem with $\mathbf { z } ( t _ { 0 } ) = \dot { \mathbf { z } } _ { 0 }$ to obtain a data sample ${ \mathbf x } = { \mathbf z } ( t _ { 1 } )$ . These models are called Continous Normalizing Flows (CNF). The change in log-density under this model follows a second differential equation, called the instantaneous change of variables formula (Chen et al., 2018):
$$\frac { \partial \log p ( { \bf z } ( t ) ) } { \partial t } = - \mathrm { T r } \left( \frac { \partial f } { \partial { \bf z } ( t ) } \right) .$$
We can compute total change in log-density by integrating across time:
$$\log p ( \mathbf { z } ( t _ { 1 } ) ) = \log p ( \mathbf { z } ( t _ { 0 } ) ) - \int _ { t _ { 0 } } ^ { t _ { 1 } } \operatorname { T r } \left( { \frac { \partial f } { \partial \mathbf { z } ( t ) } } \right) d t .$$
<table><tr><td colspan="2">Method</td><td rowspan="2">Train on data</td><td rowspan="2">One-pass Sampling</td><td rowspan="2">Exact/Unbiased Log- likelihood</td><td rowspan="2">Free- form Jacobian</td></tr><tr><td colspan="2"></td></tr><tr><td rowspan="4"></td><td>Variational Autoencoders</td><td></td><td></td><td>X</td><td>√</td></tr><tr><td>Generative Adversarial Nets</td><td></td><td>√</td><td>×</td><td>√</td></tr><tr><td>Likelihood-based Autoregressive</td><td></td><td>×</td><td>√</td><td>×</td></tr><tr><td>Normalizing Flows</td><td>X</td><td>√</td><td></td><td>X</td></tr><tr><td rowspan="3">o auegg 2aaiber</td><td>Reverse-NF,MAF, TAN</td><td></td><td>X</td><td></td><td>X</td></tr><tr><td>NICE,Real NVP, Glow, Planar CNF</td><td></td><td>√</td><td></td><td>X</td></tr><tr><td>FFJORD</td><td></td><td>「</td><td></td><td></td></tr></table>
Given a datapoint x, we can compute both the point $\mathbf { z } _ { 0 }$ which generates $\mathbf { x }$ , as well as $\log p ( \mathbf { x } )$ under the model by solving the combined initial value problem:
which integrates the combined dynamics of $z ( t )$ and the log-density of the sample backwards in time from $t _ { 1 }$ to $t _ { 0 }$ . We can then compute $\log p ( \mathbf { x } )$ using the solution of (4) and adding $\log p _ { z _ { 0 } } ( { \bf z } _ { 0 } )$ . The existence and uniqueness of (4) require that $f$ and its first derivatives be Lipschitz continuous (Khalil, 2002), which can be satisfied in practice using neural networks with smooth Lipschitz activations, such as softplus or tanh.
# 2.2.1 BACKPROPAGATING THROUGH ODE SOLUTIONS WITH THE ADJOINT METHOD
CNFs are trained to maximize (3). This objective involves the solution to an initial value problem with dynamics parameterized by $\theta$ . For any scalar loss function which operates on the solution to an initial value problem
$$L ( \mathbf { z } ( t _ { 1 } ) ) = L \left( \int _ { t _ { 0 } } ^ { t _ { 1 } } f ( \mathbf { z } ( t ) , t ; \theta ) d t \right)$$
then Pontryagin (1962) shows that its derivative takes the form of another initial value problem
$$\frac { d L } { d \theta } = - \int _ { t _ { 1 } } ^ { t _ { 0 } } \left( \frac { \partial L } { \partial \mathbf { z } ( t ) } \right) ^ { T } \frac { \partial f ( \mathbf { z } ( t ) , t ; \theta ) } { \partial \theta } d t .$$
The quantity $- { \partial L } / { \partial { \bf z } ( t ) }$ is known as the adjoint state of the ODE. Chen et al. (2018) use a black-box ODE solver to compute ${ \bf z } ( t _ { 1 } )$ , and then a separate call to a solver to compute (6) with the initial value ${ \partial L } / { \partial { \bf z } ( t _ { 1 } ) }$ . This approach is a continuous-time analog to the backpropgation algorithm (Rumelhart et al., 1986; Andersson, 2013) and can be combined with gradient-based optimization to fit the parameters $\theta$ by maximum likelihood.
# 3 SCALABLE DENSITY EVALUATION WITH UNRESTRICTED ARCHITECTURES
Switching from discrete-time dynamics to continuous-time dynamics reduces the primary computational bottleneck of normalizing flows from $\mathcal { O } ( D ^ { 3 } )$ to $\mathcal { O } ( D ^ { 2 } )$ , at the cost of introducing a numerical ODE solver. This allows the use of more expressive architectures. For example, each layer of the original normalizing flows model of Rezende & Mohamed (2015) is a one-layer neural network with only a single hidden unit. In contrast, the instantaneous transformation used in planar continuous normalizing flows (Chen et al., 2018) is a one-layer neural network with many hidden units. In this section, we construct an unbiased estimate of the log-density with $\mathcal { O } ( D )$ cost, allowing completely unrestricted neural network architectures to be used.
# 3.1 UNBIASED LINEAR-TIME LOG-DENSITY ESTIMATION
In general, computing $\operatorname { T r } \left( { \partial f } / { \partial \mathbf { z } ( t ) } \right)$ exactly costs $\mathcal { O } ( D ^ { 2 } )$ , or approximately the same cost as $D$ evaluations of $f$ , since each entry of the diagonal of the Jacobian requires computing a separate derivative of $f$ (Griewank & Walther, 2008). However, there are two tricks that can help. First, vector-Jacobian products ${ \pmb v } ^ { T } \frac { \partial f } { \partial { \bf z } }$ can be computed for approximately the same cost as evaluating $f$ using reverse-mode automatic differentiation. Second, we can get an unbiased estimate of the trace of a matrix by taking a double product of that matrix with a noise vector:
$$\operatorname { T r } ( A ) = \mathbb { E } _ { p ( \epsilon ) } [ \epsilon ^ { T } A \epsilon ] .$$
The above equation holds for any $D$ -by- $D$ matrix $A$ and distribution $p ( \epsilon )$ over $D$ -dimensional vectors such that $\mathbb { E } [ \boldsymbol { \epsilon } ] = 0$ and $\mathrm { C o v } ( \epsilon ) = I$ . The Monte Carlo estimator derived from (7) is known as Hutchinson’s trace estimator (Hutchinson, 1989; Adams et al., 2018).
To keep the dynamics deterministic within each call to the ODE solver, we can use a fixed noise vector $\epsilon$ for the duration of each solve without introducing bias:
$$\begin{array} { r l } & { \log p ( \mathbf { z } ( t _ { 1 } ) ) = \log p ( \mathbf { z } ( t _ { 0 } ) ) - \int _ { t _ { 0 } } ^ { t _ { 1 } } \operatorname { T r } \left( \frac { \partial f } { \partial \mathbf { z } ( t ) } \right) d t } \\ & { \qquad = \log p ( \mathbf { z } ( t _ { 0 } ) ) - \int _ { t _ { 0 } } ^ { t _ { 1 } } \mathbb { E } _ { p ( \epsilon ) } \left[ \epsilon ^ { T } \frac { \partial f } { \partial \mathbf { z } ( t ) } \epsilon \right] d t } \\ & { \qquad = \log p ( \mathbf { z } ( t _ { 0 } ) ) - \mathbb { E } _ { p ( \epsilon ) } \left[ \int _ { t _ { 0 } } ^ { t _ { 1 } } \epsilon ^ { T } \frac { \partial f } { \partial \mathbf { z } ( t ) } \epsilon d t \right] } \end{array}$$
Typical choices of $p ( \epsilon )$ are a standard Gaussian or Rademacher distribution (Hutchinson, 1989).
# 3.1.1 REDUCING VARIANCE WITH BOTTLENECK CAPACITY
Often, there exist bottlenecks in the architecture of the dynamics network, i.e. hidden layers whose width $H$ is smaller than the dimensions of the input $D$ . In such cases, we can reduce the variance of Hutchinson’s estimator by using the cyclic property of trace. Since the variance of the estimator for $\operatorname { T r } ( A )$ grows asymptotic to $| | \bar { A | | } _ { F } ^ { 2 }$ (Hutchinson, 1989), we suspect that having fewer dimensions should help reduce variance. If we view the dynamics as a composition of two functions $f = g \circ h ( \mathbf { z } )$ then we observe
$$\operatorname { T r } \underbrace { \left( { \frac { \partial f } { \partial \mathbf { z } } } \right) } _ { D \times D } = \operatorname { T r } \underbrace { \left( { \frac { \partial g } { \partial h } } { \frac { \partial h } { \partial \mathbf { z } } } \right) } _ { D \times D } = \operatorname { T r } \underbrace { \left( { \frac { \partial h } { \partial \mathbf { z } } } { \frac { \partial g } { \partial h } } \right) } _ { H \times H } = \mathbb { E } _ { p ( \epsilon ) } \left[ \epsilon ^ { T } { \frac { \partial h } { \partial \mathbf { z } } } { \frac { \partial g } { \partial h } } \epsilon \right] .$$
When $f$ has multiple hidden layers, we choose $H$ to be the smallest dimension. This bottleneck trick can reduce the norm of the matrix which may also help reduce the variance of the trace estimator. As introducing a bottleneck limits our model capacity, we do not use this trick in our experiments. However this trick can reduce variance when a bottleneck is used, as shown in our ablation studies.
# 3.2 FFJORD: A CONTINUOUS-TIME REVERSIBLE GENERATIVE MODEL
Our complete method uses the dynamics defined in (2) and the efficient log-likelihood estimator of (8) to produce the first scalable and reversible generative model with an unconstrained Jacobian. We call this method Free-Form Jacobian of Reversible Dyanamics (FFJORD). Pseudo-code of our method is given in Algorithm 1, and Table 1 summarizes the capabilities of our model compared to other recent generative modeling approaches.
Assuming the cost of evaluating $f$ is on the order of $\mathcal { O } ( D H )$ where $D$ is the dimensionality of the data and $H$ is the size of the largest hidden layer in $f$ , then the cost of computing the likelihood in models with repeated use of invertible transformations (1) is $\mathcal { O } ( ( D H + \bar { D ^ { 3 } } ) L )$ where $L$ is the number of transformations used. For CNF, this reduces to ${ \mathcal O } ( ( D H + D ^ { 2 } ) \hat { L } )$ for CNFs, where $\hat { L }$ is the number of evaluations of $f$ used by the ODE solver. With FFJORD, this reduces further to $\mathcal { O } ( ( D H + D ) \hat { L } )$ .
<table><tr><td colspan="2">Algorithm1 Unbiased stochastic log-density estimation using the FFJORD model Require: dynamics fe,start time to,stop time t1,data samples x,data dimension D.</td></tr><tr><td>∈ ← sample_unit_variance(x.shape) function faug([zt, log pt],t):</td><td>> Sample E outside of the integral >Augment f with log-density dynamics.</td></tr><tr><td>ft←fo(z(t),t) Taf</td><td>Evaluate neural network</td></tr><tr><td>g←εT zlz(t)</td><td> Compute vector-Jacobian product with automatic differentiation</td></tr><tr><td>Tr= ge return [ft,-Tr]</td><td> Unbiased estimateof Tr() with eTOfe</td></tr><tr><td>end function [zo,△logp] ←odeint(faug,[x,0],to,t1)</td><td>> Concatenate dynamics of state and log-density Solve theODE St fug([z(t),lgp(z(t)),t)t</td></tr></table>
# 4 EXPERIMENTS
We demonstrate FFJORD on a variety of density estimation tasks, and for approximate inference in variational autoencoders (Kingma & Welling, 2014). Experiments were conducted using a suite of GPU-based ODE-solvers and an implementation of the adjoint method for backpropagation1. In all experiments the RungeKutta 4(5) algorithm with the tableau from Shampine (1986) was used to solve the ODEs. We ensure tolerance is set low enough so numerical error is negligible; see Appendix C.
We used Hutchinson’s trace estimator (7) during training and the exact trace when reporting test results. This was done in all experiments except for our density estimation models trained on MNIST and CIFAR10 where computing the exact Jacobian trace was too expensive.
 Figure 2: Comparison of trained Glow, planar CNF, and FFJORD models on 2-dimensional distributions, including multi-modal and discontinuous densities.
The dynamics of FFJORD are defined by a neural network $f$ which takes as input the current state $\mathbf { z } ( t ) \in \mathbb { R } ^ { D }$ and the current time $t \in \mathbb { R }$ . We experimented with several ways to incorporate $t$ as an input to $f$ , such as hyper-networks, but found that simply concatenating $t$ on to ${ \bf z } ( t )$ at the input to every layer worked well and was used in all of our experiments.
# 4.1 DENSITY ESTIMATION ON TOY 2D DATA
We first train on 2 dimensional data to visualize the model and the learned dynamics.2 In Figure 2, we show that by warping a simple isotropic Gaussian, FFJORD can fit both multi-modal and even discontinuous distributions. The number of evaluations of the ODE solver is roughly 70-100 on all datasets, so we compare against a Glow model with 100 discrete layers.
The learned distributions of both FFJORD and Glow can be seen in Figure 2. Interestingly, we find that Glow learns to stretch the unimodal base distribution into multiple modes but has trouble modeling the areas of low probability between disconnected regions. In contrast, FFJORD is capable of modeling disconnected modes and can also learn convincing approximations of discontinuous density functions (middle row in Figure 2). Since the main benefit of FFJORD is the ability to train with deeper dynamics networks, we also compare against planar CNF (Chen et al., 2018) which can
 Figure 3: Samples and data from our image models. MNIST on left, CIFAR10 on right.
<table><tr><td></td><td>POWER</td><td>GAS</td><td>HEPMASS</td><td>MINIBOONE</td><td>BSDS300</td><td>MNIST</td><td>CIFAR10</td></tr><tr><td>Real NVP</td><td>-0.17</td><td>-8.33</td><td>18.71</td><td>13.55</td><td>-153.28</td><td>1.06*</td><td>3.49*</td></tr><tr><td>Glow</td><td>-0.17</td><td>-8.15</td><td>18.92</td><td>11.35</td><td>-155.07</td><td>1.05*</td><td>3.35*</td></tr><tr><td>FFJORD</td><td>-0.46</td><td>-8.59</td><td>14.92</td><td>10.43</td><td>-157.40</td><td>0.99* (1.05†)</td><td>3.40*</td></tr><tr><td>MADE</td><td>3.08</td><td>-3.56</td><td>20.98</td><td>15.59</td><td>-148.85</td><td>2.04</td><td>5.67</td></tr><tr><td>MAF</td><td>-0.24</td><td>-10.08</td><td>17.70</td><td>11.75</td><td>-155.69</td><td>1.89</td><td>4.31</td></tr><tr><td>TAN</td><td>-0.48</td><td>-11.19</td><td>15.12</td><td>11.01</td><td>-157.03</td><td>-</td><td>-</td></tr><tr><td>MAF-DDSF</td><td>-0.62</td><td>-11.96</td><td>15.09</td><td>8.86</td><td>-157.73</td><td>-</td><td>-</td></tr></table>
Table 2: Negative log-likehood on test data for density estimation models; lower is better. In nats for tabular data and bits/dim for MNIST and CIFAR10. \*Results use multi-scale convolutional architectures. †Results use a single flow with a convolutional encoder-decoder architecture.
be viewed as a single hidden layer network. Without the benefit of a flexible network, planar CNF is unable to model complex distributions.
# 4.2 DENSITY ESTIMATION ON REAL DATA
We perform density estimation on five tabular datasets preprocessed as in Papamakarios et al. (2017) and two image datasets; MNIST and CIFAR10. When reproducing Glow, we use the same configurations for Real NVP as Papamakarios et al. (2017) and add invertible fully connected layer between all coupling layers. On the tabular datasets, FFJORD performs the best out of reversible models by a wide margin but is outperformed by recent autoregressive models. Of those, FFJORD outperforms MAF (Papamakarios et al., 2017) on all but one dataset and manages to outperform TAN Oliva et al. (2018) on the MINIBOONE dataset. These models require $\mathcal { O } ( D )$ sequential computations to sample from while the best performing method, MAF-DDSF (Huang et al., 2018), cannot be sampled from without resorting to correlated or expensive sampling algorithms such as MCMC.
On MNIST we find that FFJORD can model the data as effectively as Glow and Real NVP using only a single flow defined by a single neural network. This is in contrast to Glow and Real NVP which must compose many flows to achieve similar performance. When we use multiple flows in a multiscale architecture (like those used by Glow and Real NVP) we obtain better performance on MNIST and comparable performance to Glow on CIFAR10. Notably, FFJORD is able to achieve this performance while using less than $2 \%$ as many parameters as Glow. We also note that Glow uses a learned base distribution whereas FFJORD and Real NVP use a fixed Gaussian. A summary of our results on density estimation can be found in Table 2 and samples can be seen in Figure 3. Full details on architectures used, our experimental procedure, and additional samples can be found in Appendix B.1.
In general, our approach is slower than competing methods, but we find the memory-efficiency of the adjoint method allows us to use much larger batch sizes than those methods. On the tabular datasets we used a batch sizes up to 10,000 and on the image datasets we used a batch size of 900.
# 4.3 VARIATIONAL AUTOENCODER
We compare FFJORD to other normalizing flows for use in variational inference. We train a VAE (Kingma & Welling, 2014) on four datasets using a FFJORD flow and compare to VAEs with no flow, Planar Flows (Rezende & Mohamed, 2015), Inverse Autoregressive Flow (IAF) (Kingma
<table><tr><td></td><td>MNIST</td><td>Omniglot</td><td>Frey Faces</td><td>Caltech Silhouettes</td></tr><tr><td>No Flow</td><td>86.55 ± .06</td><td>104.28 ± .39</td><td>4.53 ± .02</td><td>110.80 ± .46</td></tr><tr><td>Planar IAF</td><td>86.06 ± .31 84.20 ± .17</td><td>102.65 ± .42</td><td>4.40 ± .06</td><td>109.66 ± .42 111.58 ± .38</td></tr><tr><td></td><td></td><td>102.41 ± .04</td><td>4.47 ± .05</td><td></td></tr><tr><td>Sylvester</td><td>83.32 ± .06</td><td>99.00 ± .04</td><td>4.45 ± .04</td><td>104.62 ± .29</td></tr><tr><td>FFJORD</td><td>82.82 ± .01</td><td>98.33 ± .09</td><td>4.39 ± .01</td><td>104.03 ± .43</td></tr></table>
Table 3: Negative ELBO on test data for VAE models; lower is better. In nats for all datasets except Frey Faces which is presented in bits per dimension. Mean/stdev are estimated over 3 runs.
et al., 2016), and Sylvester normalizing flows (Berg et al., 2018). To provide a fair comparison, our encoder/decoder architectures and learning setup exactly mirror those of Berg et al. (2018).
In VAEs it is common for the encoder network to also output the parameters of the flow as a function of the input $\mathbf { x }$ . With FFJORD, we found this led to differential equations which were too difficult to integrate numerically. Instead, the encoder network outputs a low-rank update to a global weight matrix and an input-dependent bias vector. When used in recognition nets, neural network layers defining the dynamics inside FFJORD take the form
$$\mathrm { l a y e r } ( h ; \mathbf { x } , W , b ) = \sigma \left( \left( \underbrace { W } _ { D _ { o u t } \times D _ { i n } } + \underbrace { \hat { U } ( \mathbf { x } ) } _ { D _ { o u t } \times k } \underbrace { \hat { V } ( \mathbf { x } ) } _ { D _ { i n } \times k } ^ { T } \right) h + \underbrace { b } _ { D _ { o u t } \times 1 } + \underbrace { \hat { b } ( \mathbf { x } ) } _ { D _ { o u t } \times 1 } \right)$$
where $h$ is the input to the layer, $\sigma$ is an element-wise activation function, $D _ { i n }$ and $D _ { o u t }$ are the input and output dimension of this layer, and ${ \hat { U } } ( \mathbf { x } ) , { \hat { V } } ( \mathbf { x } ) , { \hat { b } } ( \mathbf { x } )$ are input-dependent parameters returned from an encoder network. A full description of the model architectures used and our experimental setup can be found in Appendix B.2.
On every dataset tested, FFJORD outperforms all other competing normalizing flows. A summary of our variational inference results can be found in Table 3.
# 5 ANALYSIS AND DISCUSSION
We performed a series of ablation experiments to gain a better understanding of the proposed model.
# 5.1 FASTER TRAINING WITH BOTTLENECK TRICK
We plotted the training losses on MNIST using an encoder-decoder architecture (see Appendix B.1 for details). Loss during training is plotted in Figure 4, where we use the trace estimator directly on the $D \times D$ Jacobian, or we use the bottleneck trick to reduce the dimension to $H \times H$ . Interestingly, we find that while the bottleneck trick (9) can lead to faster convergence when the trace is estimated using a Gaussian-distributed $\epsilon$ , we did not observe faster convergence when using a Rademacherdistributed $\epsilon$ .
 Figure 4: The variance of our model’s log-density estimator can be reduced using neural network architectures with a bottleneck layer, speeding up training.
# 5.2 NUMBER OF FUNCTION EVALUATIONS VS. DATA DIMENSION
The full computational cost of integrating the instantaneous change of variables (2) is $\mathcal { O } ( D H \widehat { L } )$ where $D$ is dimensionality of the data, $H$ is the size of the hidden state, and $\widehat { L }$ is the number of function evaluations (NFE) that the adaptive solver uses to integrate the ODE. In general, each evaluation of the model is $\mathcal { O } ( D H )$ and in practice, $H$ is typically chosen to be close to $D$ . Since the general form of the discrete change of variables equation (1) requires $\mathcal { O } ( D ^ { 3 } )$ -cost, one may wonder whether the number of evaluations $\widehat { L }$ depends on $D$ .
We train VAEs using FFJORD flows with increasing latent dimension $D$ . The NFE throughout training is shown in Figure 5. In all models, we find that the NFE increases throughout training, but converges to the same value, independent of $D$ . We conjecture that the number of evaluations is not dependent on the dimensionality of the data but the complexity of its distribution, or more specifically, how difficult it is to transform its density into the base distribution.
# 5.3 SINGLE-SCALE VS. MULTI-SCALE FFJORD
Crucial to the scalability of Real NVP and Glow is the multiscale architecture originally proposed in Dinh et al. (2017). We compare a single-scale encoder-decoder style FFJORD with a multiscale FFJORD on the MNIST dataset where both models have a comparable number of parameters and plot the total NFE–in both forward and backward passes–against the loss achieved in Figure 6. We find that while the single-scale model uses approximately one half as many function evaluations as the multiscale model, it is not able to achieve the same performance as the multiscale model.
 Figure 5: NFE used by the adaptive ODE solver is approximately independent of data-dimension. Lines are smoothed using a Gaussian filter.
 Figure 6: For image data, a single FFJORD flow can achieve near performance to multi-scale architecture while using half the number of evaluations.
# 6 SCOPE AND LIMITATIONS
Number of function evaluations can be prohibitive. The number of function evaluations required to integrate the dynamics is not fixed ahead of time, and is a function of the data, model architecture, and model parameters. This number tends to grow as the models trains and can become prohibitively large, even when memory stays constant due to the adjoint method. Various forms of regularization such as weight decay and spectral normalization (Miyato et al., 2018) can be used to reduce the this quantity, but their use tends to hurt performance slightly.
Limitations of general-purpose ODE solvers. In theory, our model can approximate any differential equation (given mild assumptions based on existence and uniqueness of the solution), but in practice our reliance on general-purpose ODE solvers restricts us to non-stiff differential equations that can be efficiently solved. ODE solvers for stiff dynamics exist, but they evaluate $f$ many more times to achieve the same error. We find that a small amount of weight decay regularizes the ODE to be sufficiently non-stiff.
# 7 CONCLUSION
We have presented FFJORD, a reversible generative model for high-dimensional data which can compute exact log-likelihoods and can be sampled from efficiently. Our model uses continuoustime dynamics to produce a generative model which is parameterized by an unrestricted neural network. All required quantities for training and sampling can be computed using automatic differentiation, Hutchinson’s trace estimator, and black-box ODE solvers. Our model stands in contrast to other methods with similar properties which rely on restricted, hand-engineered neural network architectures. We demonstrated that this additional flexibility allows our approach to achieve on-par or improved performance on density estimation and variational inference.
We believe there is much room for further work exploring and improving this method. FFJORD is empirically slower to evaluate than other reversible models like Real NVP or Glow, so we are interested specifically in ways to reduce the number of function evaluations used by the ODE-solver without hurting predictive performance. Advancements like these will be crucial in scaling this method to even higher-dimensional datasets.
# 8 ACKNOWLEDGEMENTS
We thank Yulia Rubanova and Roger Grosse for helpful discussions.
# REFERENCES
R. P. Adams, J. Pennington, M. J. Johnson, J. Smith, Y. Ovadia, B. Patton, and J. Saunderson. Estimating the Spectral Density of Large Implicit Matrices. ArXiv e-prints, February 2018.
Joel Andersson. A general-purpose software framework for dynamic optimization. PhD thesis, 2013.
Rianne van den Berg, Leonard Hasenclever, Jakub M Tomczak, and Max Welling. Sylvester normalizing flows for variational inference. arXiv preprint arXiv:1803.05649, 2018.
Ricky T. Q. Chen, Yulia Rubanova, Jesse Bettencourt, and David Duvenaud. Neural ordinary differential equations. Advances in Neural Information Processing Systems, 2018.
Laurent Dinh, David Krueger, and Yoshua Bengio. NICE: Non-linear independent components estimation. International Conference on Learning Representations Workshop, 2014.
Laurent Dinh, Jascha Sohl-Dickstein, and Samy Bengio. Density estimation using Real NVP. International Conference on Learning Representations, 2017.
Mathieu Germain, Karol Gregor, Iain Murray, and Hugo Larochelle. Made: Masked autoencoder for distribution estimation. In International Conference on Machine Learning, pp. 881–889, 2015.
Ian Goodfellow, Jean Pouget-Abadie, Mehdi Mirza, Bing Xu, David Warde-Farley, Sherjil Ozair, Aaron Courville, and Yoshua Bengio. Generative adversarial nets. In Advances in neural information processing systems, pp. 2672–2680, 2014.
Andreas Griewank and Andrea Walther. Evaluating derivatives: principles and techniques of algorithmic differentiation, volume 105. Siam, 2008.
Chin-Wei Huang, David Krueger, Alexandre Lacoste, and Aaron Courville. Neural autoregressive flows. International Conference on Machine Learning, 2018.
M.F. Hutchinson. A stochastic estimator of the trace of the influence matrix for laplacian smoothing splines. 18:1059–1076, 01 1989.
H.K. Khalil. Nonlinear Systems. Pearson Education. Prentice Hall, 2002.
Diederik P Kingma and Jimmy Ba. Adam: A method for stochastic optimization. International Conference on Learning Representations, 2015.
Diederik P Kingma and Prafulla Dhariwal. Glow: Generative flow with invertible 1x1 convolutions. Advances in Neural Information Processing Systems, 2018.
Diederik P Kingma and Max Welling. Auto-encoding variational bayes. International Conference on Learning Representations, 2014.
Diederik P Kingma, Tim Salimans, Rafal Jozefowicz, Xi Chen, Ilya Sutskever, and Max Welling. Improved variational inference with inverse autoregressive flow. In Advances in Neural Information Processing Systems, pp. 4743–4751, 2016.
Takeru Miyato, Toshiki Kataoka, Masanori Koyama, and Yuichi Yoshida. Spectral normalization for generative adversarial networks. International Conference on Learning Representations, 2018.
Junier B Oliva, Avinava Dubey, Barnabas P ´ oczos, Jeff Schneider, and Eric P Xing. Transformation ´ autoregressive networks. International Conference on Machine Learning, 2018.
Aaron van den Oord, Nal Kalchbrenner, and Koray Kavukcuoglu. Pixel recurrent neural networks. International Conference on Machine Learning, 2016.
George Papamakarios, Iain Murray, and Theo Pavlakou. Masked autoregressive flow for density estimation. In Advances in Neural Information Processing Systems, pp. 2338–2347, 2017.
Lev Semenovich Pontryagin. Mathematical theory of optimal processes. Routledge, 1962.
Danilo Jimenez Rezende and Shakir Mohamed. Variational inference with normalizing flows. International Conference on Machine Learning, 2015.
David E Rumelhart, Geoffrey E Hinton, and Ronald J Williams. Learning representations by backpropagating errors. Nature, 323(6088):533, 1986.
Lawrence F Shampine. Some practical Runge-Kutta formulas. Mathematics of Computation, 46 (173):135–150, 1986.
# APPENDIX A QUALITATIVE SAMPLES
Samples from our FFJORD models trained on MNIST and CIFAR10 can be found in Figure 7.
 Figure 7: Samples and data from our image models. MNIST on left, CIFAR10 on right.
# APPENDIX B EXPERIMENTAL DETAILS AND ADDITIONAL RESULTS
# B.1 DENSITY ESTIMATION
On the tabular datasets we performed a grid-search over network architectures. We searched over models with 1, 2, 5, or 10 flows with 1, 2, 3, or 4 hidden layers per flow. Since each dataset has a different number of dimensions, we searched over hidden dimensions equal to 5, 10, or 20 times the data dimension (hidden dimension multiplier in Table 4). We tried both the tanh and softplus nonlinearities. The best performing models can be found in the Table 4.
On the image datasets we experimented with two different model architectures; a single flow with an encoder-decoder style architecture and a multiscale architecture composed of multiple flows.
While they were able to fit MNIST and obtain competitive performance, the encoder-decoder architectures were unable to fit more complicated image datasets such as CIFAR10 and Street View House Numbers. The architecture for MNIST which obtained the results in Table 2 was composed of four convolutional layers with $6 4 \to 6 4 \to 1 2 8 \to 1 2 8$ filters and down-sampling with strided convolutions by two every other layer. There are then four transpose-convolutional layers who’s filters mirror the first four layers and up-sample by two every other layer. The softplus activation function is used in every layer.
The multiscale architectures were inspired by those presented in Dinh et al. (2017). We compose multiple flows together interspersed with “squeeze” operations which down-sample the spatial resolution of the images and increase the number of channels. These operations are stacked into a “scale block” which contains $N$ flows, a squeeze, then $N$ flows. For MNIST we use 3 scale blocks and for CIFAR10 we use 4 scale blocks and let $N = 2$ for both datasets. Each flow is defined by 3 convolutional layers with 64 filters and a kernel size of 3. The softplus nonlinearity is used in all layers.
Both models were trained with the Adam optimizer (Kingma & Ba, 2015). We trained for 500 epochs with a learning rate of .001 which was decayed to .0001 after 250 epochs. Training took place on six GPUs and completed after approximately five days.
# B.2 VARIATIONAL AUTOENCODER
Our experimental procedure exactly mirrors that of Berg et al. (2018). We use the same 7-layer encoder and decoder, learning rate (.001), optimizer (Adam Kingma & Ba (2015)), batch size (100), and early stopping procedure (stop after 100 epochs of no validaiton improvment). The only difference was in the nomralizing flow used in the approximate posterior.
We performed a grid-search over neural network architectures for the dynamics of FFJORD. We searched over networks with 1 and 2 hidden layers and hidden dimension 512, 1024, and 2048. We used flows with 1, 2, or 5 steps and wight matrix updates of rank 1, 20, and 64. We use the softplus activation function for all datasets except for Caltech Silhouettes where we used tanh. The best performing models can be found in the Table 5. Models were trained on a single GPU and training took between four hours and three days depending on the dataset.
<table><tr><td>Dataset</td><td>nonlinearity</td><td>#layers</td><td>hidden dim multiplier</td><td># flow steps</td><td>batchsize</td></tr><tr><td>POWER</td><td>tanh</td><td>3</td><td>10</td><td>5</td><td>10000</td></tr><tr><td>GAS</td><td>tanh</td><td>3</td><td>20</td><td>5</td><td>1000</td></tr><tr><td>HEPMASS</td><td>softplus</td><td>2</td><td>10</td><td>10</td><td>10000</td></tr><tr><td>MINIBOONE</td><td>softplus</td><td>2</td><td>20</td><td>1</td><td>1000</td></tr><tr><td>BSDS300</td><td> softplus</td><td>3</td><td>20</td><td>2</td><td>10000</td></tr></table>
Table 4: Best performing model architectures for density estimation on tabular data with FFJORD.
Table 5: Best performing model architectures for VAEs with FFJORD.
<table><tr><td>Dataset</td><td>nonlinearity</td><td># layers</td><td>hidden dimension</td><td>#flow steps</td><td>rank</td></tr><tr><td>MNIST</td><td>softplus</td><td>2</td><td>1024</td><td>2</td><td>64</td></tr><tr><td>Omniglot</td><td>softplus</td><td>2</td><td>512</td><td>5</td><td>20</td></tr><tr><td>Frey Faces</td><td>softplus</td><td>2</td><td>512</td><td>2</td><td>20</td></tr><tr><td>Caltech</td><td>tanh</td><td>1</td><td>2048</td><td>1</td><td>20</td></tr></table>
B.3 STANDARD DEVIATIONS FOR TABULAR DENSITY ESTIMATION
<table><tr><td></td><td>POWER</td><td>GAS</td><td>HEPMASS</td><td>MINIBOONE</td><td>BSDS300</td></tr><tr><td>Real NVP</td><td>-0.17 ± 0.01</td><td>-8.33 ± 0.14</td><td>18.71 ± 0.02</td><td>13.55 ± 0.49</td><td>-153.28 ± 1.78</td></tr><tr><td>Glow</td><td>-0.17 ± 0.01</td><td>-8.15 ± 0.40</td><td>18.92 ± 0.08</td><td>11.35 ± 0.07</td><td>-155.07 ± 0.03</td></tr><tr><td>FFJORD</td><td>-0.46 ± 0.01</td><td>-8.59 ±0.12</td><td>14.92 ± 0.08</td><td>10.43 ± 0.04</td><td>-157.40 ± 0.19</td></tr><tr><td>MADE</td><td>3.08 ± 0.03</td><td>-3.56 ± 0.04</td><td>20.98 ± 0.02</td><td>15.59 ± 0.50</td><td>-148.85 ± 0.28</td></tr><tr><td>MAF</td><td>-0.24 ± 0.01</td><td>-10.08 ± 0.02</td><td>17.70 ± 0.02</td><td>11.75 ± 0.44</td><td>-155.69 ± 0.28</td></tr><tr><td>TAN</td><td>-0.48 ± 0.01</td><td>-11.19 ± 0.02</td><td>15.12 ± 0.02</td><td>11.01 ± 0.48</td><td>-157.03 ± 0.07</td></tr><tr><td>MAF-DDSF</td><td>-0.62 ± 0.01</td><td>-11.96 ± 0.33</td><td>15.09 ± 0.40</td><td>8.86 ± 0.15</td><td>-157.73 ± 0.04</td></tr></table>
Table 6: Negative log-likehood on test data for density estimation models. Means/stdev over 3 runs. Real NVP, MADE, MAF, TAN, and MAF-DDSF results on are taken from Huang et al. (2018). In reproducing Glow, we were able to get comparable results to the reported Real NVP by removing the invertible fully connected layers.
# APPENDIX C NUMERICAL ERROR FROM THE ODE SOLVER
ODE solvers are numerical integration methods so there is error inherent in their outputs. Adaptive solvers (like those used in all of our experiments) attempt to predict the errors that they accrue and modify their step-size to reduce their error below a user set tolerance. It is important to be aware of this error when we use these solvers for density estimation as the solver outputs the density that we report and compare with other methods. When tolerance is too low, we run into machine precision errors. Similarly when tolerance is too high, errors are large, our training objective becomes biased and we can run into divergent training dynamics.
Since a valid probability density function integrates to one, we take a model trained on Figure 1 and numerically find the area under the curve using Riemann sum and a very fine grid. We do this for a range of tolerance values and show the resulting error in Figure 8. We set both atol and rtol to the same tolerance.
 Figure 8: Numerical integration shows that the density under the model does integrate to one given sufficiently low tolerance. Both log and non-log plots are shown.
The numerical error follows the same order as the tolerance, as expected. During training, we find that the error becomes non-negligible when using tolerance values higher than $\bar { 1 0 } ^ { - 5 }$ . For most of our experiments, we set tolerance to $1 0 ^ { - 5 }$ as that gives reasonable performance while requiring few number of evaluations. For the tabular experiments, we use atol $= 1 0 ^ { - 8 }$ and $\mathtt { r t o l } \mathtt { = } 1 0 ^ { - 6 }$ .123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479# LIKELIHOOD-BASED PERMUTATION INVARIANT LOSS FUNCTION FOR PROBABILITY DISTRIBUTIONS
Anonymous authors Paper under double-blind review
# ABSTRACT
We propose a permutation-invariant loss function designed for the neural networks reconstructing a set of elements without considering the order within its vector representation. Unlike popular approaches for encoding and decoding a set, our work does not rely on a carefully engineered network topology nor by any additional sequential algorithm. The proposed method, Set Cross Entropy, has a natural information-theoretic interpretation and is related to the metrics defined for sets. We evaluate the proposed approach in two object reconstruction tasks and a rule learning task.
# 1 INTRODUCTION
Sets are fundamental mathematical objects which appear frequently in the real-world dataset. However, there are only a handful of studies on learning a set representation in the machine learning literature. In this study, we propose a new objective function called Set Cross Entropy (SCE) to address the permutation invariant set generation. SCE measures the cross entropy between two sets that consists of multiple elements, where each element is represented as a multi-dimensional probability distribution in $[ 0 , 1 ] \subset \mathbb { R }$ (a closed set of reals between 0,1). SCE is invariant to the object permutation, therefore does not distinguish two vector representations of a set with the different ordering. The SCE is simple enough to fit in one line and can be naturally interpreted as a formulation of the log-likelihood maximization between two sets derived from a logical statement.
The SCE loss trains a neural network in a permutation-invariant manner, and the network learns to output a set. Importantly, this is not to say that the neural network learns to represent a function that is permutation-invariant with regard to the input. The key difference in our approach is that we allow the network to output a vector representation of a set that may have a different ordering than the examples used during the training. In contrast, previous studies focus on learning a function that returns the same output for the different permutations of the input elements. Such scenarios assume that an output value at some index is matched against the target value at the same index.
This characteristic is crucial in the tasks where the objects included in the supervised signals (training examples for the output) do not have any meaningful ordering. For example, in the logic rule learning tasks, a first-order logic horn clause does not care about the ordering inside the rule body since logical conjunctions are invariant to permutations, e.g. father $( \mathsf { c } , \mathsf { f } ) \gets ( \bar { \mathsf { p a r e n t } } ( \mathsf { c } , \mathsf { f } ) \wedge \mathsf { m a l e } ( \mathsf { f } ) )$ and fathe $\cdot ( \mathsf { c } , \mathsf { f } ) \gets ( \mathsf { m a l e } ( \mathsf { f } ) \wedge \mathsf { p a r e n t } ( \mathsf { c } , \mathsf { f } ) )$ are equivalent.
To apply our approach, no special engineering of the network topology is required other than the standard hyperparameter tuning. The only requirement is that the target output examples are the probability vectors in $[ 0 , 1 ] ^ { N \times \mathbf { \overline { { F } } } }$ , which is easily addressed by an appropriate feature engineering including autoencoders with softmax or sigmoid latent activation.
We demonstrate the effectiveness of our approach in two object-set reconstruction tasks and the supervised theory learning tasks that learn to perform the backward chaining of the horn clauses. In particular, we show that the SCE objective is superior to the training using the other set distance metrics, including Hausdorff and set average (Chamfer) distances.
# 2 BACKGROUNDS AND RELATED WORK
# 2.1 LEARNING A SET REPRESENTATION
Previous studies try to discover the appropriate structure for the neural networks that can represent a set. Notable recent work includes permutation-equivariant $/$ invariant layers that addresses the permutation in the input (Guttenberg et al., 2016; Ravanbakhsh et al., 2016; Zaheer et al., 2017).
Let $X$ be a vector representation of a set $\{ x _ { 1 } , \ldots , x _ { n } \}$ and $\pi$ be an arbitrary permutation function for a sequence. A function $f ( X )$ is permutation invariant when $\forall \pi$ ; $f ( X ) = f ( \pi ( X ) ) .$ . Zaheer et al. (2017) showed that functions are permutation-invariant iff it can be decomposed into a form
$$f ( X ) = \rho \Biggl ( \sum _ { x \in X } \phi ( x ) \Biggr )$$
where $\rho , \phi$ are the appropriate mapping function.
However, as mentioned in the introduction, the aim of these layers is to learn the functions that are permutation-invariant with regard to the input permutation, and not to reconstruct a set in a permutation-invariant manner (i.e. ignoring the ordering). In other words, permutationequivariant/invariant layers are only capable of encoding a set.
Probst (2018) recently proposed a method dubbed as “Set Autoencoder”. It additionally learns a permutation matrix that is applied before the output so that the output matches the target. The target for the permutation matrix is generated by a Gale-Shapley greedy stable matching algorithm, which requires $O ( n ^ { 2 } )$ runtime. The output is compared against the training example with a conventional loss function such as binary cross entropy or mean squared error, which requires the final output to have the same ordering as the target. Therefore, this work tries to learn the set as well as the ordering between the elements, which is conceptually different from learning to reconstruct a set while ignoring the ordering.
Another line of related work utilizes Sinkhorn iterations (Adams & Zemel, 2011; Santa Cruz et al., 2017; Mena et al., 2018) in order to directly learn the permutations. Again, these work assumes that the output is generated in a specific order (e.g. a sorting task), which does not align with the concept of the set reconstruction.
# 2.2 SET DISTANCE
Set distances / metrics are the binary functions that satisfy the metric axioms. They have been utilized for measuring the visual object matching or for feature selection (Huttenlocher et al., 1993; Dubuisson & Jain, 1994; Piramuthu, 1999). Note that, however, in this work, we use the informal usage of the terms “distance” or “metric” for any non-negative binary functions that may not satisfy the metric axioms.
There are several variants of set distances. Hausdorff distance between sets (Huttenlocher et al., 1993) is a function that satisfies the metric axiom. For two sets $X$ and $Y$ , the directed Hausdorff distance with an element-wise distance $d ( x , y )$ is defined as follows:
$${ \mathcal { H } } _ { 1 d } ( X , Y ) = \operatorname* { m a x } _ { x \in X } \operatorname* { m i n } _ { y \in Y } d ( x , y )$$
The element-wise distance $d$ is Euclidean distance or Hamming distance, for example, depending on the target domain.
Set average (pseudo) distance (Dubuisson & Jain, 1994, Eq.(6)), also known as Chamfer distance, is a modification of the original Hausdorff distance which aggregates the element-wise distances by summation. The directed version is defined as follows:
$$A _ { 1 d } ( X , Y ) = { \frac { 1 } { | X | } } \sum _ { x \in X } \operatorname* { m i n } _ { y \in Y } d ( x , y ) .$$
Set average distance has been used for image matching, as well as to autoencode the 3D point clouds in the euclidean space for shape matching (Zhu et al., 2016).
# 3 SET CROSS ENTROPY
Inspired by the various set distances, we propose a straightforward formulation of likelihood maximization between two sets of probability distributions. In what follows, we define the cross entropy between two sets $X , Y \in [ 0 , \dot { 1 } ] ^ { N \times F }$ , where $[ 0 , 1 ]$ is a closed set of reals between 0 and 1.
Let $\mathcal { X } = \left\{ X ^ { ( 1 ) } , X ^ { ( 2 ) } , . . . \right\}$ be the training dataset, and $Y$ be the output matrix of a neural network. Assume that each $X \in { \mathcal { X } }$ consists of $N$ elements where each element is represented by $F$ features, i.e. $X = \{ x _ { 1 } \ldots x _ { N } \} , x _ { i } \in \mathbb { R } ^ { F }$ . We further assume that $x _ { i } \in [ 0 , 1 ] ^ { F }$ by a suitable transformation, which can be done by the feature learning with sigmoid activation added to the latent layer. The set $X$ actually takes the vector representation, which essentially makes $X \in [ 0 , 1 ] ^ { N \times F }$ . In this paper, we focus on the binomial distribution. However, the proposed method naturally extends to the multinomial case.
For simplicity, we assume that the number of elements in the set $X$ and $Y$ is known and fixed to $N$ . Therefore $Y$ is also a matrix in $[ 0 , 1 ] ^ { N \times F }$ . Furthermore, we assume that $X$ is preprocessed and contains no duplicated elements.
In practice, if $| X |$ varies across the dataset, it suffices to take $N ^ { \mathrm { m a x } } = \operatorname* { m a x } _ { X \in { \mathcal { X } } } | X |$ , the largest number of elements in $X$ across the dataset $\mathcal { X }$ , and add the dummy, distinct objects $d _ { 0 } \dots d _ { N ^ { \mathrm { m a x } } }$ to fill in the blanks. For example, when there are $N$ objects of $F$ features and we want to normalize the size of the set to $N ^ { \prime } ( > N )$ , one way is to add an additional axis to the feature vector $( F + 1$ features) where the additional $F + 1$ -th feature is 0 for the real data and 1 for the dummy data, and the additional $N ^ { \prime } - N$ objects are generated in an arbitrary way (e.g. as a binary sequence 100000, 100001, 100010, 100011, ... for $F = 5$ )
For measuring the similarity between the two probability vectors $x , y \in [ 0 , 1 ] ^ { F }$ , the natural loss function would be the cross entropy $\operatorname { H } ( x , y )$ or, equivalently, the negative log likelihood.
$$\mathrm { H } ( x , y ) = \mathbb { E } _ { x } \langle - \log P ( x = y ) \rangle = \sum _ { i = 1 } ^ { F } - x _ { i } \log y _ { i } - ( 1 - x _ { i } ) \log ( 1 - y _ { i } ) .$$
However, applying it directly to the matrices $X , Y$ unnecessarily limits the global optima of this loss because it does not consider the permutations between $N$ objects, e.g., for $X = [ o _ { 1 } , o _ { 2 } , o _ { 3 } ]$ , $Y = \left[ o _ { 2 } , o _ { 3 } , o _ { 1 } \right]$ is not the global minima of $\mathrm { H } ( X , Y )$ . Previous approach (Probst, 2018) tried to solve this problem by learning an additional permutation matrix that “fixes” the order, basically requiring to memorize the ordering.
We take a different approach of directly fixing this loss function. The target objective is to maximize the probability of two sets being equal, thus ideally, at the global minima, two sets $X$ and $Y$ should be equal. Equivalence of two sets is defined as:
$${ \begin{array} { r l } { X = Y \Longleftrightarrow X \subseteq Y \wedge X \supseteq Y } \\ & { \qquad \Longleftrightarrow ( \forall x \in X ; x \in Y ) \wedge ( \forall y \in Y ; y \in X ) . } \end{array} }$$
However, under the assumption that $| X | = | Y | = N$ and $X$ contains $N$ distinct elements (no duplicates), $X \subseteq Y$ is a sufficient condition for $X = Y$ . (Proof: If $X \subseteq Y$ and $X ~ \nsupseteq ~ Y$ , there are some $y ^ { \prime } \in Y$ such that $y ^ { \prime } \not \in X$ . Since $N$ distinct elements in $X$ are also included in $Y , y ^ { \prime }$ becomes $Y$ ’s $N + 1$ -th element, which contradicts $| Y | = N$ . Note that this proof did not depend on the distinctness of $Y$ ’s elements.)
Under this condition, therefore,
$${ \begin{array} { r l } { X = Y \Longleftrightarrow X \subseteq Y } \\ & { \Longleftrightarrow \forall x \in X ; x \in Y } \\ & { \Longleftrightarrow \forall x \in X ; \exists y \in Y ; x = y } \\ & { \Longleftrightarrow \bigwedge { \bigvee } x = y . } \end{array} }$$
We now translate this logical formula into the corresponding log likelihood as follows:
$$\begin{array} { l } { \log P ( X = Y ) = \log P ( \bigwedge \bigvee = y ) = \displaystyle \sum _ { z \in X } \log P ( \bigvee X = y ) } \\ { \qquad x \leqslant x X \leqslant z \quad } \\ { \quad } \\ { \quad } \\ { \qquad = \displaystyle \sum _ { z \in X } \log \displaystyle \sum _ { y \in Y } P ( x = y ) \quad : \mathrm { ~ e a c h ~ } x = y _ { \mathrm { t } } \mathrm { ~ a r e ~ m u t a l } } \\ { \qquad } \\ { \quad = \displaystyle \sum _ { z \in X } \log \displaystyle \sum _ { y \in Y } \exp ( x = y ) } \\ { \qquad = \displaystyle \sum _ { z \in X } \log \operatorname* { m u e r } _ { y \in Y } \log P ( x = y ) } \\ { \qquad \quad = \displaystyle \sum _ { z \in X } \log \operatorname* { s u p } ( x = y ) , } \\ { \quad \mathrm { s e t ~ C n o s ~ E n t r o p } ; \quad \mathrm { S H } ( X , Y ) \stackrel { \mathrm { d i } } { = } \mathbb { E } _ { X } \langle - \log P ( X = Y ) \rangle } \\ { \qquad = \displaystyle - \sum _ { \mathrm { ~ l o s s u m e r ~ o p } , \mathrm { e x p } ( - \mathbb { H } ( x , y ) ) . } } \end{array}$$
∵ each $x$ is independent.
This Set Cross Entropy has the following characteristics: First, compared to the original cross entropy loss, whose global minima is limited to the data point that preserves the same ordering of the elements, SCE increases the number of global minima exponentially by making every permutations of the point also the global minima.
Next, notice that logsumexp is a smooth upper approximation of the maximum, therefore $\operatorname { S H } ( X , Y )$ is upper-bounded by the set average equivalent,
$$\operatorname { S H } ( X , Y ) \leq - \sum _ { x \in X } \operatorname* { m a x } _ { y \in Y } ( - \mathrm { H } ( x , y ) ) = \sum _ { x \in X } \operatorname* { m i n } _ { y \in Y } \mathrm { H } ( x , y ) = N \cdot A _ { \operatorname { I H } } ( X , Y ) .$$
Intuitively, this is because Eq.9 returns a value which does not account for the possibility that the current closest $y = \arg \operatorname* { m i n } _ { y } \mathrm { H } ( x , y )$ of $x$ may not converge to the $x$ in the future during the training.
We illustrate this by comparing two examples: Let $X = \{ [ 0 , 1 ] , [ 0 , 0 ] \}$ , $Y _ { 1 } = \{ [ 0 . 1 , 0 . 5 ] , [ 0 . 1 , 0 . 5 ] \}$ and $Y _ { 2 } = \{ [ 0 . 1 , 0 . { \bar { 5 } } ] , [ 0 . 9 , 0 . 5 ] \}$ . The set cross entropy Eq.8 reports the smaller loss for ${ \mathrm { S H } } ( X , Y _ { 1 } ) =$ $- \log 0 . 8 1 ~ \approx ~ 0 . 0 9$ than for $\mathrm { S H } ( X , Y _ { 2 } ) ~ = ~ - \log { 0 . 2 5 } ~ \approx ~ 0 . 6 0 .$ . This is reasonable because the global minima is given when the first axis of both $y \mathrm { s }$ are $0 \mathrm { ~ - ~ } Y _ { 2 }$ should be more penalized than $Y _ { 1 }$ for the 0.9 in the second element. In contrast, Eq.9 considers only the closest element ( $\mathrm { a r g m i n } _ { y \in Y } \mathrm { H } ( x , y ) ~ = ~ [ 0 . 1 , 0 . 5 ] )$ for each $x$ , therefore returns the same loss $=$ $- \log { 0 . 2 0 2 5 } \approx 0 . 6 9$ for both cases, ignoring [0.9, 0.5] completely. In fact, Eq.9 has zero gradient at $Y = \{ [ 0 , 0 . 5 ] , [ y , 0 . 5 ] \}$ for any $y \in [ 0 , 1 ]$ .
Furthermore, the following inequality suggests that the traditional cross entropy between the matrices $X$ and $Y$ is an even looser upper bound of Eq.9. Here, $x _ { i } , y _ { i }$ are the $i$ -th element of the vector representation of $X$ and $Y$ , respectively:
$$\begin{array} { l } { \displaystyle \mathrm { S H } ( X , Y ) \leq \sum _ { x \in X } \displaystyle \operatorname* { m i n } _ { y \in Y } \mathrm { H } ( x , y ) \qquad } & { \therefore \mathrm { E q . } 9 } \\ { \leq \displaystyle \sum _ { x _ { i } \in X } \mathrm { H } ( x _ { i } , y _ { i } ) \qquad } & { \therefore \forall y _ { i } ; \displaystyle \operatorname* { m i n } _ { y \in Y } \mathrm { H } ( x , y ) \leq \mathrm { H } ( x , y _ { i } ) } \end{array}$$
This gives a natural interpretation that ignoring the permutation reduces the cross entropy.
# 4 EVALUATION
# 4.1 OBJECT SET RECONSTRUCTION
The purpose of the task is to obtain the latent representation of a set of objects and reconstruct them, where each object is represented as a feature vector. We prepared two datasets originating from classical AI domains: Sliding tile puzzle (8-puzzle) and Blocksworld.
Learning to reason about the object-based, set representation of the environment is crucial in the robotic systems that continuously receive the list of visible objects from the visual perception module (e.g. Redmon et al. (2016, YOLO)). In a real-world systems, appropriate handling of the set is necessary because it is unnatural to assume that the objects in the environments are always reported in the same order. In particular, the objects even in the same environment state may be reported in various orders if multiple such modules are running in parallel in an asynchronous manner.
In this experiment, we show that the permutation invariant loss function like SCE is necessary for learning to reconstruct a set in such a scenario. In this setting, a network is required to reconstruct a set from a single latent representation, while the objects as the target output may be randomly reordered each time the same set is observed and presented to the neural network.
# 8 PUZZLE
Each feature vector as an object consists of 15 features, 9 of which represent the tile number (object ID) and the remaining 6 represent the coordinates. Each data point has 9 such vectors, corresponding to the 9 objects in a single tile configuration. The entire state space of the puzzle is 362880 states. We generated 5000 states and used the 4500 states as the training set.
 Figure 1: A single 8-puzzle state as a $9 \mathrm { x } 1 5$ matrix, representing 9 objects of 15 features. The first 9 features are the tile numbers and the other 6 features are the 1-hot x/y-coordinates.
We prepared an autoencoder with the permutation invariant layers (Zaheer et al., 2017) as the encoder and the fully-connected layers as the decoder. Since it uses a permutation-invariant encoder, the latent space is already guaranteed to learn a representation that is invariant to the input ordering. The key question here is then whether they can be robustly trained against the random permutations in the training examples for the output.
We tested the reconstruction ability in four scenarios: (1) In the first scenario, the dataset is provided in a standard manner. (2) In the second scenario, we augment the input dataset by repeating the elements 5 times and randomly reorder the object vectors in each set. The randomized dataset is used as the input to the network, while the target output is still the original dataset (repeated 5 times, without reordering). The purpose of this experiment is to verify the claim of the Deep Set (Zaheer et al., 2017) that it is able to handle the input in a permutation invariant manner. In order to compensate the datasize difference, the maximum training epoch is reduced by 1/5 times compared to the first scenario. (3) In the third scenario, we apply the similar operation to the target output of the network. Essentially we always feed the input in the same fixed order while forcing it to learn from the randomized target output. Each time the same data is presented, the target output has the different ordering while the input has the fixed ordering. Therefore, the training should be performed in such a way that the ordering in the output is properly ignored. (4) Finally, in the fourth scenario, the ordering in both the input and the output are randomized.
We trained the same network with four different loss functions, (a) the traditional cross entropy H, (b) Set Cross Entropy SH, (c) directed set average of the cross entropy $A _ { \mathrm { 1 H } }$ and (d) the directed Hausdorff measure of the cross entropy $\mathcal { H } _ { \mathrm { 1 H } }$ , resulting in 16 training scenarios in total. We performed the same experiment 10 times and took the statistics. The purpose of this is to address the potential concern about the stability of the training. We kept the same set of training/testing data, and the only difference between the runs is the random seed.
We first measured the Set Cross Entropy value between the test dataset and its reconstruction in the above 16 scenarios. Table 1 shows the results. The training with the standard cross entropy loss (H) succeeds in cases (1,2) while failed in cases (3,4). The case (2) reproduces the claim in (Zaheer et al., 2017) that it encodes the input in an permutation-invariant manner, while it failed in the latter cases because the training is not permutation-invariant with regard to the output. In contrast, the training with the Set Cross Entropy loss succeeds in all cases. This shows that the permutation-invariant loss function is necessary for training a network with a dataset consisting of sets.
The training with set average distance $A _ { \mathrm { 1 H } }$ also reduces the Set Cross Entropy because it is an upper-bound approximation of the Set Cross Entropy. However, in one of the 10 runs, $A _ { \mathrm { 1 H } }$ did not converge, showing that the A1H (baseline) could be unstable, possibly due to the issue explained in the example at the end of section 3. In contrast, the training with Hausdorff distance failed to learn the representation at all.
<table><tr><td rowspan="2"></td><td colspan="8">Test error in 1O runs (measured by SH)</td></tr><tr><td colspan="4">Best</td><td colspan="4">Worst</td></tr><tr><td>Target ordering</td><td>Fixed</td><td></td><td>Random</td><td></td><td>Fixed</td><td></td><td>Random</td><td></td></tr><tr><td>Input ordering</td><td>Fixed</td><td>Random</td><td>Fixed</td><td>Random</td><td>Fixed</td><td>Random</td><td>Fixed</td><td>Random</td></tr><tr><td>H SH</td><td>0.00 0.00</td><td>0.00</td><td>29.28 0.00</td><td>30.79</td><td>5.04 0.15</td><td>0.01</td><td>42.24</td><td>41.91 0.07</td></tr><tr><td>A1H</td><td></td><td>0.00</td><td>0.00</td><td>0.00</td><td></td><td>0.03 133.34</td><td>0.10 0.09</td><td>0.00</td></tr><tr><td>H1H</td><td>0.00 28.27</td><td>0.00 28.28</td><td>28.26</td><td>0.00 28.26</td><td>0.14 233.47</td><td>167.74</td><td>184.41</td><td>196.14</td></tr><tr><td></td><td></td><td></td><td></td><td></td><td></td><td>Mean</td><td></td><td></td></tr><tr><td></td><td colspan="4">Median</td><td colspan="4"></td></tr><tr><td>Target ordering</td><td>Fixed</td><td></td><td></td><td>Random</td><td>Fixed</td><td></td><td>Random</td><td></td></tr><tr><td>Input ordering</td><td>Fixed</td><td>Random</td><td>Fixed</td><td>Random</td><td>Fixed</td><td>Random</td><td>Fixed</td><td>Random</td></tr><tr><td>H</td><td>0.04</td><td>0.00</td><td>32.87</td><td>32.57</td><td>0.59</td><td>0.00</td><td>34.14</td><td>33.44</td></tr><tr><td>SH</td><td>0.00</td><td>0.00</td><td>0.00</td><td>0.00</td><td>0.02</td><td>0.00</td><td>0.02</td><td>0.01</td></tr><tr><td>A1H</td><td>0.00</td><td>0.00</td><td>0.00</td><td>0.00</td><td>0.02</td><td>13.39</td><td>0.01</td><td>0.00</td></tr><tr><td>H1H</td><td>31.85</td><td>28.39</td><td>31.33</td><td>28.56</td><td>77.85</td><td>59.27</td><td>50.37</td><td>67.50</td></tr></table>
Table 1: The summary of test errors out of 10 runs. Best results in bold. SH and $A _ { \mathrm { 1 H } }$ both succeeded to achieve a good log likelihood sufficiently often. The set average $A _ { \mathrm { 1 H } }$ however suffered from a divergence in one training instance, showing its potential instability. The traditional cross entropy H fails to converge when the output is presented in a different order in each iteration. Hausdorff distance failed to converge in all cases.
We next measured the rate of the successful reconstruction among the entire dataset. The “successful reconstruction” is defined as follows: Recall that every data point is a discrete binary vector in the 8-Puzzle dataset while the output of the network is a continuous $N \times F$ matrix of reals between 0 and 1. Therefore, we round the output of the network to $0 / 1$ and directly compare the result with the input. If every object vector in a set is matched by some of the output object vector, then it is counted as a success. Similar results were obtained in Table 6: SH and $A _ { \mathrm { 1 H } }$ both succeeded to achieve a high success rate, while other two metrics completely failed. (We rerun the experiment, therefore the divergence of $A _ { \mathrm { 1 H } }$ in the previous experiment did not happen this time.)
Finally, to address the claim that the network is able to learn from the dataset with the variable set size, we performed an experiment which applies the dummy-vector scheme (Sec. 3). In this experiment, we modified the dataset to model such a scenario by randomly dropping one to five elements out of 9 elements. The maximum number of elements is 9. The dropping scheme is specified as follows: Out of the 5000 states generated in total (including the training / testing dataset), approximately half of the states have 9 tiles, $1 / 4$ of the states have 8 tiles, ... and $1 / 2 ^ { 5 }$ of the states have 5 tiles. The elements to drop are selected randomly.
The results in Table 3 shows that the training with our proposed SH loss function achieves the best success ratio for the reconstruction. The reconstruction includes the dummy vectors, indicating that the network is able to represent not only the elements in the set but also the number of the missing elements.
# BLOCKSWORLD
In order to test the reconstruction ability for the more complex feature vectors, we prepared a photorealistic Blocksworld dataset (Fig. 2) which contains the blocks world states rendered by Blender 3D engine. There are several cylinders or cubes of various colors and sizes and two surface materials (Metal/Rubber) stacked on the floor, just like in the usual STRIPS (McDermott, 2000) Blocksworld domain. In this domain, three actions are performed: move a block onto another stack or on the
Table 2: The summary of the success rate for the 10 runs of 16 training scenarios. Best results in bold. SH and $A _ { \mathrm { 1 H } }$ both succeeded to reconstruct the binary vectors in the 8 puzzles. The traditional cross entropy $\mathrm { H }$ and the Hausdorff distance $\mathcal { H } _ { \mathrm { 1 H } }$ both failed to reconstruct the binary vectors.
<table><tr><td colspan="9">Reconstruction success ratio in 1O runs</td></tr><tr><td></td><td colspan="4">Best</td><td colspan="4">Worst</td></tr><tr><td>Target ordering</td><td colspan="2">Fixed</td><td colspan="2">Random</td><td colspan="2">Fixed</td><td colspan="2">Random</td></tr><tr><td>Input ordering</td><td>Fixed</td><td>Random</td><td>Fixed</td><td>Random</td><td>Fixed</td><td>Random</td><td>Fixed</td><td>Random</td></tr><tr><td>H SH</td><td>0.00</td><td>0.00</td><td>0.00 1.00</td><td>0.00 1.00</td><td>0.00 1.00</td><td>0.00 1.00</td><td>0.00</td><td>0.00 1.00</td></tr><tr><td>A1H</td><td>1.00 1.00</td><td>1.00</td><td></td><td>1.00</td><td>1.00</td><td></td><td>0.89</td><td>1.00</td></tr><tr><td>H1H</td><td>0.00</td><td>1.00 0.00</td><td>1.00 0.00</td><td>0.00</td><td>0.00</td><td>1.00 0.00</td><td>1.00</td><td></td></tr><tr><td></td><td></td><td>Median</td><td></td><td></td><td></td><td></td><td>0.00</td><td>0.00</td></tr><tr><td></td><td colspan="4"></td><td colspan="4">Mean</td></tr><tr><td>Target ordering</td><td>Fixed</td><td></td><td>Random</td><td></td><td>Fixed</td><td></td><td>Random</td><td></td></tr><tr><td>Input ordering</td><td>Fixed</td><td>Random</td><td>Fixed</td><td>Random</td><td>Fixed</td><td>Random</td><td>Fixed</td><td>Random</td></tr><tr><td>H SH</td><td>0.00</td><td>0.00</td><td>0.00</td><td>0.00</td><td>0.00</td><td>0.00</td><td>0.00</td><td>0.00</td></tr><tr><td></td><td>1.00</td><td>1.00</td><td>1.00</td><td>1.00</td><td>1.00</td><td>1.00</td><td>0.99</td><td>1.00</td></tr><tr><td>A1H</td><td>1.00</td><td>1.00</td><td>1.00</td><td>1.00</td><td>1.00</td><td>1.00</td><td>1.00</td><td>1.00</td></tr><tr><td>H1H</td><td>0.00</td><td>0.00</td><td>0.00</td><td>0.00</td><td>0.00</td><td>0.00</td><td>0.00</td><td>0.00</td></tr></table>
<table><tr><td colspan="9"></td></tr><tr><td></td><td colspan="4">Best</td><td colspan="3">Worst</td></tr><tr><td>Target ordering</td><td>Fixed</td><td></td><td>Random</td><td></td><td>Fixed</td><td></td><td>Random</td></tr><tr><td>Input ordering H</td><td>Fixed</td><td>Random 0.49</td><td>Fixed 0.05</td><td>Random 0.56</td><td>Fixed Random 0.00</td><td>Fixed 0.00</td><td>Random 0.00</td></tr><tr><td>SH</td><td>0.03 0.62</td><td>0.63 0.65</td><td>0.65</td><td>0.52</td><td>0.00 0.54</td><td>0.57</td><td>0.54</td></tr><tr><td>A1H</td><td>0.62</td><td>0.62 0.60</td><td>0.59</td><td>0.52</td><td>0.09</td><td>0.51</td><td>0.50</td></tr><tr><td>H1H</td><td>0.00</td><td>0.00 0.00</td><td>0.00</td><td>0.00</td><td>0.00</td><td>0.00</td><td>0.00</td></tr><tr><td></td><td></td><td>Median</td><td></td><td></td><td></td><td></td><td></td></tr><tr><td></td><td colspan="4"></td><td colspan="4">Mean</td></tr><tr><td>Target ordering</td><td>Fixed</td><td></td><td>Random</td><td></td><td>Fixed</td><td></td><td>Random</td><td></td></tr><tr><td>Input ordering</td><td>Fixed</td><td>Random</td><td>Fixed</td><td>Random</td><td>Fixed</td><td>Random</td><td>Fixed</td><td>Random</td></tr><tr><td>H SH</td><td>0.00</td><td>0.12</td><td>0.00</td><td>0.27 0.60</td><td>0.01</td><td>0.17</td><td>0.01</td><td>0.31</td></tr><tr><td></td><td>0.57</td><td>0.59</td><td>0.60</td><td></td><td>0.58</td><td>0.59</td><td>0.61</td><td>0.60</td></tr><tr><td>A1H</td><td>0.59</td><td>0.57</td><td>0.57</td><td>0.56</td><td>0.58</td><td>0.53</td><td>0.57</td><td>0.56</td></tr><tr><td>H1H</td><td>0.00</td><td>0.00</td><td>0.00</td><td>0.00</td><td>0.00</td><td>0.00</td><td>0.00</td><td>0.00</td></tr></table>
Table 3: The summary of the success rate for the 10 runs of 16 training scenarios, where the size of the set randomly varies from 4 to 9 in the dataset. Best results in bold. The proposed SH achieved the best success rate overall, $A _ { \mathrm { 1 H } }$ comes next, the traditional cross entropy H and the Hausdorff distance $\mathcal { H } _ { \mathrm { 1 H } }$ both failed in most cases.
floor, and polish/unpolish a block i.e. change the surface of a block from Metal to Rubber or vice versa. All actions are applicable only when the block is on top of a stack or on the floor. The latter actions allow changes in the non-coordinate features of the object vectors.
 Figure 2: An example Blocksworld transition. Each state has a perturbation from the jitter in the light positions and the ray-tracing noise. Objects have the different sizes, colors, shapes and surface materials. Regions corresponding to each object in the environment are extracted according to the bounding box information included in the dataset generator output, but is ideally automatically extracted by object recognition methods such as YOLO (Redmon et al., 2016). Other objects may intrude the extracted regions.
The dataset generator produces a $3 0 0 { \bf x } 2 0 0$ RGB image and a state description which contains the bounding boxes (bbox) of the objects. Extracting these bboxes is a object recognition task we do not address in this paper, and ideally, should be performed by a system like YOLO (Redmon et al., 2016). We resized the extracted image patches in the bboxes to $3 2 \mathrm { x } 3 2 $ RGB, compressed it into a feature vector of 1024 dimensions with a convolutional autoencoder, then concatenated it with the bbox $( x _ { 1 } , y _ { 1 } , x _ { 2 } , y _ { 2 } )$ which is discretized by 5 pixels and encoded as 1-hot vectors (60/40 categories for $x / y$ -axes), resulting in 1224 features per object. The generator is able to enumerate all possible states (80640 states for 5 blocks and 3 stacks). We used 2250 states as the training set and 250 states as the test set.
We also verified the results qualitatively. Some reconstruction results are visualized in Fig. 3. These visualizations are generated by pasting the image patches decoded from the first 1024 axes of the reconstructed 1224-D feature vectors in a position specified by the reconstructed bounding box in the last 200 axes.
 Figure 3: The visualizations of the Blocksworld state input (left), its reconstruction (middle) and their pixel-wise difference (right). From the left, each three columns represent (a) the traditional cross entropy H, (b) Set Cross Entropy SH, (c) directed set average of the cross entropy $A _ { \mathrm { 1 H } }$ and (d) the directed Hausdorff measure of the cross entropy $\mathcal { H } _ { \mathrm { 1 H } }$ . The proposed (b) Set Cross Entropy correctly reconstructs the input.
Results in Table 4 shows that the training with SH and $A _ { \mathrm { 1 H } }$ achieved a better test error compared to the other metrics.
<table><tr><td colspan="5">Best test error in 1O runs (measured by SH) Random</td></tr><tr><td>Target ordering</td><td colspan="4">Fixed</td></tr><tr><td>Input ordering</td><td>Fixed</td><td>Random</td><td>Fixed</td><td>Random</td></tr><tr><td>H</td><td>3360.22</td><td>3360.26</td><td>3425.89</td><td>3434.60</td></tr><tr><td>SH</td><td>3253.70</td><td>3260.04</td><td>3251.32</td><td>3252.71</td></tr><tr><td>A1H</td><td>3258.84</td><td>3251.74</td><td>3261.13</td><td>3264.82</td></tr><tr><td>H1H</td><td>3409.58</td><td>3410.77</td><td>3415.18</td><td>3373.22</td></tr></table>
Table 4: The best results of 10 runs. Both SH and $A _ { \mathrm { 1 H } }$ successfully converged below the sufficient accuracy.
In Table 5, as another metric with the more intuitive sense, we measure the difference between the visualization results of the input and the output (as shown in Fig. 3) by the Root Mean Squared Error of the pixel values averaged over RGB, pixels and the dataset. Each pixel is represented in the $[ 0 , 1 ]$ range (closed set of reals between 0 and 1), thus the 0.1 on the table means that pixels differ by 0.1 on average.
<table><tr><td rowspan="2"></td><td colspan="4">RMSE between the visualized image</td></tr><tr><td colspan="2">Fixed</td><td colspan="2">Random</td></tr><tr><td>Target ordering Input ordering</td><td>Fixed</td><td>Random</td><td>Fixed</td><td>Random</td></tr><tr><td>H</td><td>0.10</td><td>0.10</td><td>0.15</td><td>0.15</td></tr><tr><td>SH</td><td>0.08</td><td>0.08</td><td>0.07</td><td>0.08</td></tr><tr><td>A1H</td><td>0.08</td><td>0.10</td><td>0.08</td><td>0.08</td></tr><tr><td>H1H</td><td>0.14</td><td>0.15</td><td>0.16</td><td>0.15</td></tr></table>
Table 5: The best results of 10 runs. Both SH and $A _ { \mathrm { 1 H } }$ successfully converged below the sufficient accuracy.
# 4.2 RULE LEARNING ILP TASKS
The purpose of this task is to learn to generate the prerequisites (body) of the first-order-logic horn clauses from the head of the clause. Unlike the previous tasks, this task is not an autoencoding task. The bodies are considered as a set because the order of the terms inside a body does not matter for the clause to be satisfied.
The main purpose of this experiment is to show the effectiveness of our approach on set generation, not to demonstrate a more general neural theorem proving system. An interesting avenue of future work is to see how our approach can help the existing work on neural theorem proving.
We used a Countries dataset (Bouchard et al., 2015) that contains 163 countries and trained the models for $n$ -hop neighbor relations. For example, for $\begin{array} { r l r l } { n } & { { } = } & { 2 } \end{array}$ , given a head neighbor2(austria, germany, belgium) as an input, the task is to predict the body {neighborOf(austria, germany), neighborOf(germany, belgium)}, which is a set of two terms. This is a weaker form of a more general backward chaining used in Neural Theorem Proving (Rocktaschel ¨ & Riedel, 2017) because the output does not contain free variables.
In the $n$ -neighbor scenario, the input is a $2 + 1 6 3 ( n + 1 )$ -dimensional vector, which consists of a one-hot label of 2 categories for the predicate of the head, and $n + 1$ one-hot labels of 163 categories for the arguments of the head. For example, a head neighbor2(austria, germany, belgium) spends 2 dimensions for identifying the predicate neighbor2, and three 1-hot vectors of 163 categories for representing austria,germany,belgium. The output is a $n \times 3 2 8$ matrix, where each row represents a binary predicate $( 3 2 8 ~ = ~ 2 + 2 ~ { \cdot } ~ 1 6 3 )$ . This is again because the answer is {neighborOf(austria, germany), neighborOf(germany, belgium)}: There are 2 elements in the set, thus the output is a $2 \times 3 2 8$ matrix. Each element uses 2 dimensions for identifying the predicate head neighborOf and two 1-hot vectors of 163 categories for the arguments (e.g. austria and germany).
We trained the network with the neighbor- $^ n$ datasets ranging from $n = 2$ to $n = 5$ (see the result table for the detailed domain characteristics). The softmax output of the network is parsed back to the symbolic representation by selecting the index that gives the maximum probability, then compared against the test examples as a set. We counted the ratio of the clauses across the test set where every body term matches against one of the output terms. The output data (body terms) may have an arbitrary ordering, and we have another variant similar to the previous experiment: In the randomized body order dataset, the dataset is repeated 5 times, while the ordering of the terms inside each body is randomly shuffled.
Table 6 shows that the network with Set Cross Entropy achieved the best accuracy, set average generally comes in the second and the traditional cross entropy struggles. This trend was observed not only in the the randomized-body-ordering dataset, which observes the same body in a different order in each iteration, but also in the fixed-body-ordering dataset. This shows that the Set Cross Entropy relaxes the search space by adding more global minima and making the training easier.
# 5 DISCUSSION
Vinyals et al. (2016) repeatedly emphasized the advantage of limiting the possible equivalence classes of the outputs by engineering the training data for solving the combinatorial problems. For example, they pre-sorted the training example for the Delaunay triangulation (set of triangles) by the lexicographical order and trained an LSTM model with the standard cross entropy (Vinyals et al., 2015). However, this is an ad-hoc method that depends on the particular domain knowledge and, as we have shown, the difficulty of learning such an output was caused by the loss function that considers the ordering. Moreover, we showed that the standard cross entropy and the set average metrics are the less tighter upper bound of the proposed Set Cross Entropy and also that it empirically outperforms the standard cross entropy in the theory learning task, even if a specific ordering is imposed on the output.
One limitation of the current approach is that the set cross entropy contains a double-loop, therefore takes $O ( N ^ { 2 } )$ runtime for a set of $N$ objects. However, unlike the algorithm proposed in Probst (2018), which uses a sequential Gale-Shapley algorithm which also uses $O ( N ^ { 2 } )$ runtime, our loss function can be efficiently implemented on GPUs because it consists of a simple combination of logsumexp and summation.
Still, improving the runtime complexity is an important direction for future work because the other set reconstruction tasks, including 3D point clouds datasets like Shapenet (Chang et al., 2015), may contain a much larger number of elements in each set. A promising candidate for tacking this difficulty is to combine Set Cross Entropy with Approximate $k$ -Nearest Neighbor (Indyk & Motwani, 1998) methods, especially the Locality Sensitive Hashing (Wang et al., 2016, LSH). LSH can preprocess and divide the target output $X$ into the subsets within a certain radius and we can limit the inner loop to each subset. The resulting method can be seen as the midpoint of Set Cross Entropy and set average because set average (Eq.9) is the special case of this extension that uses the nearest neighbor $( \operatorname* { m i n } _ { y \in Y } H ( x , y ) )$ and worked reasonably well in the tasks evaluated in this paper. The main obstacle for this approach would be to extend Set Cross Entropy to a metric variant that satisfies the metric axioms (non-negativity, identity, symmetry, the triangular inequality) that is required for LSH methods in general. One candidate in this direction is a variant of Jensen-Shannon divergence called S2JSD (Endres & Schindelin, 2003), which satisfies the metric axioms and has a LSH method (Mao et al., 2017).
Another direction for future work is to use the Long Short Term Memory (Hochreiter & Schmidhuber, 1997) for handling the sets without imposing the shared upper bound on the number of elements in a set, which has been already explored in the literature (Vinyals et al., 2015; 2016). Since our approach is agnostic to the type of the neural network, they are orthogonal to our approach.
# 6 CONCLUSION
In this paper, we proposed Set Cross Entropy, a measure that models the likelihood between the sets of probability distributions. When the output of the neural network model can be naturally regarded as a set, Set Cross Entropy is able to relax the search space by making the permutations of a global minima also the global minima, and makes the training easier. This is in contrast to the existing approaches that try to correct the ordering of the output by learning a permutation matrix, or an ad-hoc methods that reorder the dataset using the domain-specific expert knowledge. Training based on the Set Cross Entropy is also robust against the dataset which contains vectors whose internal ordering may change time to time in an arbitrary manner. We demonstrated the effectiveness of the approach by comparing Set Cross Entropy against the normal cross entropy, as well as the other set-based metrics such as Hausdorff distance or set average (Chamfer) distance. set average distance was shown to upper-bound Set Cross Entropy, and while it performed comparably well in the object reconstruction task, it was outperformed by Set Cross Entropy in the rule learning task. Training a neural network with Hausdorff distance turned out to be particularly hard, and it failed in many scenarios, showing that it is not suitable as a loss function for the set reconstruction tasks considered in this paper.
<table><tr><td rowspan="2"></td><td colspan="7">The rate of correct answering on the test set,10 runs</td></tr><tr><td rowspan="2"></td><td colspan="6">n = 2, neighbor2(a,b,c):-neighborOf(a,b), neighborOf(b,c) Dataset: 2858 ground clauses; Training: 2250 clauses; Test: 250 clauses.</td></tr><tr><td>Target ordering</td><td colspan="2">Fixed</td><td colspan="4">Random</td></tr><tr><td></td><td>Best 0.32</td><td>Worst 0.23</td><td>Median 0.29</td><td>Mean 0.28</td><td>Best 0.36</td><td>Worst 0.25</td><td>Median 0.31</td><td>Mean 0.31</td></tr><tr><td>H SH</td><td>0.96</td><td>0.90</td><td>0.91</td><td>0.92</td><td>0.94</td><td>0.88</td><td>0.91</td><td>0.91</td></tr><tr><td>A1H</td><td>0.91</td><td>0.79</td><td>0.86</td><td>0.86</td><td>0.94</td><td>0.72</td><td>0.88</td><td>0.87</td></tr><tr><td>H1H</td><td>0.87</td><td>0.66</td><td>0.82</td><td>0.80</td><td>0.85</td><td>0.66</td><td>0.83</td><td>0.81</td></tr><tr><td></td><td colspan="6">n = 3, neighbor3(a,b,c,d):-..</td></tr><tr><td rowspan="3">Target ordering</td><td colspan="6">Dataset: 11000 ground clauses; Training: 2250 clauses; Test: 250 clauses.</td></tr><tr><td colspan="2">Fixed</td><td></td><td></td><td></td><td>Random</td><td></td></tr><tr><td>Best</td><td>Worst</td><td>Median</td><td>Mean</td><td>Best</td><td>Worst 0.06</td><td>Median</td><td>Mean</td></tr><tr><td>H</td><td>0.10</td><td>0.04</td><td>0.06</td><td>0.06</td><td>0.10</td><td>0.07</td><td>0.07</td></tr><tr><td>SH</td><td>0.72</td><td>0.55</td><td>0.61</td><td>0.62</td><td>0.70</td><td>0.53</td><td>0.66</td><td>0.64</td></tr><tr><td>A1H</td><td>0.61 0.55</td><td>0.52 0.31</td><td>0.55</td><td>0.56</td><td>0.60</td><td>0.53</td><td>0.57</td><td>0.57</td></tr><tr><td>H1H</td><td></td><td></td><td>0.44</td><td>0.44</td><td>0.57</td><td>0.37</td><td>0.43</td><td>0.45</td></tr><tr><td rowspan="3">Target ordering</td><td colspan="6">n =4,neighbor4(a,b,c,d,e):-..</td></tr><tr><td colspan="6">Dataset: 39878 ground clauses; Training: 2250 clauses; Test: 250 clauses.</td></tr><tr><td>Best</td><td>Worst</td><td>Fixed Median</td><td>Mean</td><td>Best</td><td>Random Worst</td><td>Median</td><td>Mean</td></tr><tr><td>H</td><td>0.02</td><td>0.00</td><td>0.01</td><td>0.01</td><td>0.03 0.00</td><td>0.02</td><td>0.02</td></tr><tr><td>SH</td><td>0.38</td><td>0.24</td><td>0.33</td><td>0.32</td><td>0.36</td><td>0.28 0.32</td><td>0.32</td></tr><tr><td>A1H</td><td>0.33</td><td>0.22</td><td>0.27</td><td>0.26</td><td>0.34</td><td>0.22 0.26</td><td>0.26</td></tr><tr><td>H1H</td><td>0.22</td><td>0.12</td><td>0.18</td><td>0.18</td><td>0.24</td><td>0.13 0.18</td><td>0.18</td></tr><tr><td></td><td colspan="6">n = 4, neighbor4(a,b,c,d,e):-... Dataset: 39878 ground clauses; Training: 90o0 clauses; Test: 1000 clauses.</td></tr><tr><td rowspan="4">Target ordering H</td><td></td><td>Fixed</td><td></td><td></td><td></td><td>Random</td><td></td></tr><tr><td>Best</td><td>Worst</td><td>Median</td><td>Mean</td><td>Best</td><td>Worst Median</td><td>Mean</td></tr><tr><td>0.04</td><td>0.03</td><td>0.04</td><td>0.03</td><td>0.04</td><td>0.02 0.03</td><td>0.03</td></tr><tr><td>0.87</td><td>0.81</td><td>0.82</td><td>0.83</td><td>0.86</td><td>0.77 0.82</td><td>0.82</td></tr><tr><td>SH</td><td></td><td>0.77</td><td>0.76</td><td>0.79</td><td>0.59</td><td>0.73</td><td>0.72</td></tr><tr><td>A1H</td><td>0.81 0.50</td><td>0.71</td><td></td><td></td><td></td><td>0.42</td><td>0.41</td></tr><tr><td>H1H</td><td>0.12</td><td>0.40</td><td>0.37 n = 5, neighbor5(a,b,c,d,e,f):-...</td><td>0.53</td><td>0.24</td><td></td><td></td></tr><tr><td colspan="6"></td></tr><tr><td rowspan="3">Target ordering H</td><td>Dataset: 137738 ground clauses; Training: 2250 clauses; Test: 250 clauses.</td><td>Fixed</td><td></td><td></td><td></td><td>Random</td><td></td></tr><tr><td>Best</td><td>Worst</td><td>Median</td><td>Mean</td><td>Best</td><td>Worst</td><td>Median Mean</td></tr><tr><td>0.00</td><td>0.00</td><td>0.00</td><td>0.00</td><td>0.01</td><td>0.00 0.00</td><td>0.00</td></tr><tr><td>SH</td><td>0.17</td><td>0.10 0.11</td><td>0.12</td><td>0.15</td><td>0.06</td><td>0.11</td><td>0.11</td></tr><tr><td>A1H</td><td>0.13</td><td>0.06 0.10</td><td>0.10</td><td>0.13</td><td>0.06</td><td>0.11</td><td>0.10</td></tr><tr><td>H1H</td><td>0.06</td><td>0.01 0.04</td><td>0.04</td><td>0.06</td><td>0.04</td><td>0.05</td><td>0.05</td></tr><tr><td></td><td></td><td></td><td>n = 5, neighbor5(a,b,c,d,e,f):-...</td><td></td><td></td><td></td><td></td></tr><tr><td rowspan="2">Target ordering</td><td colspan="6">Dataset: 137738 ground clauses; Training: 9000 clauses; Test: 1000 clauses.</td><td></td></tr><tr><td></td><td>Fixed</td><td></td><td></td><td></td><td>Random</td><td></td></tr><tr><td>H</td><td>Best Worst</td><td>Median 0.00</td><td>Mean 0.00</td><td>Best 0.01</td><td>Worst</td><td>Median 0.01</td><td>Mean 0.01</td></tr><tr><td>SH</td><td>0.01</td><td>0.00</td><td></td><td></td><td>0.00 0.50</td><td></td><td>0.55</td></tr><tr><td>A1H</td><td>0.65 0.53</td><td>0.52 0.46</td><td>0.55 0.48</td><td>0.56 0.48</td><td>0.60</td><td>0.56 0.50</td><td>0.50</td></tr><tr><td></td><td></td><td></td><td></td><td>0.56</td><td>0.46</td><td></td><td></td></tr><tr><td>H1H</td><td>0.20</td><td>0.04</td><td>0.11</td><td>0.11</td><td>0.18 0.07</td><td>0.13</td><td>0.13</td></tr><tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr></table>
Table 6: The summary of the rule learning task, 10 runs.
# REFERENCES
Ryan Prescott Adams and Richard S Zemel. Ranking via Sinkhorn Propagation. arXiv preprint arXiv:1106.1925, 2011. Masataro Asai and Alex Fukunaga. Classical Planning in Deep Latent Space: Bridging the SubsymbolicSymbolic Boundary. In Proc. of AAAI Conference on Artificial Intelligence, 2018. URL https: //www.aaai.org/ocs/index.php/AAAI/AAAI18/paper/view/16302. Guillaume Bouchard, Sameer Singh, and Theo Trouillon. On Approximate Reasoning Capabilities of Low-Rank Vector Spaces. AAAI Spring Syposium on Knowledge Representation and Reasoning (KRR): Integrating Symbolic and Neural Approaches, 2015. Angel X. Chang, Thomas Funkhouser, Leonidas Guibas, Pat Hanrahan, Qixing Huang, Zimo Li, Silvio Savarese, Manolis Savva, Shuran Song, Hao Su, Jianxiong Xiao, Li Yi, and Fisher Yu. ShapeNet: An Information-Rich 3D Model Repository. Technical Report arXiv:1512.03012 [cs.GR], Stanford University — Princeton University — Toyota Technological Institute at Chicago, 2015. M-P Dubuisson and Anil K Jain. A Modified Hausdorff Distance for Object Matching. In Proceedings of 12th International Conference on Pattern Recognition, pp. 566–568. IEEE, 1994. Dominik Maria Endres and Johannes E Schindelin. A New Metric for Probability Distributions. IEEE Transactions on Information theory, 2003. Nicholas Guttenberg, Nathaniel Virgo, Olaf Witkowski, Hidetoshi Aoki, and Ryota Kanai. PermutationEquivariant Neural Networks Applied to Dynamics Prediction. arXiv preprint arXiv:1612.04530, 2016. Malte Helmert. A Planning Heuristic Based on Causal Graph Analysis. In Proc. of the International Conference on Automated Planning and Scheduling(ICAPS), pp. 161–170, 2004. URL http:// www.aaai.org/Library/ICAPS/2004/icaps04-021.php. Sepp Hochreiter and Jurgen Schmidhuber. Long Short-Term Memory. ¨ Neural Computation, 9(8):1735– 1780, 1997. Daniel P. Huttenlocher, Gregory A. Klanderman, and William J Rucklidge. Comparing Images using the Hausdorff Distance. IEEE Transactions on Pattern Analysis and Machine Intelligence, 15(9):850–863, 1993. Piotr Indyk and Rajeev Motwani. Approximate Nearest Neighbors: Towards Removing the Curse of Dimensionality. In Proceedings of the thirtieth annual ACM symposium on Theory of computing, pp. 604–613. ACM, 1998. Eric Jang, Shixiang Gu, and Ben Poole. Categorical Reparameterization with Gumbel-Softmax. In Proc. of the International Conference on Learning Representations, 2017. Thanard Kurutach, Aviv Tamar, Ge Yang, Stuart Russell, and Pieter Abbeel. Learning Plannable Representations with Causal InfoGAN. In In Proceedings of ICML / IJCAI / AAMAS 2018 Workshop on Planning and Learning (PAL-18), 2018. Chris J. Maddison, Andriy Mnih, and Yee Whye Teh. The Concrete Distribution: A Continuous Relaxation of Discrete Random Variables. In Proc. of the International Conference on Learning Representations, 2017. Xianling Mao, Bo-Si Feng, Yi-Jing Hao, Liqiang Nie, Heyan Huang, and Guihua Wen. S2JSD-LSH: A Locality-Sensitive Hashing Schema for Probability Distributions. In AAAI, pp. 3244–3251, 2017. Drew V. McDermott. The 1998 AI Planning Systems Competition. AI Magazine, 21(2):35–55, 2000. URL http://www.aaai.org/ojs/index.php/aimagazine/article/view/1506. Gonzalo Mena, David Belanger, Scott Linderman, and Jasper Snoek. Learning Latent Permutations with Gumbel-Sinkhorn Networks. In Proc. of the International Conference on Learning Representations, 2018. URL https://openreview.net/forum?id $\underline { { \underline { { \mathbf { \Pi } } } } } =$ Byt3oJ-0W. Selwyn Piramuthu. The Hausdorff Distance Measure for Feature Selection in Learning Applications. In Systems Sciences, 1999. HICSS-32. Proceedings of the 32nd Annual Hawaii International Conference on, pp. 6–pp. IEEE, 1999. Malte Probst. The Set Autoencoder: Unsupervised Representation Learning for Sets. 2018. A rejected submission to ICLR2018. Siamak Ravanbakhsh, Jeff Schneider, and Barnabas Poczos. Deep Learning with Sets and Point Clouds. arXiv preprint arXiv:1611.04500, 2016. Joseph Redmon, Santosh Divvala, Ross Girshick, and Ali Farhadi. You Only Look Once: Unified, RealTime Object Detection. In Proc. of IEEE Conference on Computer Vision and Pattern Recognition, pp. 779–788, 2016. Tim Rocktaschel and Sebastian Riedel. End-to-End Differentiable Proving. In ¨ Advances in Neural Information Processing Systems, pp. 3788–3800, 2017. Rodrigo Santa Cruz, Basura Fernando, Anoop Cherian, and Stephen Gould. DeepPermNet: Visual Permutation Learning. In Proc. of IEEE Conference on Computer Vision and Pattern Recognition, pp. 6044–6052. IEEE, 2017. Oriol Vinyals, Meire Fortunato, and Navdeep Jaitly. Pointer networks. In Advances in Neural Information Processing Systems, pp. 2692–2700, 2015. URL http://papers.nips.cc/paper/ 5866-pointer-networks. Oriol Vinyals, Samy Bengio, and Manjunath Kudlur. Order Matters: Sequence to Sequence for Sets. Proc. of the International Conference on Learning Representations, 2016. Jun Wang, Wei Liu, Sanjiv Kumar, and Shih-Fu Chang. Learning to Hash for Indexing Big DataA Survey. Proceedings of the IEEE, 104(1):34–57, 2016. Manzil Zaheer, Satwik Kottur, Siamak Ravanbakhsh, Barnabas Poczos, Ruslan R Salakhutdinov, and Alexander J Smola. Deep Sets. In Advances in Neural Information Processing Systems, pp. 3391– 3401, 2017. Zhuotun Zhu, Xinggang Wang, Song Bai, Cong Yao, and Xiang Bai. Deep Learning Representation using Autoencoder for 3D Shape Retrieval. Neurocomputing, 204:41–50, 2016.
# APPENDIX
# 6.1 NETWORK MODEL FOR 8 PUZZLE
As mentioned in the earlier sections, the network has a permutation invariant encoder and the fullyconnected decoder.
The input to the network is a $9 \times 1 5$ matrix, where the first dimension represents the objects and the second dimension represents the features of each object. The encoder has two 1D convolution layers of 1000 neurons with filter size 1, modeling the element-wise network $\rho$ . The output of these layers is then aggregated by taking the sum of the first dimension. The result is then fed to two another fully-connected layers of width 1000, which maps to the latent layer of 100 neurons. All encoder layers are activated by ReLU. The latent representation is regularized and activated by Gumbel-Softmax Maddison et al. (2017); Jang et al. (2017) as the input is a categorical model.
The decoder consists of three fully-connected layers with dropout and batch normalization as shown below:
fc(1000), relu, batchnorm, dropout(0.5), fc(1000), relu, batchnorm, dropout(0.5), dense(135), reshape $( 9 \times 1 5 )$
The last layer is then split into $9 \times 9 , 9 \times 3 , 9 \times 3$ matrices and separately activated by softmax, reflecting the input dataset (Fig. 1).
# 6.2 NETWORK MODEL FOR BLOCKSWOLRD
The same network as the 8-puzzle was used, except that the input and the output is a $5 \times 1 2 2 4$ matrix. The activations of the last layer is different: The first 1024 features are activated by a sigmoid function, while the 200 features are divided into 40, 60, 40, 60 dimensions (for the one-hot bounding box information) and are separately activated by softmax.
# 6.3 FEATURE EXTRACTION FOR BLOCKSWORLD
The 32x32 RGB image patches in the Blocksworld states are compressed into the feature vectors that are later used as the input. The image features are learned by a convolutional autoencoder depicted in Fig. 4 and Fig. 5.
Input $3 2 \times 3 2 \times 3 )$ , GaussianNoise(0.1), conv2d(filte ${ = } 1 6$ , kerne $\mathsf { 1 { = } 3 \times 3 , }$ ), relu, MaxPooling ${ \mathfrak { Q } } ( 2 \times 2 )$ , conv2d(filte ${ = } 1 6$ , kerne $\mathrm { { \Omega } | = 3 \times 3 . }$ ,), relu, MaxPooling $2 { \mathrm { d } } ( 2 \times 2 )$ , conv2d(filte ${ = } 1 6$ , kernel $\mathrm { = 3 \times 3 }$ ,), sigmoid
Figure 4: The implementation of the encoder for feature selection, which outputs a $8 \times 8 \times 1 6$ tensor.
Input(8 × 8 × 16), conv2d(filte ${ = } 1 6$ , kernel=3 × 3,), relu, UpSampling2d $( 2 \times 2 )$ , conv2d(filte ${ = } 1 6$ , kerne $\mathrm { = } 3 \times 3 ,$ ,), relu, UpSampling $2 { \mathrm { d } } ( 2 \times 2 )$ , conv2d(filte ${ = } 1 6$ , kernel $= 3 \times 3 .$ ,), relu, fc(3072), sigmoid, reshape $( 3 2 \times 3 2 \times 3 )$
# 6.4 NETWORK MODEL FOR RULE LEARNING
We removed the encoder and the latent layer from the above models, and connected the input directly to the decoder. While the decoder has the same types of layers, the width is shrinked to 400. In the $_ n$ - neighbor scenario, the input is a $2 + 1 6 3 ( n + 1 )$ vector, which consists of a one-hot label of 2 categories for the predicate of the head, and $n + 1$ one-hot labels of 163 categories for the arguments of the head. 163 categories corresponds to the number of countries in the Countries dataset (Bouchard et al., 2015). The output is a $[ n , 3 2 8 ]$ matrix, where each row represents a binary predicate $3 2 8 = 2 + 2 \cdot 1 6 3$ ).
# 6.5 EXAMPLE APPLICATION OF THE PERMUTATION-INVARIANT REPRESENTATION & RECONSTRUCTION
To address the practical utility of “set reconstruction” or “set autoencoding”, we added a new experiment. We modified Latplan (Asai & Fukunaga, 2018) neural-symbolic classical planning system, a system that operates on a discrete symbolic latent space of the real-valued inputs and runs Dijkstra $\mathrm { \Phi _ { s / A ^ { * } } }$ search using a state-of-the-art symbolic classical planning solver. We modified Latplan to take the set-of-object-featurevector input rather than images. It is a high-level task planner (unlike motion planning / actuator control) that has implications on robotic systems, which perceives a set of inputs already preprocessed by the external system. For example, the image input is first fed into Object Recognition system (e.g. YOLO, (Redmon et al., 2016)) and the planner receives a set of feature vectors extracted from the image patches segmented from the raw image, rather than feeding the image input directly to the planning system.
Latplan system learns the binary latent space of an arbitrary raw input (e.g. images) with a GumbelSoftmax variational autoencoder, learns a discrete state space from the transition examples, and runs a symbolic, systematic search algorithm such as Dijkstra or $\mathbf { A } ^ { * }$ search which guarantee the optimality of the solution. Unlike RL-based planning systems, the search agent does not contain the learning aspects. The discrete plan in the latent space is mapped back to the raw image visualization of the plan execution, which requires the reconstruction capability of (V)AE. A similar system replacing Gumbel Softmax VAE with Causal InfoGAN was later proposed (Kurutach et al., 2018).
We replaced Latplan’s Gumbel-Softmax VAE with our autoencoder used in the 8-Puzzle and the Blocksworld experiments (Appendix, Sec. 6.1,Sec. 6.2). Our autoencoder also uses Gumbel Softmax in the latent layer, but it uses (Zaheer et al., 2017) encoder and is trained with Set Cross Entropy.
When the network learned the representation, it guarantees that the planner finds a solution because the search algorithm being used (e.g. Dijkstra) is a complete, systematic, symbolic search algorithm, which guarantees to find a solution whenever it is reachable in the state space. If the network cannot learn the permutation-invariant representation, the system cannot solve the problem and/or return the humancomprehensive visualization. This makes the specific permutation-invariant representation using (Zaheer et al., 2017) and the proposed Set Cross Entropy necessary when the input is given as a set of future vectors.
# 8 PUZZLE
First, the training was performed on a dataset in which the object vector ordering is randomized. The autoencoder compresses the $1 5 \times 9 = 1 3 5$ -bit binary representation (object vectors) into a permutationinvariant 100-bit discrete latent binary representation. We provided 5000 states for training the autoencoder, while the search space consists of $3 6 2 8 8 0 ( = 9 ! )$ states and 967680 transitions.
Note that each state have 9! variations due to the permutations in the order the tiles and the locations are reported. This also increases the number of transition quadratically $( ( 9 ! ) ^ { 2 } ,$ ).
We generated 40 problem instances of 8-puzzle each generated by a random walk from the goal state. 40 instances consist of 20 instances each generated by a 7-steps random walk and another 20 by 14 steps. We solved 40 instances using Fast Downward classical planner Helmert (2004) with blind heuristics in order to remove the effect of heuristics.
We compared the number of problems successfully solved by two variations of Latplan where each uses the autoencoder trained with Set Average and Set Cross Entropy, respectively, for encoding the input into binary latent space. Both version managed to solve all instances because both Set Average and Set Cross Entropy managed to train the AE from 5000 examples with a sufficient accuracy. All solutions were correct (checked manually). Since the search algorithm being used is optimal, the quality of the solution was also identical.
# BLOCKSWORLD
We solved 30 planning instances in a 4-blocks, 3-stacks environment. The instances are generated by taking a random initial state and choosing a goal state by the 3, 7, or 14 steps random walks (10 instances each). The correctness of the plans are again checked manually. The same planner configuration was used for all instances.
The search space consists of 5760 states and 34560 transitions, and each state have 4! variations due to permutations of 4 blocks. We provided 1000 randomly selected states for training the autoencoder.

 Figure 6: (Left) An example plan in a set-of-object-vector form, decoded from its binary latent representation using the permutation-invariant autoencoder (the plan is executed from top to bottom). (Right) Its visualization using the tile images (taken from MNIST) pasted onto a black canvas (The plan is executed from left to right, top to bottom).
We compared the number of problems successfully solved by Latplan between two variations of Latplan using the autoencoder trained with Set Average and Set Cross Entropy, respectively. For the total of 30 instances, both Latplan $\mathbf { \Gamma } _ { \mathrm { + } \mathrm { S e t } }$ Avg and Latplan $\mathrm { \mathbf { \Omega } _ { 1 + } S C E }$ returned plans, however the plans returned by Latplan $+ \mathrm { S e t }$ Avg were correct in 11 instnaces, while Latplan $+ \mathrm { S C E }$ returned 14 correct instances (Details in Table 7).
As the autoencoder trained by Set Average had larger reconstruction error, it sometimes fails to capture the essential feature of the input, causing the system to return an invalid plan. The common error was changing the surface of the blocks or swapping the blocks without a proper action needed, e.g., moving more than two blocks, move a block and polish another block in a single time step, etc.
<table><tr><td>Random walk steps used for generating</td><td colspan="2">The number of solved instances (out of 1O instances each)</td></tr><tr><td>the problem instances 3</td><td>SH 7</td><td>A1H</td></tr><tr><td>7</td><td>5</td><td>7</td></tr><tr><td>14</td><td>2</td><td>3 1</td></tr></table>
Table 7: The number of instances solved by Latplan using a VAE trained by Set Cross Entropy (SH) and Set Average $( A _ { \mathrm { 1 H } } )$ of the cross entropy.
 Figure 7: An example of a problem instance. (Left) The initial state. (Right) The goal state. The planner should unpolish a green cube and move the blocks to the appropriate goal position, while also following the environment constraint that the blocks can move or polished only when it is on top of a stack (including the floor itself).
 Figure 8: An example of a successful plan execution, returned by Latplan using the AE trained by the proposed Set Cross Entropy method. The AE is used for encoding the object-vector input into a binary space that is suitable for Dijkstra search. While the problem was generated by a 7-step random walk from the goal state, Latplan found a shorter, optimal solution because of the underlying optimal search algorithm (Dijkstra).
 Figure 9: The decoded solution found by Latplan for the same instance, where the AE is trained by SetAverage, which had a higher mean square error for the reconstruction. As a result, not only the initial state is invalid, but also, at the second step, two blocks are simultaneously moved in a single action, which is an invalid state transition.
6.6 ENTIRE PLANNING RESULTS
# 8 PUZZLE
Problem 000, generated by 007 steps
Set Cross Entropy
Set Average




Problem 001, generated by 007 steps
Set Cross Entropy
Set Average




Problem 002, generated by 007 steps
Set Cross Entropy
Set Average




Problem 003, generated by 007 steps
Set Cross Entropy
Set Average





Problem 006, generated by 007 steps
Set Cross Entropy
Set Average




Problem 007, generated by 007 steps
Set Cross Entropy
Set Average















# BLOCKSWORLD




<table><tr><td rowspan=1 colspan=9>Problem O09,generated by 014 stepsSet Cross Entropy (X) Set Average (X)</td></tr><tr><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1>■</td><td rowspan=1 colspan=1>1</td><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1>□</td><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1>:1</td></tr><tr><td rowspan=1 colspan=1>1.</td><td rowspan=1 colspan=1>1</td><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1>:</td><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1>1</td><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1>1</td></tr></table>123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475# COLORING GRAPH NEURAL NETWORKS FOR NODE DISAMBIGUATION
Anonymous authors Paper under double-blind review
# ABSTRACT
In this paper, we show that a simple coloring scheme can improve, both theoretically and empirically, the expressive power of Message Passing Neural Networks (MPNNs). More specifically, we introduce a graph neural network called Colored Local Iterative Procedure (CLIP) that uses colors to disambiguate identical node attributes, and show that this representation is a universal approximator of continuous functions on graphs with node attributes. Our method relies on separability, a key topological characteristic that allows to extend well-chosen neural networks into universal representations. Finally, we show experimentally that CLIP is capable of capturing structural characteristics that traditional MPNNs fail to distinguish, while being state-of-the-art on benchmark graph classification datasets.
# 1 INTRODUCTION
Learning good representations is seen by many machine learning researchers as the main reason behind the tremendous successes of the field in recent years (Bengio et al., 2013). In image analysis (Krizhevsky et al., 2012), natural language processing (Vaswani et al., 2017) or reinforcement learning (Mnih et al., 2015), groundbreaking results rely on efficient and flexible deep learning architectures that are capable of transforming a complex input into a simple vector while retaining most of its valuable features. The universal approximation theorem (Cybenko, 1989; Hornik et al., 1989; Hornik, 1991; Pinkus, 1999) provides a theoretical framework to analyze the expressive power of such architectures by proving that, under mild hypotheses, multi-layer perceptrons (MLPs) can uniformly approximate any continuous function on a compact set. This result provided a first theoretical justification of the strong approximation capabilities of neural networks, and was the starting point of more refined analyses providing valuable insights into the generalization capabilities of these architectures (Baum and Haussler, 1989; Geman et al., 1992; Saxe et al., 2014; Bartlett et al., 2018).
Despite a large literature and state-of-the-art performance on benchmark graph classification datasets, graph neural networks yet lack a similar theoretical foundation (Xu et al., 2019). Universality for these architectures is either hinted at via equivalence with approximate graph isomorphism tests $k$ -WL tests in Xu et al. 2019; Maron et al. 2019a), or proved under restrictive assumptions (finite node attribute space in Murphy et al. 2019). In this paper, we introduce Colored Local Iterative Procedure1 (CLIP), which tackles the limitations of current Message Passing Neural Networks (MPNNs) by showing, both theoretically and experimentally, that adding a simple coloring scheme can improve the flexibility and power of these graph representations. More specifically, our contributions are: 1) we provide a precise mathematical definition for universal graph representations, 2) we present a general mechanism to design universal neural networks using separability, 3) we propose a novel node coloring scheme leading to CLIP, the first provably universal extension of MPNNs, 4) we show that CLIP achieves state of the art results on benchmark datasets while significantly outperforming traditional MPNNs as well as recent methods on graph property testing.
The rest of the paper is organized as follows: Section 2 gives an overview of the graph representation literature and related works. Section 3 provides a precise definition for universal representations, as well as a generic method to design them using separable neural networks. In Section 4, we show that most state-of-the-art representations are not sufficiently expressive to be universal. Then, using the analysis of Section 3, Section 5 provides CLIP, a provably universal extension of MPNNs. Finally,
Section 6 shows that CLIP achieves state-of-the-art accuracies on benchmark graph classification taks, as well as outperforming its competitors on graph property testing problems.
# 2 RELATED WORKS
The first works investigating the use of neural networks for graphs used recurrent neural networks to represent directed acyclic graphs (Sperduti and Starita, 1997; Frasconi et al., 1998). More generic graph neural networks were later introduced by Gori et al. (2005); Scarselli et al. (2009), and may be divided into two categories. 1) Spectral methods (Bruna et al., 2014; Henaff et al., 2015; Defferrard et al., 2016; Kipf and Welling, 2017) that perform convolution on the Fourier domain of the graph through the spectral decomposition of the graph Laplacian. 2) Message passing neural networks (Gilmer et al., 2017), sometimes simply referred to as graph neural networks, that are based on the aggregation of neighborhood information through a local iterative process. This category contains most state-of-the-art graph representation methods such as (Duvenaud et al., 2015; Grover and Leskovec, 2016; Lei et al., 2017; Ying et al., 2018; Verma and Zhang, 2019), DeepWalk (Perozzi et al., 2014), graph attention networks (Velickovic et al., 2018), graphSAGE (Hamilton et al., 2017) or GIN (Xu et al., 2019).
Recently, (Xu et al., 2019) showed that MPNNs were, at most, as expressive as the WeisfeilerLehman (WL) test for graph isomorphism (Weisfeiler and Lehman, 1968). This suprising result led to several works proposing MPNN extensions to improve their expressivity, and ultimately tend towards universality (Maron et al., 2019a;b;c; Murphy et al., 2019; Chen et al., 2019). However, these graph representations are either as powerful as the $k$ -WL test (Maron et al., 2019a), or provide universal graph representations under the restrictive assumption of finite node attribute space (Murphy et al., 2019). Other recent approaches (Maron et al., 2019c) implies quadratic order of tensors in the size of the considered graphs. Some more powerfull GNNs are studied and benchmarked on real classical datasets and on graph property testing (Kriege et al., 2018; Murphy et al., 2019; Chen et al., 2019): a set of problems that classical MPNNs cannot handle. Our work thus provides a more general and powerful result of universality, matching the original definition of (Cybenko, 1989) for MLPs.
# 3 UNIVERSAL REPRESENTATIONS VIA SEPARABILITY
In this section we present the theoretical tools used to design our universal graph representation. More specifically, we show that separable representations are sufficiently flexible to capture all relevant information about a given object, and may be extended into universal representations.
# 3.1 NOTATIONS AND BASIC ASSUMPTIONS
Let $\mathcal { X } , \mathcal { y }$ be two topological spaces, then $\mathcal { F } ( \mathcal { X } , \mathcal { Y } )$ (resp. $\mathcal { C } ( \mathcal { X } , \mathcal { Y } ) )$ denotes the space of all functions (resp. continuous functions) from $\mathcal { X }$ to $\mathcal { V }$ . Moreover, for any group $G$ acting on a set $\mathcal { X }$ , $\mathcal { X } / G$ denotes the set of orbits of $\mathcal { X }$ under the action of $G$ (see Appendix B for more details). Finally, $\| \cdot \|$ is a norm on $\mathbb { R } ^ { d }$ , and $\mathcal { P } _ { n }$ is the set of all permutation matrices of size $n$ . In what follows, we assume that all the considered topological spaces are Hausdorff (see e.g. (Bourbaki, 1998) for an in-depth review): each pair of distinct points can be separated by two disjoint open sets. This assumption is rather weak (e.g. all metric spaces are Hausdorff) and is verified by most topological spaces commonly encountered in the field of machine learning.
# 3.2 UNIVERSAL REPRESENTATIONS
Let $\mathcal { X }$ be a set of objects (e.g. vectors, images, graphs, or temporal data) to be used as input information for a machine learning task (e.g. classification, regression or clustering). In what follows, we denote as vector representation of $\mathcal { X }$ a function $f : \mathcal { X } \overset { } { \to } \mathbb { R } ^ { d }$ that maps each element $x \in \mathcal { X }$ to a $d$ -dimensional vector $f ( x ) \in \mathbb { R } ^ { d }$ . A standard setting for supervised representation learning is to define a class of vector representations $\mathfrak { F } _ { d } \subset \mathcal { F } ( \mathcal { X } , \mathbb { R } ^ { d } )$ (e.g. convolutional neural networks for images) and use the target values (e.g. image classes) to learn a good vector representation in light of the supervised learning task (i.e. one vector representation $f \in \mathfrak { F } _ { d }$ that leads to a good accuracy on the learning task). In order to present more general results, we will consider neural network architectures that can output vectors of any size, i.e. $\mathfrak { F } \subset \cup _ { d \in \mathbb { N } ^ { * } } \mathcal { F } ( \mathcal { X } , \mathbb { R } ^ { d } )$ , and will denote $\mathfrak { F } _ { d } = \mathfrak { F } \cap \mathcal { F } ( \mathcal { X } , \mathbb { R } ^ { d } )$
 Figure 1: Concatenation of two MLPs $f$ and $g$
 Figure 2: Universal representations can easily be created by combining a separable representation with an MLP.
the set of $d$ -dimensional vector representations of $\mathfrak { F }$ . A natural characteristic to ask from the class $\mathfrak { F }$ is to be generic enough to approximate any vector representation, a notion that we will denote as universal representation (Hornik et al., 1989).
Definition 1. A class of vector representations $\mathfrak { F } \subset \cup _ { d \in \mathbb { N } ^ { * } } \mathcal { F } ( \mathcal { X } , \mathbb { R } ^ { d } )$ is called a universal representation of $\mathcal { X }$ if for any compact subset $K \subset { \mathcal { X } }$ and $d \in \mathbb { N } ^ { * }$ , $\mathcal { F }$ is uniformly dense in $\mathcal { C } ( K , \mathbb { R } ^ { d } )$ .
In other words, $\mathfrak { F }$ is a universal representation of a normed space $\mathcal { X }$ if and only if, for any continuous function $\phi : \mathcal { X } \mathbb { R } ^ { d }$ , any compact $K \subset { \mathcal { X } }$ and any $\varepsilon > 0$ , there exists $f \in \mathfrak { F }$ such that
$$\forall x \in K , \ \| \phi ( x ) - f ( x ) \| \leq \varepsilon .$$
One of the most fundamental theorems of neural network theory states that one hidden layer MLPs are universal representations of the $m$ -dimensional vector space $\mathbb { R } ^ { m }$ .
Theorem 1 (Pinkus, 1999, Theorem 3.1). Let $\varphi : \mathbb { R } \mathbb { R }$ be a continuous non polynomial activation function. For any compact $K \subset \mathbb { R } ^ { m }$ and $d \in \mathbb { N } ^ { * }$ , two layers neural networks with activation $\varphi$ are uniformly dense in the set $\mathcal { C } ( K , \mathbb { R } ^ { d } )$ .
However, for graphs and structured objects, universal representations are hard to obtain due to their complex structure and invariance to a group of transformations (e.g. permutations of the node labels). We show in this paper that a key topological property, separability, may lead to universal representations of those structures.
# 3.3 SEPARABILITY IS (ALMOST) ALL YOU NEED
Loosely speaking, universal representations can approximate any vector-valued function. It is thus natural to require that these representations are expressive enough to separate each pair of dissimilar elements of $\mathcal { X }$ .
Definition 2 (Separability). A set of functions $\mathfrak { F } \subset \mathcal { F } ( \mathcal { X } , \mathcal { Y } )$ is said to separate points of $\mathcal { X }$ if for every pair of distinct points $x$ and $y$ , there exists $f \in \mathfrak { F }$ such that $f ( x ) \neq { \bar { f } } ( y )$ .
For a class of vector representations $\mathfrak { F } \subset \cup _ { d \in \mathbb { N } ^ { * } } \mathcal { F } ( \mathcal { X } , \mathbb { R } ^ { d } )$ , we will say that $\mathfrak { F }$ is separable if its 1-dimensional representations $\mathfrak { F } _ { 1 }$ separates points of $\mathcal { X }$ . Separability is rather weak, as we only require the existence of different outputs for every pair of inputs. Unsurprisingly, we now show that it is a necessary condition for universality (see Appendix A for all the detailed proofs).
Proposition 1. Let $\mathfrak { F }$ be a universal representation of $\mathcal { X }$ , then $\mathfrak { F } _ { 1 }$ separates points of $\mathcal { X }$
While separability is necessary for universal representations, it is also key to designing neural network architectures that can be extended into universal representations. More specifically, under technical assumptions, separable representations can be composed with a universal representation of $\mathbb { R } ^ { d }$ (such as MLPs) to become universal.
Theorem 2. For all $d \geq 0 ,$ , let $\mathcal { M } _ { d }$ be a universal approximation of $\mathbb { R } ^ { d }$ . Let $\mathfrak { F }$ be a class of vector representations of $\mathcal { X }$ such that:
(i) Continuity: every $f \in \mathfrak { F }$ is continuous, (ii) Stability by concatenation: for all $f , g \in { \mathfrak { F } }$ , $x \mapsto ( f ( x ) , g ( x ) ) \in \mathfrak { F } ,$ ,
# (iii) Separability: $\mathfrak { F } _ { 1 }$ separates points of $\mathcal { X }$
Then $\{ \psi \circ f : \exists d \geq 1$ s.t. $\psi \in \mathcal { M } _ { d } , f \in \mathfrak { F } \}$ is a universal representation of $\mathcal { X }$ .
Stability by concatenation is verified by most neural networks architectures, as illustrated for MLPs in Figure 1. The proof of Theorem 2 relies on the Stone-Weierstrass theorem (see e.g. Rudin, 1987, Theorem 7.32) whose assumptions are continuity, separability, and the fact that the class of functions is an algebra. Fortunately, composing a separable and concatenable representation with a universal representation automatically leads to an algebra, and thus the applicability of the StoneWeierstrass theorem and the desired result. A complete derivation is available in Appendix A. Since MLPs are universal representations of $\mathbb { R } ^ { d }$ , Theorem 2 implies a convenient way to design universal representations of more complex object spaces: create a separable representation and compose it with a simple MLP (see Figure 2).
Corollary 1. A continuous, concatenable and separable representation of $\mathcal { X }$ composed with an MLP is universal.
Note that many neural networks of the deep learning literature have this two steps structure, including classical image CNNs such as AlexNet (Krizhevsky et al., 2012) or Inception (Szegedy et al., 2016). In this paper, we use Corollary 1 to design universal graph and neighborhood representations, although the method is much more generic and may be applied to other objects.
# 4 LIMITATIONS OF EXISTING REPRESENTATIONS
In this section, we first provide a proper definition for graphs with node attributes, and then show that message passing neural networks are not sufficiently expressive to be universal.
# 4.1 GRAPHS WITH NODE ATTRIBUTES
Consider a dataset of $n$ interacting objects (e.g. users of a social network) in which each object $i \in [ [ 1 , n ] ]$ has a vector attribute $v _ { i } \in \mathbb { R } ^ { m }$ and is a node in an undirected graph $G$ with adjacency J Kmatrix A ∈ Rn×n.
Definition 3. The space of graphs of size $n$ with $m$ -dimensional node attributes is the quotient space
$$\mathbf { G r a p h } _ { m , n } = \left\{ ( v , A ) \in \mathbb { R } ^ { n \times m } \times \mathbb { R } ^ { n \times n } \right\} / \mathcal { P } _ { n } ,$$
where $A$ is the adjacency matrix of the graph, $v$ contains the $m$ -dimensional representation of each node in the graph and the set of permutations matrices $\mathcal { P } _ { n }$ is acting on $( v , A )$ by
$$\forall P \in \mathcal { P } _ { n } , \quad P \cdot ( v , A ) = ( P v , P A P ^ { \top } ) .$$
Moreover, we limit ourselves to graphs of maximum size $n _ { \mathrm { m a x } }$ , where $n _ { \mathrm { m a x } }$ is a large integer. This allows us to consider functions on graphs of different sizes without obtaining infinite dimensional spaces and infinitely complex functions that would be impossible to learn via a finite number of samples. We thus define Graphm = Sn≤nmax . More details on the technical topological aspects of the definition are available in Appendix B, as well as a proof that $\mathbf { G r a p h } _ { m }$ is Hausdorff.
# 4.2 MESSAGE PASSING NEURAL NETWORKS
A common method for designing graph representations is to rely on local iterative procedures. Following the notations of $\mathrm { X u }$ et al. (2019), a message passing neural network (MPNN) (Gilmer et al., 2017) is made of three consecutive phases that will create intermediate node representations $x _ { i , t }$ for each node $i \in [ [ 1 , n ] ]$ and a final graph representation $x _ { G }$ as described by the following J Kprocedure: 1) Initialization: All node representations are initialized with their node attributes $x _ { i , 0 } = v _ { i }$ . 2) Aggregation and combination: $T$ local iterative steps are performed in order to capture larger and larger structural characteristics of the graph. 3) Readout: This step combines all final node representations into a single graph representation: $x _ { G } = \mathtt { R E A D O U T } \big ( \{ x _ { i , T } \} _ { i \in [ [ 1 , n ] ] } \big )$ , where READOUT is permutation invariant.
 Figure 3: Example of two valid colorings of the same attributed graph. Note that each $V _ { k }$ contains nodes with identical attributes.
Unfortunately, while MPNNs are very efficient in practice and proven to be as expressive as the Weisfeiler-Lehman algorithm (Weisfeiler and Lehman, 1968; Xu et al., 2019), they are not sufficiently expressive to construct isomorphism tests or separate all graphs (for example, consider $k$ -regular graphs without node attributes, for which a small calculation shows that any MPNN representation will only depend on the number of nodes and degree $k$ (Xu et al., 2019)). As a direct application of Proposition 1, MPNNs are thus not expressive enough to create universal representations.
# 5 EXTENDING MPNNS USING A SIMPLE COLORING SCHEME
In this section, we present Colored Local Iterative Procedure (CLIP), an extension of MPNNs using colors to differentiate identical node attributes, that is able to capture more complex structural graph characteristics than traditional MPNNs. This is proved theoretically through a universal approximation theorem in Section 5.3 and experimentally in Section 6. CLIP is based on three consecutive steps: 1) graphs are colored with several different colorings, 2) a neighborhood aggregation scheme provides a vector representation for each colored graph, 3) all vector representations are combined to provide a final output vector. We now provide more information on the coloring scheme.
# 5.1 COLORS TO DIFFERENTIATE NODES
In order to distinguish non-isomorphic graphs, our approach consists in coloring nodes of the graph with identical attributes. This idea is inspired by classical graph isomorphism algorithms that use colors to distinguish nodes (McKay, 1981), and may be viewed as an extension of one-hot encodings used for graphs without node attributes $\mathrm { { X u } }$ et al., 2019).
For any $k \in \mathbb N$ , let $C _ { k }$ be a finite set of $k$ colors. These colors may be represented as one-hot encodings ( $C _ { k }$ is the natural basis of $\mathbb { R } ^ { k }$ ) or more generally any finite set of $k$ elements. At initialization, we first partition the nodes into groups of identical attributes $V _ { 1 } , . . . , V _ { K } \subset [ [ 1 , n ] ]$ . Then, for a subset $V _ { k }$ of size $| V _ { k } |$ , we give to each of its nodes a distinct color from $C _ { k }$ J K(hence a subset of size $| V _ { k } | )$ . For example, Figure 3 shows two colorings of the same graph, which is decomposed in three groups $V _ { 1 }$ , $V _ { 2 }$ and $V _ { 3 }$ containing nodes with attributes $a , b$ and $c$ respectively. Since $V _ { 1 }$ contains only two nodes, a coloring of the graph will attribute two colors $( ( 1 , 0 )$ and $( 0 , 1 )$ , depicted as blue and red) to these nodes. More precisely, the set of colorings $ { \mathcal { C } } ( v , A )$ of a graph ${ \cal { G } } = ( v , A )$ are defined as
$$\mathcal { C } ( v , A ) = \Big \{ ( c _ { 1 } , . . . , c _ { n } ) : \forall k \in [ [ 1 , K ] ] , ( c _ { i } ) _ { i \in V _ { k } } \mathrm { { i s } a p e r m u t a t i o n { o f } } C _ { | V _ { k } | } \Big \} .$$
# 5.2 THE CLIP ALGORITHM
In the CLIP algorithm, we add a coloring scheme to an MPNN in order to distinguish identical node attributes. This is achieved by modifying the initialization and readout phases of MPNNs as follows.
1. Colored initialization: We first select a set ${ \mathcal { C } } _ { k } \subseteq { \mathcal { C } } ( v , A )$ of $k$ distinct colorings uniformly at random (see Eq. (4)). Then, for each coloring $c \in { \mathcal { C } } _ { k }$ , node representations are initialized with their node attributes concatenated with their color: $\boldsymbol { x } _ { i , 0 } ^ { c } = \left( \boldsymbol { v } _ { i } , \boldsymbol { c } _ { i } \right)$ .
2. Aggregation and combination: This step is performed for all colorings $c \in { \mathcal { C } } _ { k }$ using a universal set representation as the aggregation function: $\begin{array} { r } { \boldsymbol { x } _ { i , t + 1 } ^ { c } = \psi ^ { ( t ) } \big ( \boldsymbol { x } _ { i , t } ^ { c } , \sum _ { j \in \mathcal { N } _ { i } } \varphi ^ { ( t ) } \bar { ( } \boldsymbol { x } _ { j , t } ^ { c } ) \big ) } \end{array}$ , where $\psi$ and $\varphi$ are MLPs with continuous non-polynomial activation functions and $\psi ( x , y )$ denotes the result of $\psi$ applied to the concatenation of $x$ and $y$ . The aggregation scheme we propose is closely related to DeepSet (Zaheer et al., 2017), and a direct application of Corollary 1 proves the universality of our architecture. More details, as well as the proof of universality, are available in Appendix C.
3. Colored readout: This step performs a maximum over all possible colorings in order to obtain a final coloring-independent graph representation. In order to keep the stability by concatenation, the maximum is taken coefficient-wise
$$x _ { G } = \psi \left( \operatorname* { m a x } _ { c \in \mathcal { C } _ { k } } \sum _ { i = 1 } ^ { n } x _ { i , T } ^ { c } \right) ,$$
where $\psi$ is an MLP with continuous non polynomial activation functions.
We treat $k$ as a hyper-parameter of the algorithm and call $k$ -CLIP (resp. $\infty$ -CLIP) the algorithm using $k$ colorings (resp. all colorings, i.e. $\boldsymbol { \bar { k } } = | \mathcal { C } ( \boldsymbol { v } , \boldsymbol { A } ) | )$ . Note that, while our focus is graphs with node attributes, the approach used for CLIP is easily extendable to similar data structures such as directed or weighted graphs with node attributes, graphs with node labels, graphs with edge attributes or graphs with additional attributes at the graph level.
# 5.3 UNIVERSAL REPRESENTATION THEOREM
As the colorings are chosen at random, the CLIP representation is itself random as soon as $k <$ $| \mathcal { C } ( v , A ) |$ , and the number of colorings $k$ will impact the variance of the representation. However, $\infty$ -CLIP is deterministic and permutation invariant, as MPNNs are permutation invariant. The separability is less trivial and is ensured by the coloring scheme.
Theorem 3. The $\infty$ -CLIP algorithm with one local iteration $T = 1 .$ ) is a universal representation of the space $\mathbf { G r a p h } _ { m }$ of graphs with node attributes.
The proof of Theorem 3 relies on showing that $\infty$ -CLIP is separable and applying Corollary 1. This is achieved by fixing a coloring on one graph and identifying all nodes and edges of the second graph using the fact that all pairs $( v _ { i } , c _ { i } )$ are dissimilar (see Appendix D). Similarly to the case of MLPs, only one local iteration is necessary to ensure universality of the representation. This rather counter-intuitive result is due to the fact that all nodes can be identified by their color, and the readout function can aggregate all the structural information in a complex and non-trivial way. However, as for MLPs, one may expect poor generalization capabilities for CLIP with only one local iteration, and deeper networks may allow for more complex representations and better generalization. This point is addressed in the experiments of Section 6. Moreover, $\infty$ -CLIP may be slow in practice due to a large number of colorings, and reducing $k$ will speed-up the computation. Fortunately, while $k$ -CLIP is random, a similar universality theorem still holds even for $k = 1$ .
Theorem 4. The 1-CLIP algorithm with one local iteration $T = 1 .$ ) is a random representation whose expectation is a universal representation of the space $\mathbf { G r a p h } _ { m }$ of graphs with node attributes.
The proof of Theorem 4 relies on using $\infty$ -CLIP on the augmented node attributes $\boldsymbol { v } _ { i } ^ { \prime } = \left( v _ { i } , c _ { i } \right)$ . As all node attributes are, by design, different, the max over all colorings in Eq. (5) disappears and, for any coloring, 1-CLIP returns an $\varepsilon$ -approximation of the target function (see Appendix D).
Remark 1. Note that the variance of the representation may be reduced by averaging over multiple samples. Moreover, the proof of Theorem 4 shows that the variance can be reduced to an arbitrary precision given enough training epochs, although this may lead to very large training times in practice.
# 5.4 COMPUTATIONAL COMPLEXITY
As the local iterative steps are performed $T$ times on each node and the complexity of the aggregation depends on the number of neighbors of the considered node, the complexity is proportional to the number of edges of the graph $E$ and the number of steps $T$ . Moreover, CLIP performs this iterative aggregation for each coloring, and its complexity is also proportional to the number of chosen colorings $k = | \mathcal { C } _ { k } |$ . Hence the complexity of the algorithm is in $O ( k E T )$ .
Note that the number of all possible colorings for a given graph depends exponentially in the size of the groups $V _ { 1 } , . . . , V _ { K }$ ,
$$| { \mathcal C } ( v , A ) | = \prod _ { k = 1 } ^ { K } | V _ { k } | ! ,$$
and thus $\infty$ -CLIP is practical only when most node attributes are dissimilar. This worst case exponential dependency in the number of nodes can hardly be avoided for universal representations. Indeed, a universal graph representation should also be able to solve the graph isomorphism problem. Despite the existence of polynomial time algorithms for a broad class of graphs (Luks, 1982; Bodlaender, 1990), graph isomorphism is still quasi-polynomial in general (Babai, 2016). As a result, creating a universal graph representation with polynomial complexity for all possible graphs and functions to approximate is highly unlikely, as it would also induce a graph isomorphism test of polynomial complexity and thus solve a very hard and long standing open problem of theoretical computer science.
# 6 EXPERIMENTS
In this section we show empirically the practical efficiency of CLIP and its relaxation. We run two sets of experiments to compare CLIP w.r.t. state-of-the-art methods in supervised learning settings: i) on 5 real-world graph classification datasets and ii) on 4 synthetic datasets to distinguish structural graph properties and isomorphism. Both experiments follow the same experimental protocol as described in $\mathrm { X u }$ et al. (2019): 10-fold cross validation with grid search hyper-parameter optimization. More details on the experimental setup are provided in Appendix E.
# 6.1 CLASSICAL BENCHMARK DATASETS
We performed experiments on five benchmark datasets extracted from standard social networks (IMDBb and IMDBm) and bio-informatics databases (MUTAG, PROTEINS and PTC). All dataset characteristics (e.g. size, classes), as well as the experimental setup, are available in Appendix E. Following standard practices for graph classification on these datasets, we use one-hot encodings of node degrees as node attributes for IMDBb and IMDBm (Xu et al., 2019), and perform singlelabel multi-class classification on all datasets. We compared CLIP with six state-of-the-art baseline algorithms: 1) WL: Weisfeiler-Lehman subtree kernel (Shervashidze et al., 2011), 2) AWL: Anonymous Walk Embeddings (Ivanov and Burnaev, 2018), 3) DCNN: Diffusion-convolutional neural networks (Atwood and Towsley, 2016), 4) PS: PATCHY-SAN (Niepert et al., 2016), 5) DGCNN: Deep Graph CNN (Zhang et al., 2018) and 6) GIN: Graph Isomorphism Network (Xu et al., 2019). WL and AWL are representative of unsupervised methods coupled with an SVM classifier, while DCNN, PS, DGCNN and GIN are four deep learning architectures. As the same experimental protocol as that of Xu et al. (2019) was used, we present their reported results on Table 1.
Table 1: Classification accuracies of the compared methods on benchmark datasets. The best performer w.r.t. the mean is highlighted with an asterisk. We perform an unpaired t-test with asymptotic significance of 0.1 w.r.t. the best performer and highlight with boldface the ones for which the difference is not statistically significant. 0-CLIP is the CLIP architecture without any colorings.
<table><tr><td>Dataset</td><td>PTC</td><td>IMDBb</td><td>IMDBm</td><td>PROTEINS</td><td>MUTAG</td></tr><tr><td>WL DCNN</td><td>59.9±4.3</td><td>73.8±3.9</td><td>50.9±3.8</td><td>75.0±3.1</td><td>90.4±5.7</td></tr><tr><td>PS</td><td>56.6 60.0±4.8</td><td>49.1</td><td>33.5</td><td>61.3</td><td>67.0</td></tr><tr><td></td><td></td><td>71.0±2.2</td><td>45.2±2.8</td><td>75.9±2.8</td><td>92.6±4.2</td></tr><tr><td>DGCNN</td><td>58.6</td><td>70.0</td><td>47.8</td><td>75.5</td><td>85.8</td></tr><tr><td>AWL</td><td>=</td><td>74.5±5.9</td><td>51.5±3.6</td><td>/</td><td>87.9±9.8</td></tr><tr><td>GIN</td><td>64.6±7.0</td><td>75.1±5.1</td><td>52.3±2.8</td><td>76.2±2.8</td><td>89.4±5.6</td></tr><tr><td>0-CLIP</td><td>65.9±4.0</td><td>75.4±2.0</td><td>52.5±2.6*</td><td>77.0±3.2</td><td>90.0±5.1</td></tr><tr><td>CLIP</td><td>67.9±7.1*</td><td>76.0±2.7*</td><td>52.5±3.0*</td><td>77.1±4.4*</td><td>93.9±4.0*</td></tr></table>
As Table 1 shows, CLIP can achieve state-of-the-art performance on the five benchmark datasets. Moreover, CLIP is consistent across all datasets, while all other competitors have at least one weak performance. This is a good indicator of the robustness of the method to multiple classification tasks and dataset types. Finally, the addition of colors does not improve the accuracy for these graph classification tasks, except on the MUTAG dataset. This may come from the small dataset sizes (leading to high variances) or an inherent difficulty of these classification tasks, and contrasts with the clear improvements of the method for property testing (see Section 6.2). More details on the performance of CLIP w.r.t. the number of colors $k$ are available in Appendix E.
Remark 2. In three out of five datasets, none of the recent state-of-the-art algorithms have statistically significantly better results than older methods (e.g. WL). We argue that, considering the high variances of all classification algorithms on classical graph datasets, graph property testing may be better suited to measure the expressiveness of graph representation learning algorithms in practice.
# 6.2 GRAPH PROPERTY TESTING
We now investigate the ability of CLIP to identify structural graph properties, a task which was previously used to evaluate the expressivity of graph kernels and on which the Weisfeiler-Lehman subtree kernel has been shown to fail for bounded-degree graphs (Kriege et al., 2018). The performance of our algorithm is evaluated for the binary classification of four different structural properties: 1) connectivity, 2) bipartiteness, 3) triangle-freeness, 4) circular skip links (Murphy et al., 2019) (see Appendix E for precise definitions of these properties) against three competitors: a) GIN, arguably the most efficient MPNN variant yet published (Xu et al., 2019), b) Ring-GNN, a permutation invariant network that uses the ring of matrix addition and multiplication (Chen et al., 2019), c) RP-GIN, the Graph Isomorphism Network combined with Relational Pooling, as described by Murphy et al. (2019), which is able to distinguish certain cases of non-isomorphic regular graphs. We provide all experimental details in Appendix E.
Table 2: Classification accuracies of the synthetic datasets. $k$ -RP-GIN refers to a relational pooling averaged over $k$ random permutations. We report Ring-GNN results from Chen et al. (2019).
<table><tr><td>Property</td><td>Connectivity</td><td>Bipartiteness</td><td>Triangle-freeness</td><td colspan="3">Circular skip links</td></tr><tr><td></td><td>mean ± std</td><td>mean ± std</td><td>mean ± std</td><td>mean ± std</td><td>max</td><td>min</td></tr><tr><td>GIN</td><td>55.2 ± 4.4</td><td>53.1 ±4.7</td><td>50.7±6.1</td><td>10.0 ± 0.0</td><td>10.0</td><td>10.0</td></tr><tr><td>Ring-GNN</td><td>=</td><td>=</td><td>1</td><td>(?) ± 15.7</td><td>80.0</td><td>10.0</td></tr><tr><td>1-RP-GIN</td><td>66.1±5.2</td><td>66.0±5.1</td><td>63.0±3.6</td><td>20.0 ± 7.0</td><td>28.6</td><td>10.0</td></tr><tr><td>16-RP-GIN</td><td>83.3±7.9</td><td>64.9±4.1</td><td>65.7±3.3</td><td>37.6 ± 12.9</td><td>53.3</td><td>10.0</td></tr><tr><td>0-CLIP</td><td>56.5 ± 4.0</td><td>55.4 ± 5.7</td><td>59.6 ± 3.8</td><td>10.0 ± 0.0</td><td>10.0</td><td>10.0</td></tr><tr><td>1-CLIP</td><td>73.3 ± 2.2</td><td>63.3 ±1.9</td><td>63.5 ±7.3</td><td>61.9 ±11.9</td><td>80.7</td><td>36.7</td></tr><tr><td>16-CLIP</td><td>99.7 ± 0.5</td><td>99.2 ± 0.9</td><td>94.2±3.4</td><td>90.8 ± 6.8</td><td>98.7</td><td>76.0</td></tr></table>
Table 2 shows that CLIP is able to capture the structural information of connectivity, bipartiteness, triangle-freeness and circular skip links, while MPNN variants fail to identify these graph properties. Furthermore, we observe that CLIP outperforms RP-GIN, that was shown to provide very expressive representations for regular graphs (Murphy et al., 2019), even with a high number of permutations (the equivalent of colors in their method is set to $k = 1 6$ ). Moreover, both for $k$ -RP-GIN and $k$ -CLIP, the increase of permutations and colorings respectively lead to higher accuracies. In particular, CLIP can capture almost perfectly the different graph properties with as little as $k = 1 6$ colorings.
# 7 CONCLUSION
In this paper, we showed that a simple coloring scheme can improve the expressive power of MPNNs. Using such a coloring scheme, we extended MPNNs to create CLIP, the first universal graph representation. Universality was proven using the novel concept of separable neural networks, and our experiments showed that CLIP is state-of-the-art on both graph classification datasets and property testing tasks. The coloring scheme is especially well suited to hard classification tasks that require complex structural information to learn. The framework is general and simple enough to extend to other data structures such as directed, weighted or labeled graphs. Future work includes more detailed and quantitative approximation results depending on the parameters of the architecture such as the number of colors $k$ , or number of hops of the iterative neighborhood aggregation.
# REFERENCES
Atwood, J. and Towsley, D. (2016). Diffusion-convolutional neural networks. In Advances in Neural Information Processing Systems.
Babai, L. (2016). Graph isomorphism in quasipolynomial time. In Proceedings of the forty-eighth annual ACM symposium on Theory of Computing, pages 684–697. ACM.
Bartlett, P., Helmbold, D., and Long, P. (2018). Gradient descent with identity initialization efficiently learns positive definite linear transformations. In International Conference on Machine Learning, pages 520–529.
Baum, E. B. and Haussler, D. (1989). What size net gives valid generalization? In Advances in neural information processing systems, pages 81–90.
Bengio, Y., Courville, A., and Vincent, P. (2013). Representation learning: A review and new perspectives. IEEE transactions on pattern analysis and machine intelligence, 35(8):1798–1828.
Bodlaender, H. L. (1990). Polynomial algorithms for graph isomorphism and chromatic index on partial k-trees. Journal of Algorithms, 11(4):631–643.
Bourbaki, N. (1998). General Topology: Chapters 1-4. Number vol. 4 in Addison-Wesley series in mathematics. Springer.
Bruna, J., Zaremba, W., Szlam, A., and Lecun, Y. (2014). Spectral networks and locally connected networks on graphs. ICLR.
Chen, Z., Villar, S., Chen, L., and Bruna, J. (2019). On the equivalence between graph isomorphism testing and function approximation with gnns. NeurIPS 2019, abs/1905.12560.
Cybenko, G. (1989). Approximation by superpositions of a sigmoidal function. Mathematics of control, signals and systems, 2(4):303–314.
Defferrard, M., Bresson, X., and Vandergheynst, P. (2016). Convolutional neural networks on graphs with fast localized spectral filtering. In Advances in Neural Information Processing Systems, pages 3844–3852.
Duvenaud, D. K., Maclaurin, D., Iparraguirre, J., Bombarell, R., Hirzel, T., Aspuru-Guzik, A., and Adams, R. P. (2015). Convolutional networks on graphs for learning molecular fingerprints. In Advances in neural information processing systems, pages 2224–2232.
Erdös, P. and Rényi, A. (1959). On random graphs i. Publicationes Mathematicae Debrecen, 6:290.
Frasconi, P., Gori, M., and Sperduti, A. (1998). A general framework for adaptive processing of data structures. IEEE transactions on Neural Networks, 9(5):768–786.
Geman, S., Bienenstock, E., and Doursat, R. (1992). Neural networks and the bias/variance dilemma. Neural computation, 4(1):1–58.
Gilmer, J., Schoenholz, S. S., Riley, P. F., Vinyals, O., and Dahl, G. E. (2017). Neural message passing for quantum chemistry. ICML.
Gori, M., Monfardini, G., and Scarselli, F. (2005). A new model for learning in graph domains. In Neural Networks, 2005. IJCNN’05. Proceedings. 2005 IEEE International Joint Conference on, volume 2, pages 729–734. IEEE.
Grover, A. and Leskovec, J. (2016). node2vec: Scalable feature learning for networks. In Proceedings of the 22nd ACM SIGKDD international conference on Knowledge discovery and data mining, pages 855–864. ACM.
Guttenberg, N., Virgo, N., Witkowski, O., Aoki, H., and Kanai, R. (2016). Permutation-equivariant neural networks applied to dynamics prediction. arXiv preprint arXiv:1612.04530.
Hamilton, W., Ying, Z., and Leskovec, J. (2017). Inductive representation learning on large graphs. In Advances in Neural Information Processing Systems, pages 1024–1034.
Henaff, M., Bruna, J., and LeCun, Y. (2015). Deep convolutional networks on graph-structured data. arXiv preprint arXiv:1506.05163.
Hornik, K. (1991). Approximation capabilities of multilayer feedforward networks. Neural networks, 4(2):251–257.
Hornik, K., Stinchcombe, M., and White, H. (1989). Multilayer feedforward networks are universal approximators. Neural networks, 2(5):359–366.
Ivanov, S. and Burnaev, E. (2018). Anonymous walk embeddings. ICML.
Kipf, T. N. and Welling, M. (2017). Semi-supervised classification with graph convolutional networks. ICLR.
Kriege, N. M., Morris, C., Rey, A., and Sohler, C. (2018). A property testing framework for the theoretical expressivity of graph kernels. In Proceedings of the Twenty-Seventh International Joint Conference on Artificial Intelligence, IJCAI-18, pages 2348–2354. International Joint Conferences on Artificial Intelligence Organization.
Krizhevsky, A., Sutskever, I., and Hinton, G. E. (2012). Imagenet classification with deep convolutional neural networks. In Advances in Neural Information Processing Systems, pages 1097–1105.
Lei, T., Jin, W., Barzilay, R., and Jaakkola, T. (2017). Deriving neural architectures from sequence and graph kernels. ICML.
Luks, E. M. (1982). Isomorphism of graphs of bounded valence can be tested in polynomial time. Journal of Computer and System Sciences, 25(1):42 – 65.
Maron, H., Ben-Hamu, H., Serviansky, H., and Lipman, Y. (2019a). Provably powerful graph networks. NeurIPS.
Maron, H., Ben-Hamu, H., Shamir, N., and Lipman, Y. (2019b). Invariant and equivariant graph networks. In International Conference on Learning Representations.
Maron, H., Fetaya, E., Segol, N., and Lipman, Y. (2019c). On the universality of invariant networks. ICML 2019.
McKay, B. D. (1981). Practical graph isomorphism. Congressus Numerantium, 30:45–87.
Mnih, V., Kavukcuoglu, K., Silver, D., Rusu, A. A., Veness, J., Bellemare, M. G., Graves, A., Riedmiller, M., Fidjeland, A. K., Ostrovski, G., Petersen, S., Beattie, C., Sadik, A., Antonoglou, I., King, H., Kumaran, D., Wierstra, D., Legg, S., and Hassabis, D. (2015). Human-level control through deep reinforcement learning. Nature, 518(7540):529–533.
Murphy, R., Srinivasan, B., Rao, V., and Ribeiro, B. (2019). Relational pooling for graph representations. In Chaudhuri, K. and Salakhutdinov, R., editors, Proceedings of the 36th International Conference on Machine Learning, volume 97 of Proceedings of Machine Learning Research, pages 4663–4673, Long Beach, California, USA. PMLR.
Niepert, M., Ahmed, M., and Kutzkov, K. (2016). Learning convolutional neural networks for graphs. In International conference on machine learning.
Perozzi, B., Al-Rfou, R., and Skiena, S. (2014). Deepwalk: Online learning of social representations. In Proceedings of the 20th ACM SIGKDD international conference on Knowledge discovery and data mining, pages 701–710. ACM.
Pinkus, A. (1999). Approximation theory of the mlp model in neural networks. Acta numerica, 8:143–195.
Qi, C. R., Su, H., Mo, K., and Guibas, L. J. (2017). Pointnet: Deep learning on point sets for 3d classification and segmentation. CVPR.
Rudin, W. (1987). Real and Complex Analysis, 3rd Ed. McGraw-Hill, Inc., New York, NY, USA.
Saxe, A. M., McClelland, J. L., and Ganguli, S. (2014). Exact solutions to the nonlinear dynamics of learning in deep linear neural networks. ICLR. Scarselli, F., Gori, M., Tsoi, A. C., Hagenbuchner, M., and Monfardini, G. (2009). The graph neural network model. IEEE Transactions on Neural Networks, 20(1):61–80. Shervashidze, N., Schweitzer, P., Leeuwen, E. J. v., Mehlhorn, K., and Borgwardt, K. M. (2011). Weisfeiler-lehman graph kernels. Journal of Machine Learning Research. Sperduti, A. and Starita, A. (1997). Supervised neural networks for the classification of structures. IEEE Transactions on Neural Networks, 8(3):714–735. Szegedy, C., Vanhoucke, V., Ioffe, S., Shlens, J., and Wojna, Z. (2016). Rethinking the inception architecture for computer vision. In Proceedings of the IEEE conference on computer vision and pattern recognition, pages 2818–2826. Vaswani, A., Shazeer, N., Parmar, N., Uszkoreit, J., Jones, L., Gomez, A. N., Kaiser, ł., and Polosukhin, I. (2017). Attention is all you need. In Advances in Neural Information Processing Systems, pages 5998–6008. Curran Associates, Inc. Velickovic, P., Cucurull, G., Casanova, A., Romero, A., Lio, P., and Bengio, Y. (2018). Graph attention networks. ICLR. Verma, S. and Zhang, Z.-L. (2019). Graph capsule convolutional neural networks. ICLR. Weisfeiler, B. and Lehman, A. (1968). A reduction of a graph to a canonical form and an algebra arising during this reduction. Nauchno-Technicheskaya Informatsia, 2(9):12–16. Xu, K., Hu, W., Leskovec, J., and Jegelka, S. (2019). How powerful are graph neural networks? ICLR. Ying, R., You, J., Morris, C., Ren, X., Hamilton, W. L., and Leskovec, J. (2018). Hierarchical graph representation learning with differentiable pooling. In Advances in Neural Information Processing Systems, pages 4805–4815. Zaheer, M., Kottur, S., Ravanbakhsh, S., Póczos, B., Salakhutdinov, R., and Smola, A. J. (2017). Deep sets. In Advances in Neural Information Processing Systems. Zhang, M., Cui, Z., Neumann, M., and Chen, Y. (2018). An end-to-end deep learning architecture for graph classification. In Proceedings of AAAI Conference on Artificial Inteligence.
# A PROOFS OF THE UNIVERSALITY OF SEPARABLE NEURAL NETWORKS
Proof of Theorem 2. The proof relies on the Stone-Weierstrass theorem we recall below. We refer to (Rudin, 1987, Theorem 7.32) for a detailed proof of the following classical theorem.
Theorem 5 (Stone-Weierstrass). Let $\mathcal { A }$ be an algebra of real functions on a compact Hausdorff set $K$ . If $\mathcal { A }$ separates points of $K$ and contains a non-zero constant function, then $\mathcal { A }$ is uniformly dense in ${ \mathcal { C } } ( K , \mathbb { R } )$ .
We verify that under the assumptions of Theorem 2 the Stone-Weierstrass theorem applies. In this setting, we first prove the theorem for $m = 1$ and use induction for the general case.
Let $K \subset { \mathcal { X } }$ be a compact subset of $\mathcal { X }$ . We will denote
$$\begin{array} { r } { \mathcal { A } _ { 0 } = \left\{ \psi \circ f \ : \ \exists d \geq 1 \mathrm { ~ s . t . ~ } \psi \in \mathcal { C } ( \mathbb { R } ^ { d } , \mathbb { R } ) , f \in \mathfrak { F } \right\} , } \end{array}$$
and will proceed in two steps: we first show that $\mathcal { A } _ { \mathrm { 0 } }$ is uniformly dense in ${ \mathcal { C } } ( K , \mathbb { R } )$ , then that $\mathcal { A }$ is dense in $\mathcal { A } _ { 0 }$ , hence proving Theorem 2.
Lemma 1. $\mathcal { A } _ { 0 }$ is a subalgebra of ${ \mathcal { C } } ( K , \mathbb { R } )$ .
Proof. The subset $\mathcal { A } _ { \mathrm { 0 } }$ contains zero and all constants. Let $f , g \in { \mathcal { A } } _ { 0 }$ so that
$$f ( x ) = \psi _ { f } \circ \varphi _ { f } ( x ) , g ( x ) = \psi _ { g } \circ \varphi _ { g } ( x ) ,$$
with $\psi _ { f } : \mathbb { R } ^ { d _ { f } } \mathbb { R }$ and $\psi _ { g } : \mathbb { R } ^ { d _ { g } } \mathbb { R }$ . Consider $\psi : \mathbb { R } ^ { d _ { f } + d _ { g } } \mathbb { R }$ such that $\psi ( a , b ) = $ $\psi _ { f } ( a ) + \psi _ { g } ( b )$ . We define $\varphi ( \bar { \boldsymbol { x } } ) = ( \varphi _ { f } ( \boldsymbol { x } ) , \varphi _ { g } ( \boldsymbol { x } ) ) \in \mathbb { R } ^ { d _ { f } + d _ { g } }$ and by assumption $\varphi \in { \mathfrak { F } }$ . We have
$$\begin{array} { r l } { ( f + g ) ( x ) = \psi ( \varphi _ { f } ( x ) , \varphi _ { g } ( x ) ) } & { { } } \\ { \qquad = \psi \circ \varphi ( x ) } & { { } } \end{array}$$
so that $f + g \in { \mathcal { A } } _ { 0 }$ and we conclude that $\mathcal { A } _ { 0 }$ is a vectorial subspace of ${ \mathcal { C } } ( K , \mathbb { R } )$ . We proceed similarly for the product in order to finish the proof of the lemma. □
Because $\mathfrak { F } _ { 1 }$ separates the points of $\mathcal { X }$ by assumption, $A _ { 0 }$ also separates the points of $\mathcal { X }$ . Indeed, let $x \neq y$ two distinct points of $X$ so that $\exists f \in \mathfrak { F }$ such that $f ( x ) \neq f ( y )$ . There exists $g \in \mathcal { C } ( \mathbb { R } ^ { d } , \mathbb { R } )$ such that $g ( f ( x ) ) \bar { \neq } g ( f ( y ) )$ . From Theorem 5 we deduce that $A _ { 0 }$ is uniformly dense in ${ \mathcal { C } } ( K , \mathbb { R } )$ for all compact subsets $K \subset { \mathcal { X } }$ .
Finally we state that:
Lemma 2. For any compact subset $K \subset { \mathcal { X } }$ , $\mathcal { A }$ is uniformly dense in $\mathcal { A } _ { \mathrm { 0 } }$
Proof. Let $\epsilon > 0$ and $h = \psi _ { 0 } \circ f \in \mathcal { A } _ { 0 }$ with $f \in { \mathfrak { F } }$ and $\psi _ { 0 } \in \mathcal { C } ( \mathbb { R } ^ { d } , \mathbb { R } )$ . Thanks to the continuity of $f$ , the image $\tilde { K } = f ( K )$ is a compact of $\mathbb { R } ^ { d }$ . By Theorem 1 there exists an MLP $\psi$ such that $\| \psi - \psi _ { 0 } \| _ { \tilde { K } , \infty } \le \epsilon .$ . We have $\psi \circ f \in { \mathcal { A } }$ and $\| \psi _ { 0 } \circ f - \psi \circ f \| _ { K , \infty } \leq \epsilon$ which concludes the proof.
This last lemma completes the proof in the case $m = 1$ . For $m \geq 2$ consider $\mathcal { A } _ { 0 } = \{ \psi \circ f : \exists d \geq$ 1 s.t. $\psi \in \mathcal { C } ( \mathbb { R } ^ { d } , \mathbb { R } ^ { m } ) , f \in \mathfrak { F } \}$ and proceed in a similar manner than Lemma 2 by decomposing $\psi \in \mathcal { C } ( \mathbb { R } ^ { d } , \mathbb { R } ^ { m } )$ as
$$\psi ( x ) = \left( \begin{array} { c } { { \psi _ { 1 } ( x ) } } \\ { { \psi _ { 2 } ( x ) } } \\ { { \vdots } } \\ { { \psi _ { m } ( x ) } } \end{array} \right) ,$$
and applying Lemma 1 for each coefficient function $\psi _ { i } \in \mathcal { C } ( \mathbb { R } ^ { d } , \mathbb { R } )$ .
Proof of Proposition $^ { l }$ . Assume that there exists $x , y \in { \mathcal { X } }$ s.t. $\forall f \in \mathfrak { F } _ { 1 }$ , $f ( x ) = f ( y )$ . Then $K =$ $\{ x , y \}$ is a compact subset of $\mathcal { X }$ and let $\phi \in \mathcal { C } ( K , \mathbb { R } )$ be such that $\phi ( x ) = 1$ and $\phi ( y ) = 0$ . Thus, for all $f \in \mathfrak { F } _ { 1 }$ , $\begin{array} { r } { \operatorname* { m a x } _ { z \in \{ x , y \} } \| \phi ( z ) - f ( z ) \| \ge 1 / 2 } \end{array}$ which contradicts universality (see Definition 1).
# B GROUP ACTION ON HAUSDORFF SPACES
In what follows, $\mathcal { X }$ is always a topological set and $G$ a group of transformations acting on $\mathcal { X }$ . The orbits of $\mathcal { X }$ under the action of $G$ are the sets $G x = { \bar { \{ g \cdot x : g \in G \} } }$ . Moreover, we denote as $\mathcal { X } / G$ the quotient space of orbits, also defined by the equivalence relation: $x \sim y \iff \exists g \in G$ s.t. $x = g \cdot y$ . As stated in Section 5, graphs with node attributes can be defined using invariance by permutation of the labels. We prove here that the resulting spaces are Hausdorff.
Definition 4 (Group invariance). Let $G$ a group, a function $f : \mathcal { X } \mathcal { Y }$ is $G$ -invariant if
$$\forall x \in { \mathcal { X } } , \forall g \in G , f ( x ) = f ( g \cdot x ) .$$
Lemma 3 ((Bourbaki, 1998, I, $\ S 8 . 3 )$ ). Let $\mathcal { X }$ be a Hausdorff space and $\mathcal { R }$ an equivalence relation of $\mathcal { X }$ . Then $\mathcal { X } / \mathcal { R }$ is Hausdorff if and only if any two distinct equivalence classes in $\mathcal { X }$ are contained in disjoints saturated open subsets of $\mathcal { X }$ .
Thanks to this lemma we prove the following proposition.
Proposition 2. Let $G$ a finite group acting on an Hausdorff space $\mathcal { X }$ , then the orbit space $\mathcal { X } / G$ is Hausdorff.
Proof. Let $G x$ and $G y$ two distinct classes with disjoint open neighbourhood $U$ and $V$ . By finiteness of $G$ , the application $\pi : \mathcal { X } \to \mathcal { X } / G$ is open, hence the saturated sets $\tilde { U } ~ = ~ \pi ^ { - 1 } [ \pi ( U ) ]$ and $\tilde { V } = \pi ^ { - 1 } [ \pi ( V ) ]$ are open. Suppose that there exists $z \in \tilde { U } \cap \tilde { V }$ , then $\pi ( z ) \in \pi ( U ) \cap \pi ( V )$ and we finally get that $G z \subset U \cap V = \emptyset$ . Therefore $\tilde { U } \cap \tilde { V }$ is empty and $\mathcal { X } / G$ is Hausdorff by Lemma 3.
Proposition 2 directly implies that the spaces $\mathbf { G r a p h } _ { m }$ and Neighborhood $_ m$ are Hausdorff.
# C UNIVERSALITY OF THE NODE AGGREGATION SCHEME
We now provide more details on the aggregation and combination scheme of CLIP, and show that a simple application of Corollary 1 is sufficient to prove its universality for node neighborhoods. Each local aggregation step takes as input a couple $( x _ { i } , \bar { \{ x _ { j } \} } _ { j \in \mathcal { N } _ { i } } )$ where $x _ { i } \in \mathbb { R } ^ { m }$ is the representation of node $i$ , and $\{ x _ { j } \} _ { j \in \mathcal { N } _ { i } }$ is the set of vector representations of the neighbors of node $i$ . In the following, we show how to use Corollary 1 to design universal representations for node neighborhoods.
Definition 5. The set of node neighborhoods for $m$ -dimensional node attributes is defined as
$$\mathbf { N e i g h b o r h o o d } _ { m } = \mathbb { R } ^ { m } \times \bigcup _ { n \leq n _ { \operatorname* { m a x } } } \left( \mathbb { R } ^ { n \times m } / \mathcal { P } _ { n } \right) ,$$
where the set of permutation matrices $\mathcal { P } _ { n }$ is acting on $\mathbb { R } ^ { \times m }$ by $P \cdot v = P v$ .
The main difficulty to design universal neighborhood representations is that the node neighborhoods of Definition 5 are permutation invariant w.r.t. neighboring node attributes, and hence require permutation invariant representations. The graph neural network literature already contains several deep learning architectures for permutation invariant sets (Guttenberg et al., 2016; Qi et al., 2017; Zaheer et al., 2017; Xu et al., 2019), among which PointNet and DeepSet have the notable advantage of being provably universal for sets. Following Corollary 1, we compose a separable permutation invariant network with an MLP that will aggregate both information from the node itself and its neighborhood. While our final architecture is similar to Deepset (Zaheer et al., 2017), this section emphasizes that the general universality theorems of Section 3 are easily applicable in many settings including permutation invariant networks. The permutation invariant set representation used for the aggregation step of CLIP is as follows:
$$\mathrm { N O D E A G G R E G A T I O N } ( x , S ) = \psi \left( x , \sum _ { y \in S } \varphi ( y ) \right) ,$$
where $\psi$ and $\varphi$ are MLPs with continuous non-polynomial activation functions and $\psi ( x , y )$ denotes the result of the MLP $\psi$ applied to the concatenation of $x$ and $y$ .
Theorem 6. The set representation described in Eq. (9) is a universal representation of Neighborhoodm.
Proof. By construction, NODEAGGREGATION is a continuous and concatenable representation. Moreover, its final stage is an MLP, and we thus only have to prove separability in order to use Corollary 1 and prove universality. Let $( x ^ { 1 } , S ^ { 1 } ) , ( x ^ { 2 } , \mathbf { \bar { \xi } } S ^ { 2 } ) \in \mathbf { N e i g h b o r h o o d } _ { m }$ and suppose that $( x ^ { 1 } , S ^ { 1 } ) { \overset { . } { \neq } } ( x ^ { 2 } , { \bar { S } } ^ { 2 } )$ . First, if $x ^ { 1 } \neq x ^ { 2 }$ , the final MLP $\psi$ can separate $x ^ { 1 }$ and $x ^ { 2 }$ . Otherwise, $\dot { S } ^ { 1 } \neq S ^ { 2 }$ , and let us assume that $S ^ { 1 } \setminus S ^ { 2 } \ne \emptyset$ (otherwise $S ^ { 2 } \setminus S ^ { 1 } \ne \emptyset$ and the argument is identical). Since MLPs are universal representations of $\mathbb { R } ^ { m }$ , there exists an MLP $\varphi$ such that, $\forall s \in S ^ { 1 } \cup S ^ { 2 }$ ,
$$\begin{array} { c } { { \varphi ( s ) \geq 1 \mathrm { i f } s \in S ^ { 1 } \setminus S ^ { 2 } , } } \\ { { | \varphi ( s ) | \leq \varepsilon \mathrm { o t h e r w i s e } , } } \end{array}$$
Taking $\psi ( x , y ) = y$ and $\varepsilon = 1 / 3 \operatorname* { m a x } \{ | S ^ { 1 } | , | S ^ { 2 } | \}$ , we have
$$\begin{array} { r l } & { \mathrm { N O D E A G G R E G A T I O N } ( x ^ { 1 } , S ^ { 1 } ) \ge 2 / 3 , } \\ & { \mathrm { N O D E A G G R E G A T I O N } ( x ^ { 2 } , S ^ { 2 } ) \le 1 / 3 , } \end{array}$$
which proves separability and, using Corollary 1, the universality of the representation.
# D PROOF OF THE UNIVERSALITY OF CLIP
Proof of Theorem 3. First of all, as the activation functions of the MLPs are continuous, CLIP is made of continuous and concatenable functions, and is thus also continuous and concatenable. Second, as the node aggregation step (denoted NODEAGGREGATION below) is a universal set representation (see Appendix C), it is capable of approximating any continuous function. We will thus first replace this function by a continuous function $\phi$ , and then show that the result still holds for NODEAGGREGATION(1) by a simple density argument. Let $G ^ { 1 } = ( v ^ { 1 } , A ^ { 1 } )$ and $G ^ { 2 } = ( \underline { { { v } } } ^ { 2 } , A ^ { 2 } )$ be two distinct graphs of respective sizes $n _ { 1 }$ and $n _ { 2 }$ (up to a permutation). If $n ^ { 1 } \neq n ^ { 2 }$ , then $\psi ( x ) = x$ and $\phi ( x ) = 1$ returns the number of nodes, and hence $\dot { x _ { G ^ { 1 } } } = n ^ { 1 } \neq n ^ { 2 } = x _ { G ^ { 2 } }$ . Otherwise, let $V = \{ v _ { i } ^ { k } \} _ { i \in [ [ 1 , n ^ { 1 } ] ] , k \in \{ 1 , 2 \} }$ be the set of node attributes of $G ^ { 1 }$ and $G ^ { 2 }$ , $c ^ { 1 }$ be a coloring of $G ^ { 1 }$ , $\psi ( x ) = x$ and $\phi$ J Kbe a continuous function such that, $\forall x \in V$ and $S \subset V$ ,
$$\phi ( x , S ) = \sum _ { i = 1 } ^ { n ^ { 1 } } \mathbb { 1 } \{ x = ( v _ { i } ^ { 1 } , c _ { i } ^ { 1 } ) \} \prod _ { j \neq i } \mathbb { 1 } \left\{ A _ { i j } ^ { 1 } = \mathbb { 1 } \{ ( v _ { j } ^ { 1 } , c _ { j } ^ { 1 } ) \in S \} \right\} .$$
The existence of $\phi \in \mathcal { C } ( \mathbb { R } ^ { m } , \mathbb { R } )$ is assured by Urysohn’s lemma (see e.g. (Rudin, 1987, lemma 2.12)). Then, $x _ { G }$ counts the number of matching neighborhoods for the best coloring, and we have $x _ { G ^ { 1 } } = n ^ { 1 }$ and $x _ { G ^ { 2 } } \leq n ^ { 1 } - 1$ . Finally, taking $\varepsilon \stackrel { - } { < } 1 / 2 n ^ { 1 }$ in the definition of universal representation leads to the desired result, as then, using an $\varepsilon$ -approximation of $\phi$ as NODEAGGREGATION(1), we have $x _ { G ^ { 1 } } > n ^ { 1 } - 1 / 2 > x _ { G ^ { 2 } }$ . □
Proof of Theorem 4. Consider a continuous function $\psi : { \bf G r a p h } _ { m } \mathbb { R } ^ { d }$ and a compact $K ^ { \prime } \subset$ Graphm. Let extend K0 with K = K0 × [0, 1]nmax and we define φ : Graphm+nmax with $\phi ( ( v , c ) , { \overset { . . . } { A } } ) = \psi ( v , A )$ for all $c \in \mathcal { C } ( v , A )$ . Since $\infty$ -CLIP is universal there exists $\ddot { f } \in \infty$ -CLIP such that, for all $( ( v , c ) , A ) \in K$ ,
$$\begin{array} { r } { \| \phi ( ( v , c ) , A ) - f ( ( v , c ) , A ) \| \le \varepsilon , } \end{array}$$
hence
$$\| \psi ( v , A ) - f ( ( v , c ) , A ) \| \leq \varepsilon .$$
Moreover, observe that for any coloring $c \in \mathcal { C } ( v , A )$ , $\infty$ -CLIP and 1-CLIP applied to $( ( v , c ) , A )$ returns the same result, as all node attributes are dissimilar (by definition of the colorings) and ${ \mathcal { C } } ( ( v , c ) , A ) = \emptyset$ . Finally, 1-CLIP applied to $( v , A )$ is equivalent to applying 1-CLIP to $( ( v , C ) , A )$ where $C$ is a random coloring in $\mathcal { C } ( v , A )$ , and Eq. (12) thus implies that any random sample of 1-CLIP is within an $\varepsilon$ error of the target function $\psi$ . As a result, its expectation is also within an $\varepsilon$ error of the target function $\psi$ , which proves the universality of the expectation of 1-CLIP. □
# E EXPERIMENTAL DETAILS
# E.1 REAL-WORLD DATASETS
Table 3 summarizes the characteristics of all benchmark graph classification datasets used in Section 6.1. We now provide complementary information on these datasets.
Social Network Datasets (IMDBb, IMDBm): These datasets refer to collaborations between actors/actresses, where each graph is an ego-graph of every actor and the edges occur when the connected nodes/actors are playing in the same movie. The task is to classify the genre of the movie that the graph derives from. IMDBb is a single-class classification dataset, while IMDBm is multi-class. For both social network datasets, we used one-hot encodings of node degrees as node attribute vectors.
Bio-informatics Datasets (MUTAG, PROTEINS, PTC): MUTAG consists of mutagenic aromatic and heteroaromatic nitrocompounds with 7 discrete labels. PROTEINS consists of nodes, which correspond to secondary structureelements and the edges occur when the connected nodes are neighbors in the amino-acidsequence or in 3D space. It has 3 discrete labels. PTC consists of chemical compounds that reports the carcinogenicity for male and female rats and it has 19 discrete labels. For all bio-informatics datasets we used the node labels as node attribute vectors.
Experimentation protocol: We follow the same experimental protocol as described in $\mathrm { X u }$ et al. (2019), and thus report the results provided in this paper corresponding to the accuracy of our six baselines in Table 1. We optimized the CLIP hyperparameters by grid search according to 10-fold cross-validated accuracy means. We use 2-layer MLPs, an initial learning rate of 0.001 and decreased the learning rate by 0.5 every 50 epochs for all possible settings. For all datasets the hyperparameters we tested are: the number of hidden units within $\{ 3 2 , 6 4 \}$ , the number of colorings $\bar { c } \in \bar { \{ 1 , 2 , 4 , 8 \} }$ , the number of MPNN layers within $\{ 1 , 3 , 5 \}$ , the batch size within $\{ 3 2 , 6 4 \}$ , and the number of epochs, that means, we select a single epoch with the best cross-validation accuracy averaged over the 10 folds. Note that standard deviations are fairly high for all models due to the small size of these classic datasets.
Table 3: Characteristics of the benchmark graph classification datasets used in Section 6.1. E.1.1 CLIP PERFORMANCES W.R.T. THE NUMBER OF COLORINGS $k$
<table><tr><td>Dataset</td><td>PTC</td><td>IMDBb</td><td>IMDBm</td><td>PROTEINS</td><td>MUTAG</td></tr><tr><td># graphs</td><td>344</td><td>1000</td><td>1500</td><td>1113</td><td>188</td></tr><tr><td>#classes</td><td>2</td><td>2</td><td>3</td><td>2</td><td>2</td></tr><tr><td>Avg # nodes</td><td>14.29</td><td>19.77</td><td>13.00</td><td>39.06</td><td>17.93</td></tr><tr><td>Avg degree</td><td>2.05</td><td>9.76</td><td>10.14</td><td>3.72</td><td>2.21</td></tr></table>
Table 4 summarizes the performances of CLIP while increasing the number of colorings $k$ . Overall we can see a small increase in performances and a reduction of the variances when $k$ is increasing. Nevertheless we should not jump to any conclusions since none of the models are statistically significantly better than the others.
Table 4: Ablation study: classification accuracies of $k$ -CLIP on benchmark datasets w.r.t $k$
<table><tr><td>Dataset</td><td>PTC</td><td>IMDBb</td><td>IMDBm</td><td>PROTEINS</td><td>MUTAG</td></tr><tr><td>0-CLIP</td><td>65.9±4.0</td><td>75.4±2.0</td><td>52.5±2.6</td><td>77.0±3.2</td><td>90.0±5.1</td></tr><tr><td>1-CLIP</td><td>65.3±12.8</td><td>75.2±3.9</td><td>52.2±4.0</td><td>75.1±4.5</td><td>91.1±7.0</td></tr><tr><td>4-CLIP</td><td>65.9±5.7</td><td>75.8±5.0</td><td>51.8±2.9</td><td>77.1±4.4</td><td>92.2±7.0</td></tr><tr><td>8-CLIP</td><td>67.9±7.1</td><td>75.7±3.8</td><td>52.5±3.0</td><td>76.8±4.8</td><td>93.9±4.1</td></tr><tr><td>16-CLIP</td><td>66.5±5.4</td><td>76.0±2.7</td><td>52.5±4.5</td><td>76.6±2.8</td><td>91.7±6.0</td></tr></table>
We note that on the IMDBb and PROTEINS datasets the difference between using or not a coloring scheme does not have a big impact on the performances. However, adding colors increases the performances of the algorithm on three out of five real world datasets. The property testing section (Section 6.2) shows empirically that the color scheme improves the expressiveness of CLIP.
# E.2 GRAPH PROPERTY TESTING
In Section 6.2 we evaluate the expressive power of CLIP on benchmark synthetic datasets. Our goal is to show that CLIP is able to distinguish basic graph properties, where classical MPNN cannot. We considered a binary classification task and we constructed balanced synthetic datasets2 for each of the examined graph properties. The 20-node graphs are generated using Erdös-Rényi model (Erdös and Rényi, 1959) (and its bipartite version for the bipartiteness) with different probabilities $p$ for edge creation. All nodes share the same (scalar) attribute. We thus have uninformative feature vectors.
In particular, we generated datasets for different classical tasks Kriege et al. (2018): 1) connectivity, 2) bipartiteness, 3) triangle-freeness, and 4) circular skip links (Murphy et al., 2019). In the following, we present the generating protocol of the synthetic datasets and the experimentation setup we used for the experiments.
# Synthetic datasets:
In every case of synthetic dataset we follow the same pattern: we generate a set of random graphs using Erdös-Rényi model, which contain a specific graph property and belong to the same class and by proper edge addition we remove this property, thus creating the second class of graphs. By this way, we assure that we do not change different structural characteristics other than the examined graph property.
- Connectivity dataset: this dataset consists of 1000 (20-node) graphs with 500 positive samples and 500 negative ones. The positive samples correspond to disconnected graphs with two 10-node connected components selected among randomly generated graphs with an Erdös-Rényi model probability of $p = 0 . 5$ . We constructed negative samples by adding to positive samples a random edge between the two connected components.
- Bipartiteness dataset: this dataset consists of 1000 (20-node) graphs with 500 positive samples and 500 negative ones. The positive samples correspond to bipartite graphs generated with an Erdös-Rényi (bipartite) model probability of $p = 0 . 5$ . For the negative samples (non-bipartite graphs) we chose the positive samples and for each of them we added an edge between randomly selected nodes from the same partition, in order to form odd cycles 3.
- Triangle-freeness dataset: this dataset consists of 1000 (20-node) graphs with 500 positive samples and 500 negative ones. The positive samples correspond to triangle-free graphs selected among randomly generated graphs with an Erdös-Rényi model probability of $p \ = \ 0 . 1$ . We constructed negative samples by randomly adding new edges to positive samples until it creates at least one triangle.
- Circular skip links: this dataset consists of 150 graphs of 41 nodes as described in (Murphy et al., 2019; Chen et al., 2019). The Circular Skip Links graphs are undirected regular graphs with node degree 4. We denote a Circular skip link graph by $G _ { n , k }$ an undirected graph of $n$ nodes, where $( i , { \bar { j } } ) \in E$ holds if and only if $| i - j | \equiv 1$ or $k ( { \bmod { n } } )$ This is a 10-class multiclass classification task whose objective is to classify each graph according to its isomorphism class.
Experimentation protocol: We evaluate the different configurations of CLIP and its competitors GIN and RP-GIN based on their hyper-parameters. For the architecture implementation of the GIN, we followed the best performing architecture, presented in $\mathrm { X u }$ et al. (2019). In particular, we used the summation as the aggregation operator, MLPs as the combination level for the node embedding generation and the sum operator for the readout function along with its refined version of concatenated graph representations across all iterations/layers of GIN, as described in $\mathrm { X u }$ et al. (2019).
In all the tested configurations for CLIP and its competitors (GIN, RP-GIN) we fixed the number of layers of the MLPs and the learning rate: we chose 2-layer MLPs and we used the Adam optimizer with initial learning rate of 0.001 along with a scheduler decaying the learning rate by 0.5 every 50 epochs. Concerning the other hyper-parameters, we optimized: the number of hidden units within $\{ \bar { 1 6 } , 3 2 , 6 4 \}$ (except for the CSL task where we only use 16 hidden units to be fair w.r.t. RP-GIN and Ring-GNN benchmarks), the number of MPNN layers within $\{ 1 , 2 , 3 , 5 \}$ , the batch size within $\{ 3 2 , 6 4 \}$ , and ran the model over 400 epochs. Regarding the RP-GIN architecture (Murphy et al., 2019) we optimized the one-hot encoding dimension of the first update within $\{ 5 , 1 0 , 1 5 , 2 0 , 2 5 , 3 0 \}$ and the number of inference permutations within $\{ 1 , 5 , 1 6 \}$ . Regarding the CLIP algorithm, we optimized the number of colorings $c \in \{ 1 , 2 , 4 , 8 , 1 6 \}$ . We then performed a 10-fold cross validation with early stopping for the hyper-parameter optimization and we reported the best 10-fold crossvalidated mean accuracy with its associated standard deviation.123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398# TOWARDS DEEP LEARNING MODELS RESISTANT TO ADVERSARIAL ATTACKS
Aleksander M ˛adry, Aleksandar Makelov, Ludwig Schmidt, Dimitris Tsipras, Adrian Vladu∗
Department of Electrical Engineering and Computer Science Massachusetts Institute of Technology Cambridge, MA 02139, USA {madry,amakelov,ludwigs,tsipras,avladu}@mit.ed
# ABSTRACT
Recent work has demonstrated that neural networks are vulnerable to adversarial examples, i.e., inputs that are almost indistinguishable from natural data and yet classified incorrectly by the network. To address this problem, we study the adversarial robustness of neural networks through the lens of robust optimization. This approach provides us with a broad and unifying view on much prior work on this topic. Its principled nature also enables us to identify methods for both training and attacking neural networks that are reliable and, in a certain sense, universal. In particular, they specify a concrete security guarantee that would protect against a well-defined class of adversaries. These methods let us train networks with significantly improved resistance to a wide range of adversarial attacks. They also suggest robustness against a first-order adversary as a natural security guarantee. We believe that robustness against such well-defined classes of adversaries is an important stepping stone towards fully resistant deep learning models.
# 1 INTRODUCTION
Recent breakthroughs in computer vision and speech recognition are bringing trained classifiers into the center of security-critical systems. Important examples include vision for autonomous cars, face recognition, and malware detection. These developments make security aspects of machine learning increasingly important. In particular, resistance to adversarially chosen inputs is becoming a crucial design goal. While trained models tend to be very effective in classifying benign inputs, recent work (Dalvi et al., 2004; Szegedy et al., 2013; Goodfellow et al., 2014; Nguyen et al., 2015; Sharif et al., 2016) shows that an adversary is often able to manipulate the input so that the model produces an incorrect output.
This phenomenon has received particular attention in the context of deep neural networks, and there is now a quickly growing body of work on this topic (Fawzi et al., 2015; Kurakin et al., 2016; Papernot & McDaniel, 2016; Rozsa et al., 2016; Torkamani, 2016; Sokolic et al., 2016; Tramèr et al., 2017b). Computer vision presents a particularly striking challenge: very small changes to the input image can fool state-of-the-art neural networks with high probability (Szegedy et al., 2013; Goodfellow et al., 2014; Nguyen et al., 2015; Sharif et al., 2016; Moosavi-Dezfooli et al., 2016). This holds even when the benign example was classified correctly, and the change is imperceptible to a human. Apart from the security implications, this phenomenon also demonstrates that our current models are not learning the underlying concepts in a robust manner. All these findings raise a fundamental question:
# How can we learn models robust to adversarial inputs?
There are now many proposed defense mechanisms for the adversarial setting. Examples include defensive distillation (Papernot et al., 2016a; Papernot & McDaniel, 2016), feature squeezing (Xu et al., 2017), and several detection approaches for adversarial inputs (see Carlini & Wagner (2017) for references). While these works constitute important first steps in exploring the realm of possibilities, they do not offer a good understanding of the guarantees they provide. We can never be certain that a particular defense mechanism prevents the existence of some well-defined class of adversarial attacks. This makes it difficult to navigate the landscape of adversarial robustness or to fully evaluate the possible security implications. Moreover, subsequent work (Carlini & Wagner, 2016a; He et al., 2017) has shown that most of these defenses can be bypassed by stronger, adaptive adversaries.
In this paper, we study the adversarial robustness of neural networks through the lens of robust optimization. We use a natural saddle point (min-max) formulation to capture the notion of security against adversarial attacks in a principled manner. This formulation allows us to be precise about the type of security guarantee we would like to achieve, i.e., the broad class of attacks we want to be resistant to (in contrast to defending only against specific known attacks). The formulation also enables us to cast both attacks and defenses into a common theoretical framework. Most prior work on adversarial examples naturally fits into this framework. In particular, adversarial training directly corresponds to optimizing this saddle point problem. Similarly, prior methods for attacking neural networks correspond to specific algorithms for solving the underlying optimization problem.
Equipped with this perspective, we make the following contributions.
1. We conduct a careful experimental study of the optimization landscape corresponding to this saddle point formulation. Despite the non-convexity and non-concavity of its constituent parts, we find that the underlying optimization problem is tractable after all. In particular, we provide strong evidence that first-order methods can reliably solve this problem and motivate projected gradient descent (PGD) as a universal “first-order adversary”, i.e., the strongest attack utilizing the local first order information about the network. We supplement these insights with ideas from real analysis to further motivate adversarial training against a PGD adversary as a strong and natural defense.
2. We explore the impact of network architecture on adversarial robustness and find that model capacity plays an important role. To reliably withstand strong adversarial attacks, networks require a significantly larger capacity than for correctly classifying benign examples only. This shows that a robust decision boundary of the saddle point problem can be significantly more complicated than a decision boundary that simply separates the benign data points.
3. Building on the above insights, we train networks on MNIST and CIFAR10 that are robust to a wide range of adversarial attacks against adversaries bounded by 0.3 and 8 in $\ell _ { \infty }$ norm respectively. Our approach is based on optimizing the aforementioned saddle point formulation and uses our optimal “first-order adversary”. Our best MNIST model achieves an accuracy of more than $89 \%$ against the strongest adversaries in our test suite. In particular, our MNIST network is even robust against white box attacks of an iterative adversary. Our CIFAR10 model achieves an accuracy of $46 \%$ against the same adversary. Furthermore, in case of the weaker black box (transfer) attacks, our MNIST and CIFAR10 networks achieve an accuracy of more than $9 5 \%$ and $64 \%$ , respectively (a more detailed overview can be found in Tables 1 and 2). To the best of our knowledge, we are the first to achieve these levels of robustness on MNIST and CIFAR10 against a broad set of attacks.
Overall, these findings suggest that secure neural networks are within reach. In order to further support this claim, we have invited the community to attempt attacks against our MNIST and CIFAR10 networks in the form of an open challenge1,2. At the time of writing, we received about fifteen submissions to the MNIST challenge and the best submission achieved roughly $93 \%$ accuracy in a black box attack. We received no submissions for the CIFAR10 challenge that went beyond the $64 \%$ accuracy of our attack. Considering that other proposed defenses were often quickly broken (Carlini & Wagner, 2017), we believe that our robust models are significant progress on the defense side. Furthermore, recent work (Carlini et al., 2017) on verifiable adversarial examples showed that our proposed defense reliably increased the robustness to any $\ell _ { \infty }$ -bounded attack.
# 2 AN OPTIMIZATION VIEW ON ADVERSARIAL ROBUSTNESS
Much of our discussion will revolve around an optimization view of adversarial robustness. This perspective not only captures the phenomena we want to study in a precise manner, but will also inform our investigations. To this end, let us consider a standard classification task with an underlying data distribution $\mathcal { D }$ over pairs of examples $\boldsymbol { x } \in \mathbb { R } ^ { d }$ and corresponding labels $y \in [ k ]$ . We also assume that we are given a suitable loss function $L ( \theta , x , y )$ , for instance the cross-entropy loss for a neural network. As usual, $\theta \in \mathbb { R } ^ { p }$ is the set of model parameters. Our goal then is to find model parameters $\theta$ that minimize the risk $\mathbb { E } _ { ( x , y ) \sim \mathcal { D } } [ L ( x , y , \theta ) ]$ .
Empirical risk minimization (ERM) has been tremendously successful as a recipe for finding classifiers with small population risk. Unfortunately, ERM often does not yield models that are robust to adversarially crafted examples (Goodfellow et al., 2014; Kurakin et al., 2016; Moosavi-Dezfooli et al., 2016; Tramèr et al., 2017b). Formally, there are efficient algorithms (“adversaries”) that take an example $x$ belonging to class $c _ { 1 }$ as input and find examples $x ^ { \mathrm { a d v } }$ such that $x ^ { \mathrm { a d v } }$ is very close to $x$ but the model incorrectly classifies $x ^ { \mathrm { a d v } }$ as belonging to class $c _ { 2 } \neq c _ { 1 }$ .
In order to reliably train models that are robust to adversarial attacks, it is necessary to augment the ERM paradigm. Instead of resorting to methods that directly focus on improving the robustness to specific attacks, our approach is to first propose a concrete guarantee that an adversarially robust model should satisfy. We then adapt our training methods towards achieving this guarantee.
The first step towards such a guarantee is to specify an threat model, i.e., a precise definition of the attacks our models should be resistant to. For each data point $x$ , we introduce a set of allowed perturbations $S \subseteq \mathbb { R } ^ { d }$ that formalizes the manipulative power of the adversary. In image classification, we choose $s$ so that it captures perceptual similarity between images. For instance, the $\ell _ { \infty }$ -ball around $x$ has recently been studied as a natural notion for adversarial perturbations (Goodfellow et al., 2014). While we focus on robustness against $\ell _ { \infty }$ -bounded attacks in this paper, we remark that more comprehensive notions of perceptual similarity are an important direction for future research.
Next, we modify the definition of population risk $\mathbb { E } _ { \mathcal { D } } [ L ]$ by incorporating the above adversary. Instead of computing the loss $L$ directly on samples from the distribution $\mathcal { D }$ , we allow the adversary to perturb the input first. This gives rise to the following saddle point problem, which is our central object of study:
$$\operatorname* { m i n } _ { \theta } \rho ( \theta ) , \quad \mathrm { w h e r e } \quad \rho ( \theta ) = \mathbb { E } _ { ( x , y ) \sim \mathcal { D } } \left[ \operatorname* { m a x } _ { \delta \in \mathcal { S } } L ( \theta , x + \delta , y ) \right] \ .$$
Formulations of this type (and their finite-sample counterparts) have a long history in robust optimization, going back to Wald (Wald, 1939; 1945; 1992). It turns out that this formulation is also particularly useful in our context. We will refer to the quantity $\rho ( \theta )$ as the adversarial loss of the network with parameters $\theta$ .
First, this formulation gives us a unifying perspective that encompasses much prior work on adversarial robustness. Our perspective stems from viewing the saddle point problem as the composition of an inner maximization problem and an outer minimization problem. Both of these problems have a natural interpretation in our context. The inner maximization problem aims to find an adversarial version of a given data point $x$ that achieves a high loss. This is precisely the problem of attacking a given neural network. On the other hand, the goal of the outer minimization problem is to find model parameters so that the adversarial loss given by the inner attack problem is minimized. This is precisely the problem of training a robust classifier using adversarial training techniques.
Second, the saddle point problem specifies a clear goal that a robust classifier should achieve, as well as a quantitative measure of its robustness. In particular, when the parameters $\theta$ yield a (nearly) vanishing risk, the corresponding model is perfectly robust to attacks specified by our threat model.
Our paper investigates the structure of this saddle point problem in the context of deep neural networks. This formulation will be the main drive of our investigations that will lead us to training techniques that produce models with high resistance to a wide range of adversarial attacks.
# 3 TOWARDS ADVERSARIALLY ROBUST NETWORKS
Current work on adversarial examples usually focuses on specific defensive mechanisms, or on attacks against such defenses. An important feature of formulation (2.1) is that attaining small adversarial loss gives a guarantee that no allowed attack will fool the network. By definition, no adversarial perturbations are possible because the loss is small for all perturbations allowed by our threat model. This perspective allows us to reduce the task of finding truly robust models to an optimization problem. Hence, we can now focus our attention solely on obtaining a good solution to Problem (2.1).
Gradients from attacks. Since Stochastic Gradient Descent (SGD) and its variants are by far the most successful algorithms for training neural networks, we also want to apply SGD to Problem (2.1). This raises the question how we can compute gradients $\nabla _ { \boldsymbol { \theta } } \rho ( \boldsymbol { \theta } )$ for the outer minimization problem. Since the adversarial loss function $\rho ( \theta )$ corresponds to a maximization problem, we cannot simply apply the usual backpropagation algorithm. Instead, a natural approach is to compute the gradient at the maximizer of the inner maximization problem. A priori, it is not clear that this is a valid descent direction for the saddle point problem. However, for the case of continuously differentiable functions, Danskin’s theorem – a classic theorem in optimization – states that this is indeed true and gradients at maximizers of the inner problem correspond to descent directions for the saddle point problem (see Appendix C for details).
Leveraging this connection, our goal now is to find a reliable algorithm for solving the inner maximization problem, i.e., to evaluate $\rho ( \theta )$ . When instantiated for a batch of examples (instead of the expectation over the entire distribution $\mathcal { D }$ ), finding a maximizer $\delta \in S$ of $\rho ( \theta )$ corresponds exactly to finding an attack on the neural network. This allows us to employ known attacks as inner maximization algorithms. Prior work has proposed methods such as the Fast Gradient Sign Method (FGSM) and multiple variations of it (Goodfellow et al., 2014). FGSM is an attack for an $\ell _ { \infty }$ -bounded adversary and computes an adversarial example as
$$x + \varepsilon \operatorname { s g n } ( \nabla _ { x } L ( \theta , x , y ) ) .$$
One can interpret this attack as a simple one-step scheme for maximizing the inner part of the saddle point formulation. A more powerful adversary is the multi-step variant $\bar { \mathrm { F G S M } } ^ { k }$ , which is essentially projected gradient descent (PGD) on the negative loss function (Kurakin et al., 2016):3
$$x ^ { t + 1 } = \operatorname { P r o j } _ { x + S } \left( x ^ { t } + \alpha \operatorname { s g n } ( \nabla _ { x ^ { t } } L ( \theta , x ^ { t } , y ) ) \right) .$$
Loss landscape. While PGD is a well-motivated approach for the inner maximization problem, it is not clear whether we can actually find a good solution in a reasonable amount of time. The problem is non-concave, so a priori we have no guarantees on the solution quality of PGD. One of our contributions is demonstrating that, in practice, the inner maximization problem is indeed well-behaved. In particular, we experimentally explore the structure given by the non-concave inner problem and find that its loss landscape has a surprisingly tractable structure of local maxima (see Appendix A). This structure also points towards projected gradient descent as the “ultimate” first-order adversary (see Section 5).
Despite the fact that the exact assumptions of Danskin’s theorem do not hold for our problem (the function is not continuously differentiable due to ReLU activations, and we only compute approximate maximizers of the inner problem), our experiments suggest that we can still use these gradients to optimize our problem. By applying SGD using the gradient of the loss at adversarial examples, we can consistently reduce the loss of the saddle point problem during training (e.g., see Figure 1 in Section 4). These observations suggest that we reliably optimize the saddle point formulation (2.1) and thus train robust classifiers.
Model capacity. Before we proceed to our main experiment results in the next section, we briefly mention another important insight from our robust optimization perspective. Solving the problem from Equation (2.1) successfully is not sufficient to guarantee robust and accurate classification. We also require that the value of the problem (i.e., the final loss we achieve against adversarial examples) is small, which then provides guarantees for the performance of our classifier. In particular, achieving a very small value corresponds to a perfect classifier, which is robust to adversarial inputs. In Appendix B, we show experimentally that network capacity plays a crucial role in enabling robustness. In particular, training a robust classifier requires a significantly larger network than only achieving high accuracy on natural examples.
# 4 EXPERIMENTS: ADVERSARIALLY ROBUST DEEP LEARNING MODELS?
Following our understanding developed in the previous section, we can now apply our proposed approach to train robust classifiers. For both MNIST and CIFAR10, our adversary of choice will be projected gradient descent starting from a random perturbation around the natural example. As our experiments suggest (Appendix A) this algorithm is very efficient at reliably producing examples of (near) maximal loss. In a sense, it seems to correspond to a “ultimate” f irst order adversary. Since we are training the model for multiple epochs, we did not see any benefit in restarting PGD multiple times per batch – a new start is chosen each time the same example is encountered.
During the training procedure against the PGD adversary, we observe a steady decrease in the training loss of adversarial examples, illustrated in Figure 1. This behavior indicates that we are consistently decreasing the adversarial loss and indeed successfully solving our original optimization problem.
 Figure 1: Cross-entropy loss on adversarial examples during training. The plots show how the adversarial loss on training examples evolves during training the MNIST and CIFAR10 networks against a PGD adversary. The sharp drops in the CIFAR10 plot correspond to decreases in training learning rate. These plots illustrate that we can consistently reduce the value of the inner problem of the saddle point formulation (2.1), thus producing an increasingly robust classifier.
We evaluate the trained models against a range of adversaries. We illustrate our results in Table 1 for MNIST and Table 2 for CIFAR10. The adversaries we consider are:
• White-box attacks with PGD for a different number of of iterations and restarts, denoted by source A. White-box attacks from Carlini & Wagner (2016b). We use their suggested loss function and minimize it using PGD. This is denoted as CW, where the corresponding attack with a high confidence parameter $\kappa = 5 0$ ) is denoted as $\mathrm { C W } +$ . • Black-box attacks from an independently trained copy of the network, denoted A’. • Black-box attacks from a version of the same network trained only on natural examples, denoted $A _ { n a t }$ . • Black-box attacks from a different convolution architecture, denoted B, described in Tramèr et al. (2017a).
MNIST. We run 40 iterations of projected gradient descent as our adversary, with a step size of 0.01 (we choose to take gradient steps in the $\ell _ { \infty }$ norm, i.e. adding the sign of the gradient, since this makes the choice of the step size simpler). We train and evaluate against perturbations of size $\varepsilon = 0 . 3$ We use a network consisting of two convolutional layers with 32 and 64 filters respectively, each followed by $2 \times 2$ max-pooling, and a fully connected layer of size 1024. When trained with natural examples, this network reaches $9 9 . 2 \%$ accuracy on the evaluation set. However, when evaluating on examples perturbed with FGSM the accuracy drops to $6 . 4 \%$ . Given that the resulting MNIST model is very robust, we investigated the learned parameters in order to understand how they affect adversarial robustness. The results of the investigation are presented in Appendix E.
CIFAR10. For the CIFAR10 dataset, we use the two architectures described in $\mathbf { B }$ (the original Resnet and its $1 0 \times$ wider variant). We trained the network against a PGD adversary with $\ell _ { \infty }$ projected
Table 1: MNIST: Performance of the adversarially trained network against different adversaries for $\varepsilon = 0 . 3$ . For each model of attack we show the most successful attack with bold. The source networks used for the attack are: the network itself (A) (white-box attack), an indepentenly initialized and trained copy of the network (A’), architecture B from Tramèr et al. (2017a) (B).
<table><tr><td rowspan=1 colspan=1>Method</td><td rowspan=1 colspan=1>Steps</td><td rowspan=1 colspan=1>Restarts</td><td rowspan=1 colspan=1>Source</td><td rowspan=1 colspan=1>Accuracy</td></tr><tr><td rowspan=1 colspan=1>Natural</td><td rowspan=1 colspan=1>二</td><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1>-</td><td rowspan=1 colspan=1>98.8%</td></tr><tr><td rowspan=1 colspan=1>FGSM</td><td rowspan=1 colspan=1>-</td><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1>A</td><td rowspan=1 colspan=1>95.6%</td></tr><tr><td rowspan=1 colspan=1>PGD</td><td rowspan=1 colspan=1>40</td><td rowspan=1 colspan=1>1</td><td rowspan=1 colspan=1>A</td><td rowspan=1 colspan=1>93.2%</td></tr><tr><td rowspan=1 colspan=1>PGD</td><td rowspan=1 colspan=1>100</td><td rowspan=1 colspan=1>1</td><td rowspan=1 colspan=1>A</td><td rowspan=1 colspan=1>91.8%</td></tr><tr><td rowspan=1 colspan=1>PGD</td><td rowspan=1 colspan=1>40</td><td rowspan=1 colspan=1>20</td><td rowspan=1 colspan=1>A</td><td rowspan=1 colspan=1>90.4%</td></tr><tr><td rowspan=1 colspan=1>PGD</td><td rowspan=1 colspan=1>100</td><td rowspan=1 colspan=1>20</td><td rowspan=1 colspan=1>A</td><td rowspan=1 colspan=1>89.3%</td></tr><tr><td rowspan=1 colspan=1>Targeted</td><td rowspan=1 colspan=1>40</td><td rowspan=1 colspan=1>1</td><td rowspan=1 colspan=1>A</td><td rowspan=1 colspan=1>92.7%</td></tr><tr><td rowspan=1 colspan=1>CW</td><td rowspan=1 colspan=1>40</td><td rowspan=1 colspan=1>1</td><td rowspan=1 colspan=1>A</td><td rowspan=1 colspan=1>94.0%</td></tr><tr><td rowspan=1 colspan=1>CW+</td><td rowspan=1 colspan=1>40</td><td rowspan=1 colspan=1>1</td><td rowspan=1 colspan=1>A</td><td rowspan=1 colspan=1>93.9%</td></tr><tr><td rowspan=1 colspan=1>FGSM</td><td rowspan=1 colspan=1>-</td><td rowspan=1 colspan=1>-</td><td rowspan=1 colspan=1>A</td><td rowspan=1 colspan=1>96.8%</td></tr><tr><td rowspan=1 colspan=1>PGD</td><td rowspan=1 colspan=1>40</td><td rowspan=1 colspan=1>1</td><td rowspan=1 colspan=1>A</td><td rowspan=1 colspan=1>96.0%</td></tr><tr><td rowspan=1 colspan=1>PGD</td><td rowspan=1 colspan=1>100</td><td rowspan=1 colspan=1>20</td><td rowspan=1 colspan=1>A</td><td rowspan=1 colspan=1>95.7%</td></tr><tr><td rowspan=1 colspan=1>CW</td><td rowspan=1 colspan=1>40</td><td rowspan=1 colspan=1>1</td><td rowspan=1 colspan=1>A</td><td rowspan=1 colspan=1>97.0%</td></tr><tr><td rowspan=1 colspan=1>CW+</td><td rowspan=1 colspan=1>40</td><td rowspan=1 colspan=1>1</td><td rowspan=1 colspan=1>A</td><td rowspan=1 colspan=1>96.4%</td></tr><tr><td rowspan=1 colspan=1>FGSM</td><td rowspan=1 colspan=1>-</td><td rowspan=1 colspan=1>-</td><td rowspan=1 colspan=1>B</td><td rowspan=1 colspan=1>95.4%</td></tr><tr><td rowspan=1 colspan=1>PGD</td><td rowspan=1 colspan=1>40</td><td rowspan=1 colspan=1>1</td><td rowspan=1 colspan=1>B</td><td rowspan=1 colspan=1>96.4%</td></tr><tr><td rowspan=1 colspan=1>CW+</td><td rowspan=1 colspan=1>-</td><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1>B</td><td rowspan=1 colspan=1>95.7%</td></tr></table>
gradient descent again, this time using 7 steps of size 2, and a total $\varepsilon = 8$ . For our hardest adversary we chose 20 steps with the same settings, since other hyperparameter choices didn’t offer a significant decrease in accuracy. The results of our experiments appear in Table 2. The adversarial robustness of our network is significant, given the power of iterative adversaries, but still far from satisfactory. We believe that further progress is possible along these lines by understanding how adversarial training works and what techniques can complement it leading to robust models.
Table 2: CIFAR10: Performance of the adversarially trained network against different adversaries for $\varepsilon = 8$ . For each model of attack we show the most effective attack in bold. The source networks considered for the attack are: the network itself (A) (white-box attack), an independtly initialized and trained copy of the network (A’), a copy of the network trained on natural examples $( \mathrm { A } _ { n a t } )$ .
<table><tr><td rowspan=1 colspan=1>Method</td><td rowspan=1 colspan=1>Steps</td><td rowspan=1 colspan=1>Source</td><td rowspan=1 colspan=1>Accuracy</td></tr><tr><td rowspan=1 colspan=1>Natural</td><td rowspan=1 colspan=1>-</td><td rowspan=1 colspan=1>-</td><td rowspan=1 colspan=1>87.3%</td></tr><tr><td rowspan=1 colspan=1>FGSM</td><td rowspan=1 colspan=1>-</td><td rowspan=1 colspan=1>A</td><td rowspan=1 colspan=1>56.1%</td></tr><tr><td rowspan=1 colspan=1>PGD</td><td rowspan=1 colspan=1>7</td><td rowspan=1 colspan=1>A</td><td rowspan=1 colspan=1>50.0%</td></tr><tr><td rowspan=1 colspan=1>PGD</td><td rowspan=1 colspan=1>20</td><td rowspan=1 colspan=1>A</td><td rowspan=1 colspan=1>45.8%</td></tr><tr><td rowspan=1 colspan=1>CW</td><td rowspan=1 colspan=1>30</td><td rowspan=1 colspan=1>A</td><td rowspan=1 colspan=1>46.8%</td></tr><tr><td rowspan=1 colspan=1>FGSM</td><td rowspan=1 colspan=1>-</td><td rowspan=1 colspan=1>A</td><td rowspan=1 colspan=1>67.0%</td></tr><tr><td rowspan=1 colspan=1>PGD</td><td rowspan=1 colspan=1>7</td><td rowspan=1 colspan=1>A</td><td rowspan=1 colspan=1>64.2%</td></tr><tr><td rowspan=1 colspan=1>CW</td><td rowspan=1 colspan=1>30</td><td rowspan=1 colspan=1>A</td><td rowspan=1 colspan=1>78.7%</td></tr><tr><td rowspan=1 colspan=1>FGSM</td><td rowspan=1 colspan=1>-</td><td rowspan=1 colspan=1>Anat</td><td rowspan=1 colspan=1>85.6%</td></tr><tr><td rowspan=1 colspan=1>PGD</td><td rowspan=1 colspan=1>7</td><td rowspan=1 colspan=1>Anat</td><td rowspan=1 colspan=1>86.0%</td></tr></table>
Resistance for different values of $\varepsilon$ and $\ell _ { 2 }$ -bounded attacks. In order to perform a broader evaluation of the adversarial robustness of our models, we run two kinds of additional experiments. On one hand, we investigate the resistance to $\ell _ { \infty }$ -bounded attacks for different values of $\varepsilon$ . On the other hand, we examine the resistance of our model to attacks that are bounded in $\ell _ { 2 }$ as opposed to $\ell _ { \infty }$ norm. The results appear in Figure 2. We emphasize that the models we are examining here correspond to training against $\ell _ { \infty }$ -bounded attacks with the original value of $\varepsilon = 0 . 3$ , for
MNIST, and $\varepsilon = 8$ for CIFAR10. In particular, our MNIST model retains significant resistance to $\ell _ { 2 }$ -norm-bounded perturbations too – it has good accuracy even for $\varepsilon = 4 . 5 . \mathrm { W e }$ provide a sample of corresponding adversarial examples in Figure 12 of Appendix F. One can observe that some of the underlying perturbations are large enough that even a human could be confused.
Training Accuracy. It is worth noting our MNIST and (wide) CIFAR10 networks reached $100 \%$ adversarial accuracy on the training set. That is we can fit the training set even against a PGD adversary of $\varepsilon = 0 . 3$ and $\varepsilon = 8$ respectively. This shows that the landscape of the underlying optimization problem is tractable and does not present a significant barrier to our techniques.
 Figure 2: Performance of our adversarially trained networks against PGD adversaries of different strength. The MNIST and CIFAR10 networks were trained against $\varepsilon = 0 . 3$ and $\varepsilon = 8$ PGD $\ell _ { \infty }$ adversaries respectively (the training $\varepsilon$ is denoted with a red dashed lines in the $\ell _ { \infty }$ plots). We notice that for $\varepsilon$ less or equal to the value used during training, the performance is equal or better.
Running Time. Unfortunately, solving the robust version of the problem instead of the standard one imposes a significant computational overhead. Standard training requires one forward and one backward pass through the network for each training batch. Instead, adversarial training with a $k$ -step PGD adversary, requires additionally $k$ forward and $k$ backward passes through the network to compute the adversarial version of the training batch. This implies an increase in running time of a factor of $( k + 1 )$ . We hope that future research will propose ways to mitigate this drawback.
# 5 FIRST-ORDER ADVERSARIES.
Our exploration of the loss landscape (Appendix A) shows that the local maxima found by PGD all have similar loss values, both for normally trained networks and adversarially trained networks. This concentration phenomenon suggests an intriguing view on the problem in which robustness against the PGD adversary yields robustness against all first-order adversaries, i.e., attacks that rely only on first-order information. As long as the adversary only uses gradients of the loss function with respect to the input, we conjecture that it will not find significantly better local maxima than PGD. This hypothesis is validated by the experimental evidence provided in Section 4: if we train a network to be robust against PGD adversaries, it becomes robust against a wide range of other attacks as well.
Of course, our exploration with PGD does not preclude the existence of some isolated maxima with much larger function value. However, our experiments suggest that such better local maxima are hard to find with first order methods: even a large number of random restarts did not find function values with significantly different loss values (see Appendix A). Incorporating the computational power of the adversary into the threat model should be reminiscent of the notion of polynomially bounded adversary that is a cornerstone of modern cryptography. There, this classic threat model allows the adversary to only solve problems that require at most polynomial computation time. Here, we employ an optimization-based view on the power of the adversary as it is more suitable in the context of machine learning. After all, we have not yet developed a thorough understanding of the computational complexity of many recent machine learning problems. However, the vast majority of optimization problems in ML is solved with first-order methods, and variants of SGD are the most effective way of training deep learning models in particular. Hence we believe that the class of attacks relying on first-order information is, in some sense, universal for the current practice of deep learning.
Put together, these two ideas chart the way towards machine learning models with guaranteed robustness. If we train the network to be robust against PGD adversaries, it will be robust against a wide range of attacks that encompasses all current approaches.
In fact, this robustness guarantee would become even stronger in the context of transfer attacks, i.e., attacks in which the adversary does not have a direct access to the target network. Instead, the adversary only has less specific information such as the (rough) model architecture and the training data set. One can view this threat model as an example of “zero order” attacks, i.e., attacks in which the adversary has no direct access to the classifier and is only able to evaluate it on chosen examples without gradient feedback. Still, even for the case of zero-order attacks, the gradient of the network can be estimated using a finite differences method, rendering first-order attacks also relevant in this context.
We discuss transferability in Appendix D. We observe that increasing network capacity and strengthening the adversary we train against (FGSM or PGD training, rather than natural training) improves resistance against transfer attacks. Also, as expected, the resistance of our best models to such attacks tends to be significantly larger than to the (strongest) first order attacks.
# 6 RELATED WORK
Due to the growing body of work on adversarial examples in the context of deep learning networks (Gu & Rigazio, 2014; Fawzi et al., 2015; Torkamani, 2016; Papernot et al., 2016b; Carlini & Wagner, 2016a; Tramèr et al., 2017b; Goodfellow et al., 2014; Kurakin et al., 2016), we focus only on the most related papers here. Before we compare our contributions, we remark that robust optimization has been studied outside deep learning for multiple decades. We refer the reader to Ben-Tal et al. (2009) for an overview of this field.
To the best of our knowledge, in the context of adversarial examples, an explicit formulation of the min-max optimization first appeared in Huang et al. (2015), Shaham et al. (2015), and Lyu et al. (2015). All of these works, however, consider very weak adversaries/methods for solving the maximization problem, mainly relying on linearizing the loss and performing a single step, similar to FGSM. These adversaries do not capture the full range of possible attacks and thus training only against them leaves the resulting classifier vulnerable to more powerful, iterative attacks.
Recent work on adversarial training on ImageNet also observed that the model capacity is important for adversarial training Kurakin et al. (2016). However, their work was focused on FGSM attacks, since they report the iterative attacks are too expensive computationally and don’t provide any significant benefits. In contrast to that, we discover that for the datasets we considered training against iterative adversaries does result in a model that is robust against such adversaries.
A more recent paper (Tramèr et al., 2017b) also explores the transferability phenomenon. This exploration focuses mostly on the region around natural examples where the loss is (close to) linear. When large perturbations are allowed, this region does not give a complete picture of the adversarial landscape. This is confirmed by our experiments, as well as pointed out by Tramèr et al. (2017a).
Another recent paper (Tramèr et al., 2017a), considers adversarial training using black-box attacks from similar networks in order to increase the robustness of the network against such adversaries. However, this is not an effective defense against the white-box setting we consider, since a PGD adversary can reliably produce adversarial examples for such networks.
# 7 CONCLUSION
Our findings provide evidence that deep neural networks can be made resistant to adversarial attacks. As our theory and experiments indicate, we can design reliable adversarial training methods. One of the key insights behind this is the unexpectedly regular structure of the underlying optimization task: even though the relevant problem corresponds to the maximization of a highly non-concave function with many distinct local maxima, their values are highly concentrated. Overall, our findings give us hope that adversarially robust deep learning models may be within current reach.
For the MNIST dataset, our networks are very robust, achieving high accuracy for a wide range of powerful adversaries and large perturbations. Our experiments on CIFAR10 have not reached the same level of performance yet. However, our results already show that our techniques lead to significant increase in the robustness of the network. We believe that further exploring this direction will lead to adversarially robust networks for this dataset.
# ACKNOWLEDGMENTS
Aleksander M ˛adry, Aleksandar Makelov, and Dimitris Tsipras were supported by the NSF Grant No. 1553428, a Google Research Fellowship, and a Sloan Research Fellowship. Ludwig Schmidt was supported by a Google PhD Fellowship. Adrian Vladu was supported by the NSF Grants No. 1111109 and No. 1553428.
We thank Wojciech Matusik for kindly providing us with computing resources to perform this work.
# REFERENCES
Tensor flow models repository. https://github.com/tensorflow/models/tree/ master/resnet, 2017. Aharon Ben-Tal, Laurent El Ghaoui, and Arkadi Nemirovski. Robust optimization. Princeton University Press, 2009. Nicholas Carlini and David Wagner. Defensive distillation is not robust to adversarial examples. arXiv preprint arXiv:1607.04311, 2016a. Nicholas Carlini and David Wagner. Towards evaluating the robustness of neural networks. arXiv preprint arXiv:1608.04644, 2016b. Nicholas Carlini and David Wagner. Adversarial examples are not easily detected: Bypassing ten detection methods. arXiv preprint arXiv:1705.07263, 2017. Nicholas Carlini, Guy Katz, Clark Barrett, and David L Dill. Ground-truth adversarial examples. arXiv preprint arXiv:1709.10207, 2017. Nilesh Dalvi, Pedro Domingos, Mausam, Sumit Sanghai, and Deepak Verma. Adversarial classification. In International Conference on Knowledge Discovery and Data Mining (KDD), 2004. Alhussein Fawzi, Omar Fawzi, and Pascal Frossard. Analysis of classifiers’ robustness to adversarial perturbations. arXiv preprint arXiv:1502.02590, 2015. Ian J. Goodfellow, Jonathon Shlens, and Christian Szegedy. Explaining and harnessing adversarial examples. arXiv preprint arXiv:1412.6572, 2014. Shixiang Gu and Luca Rigazio. Towards deep neural network architectures robust to adversarial examples. arXiv preprint arXiv:1412.5068, 2014. Kaiming He, Xiangyu Zhang, Shaoqing Ren, and Jian Sun. Deep residual learning for image recognition. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pp. 770–778, 2016. Warren He, James Wei, Xinyun Chen, Nicholas Carlini, and Dawn Song. Adversarial example defenses: Ensembles of weak defenses are not strong. arXiv preprint arXiv:1706.04701, 2017. Ruitong Huang, Bing Xu, Dale Schuurmans, and Csaba Szepesvári. Learning with a strong adversary. arXiv preprint arXiv:1511.03034, 2015. Alexey Kurakin, Ian J. Goodfellow, and Samy Bengio. Adversarial machine learning at scale. arXiv preprint arXiv:1611.01236, 2016. Chunchuan Lyu, Kaizhu Huang, and Hai-Ning Liang. A unified gradient regularization family for adversarial examples. In Data Mining (ICDM), 2015 IEEE International Conference on, pp. 301–309. IEEE, 2015. Seyed-Mohsen Moosavi-Dezfooli, Alhussein Fawzi, and Pascal Frossard. Deepfool: A simple and accurate method to fool deep neural networks. In 2016 IEEE Conference on Computer Vision and Pattern Recognition, CVPR 2016, Las Vegas, NV, USA, June 27-30, 2016, pp. 2574–2582, 2016. Anh Mai Nguyen, Jason Yosinski, and Jeff Clune. Deep neural networks are easily fooled: High confidence predictions for unrecognizable images. In IEEE Conference on Computer Vision and Pattern Recognition, CVPR 2015, Boston, MA, USA, June 7-12, 2015, pp. 427–436, 2015.
Nicolas Papernot and Patrick D. McDaniel. On the effectiveness of defensive distillation. arXiv preprint arXiv:1607.05113, 2016.
Nicolas Papernot, Patrick McDaniel, Xi Wu, Somesh Jha, and Ananthram Swami. Distillation as a defense to adversarial perturbations against deep neural networks. In Security and Privacy (SP), 2016 IEEE Symposium on, pp. 582–597. IEEE, 2016a.
Nicolas Papernot, Patrick D. McDaniel, Somesh Jha, Matt Fredrikson, Z. Berkay Celik, and Ananthram Swami. The limitations of deep learning in adversarial settings. In IEEE European Symposium on Security and Privacy, EuroS&P 2016, Saarbrücken, Germany, March 21-24, 2016, pp. 372–387, 2016b.
Andras Rozsa, Manuel Günther, and Terrance E. Boult. Towards robust deep neural networks with BANG. arXiv preprint arXiv:1612.00138, 2016.
Uri Shaham, Yutaro Yamada, and Sahand Negahban. Understanding adversarial training: Increasing local stability of neural nets through robust optimization. arXiv preprint arXiv:1511.05432, 2015.
Mahmood Sharif, Sruti Bhagavatula, Lujo Bauer, and Michael K. Reiter. Accessorize to a crime: Real and stealthy attacks on state-of-the-art face recognition. In Proceedings of the 2016 ACM SIGSAC Conference on Computer and Communications Security, Vienna, Austria, October 24-28, 2016, pp. 1528–1540, 2016.
Jure Sokolic, Raja Giryes, Guillermo Sapiro, and Miguel RD Rodrigues. Robust large margin deep neural networks. arXiv preprint arXiv:1605.08254, 2016.
Christian Szegedy, Wojciech Zaremba, Ilya Sutskever, Joan Bruna, Dumitru Erhan, Ian J. Goodfellow, and Rob Fergus. Intriguing properties of neural networks. arXiv preprint arXiv:1312.6199, 2013.
MohamadAli Torkamani. Robust Large Margin Approaches for Machine Learning in Adversarial Settings. PhD thesis, University of Oregon, 2016.
Florian Tramèr, Alexey Kurakin, Nicolas Papernot, Dan Boneh, and Patrick D. McDaniel. Ensemble adversarial training: Attacks and defenses. arXiv preprint arXiv:1705.07204, 2017a.
Florian Tramèr, Nicolas Papernot, Ian J. Goodfellow, Dan Boneh, and Patrick D. McDaniel. The space of transferable adversarial examples. arXiv preprint arXiv:1704.03453, 2017b. URL http://arxiv.org/abs/1704.03453.
Abraham Wald. Contributions to the theory of statistical estimation and testing hypotheses. The Annals of Mathematical Statistics, 10(4):299–326, 1939.
Abraham Wald. Statistical decision functions which minimize the maximum risk. Annals of Mathematics, pp. 265–280, 1945.
Abraham Wald. Statistical decision functions. In Breakthroughs in Statistics, pp. 342–357. Springer, 1992.
Weilin Xu, David Evans, and Yanjun Qi. Feature squeezing: Detecting adversarial examples in deep neural networks. arXiv preprint arXiv:1704.01155, 2017.
# A THE LANDSCAPE OF ADVERSARIAL EXAMPLES
The inner problem of the saddle point formulation (2.1) corresponds to finding an adversarial example for a given network and data point (subject to our attack model). As this problem requires us to maximize a highly non-concave function, one would expect it to be intractable. Indeed, this is the conclusion reached by prior work which then resorted to linearizing the inner maximization problem (Huang et al., 2015; Shaham et al., 2015). As pointed out above, this linearization approach yields well-known methods such as FGSM. While training against FGSM adversaries has shown some successes, recent work also highlights important shortcomings of this one-step approach (Tramèr et al., 2017a).
To understand the inner problem in more detail, we investigate the landscape of local maxima for multiple models on MNIST and CIFAR10. The main tool in our experiments is projected gradient descent (PGD), since it is the standard method for large-scale constrained optimization. In order to explore a large part of the loss landscape, we re-start PGD from many points in the $\ell _ { \infty }$ balls around data points from the respective evaluation sets.
Surprisingly, our experiments show that the inner problem is tractable after all, at least from the perspective of first-order methods. While there are many local maxima spread widely apart within $x _ { i } + \mathcal { S }$ , they tend to have very well-concentrated loss values. This echoes the folklore belief that training neural networks is possible because the loss (as a function of model parameters) typically has many local minima with very similar values.
Specifically, in our experiments we found the following phenomena:
• We observe that the loss achieved by the adversary increases in a fairly consistent way and plateaus rapidly when performing projected $\ell _ { \infty }$ gradient descent for randomly chosen starting points inside $x + { \mathcal { S } }$ (see Figure 3).
 Figure 3: Cross-entropy loss values while creating an adversarial example from the MNIST and CIFAR10 evaluation datasets. The plots show how the loss evolves during 20 runs of projected gradient descent (PGD). Each run starts at a uniformly random point in the $\ell _ { \infty }$ -ball around the same natural example (additional plots for different examples appear in Figure 11). The adversarial loss plateaus after a small number of iterations. The optimization trajectories and final loss values are also fairly clustered, especially on CIFAR10. Moreover, the final loss values on adversarially trained networks are significantly smaller than on their naturally trained counterparts.
• Investigating the concentration of maxima further, we observe that over a large number of random restarts, the loss of the final iterate follows a well-concentrated distribution without extreme outliers (see Figure 4; we verified this concentration based on $1 0 ^ { 5 }$ restarts). To demonstrate that maxima are noticeably distinct, we also measured the $\ell _ { 2 }$ distance and angles between all pairs of them and observed that distances are distributed close to the expected distance between two random points in the $\ell _ { \infty }$ ball, and angles are close to $9 0 °$ . Along the line segment between local maxima, the loss is convex, attaining its maximum at the endpoints and is reduced by a constant factor in the middle. Nevertheless, for the entire segment, the loss is considerably higher than that of a random point. • Finally, we observe that the distribution of maxima suggests that the recently developed subspace view of adversarial examples is not fully capturing the richness of attacks (Tramèr et al., 2017b). In particular, we observe adversarial perturbations with negative inner product with the gradient
 Figure 4: Values of the local maxima given by the cross-entropy loss for five examples from the MNIST and CIFAR10 evaluation datasets. For each example, we start projected gradient descent (PGD) from $1 0 ^ { 5 }$ uniformly random points in the $\ell _ { \infty }$ -ball around the example and iterate PGD until the loss plateaus. The blue histogram corresponds to the loss on a naturally trained network, while the red histogram corresponds to the adversarially trained counterpart. The loss is significantly smaller for the adversarially trained networks, and the final loss values are very concentrated without any outliers.
of the example, and deteriorating overall correlation with the gradient direction as the scale of perturbation increases.
# B NETWORK CAPACITY AND ADVERSARIAL ROBUSTNESS
For a fixed set $s$ of possible perturbations, the value of the problem (2.1) is entirely dependent on the architecture of the classifier we are learning. Consequently, the architectural capacity of the model becomes a major factor affecting its overall performance. At a high level, classifying examples in a robust way requires a stronger classifier, since the presence of adversarial examples changes the decision boundary of the problem to a more complicated one (see Figure 5 for an illustration).
 Figure 5: A conceptual illustration of “natural” vs. “adversarial” decision boundaries. Left: A set of points that can be easily separated with a simple (in this case, linear) decision boundary. Middle: The simple decision boundary does not separate the $\ell _ { \infty }$ -balls (here, squares) around the data points. Hence there are adversarial examples (the red stars) that will be misclassified. Right: Separating the $\ell _ { \infty }$ -balls requires a significantly more complicated decision boundary. The resulting classifier is robust to adversarial examples with bounded $\ell _ { \infty }$ -norm perturbations.
Our experiments verify that capacity is crucial for robustness, as well as for the ability to successfully train against strong adversaries. For the MNIST dataset, we consider a simple convolutional network and study how its behavior changes against different adversaries as we keep doubling the size of network (i.e. double the number of convolutional filters and the size of the fully connected layer). The initial network has a convolutional layer with 2 filters, followed by another convolutional layer with 4 filters, and a fully connected hidden layer with 64 units. Convolutional layers are followed by $2 \times 2$ max-pooling layers and adversarial examples are constructed with $\varepsilon = 0 . 3$ . The results are in Figure 6.
For the CIFAR10 dataset, we used the Resnet model He et al. (2016); TFM (2017). We performed data augmentation using random crops and flips, as well as per image standarization. To increase the capacity, we modified the network incorporating wider layers by a factor of 10. This results in a network with 5 residual units with (16, 160, 320, 640) filters each. This network can achieve an accuracy of $9 5 . 2 \%$ when trained with natural examples. Adversarial examples were constructed with $\varepsilon = 8$ . Results on capacity experiments appear in Figure 6.
We observe the following phenomena:
Capacity alone helps. We observe that increasing the capacity of the network when training using only natural examples (apart from increasing accuracy on these examples) increases the robustness against one-step perturbations. This effect is greater when considering adversarial examples with smaller $\varepsilon$ .
FGSM adversaries don’t increase robustness (for large $\varepsilon$ ). When training the network using adversarial examples generated with the FGSM, we observe that the network overfits to these adversarial examples. This behavior is known as label leaking Kurakin et al. (2016) and stems from the fact that the adversary produces a very restricted set of adversarial examples that the network can overfit to. These networks have poor performance on natural examples and don’t exhibit any kind of robustness against PGD adversaries. For the case of smaller $\varepsilon$ the loss is ofter linear enough in the $\ell _ { \infty }$ ball around natural examples, that FGSM finds adversarial examples close to those found by PGD thus being a reasonable adversary to train against.
Weak models may fail to learn non-trivial classifiers. In the case of small capacity networks, attempting to train against a strong adversary (PGD) prevents the network from learning anything meaningful. The network converges to always predicting a fixed class, even though it could converge to an accurate classifier through natural training. The small capacity of the network forces the training procedure to sacrifice performance on natural examples in order to provide any kind of robustness against adversarial inputs.
The value of the saddle point problem decreases as we increase the capacity. Fixing an adversary model, and training against it, the value of (2.1) drops as capacity increases, indicating the the model can fit the adversarial examples increasingly well.
More capacity and stronger adversaries decrease transferability. Either increasing the capacity of the network, or using a stronger method for the inner optimization problem reduces the effectiveness of transferred adversarial inputs. We validate this experimentally by observing that the correlation between gradients from the source and the transfer network, becomes less significant as capacity increases. We describe our experiments in Appendix D.
# C STATEMENT AND APPLICATION OF DANSKIN’S THEOREM
Recall that our goal is to minimize the value of the saddle point problem
$$\operatorname* { m i n } _ { \theta } \rho ( \theta ) , \quad \mathrm { w h e r e } \quad \rho ( \theta ) = \mathbb { E } _ { ( x , y ) \sim \mathcal { D } } \left[ \operatorname* { m a x } _ { \delta \in \mathcal { S } } L ( \theta , x + \delta , y ) \right] \ .$$
In practice, we don’t have access to the distribution $\mathcal { D }$ so both the gradients and the value of $\rho ( \theta )$ will be computed using sampled input points. Therefore we can consider –without loss of generality– the case of a single random example $x$ with label $y$ , in which case the problem becomes
$$\operatorname* { m i n } _ { \theta } \operatorname* { m a x } _ { \delta \in S } g ( \theta , \delta ) , \quad \mathrm { w h e r e } \quad g ( \theta , \delta ) = L ( \theta , x + \delta , y ) ~ .$$
If we assume that the loss $L$ is continuously differentiable in $\theta$ , we can compute a descent direction for $\theta$ by utilizing the classical theorem of Danskin.

Figure 6: The effect of network capacity on the performance of the network. We trained MNIST and CIFAR10 networks of varying capacity on: (a) natural examples, (b) with FGSM-made adversarial examples, (c) with PGD-made adversarial examples. In the first three plots/tables of each dataset, we show how the natural and adversarial accuracy changes with respect to capacity for each training regime. In the final plot/table, we show the value of the cross-entropy loss on the adversarial examples the networks were trained on. This corresponds to the value of our saddle point formulation (2.1) for different sets of allowed perturbations.
Theorem C.1 (Danskin). Let $s$ be nonempty compact topological space and $g : \mathbb { R } ^ { n } \times S \mathbb { R }$ be such that $g ( \cdot , \delta )$ is differentiable for every $\delta \in S$ and $\nabla _ { \boldsymbol { \theta } } g ( \boldsymbol { \theta } , \boldsymbol { \delta } )$ is continuous on $\mathbb { R } ^ { n } \times S$ . Also, let $\delta ^ { * } ( \theta ) = \{ \delta \in \arg \operatorname* { m a x } _ { \delta \in { \mathcal { S } } } g ( \theta , \delta ) \}$ .
Then the corresponding max-function
$$\phi ( \theta ) = \operatorname* { m a x } _ { \delta \in { \mathcal { S } } } g ( \theta , \delta )$$
is locally Lipschitz continuous, directionally differentiable, and its directional derivatives satisfy
$$\phi ^ { \prime } ( \theta , h ) = \operatorname* { s u p } _ { \delta \in \delta ^ { * } ( \theta ) } h ^ { \top } \nabla _ { \theta } g ( \theta , \delta ) .$$
In particular, if for some $\theta \in \mathbb { R } ^ { n }$ the set $\delta ^ { * } ( \theta ) = \{ \delta _ { \theta } ^ { * } \}$ is a singleton, the the max-function is differentiable at $\theta$ and
$$\nabla \phi ( \theta ) = \nabla _ { \theta } g ( \theta , \delta _ { \theta } ^ { * } ) .$$
The intution behind the theorem is that since gradients are local objects, and the function $\phi ( \theta )$ is locally the same as $g ( \theta , \delta _ { \theta } ^ { * } )$ their gradients will be the same. The theorem immediately gives us the following corollary, stating the we can indeed compute gradients for the saddle point by computing gradients at the inner optimizers.
Corollary C.2. Let $\overline { { \delta } }$ be such that $\bar { \delta } \in \mathcal { S }$ and is a maximizer for maxδ $L ( \theta , x + \delta , y )$ . Then, as long as it is nonzero, $- \nabla _ { \boldsymbol { \theta } } L ( \boldsymbol { \theta } , \boldsymbol { x } + \overline { { \boldsymbol { \delta } } } , y )$ is a descent direction for $\phi ( \theta ) = \mathrm { m a x } _ { \delta \in { \cal S } } { \cal L } ( \theta , x + \delta , y )$ .
Proof of Corollary C.2. We apply Theorem C.1 to $g ( \theta , \delta ) : = L ( \theta , x + \delta , y )$ and $S = B _ { \parallel \cdot \parallel } ( \varepsilon )$ . We see that the directional derivative in the direction of $h = \nabla _ { \boldsymbol { \theta } } L ( \boldsymbol { \theta } , x + \overline { { \boldsymbol { \delta } } } , y )$ satisfies
$$\phi ^ { \prime } ( \theta , h ) = \operatorname* { s u p } _ { \delta \in \delta ^ { * } ( \theta ) } h ^ { \top } \nabla _ { \theta } L ( \theta , x + \delta , y ) \geq h ^ { \top } h = \| \nabla _ { \theta } L ( \theta , x + \bar { \delta } , y ) \| _ { 2 } ^ { 2 } \geq 0 .$$
If this gradient is nonzero, then the inequality above is strict. Therefore it gives a descent direction.
A technical issue is that, since we use ReLU and max-pooling units in our neural network architecture, the loss function is not continuously differentiable. Nevertheless, since the set of discontinuities has measure zero, we can assume that this will not be an issue in practice, as we will never encounter the problematic points.
Another technical issue is that, due to the not concavity of the inner problem, we are not able to compute global maximizers, since PGD will converge to local maxima. In such cases, we can consider a subset $S ^ { \prime }$ of $s$ such that the local maximum is a global maximum in the region $S ^ { \prime }$ . Applying the theorem for $S ^ { \prime }$ gives us that the gradient corresponds to a descent direction for the saddle point problem when the adversary is constrained in $S ^ { \prime }$ . Therefore if the inner maximum is a true adversarial example for the network, then SGD using the gradient at that point will decrease the loss value at this particular adversarial examples, thus making progress towards a robust model.
These arguments suggest that the conclusions of the theorem are still valid in our saddle point problem, and –as our experiments confirm– we can solve it reliably.
# D TRANSFERABILITY
A lot of recent literature on adversarial training discusses the phenomenon of transferability Goodfellow et al. (2014); Kurakin et al. (2016); Tramèr et al. (2017b), i.e. adversarial examples transfer between differently trained networks. This raises concerns for practical applications, since it suggests that deep networks are extremely vulnerable to attacks, even when there is no direct access to the target network.
This phenomenon is further confirmed by our current experiments. 4 Moreover, we notice that the extent to which adversarial examples transfer decreases as we increase either network capacity or the power of the adversary used for training the network. This serves as evidence for the fact that the transferability phenomenon can be alleviated by using high capacity networks in conjunction with strong oracles for the inner optimization problem.
MNIST. In an attempt to understand these phenomena we inspect the loss functions corresponding to the trained models we used for testing transferability. More precisely, we compute angles between gradients of the loss functions evaluated over a large set of input examples, and plot their distribution. Similarly, we plot the value of the loss functions between clean and perturbed examples for both the source and transfer networks. In Figure 8 we plot our experimental findings on the MNIST dataset for $\varepsilon = 0 . 3$ . We consider a naturally trained large network (two convolutional layers of sizes 32 and 64, and a fully connected layer of size 1024), which we train twice starting with different initializations. We plot the distribution of angles between gradients for the same test image in the two resulting networks (orange histograms), noting that they are somewhat correlated. As opposed to this, we see that pairs of gradients for random pairs of inputs for one architecture are as uncorrelated as they can be (blue histograms), since the distribution of their angles looks Gaussian.
Next, we run the same experiment on a naturally trained very large network (two convolutional layers of sizes 64 and 128, and a fully connected layer of size 1024). We notice a mild increase in classification accuracy for transferred examples.
Finally, we repeat the same set of experiments, after training the large and very large networks against the FGSM adversary. We notice that gradients between the two architectures become significantly less correlated. Also, the classification accuracy for transferred examples increases significantly compared to the naturally trained networks.
We further plot how the value of the loss function changes when moving from the natural input towards the adversarially perturbed input (in Figure 8 we show these plots for four images in the MNIST test dataset), for each pair of networks we considered. We observe that, while for the naturally trained networks, when moving towards the perturbed point, the value of the loss function on the transfer architecture tends to start increasing soon after it starts increasing on the source architecture. In contrast, for the stronger models, the loss function on the transfer network tends to start increasing later, and less aggressively.
CIFAR10. For the CIFAR10 dataset, we investigate the transferability of the FGSM and PGD adversaries between our simple and wide architectures, each trained on natural, FGSM and PGD examples. Transfer accuracies for the FGSM adversary and PGD adversary between all pairs of such configurations (model $^ +$ training method) with independently random weight initialization are given in tables 3 and 4 respectively. The results exhibit the following trends:
• Stronger adversaries decrease transferability: In particular, transfer attacks between two PGD-trained models are less successful than transfer attacks between their naturally-trained counterparts. Moreover, adding PGD training helps with transferability from all adversarial datasets, except for those with source a PGD-trained model themselves. This applies to both FGSM attacks and PGD attacks. Capacity decreases transferability: In particular, transfer attacks between two PGDtrained wide networks are less successful than transfer attacks between their simple PGDtrained counterparts. Moreover, with few close exceptions, changing the architecture from simple to wide (and keeping the training method the same) helps with transferability from all adversarial datasets.
We additionally plotted how the loss of a network behaves in the direction of FGSM and PGD examples obtained from itself and an independently trained copy; results for the simple naturally trained network and the wide PGD trained network are given in Table 7. As expected, we observe the following phenomena:
• sometimes, the FGSM adversary manages to increase loss faster near the natural example, but as we move towards the boundary of the $\ell _ { \infty }$ box of radius $\varepsilon$ , the PGD attack always achieves higher loss. • the transferred attacks do worse than their white-box counterparts in terms of increasing the loss; • and yet, the transferred PGD attacks dominate the white-box FGSM attacks for the naturally trained network (and sometimes for the PGD-trained one too).
Table 3: CIFAR10: black-box FGSM attacks. We create FGSM adversarial examples with $\varepsilon = 8$ from the evaluation set on the source network, and then evaluate them on an independently initialized target network.
<table><tr><td rowspan=1 colspan=1>SourceTarget</td><td rowspan=1 colspan=1>Simple(naturaltraining)</td><td rowspan=1 colspan=1>Simple(FGSMtraining)</td><td rowspan=1 colspan=1>Simple(PGDtraining)</td><td rowspan=1 colspan=1>Wide(naturaltraining)</td><td rowspan=1 colspan=1>Wide(FGSMtraining)</td><td rowspan=1 colspan=1>Wide(PGDtraining)</td></tr><tr><td rowspan=1 colspan=1>Simple(natural training)</td><td rowspan=1 colspan=1>32.9%</td><td rowspan=1 colspan=1>74.0%</td><td rowspan=1 colspan=1>73.7%</td><td rowspan=1 colspan=1>27.6%</td><td rowspan=1 colspan=1>71.8%</td><td rowspan=1 colspan=1>76.6%</td></tr><tr><td rowspan=1 colspan=1>Simple(FGSM training)</td><td rowspan=1 colspan=1>64.2%</td><td rowspan=1 colspan=1>90.7%</td><td rowspan=1 colspan=1>60.9%</td><td rowspan=1 colspan=1>61.5%</td><td rowspan=1 colspan=1>90.2%</td><td rowspan=1 colspan=1>67.3%</td></tr><tr><td rowspan=1 colspan=1>Simple(PGD training)</td><td rowspan=1 colspan=1>77.1%</td><td rowspan=1 colspan=1>78.1%</td><td rowspan=1 colspan=1>60.2%</td><td rowspan=1 colspan=1>77.0%</td><td rowspan=1 colspan=1>77.9%</td><td rowspan=1 colspan=1>66.3%</td></tr><tr><td rowspan=1 colspan=1>Wide(natural training)</td><td rowspan=1 colspan=1>34.9%</td><td rowspan=1 colspan=1>78.7%</td><td rowspan=1 colspan=1>80.2%</td><td rowspan=1 colspan=1>21.3%</td><td rowspan=1 colspan=1>75.8%</td><td rowspan=1 colspan=1>80.6%</td></tr><tr><td rowspan=1 colspan=1>Wide(FGSM training)</td><td rowspan=1 colspan=1>64.5%</td><td rowspan=1 colspan=1>93.6%</td><td rowspan=1 colspan=1>69.1%</td><td rowspan=1 colspan=1>53.7%</td><td rowspan=1 colspan=1>92.2%</td><td rowspan=1 colspan=1>72.8%</td></tr><tr><td rowspan=1 colspan=1>Wide(PGD training)</td><td rowspan=1 colspan=1>85.8%</td><td rowspan=1 colspan=1>86.6%</td><td rowspan=1 colspan=1>73.3%</td><td rowspan=1 colspan=1>85.6%</td><td rowspan=1 colspan=1>86.2%</td><td rowspan=1 colspan=1>67.0%</td></tr></table>
Table 4: CIFAR10: black-box PGD attacks. We create PGD adversarial examples with $\varepsilon = 8$ for 7 iterations from the evaluation set on the source network, and then evaluate them on an independently initialized target network.
<table><tr><td rowspan=1 colspan=1>SourceTarget</td><td rowspan=1 colspan=1>Simple(naturaltraining)</td><td rowspan=1 colspan=1>Simple(FGSMtraining)</td><td rowspan=1 colspan=1>Simple(PGDtraining)</td><td rowspan=1 colspan=1>Wide(naturaltraining)</td><td rowspan=1 colspan=1>Wide(FGSMtraining)</td><td rowspan=1 colspan=1>Wide(PGDtraining)</td></tr><tr><td rowspan=1 colspan=1>Simple(natural training)</td><td rowspan=1 colspan=1>6.6%</td><td rowspan=1 colspan=1>71.6%</td><td rowspan=1 colspan=1>71.8%</td><td rowspan=1 colspan=1>1.4%</td><td rowspan=1 colspan=1>51.4%</td><td rowspan=1 colspan=1>75.6%</td></tr><tr><td rowspan=1 colspan=1>Simple(FGSM training)</td><td rowspan=1 colspan=1>66.3%</td><td rowspan=1 colspan=1>40.3%</td><td rowspan=1 colspan=1>58.4%</td><td rowspan=1 colspan=1>65.4%</td><td rowspan=1 colspan=1>26.8%</td><td rowspan=1 colspan=1>66.2%</td></tr><tr><td rowspan=1 colspan=1>Simple(PGD training)</td><td rowspan=1 colspan=1>78.1%</td><td rowspan=1 colspan=1>78.2%</td><td rowspan=1 colspan=1>57.7%</td><td rowspan=1 colspan=1>77.9%</td><td rowspan=1 colspan=1>78.1%</td><td rowspan=1 colspan=1>65.2%</td></tr><tr><td rowspan=1 colspan=1>Wide(natural training)</td><td rowspan=1 colspan=1>10.9%</td><td rowspan=1 colspan=1>79.6%</td><td rowspan=1 colspan=1>79.1%</td><td rowspan=1 colspan=1>0.0%</td><td rowspan=1 colspan=1>51.3%</td><td rowspan=1 colspan=1>79.7%</td></tr><tr><td rowspan=1 colspan=1>Wide(FGSM training)</td><td rowspan=1 colspan=1>67.6%</td><td rowspan=1 colspan=1>51.7%</td><td rowspan=1 colspan=1>67.4%</td><td rowspan=1 colspan=1>56.5%</td><td rowspan=1 colspan=1>0.0%</td><td rowspan=1 colspan=1>71.6%</td></tr><tr><td rowspan=1 colspan=1>Wide(PGD training)</td><td rowspan=1 colspan=1>86.4%</td><td rowspan=1 colspan=1>86.8%</td><td rowspan=1 colspan=1>72.1%</td><td rowspan=1 colspan=1>86.0%</td><td rowspan=1 colspan=1>86.3%</td><td rowspan=1 colspan=1>64.2%</td></tr></table>
Table 5: CIFAR10: white-box attacks for $\varepsilon = 8$ . For each architecture and training method, we list the accuracy of the resulting network on the full CIFAR10 evaluation set of 10,000 examples. The FGSM random method is the one suggested by Tramèr et al. (2017a), whereby we first do a small random perturbation of the natural example, and the apply FGSM to that.
<table><tr><td rowspan=1 colspan=1>AdversaryModel</td><td rowspan=1 colspan=1>Natural</td><td rowspan=1 colspan=1>FGSM</td><td rowspan=1 colspan=1>FGSM random|PGD (7 steps)</td><td rowspan=1 colspan=1>FGSM random|PGD (7 steps)</td><td rowspan=1 colspan=1>PGD (20 steps)</td></tr><tr><td rowspan=1 colspan=1>Simple(natural training)</td><td rowspan=1 colspan=1>92.7%</td><td rowspan=1 colspan=1>27.5%</td><td rowspan=1 colspan=1>19.6%</td><td rowspan=1 colspan=1>1.2%</td><td rowspan=1 colspan=1>0.8%</td></tr><tr><td rowspan=1 colspan=1>Simple(FGSM training)</td><td rowspan=1 colspan=1>87.4%</td><td rowspan=1 colspan=1>90.9%</td><td rowspan=1 colspan=1>90.4%</td><td rowspan=1 colspan=1>0.0%</td><td rowspan=1 colspan=1>0.0%</td></tr><tr><td rowspan=1 colspan=1>Simple(PGD training)</td><td rowspan=1 colspan=1>79.4%</td><td rowspan=1 colspan=1>51.7%</td><td rowspan=1 colspan=1>55.9%</td><td rowspan=1 colspan=1>47.1%</td><td rowspan=1 colspan=1>43.7%</td></tr><tr><td rowspan=1 colspan=1>Wide(natural training)</td><td rowspan=1 colspan=1>95.2%</td><td rowspan=1 colspan=1>32.7%</td><td rowspan=1 colspan=1>25.1%</td><td rowspan=1 colspan=1>4.1%</td><td rowspan=1 colspan=1>3.5%</td></tr><tr><td rowspan=1 colspan=1>Wide(FGSM training)</td><td rowspan=1 colspan=1>90.3%</td><td rowspan=1 colspan=1>95.1%</td><td rowspan=1 colspan=1>95.0%</td><td rowspan=1 colspan=1>0.0%</td><td rowspan=1 colspan=1>0.0%</td></tr><tr><td rowspan=1 colspan=1>Wide(PGD training)</td><td rowspan=1 colspan=1>87.3%</td><td rowspan=1 colspan=1>56.1%</td><td rowspan=1 colspan=1>60.3%</td><td rowspan=1 colspan=1>50.0%</td><td rowspan=1 colspan=1>45.8%</td></tr></table>
 Figure 7: CIFAR10: change of loss function in the direction of white-box and black-box FGSM and PGD examples with $\varepsilon = 8$ for the same five natural examples. Each line shows how the loss changes as we move from the natural example to the corresponding adversarial example. Top: simple naturally trained model. Bottom: wide PGD trained model. We plot the loss of the original network in the direction of the FGSM example for the original network (red lines), 5 PGD examples for the original network obtained from 5 random starting points (blue lines), the FGSM example for an independently trained copy network (green lines) and 5 PGD examples for the copy network obtained from 5 random starting points (black lines). All PGD attacks use 100 steps with step size 0.3.
<table><tr><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1>Source</td><td rowspan=1 colspan=1>Transfer</td></tr><tr><td rowspan=1 colspan=1>Clean</td><td rowspan=1 colspan=1>99.2%</td><td rowspan=1 colspan=1>99.2%</td></tr><tr><td rowspan=1 colspan=1>FGSM</td><td rowspan=1 colspan=1>3.9%</td><td rowspan=1 colspan=1>41.9%</td></tr><tr><td rowspan=1 colspan=1>PGD</td><td rowspan=1 colspan=1>0.0%</td><td rowspan=1 colspan=1>26.0%</td></tr></table>
<table><tr><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1>Source</td><td rowspan=1 colspan=1>Transfer</td></tr><tr><td rowspan=1 colspan=1>Clean</td><td rowspan=1 colspan=1>92.9%</td><td rowspan=1 colspan=1>96.1%</td></tr><tr><td rowspan=1 colspan=1>FGSM</td><td rowspan=1 colspan=1>99.9%</td><td rowspan=1 colspan=1>62.0%</td></tr><tr><td rowspan=1 colspan=1>PGD</td><td rowspan=1 colspan=1>0.0%</td><td rowspan=1 colspan=1>54.1%</td></tr></table>
Large network, FGSM training
Very large network, natural training
<table><tr><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1>Source</td><td rowspan=1 colspan=1>Transfer</td></tr><tr><td rowspan=1 colspan=1>Clean</td><td rowspan=1 colspan=1>99.2%</td><td rowspan=1 colspan=1>99.3%</td></tr><tr><td rowspan=1 colspan=1>FGSM</td><td rowspan=1 colspan=1>7.2%</td><td rowspan=1 colspan=1>44.6%</td></tr><tr><td rowspan=1 colspan=1>PGD</td><td rowspan=1 colspan=1>0.0%</td><td rowspan=1 colspan=1>35.0%</td></tr></table>
<table><tr><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1>Source</td><td rowspan=1 colspan=1>Transfer</td></tr><tr><td rowspan=1 colspan=1>Clean</td><td rowspan=1 colspan=1>96.4%</td><td rowspan=1 colspan=1>97.8%</td></tr><tr><td rowspan=1 colspan=1>FGSM</td><td rowspan=1 colspan=1>99.4%</td><td rowspan=1 colspan=1>71.6%</td></tr><tr><td rowspan=1 colspan=1>PGD</td><td rowspan=1 colspan=1>0.0%</td><td rowspan=1 colspan=1>60.6%</td></tr></table>
 Figure 8: Transferability experiments for four different instances (naturally trained large and very large networks, and FGSM-trained large and very large networks, respectively). For each instance we ran the same training algorithm twice, starting from different initializations. Tables on the left show the accuracy of the networks against three types of input (clean, perturbed with FGSM, perturbed with PGD ran for 40 steps); the first column shows the resilience of the first network against examples produced using its own gradients, the second column shows resilience of the second network against examples transferred from the former network. The histograms reflect angles between pairs of gradients corresponding to the same inputs versus the baseline consisting of angles between gradients from random pairs of points. Images on the right hand side reflect how the loss functions of the native and the transfer network change when moving in the direction of the perturbation; the perturbation is at 1 on the horizontal axis. Plots in the top row are for FGSM perturbations, plots in the bottom row are for PGD perturbations produced over 40 iterations.
Very large network, FGSM training
Large network, natural training
# E MNIST INSPECTION
The robust MNIST model described so far is small enough that we can visually inspect most of its parameters. Doing so will allow us to understand how it is different from a naturally trained variant and what are the general characteristics of a network that is robust against $\ell _ { \infty }$ adversaries. We will compare three different networks: a naturally trained model, and two adversarially trained ones. The latter two models are identical, modulo the random weight initialization, and were used as the public and secret models used for our robustness challenge.
Initially, we examine the first convolutional layer of each network. We observe that the robust models only utilize 3 out of the total 32 filters, and for each of these filters only one weight is non-zero. By doing so, the convolution degrades into a scaling of the original image. Combined with the bias and the ReLU that follows, this results in a thresholding filter, or equivalently $\mathrm { R e L U } ( \alpha x - \beta )$ for some constants $\alpha$ , $\beta$ . From the perspective of adversarial robustness, thresholding filters are immune to any perturbations on pixels with value less than $\beta - \varepsilon$ . We visualize a sample of the filters in Figure 9 (plots a, c, and e).
Having observed that the first layer of the network essentially maps the original image to three copies thresholded at different values, we examine the second convolutional layer of the classifier. Again, the filter weights are relatively sparse and have a significantly wider value range than the naturally trained version. Since only three channels coming out of the first layer matter, is follows (and is verified) that the only relevant convolutional filters are those that interact with these three channels. We visualize a sample of the filters in Figure 9 (plots b, d, and f).
Finally, we examine the softmax/output layer of the network. While the weights seem to be roughly similar between all three version of the network, we notice a significant difference in the class biases. The adversarially trained networks heavily utilize class biases (far from uniform), and do so in a way very similar to each other. A plausible explanation is that certain classes tend to be very vulnerable to adversarial perturbations, and the network learns to be more conservative in predicting them. The plots can be found in Figure 10.
All of the “tricks” described so far seem intuitive to a human and would seem reasonable directions when trying to increase the adversarial robustness of a classifier. We emphasize the none of these modifications were hard-coded in any way and they were all learned solely through adversarial training. We attempted to manually introduce these modifications ourselves, aiming to achieve adversarial robustness without adversarial training, but with no success. A simple PGD adversary could fool the resulting models on all the test set examples.
 (a) Natural Model First Conv. Layers (b) Natural Model Second Conv. Layer Figure 9: Visualizing a sample of the convolutional filters. For the natural model (a,b) we visualize random filters, since there is no observable difference in any of them. For the first layer of robust networks we make sure to include the 3 non-zero filters. For the second layer, the first three columns represent convolutional filters that utilize the 3 non-zero channels, and we choose the most interesting ones (larger range of values). We observe that adversarially trained networks have significantly more concentrated weights. Moreover, the first convolutional layer degrades into a few thresholding filters.
 Figure 10: Softmax layer examination. For each network we create a histogram of the layer’s weights and plot the per-class bias. We observe that while weights are similar (slightly more concentrated for the natural one) the biases are far from uniform and with a similar pattern for the two adversarially trained networks.
 Figure 11: Loss function value over PGD iterations for 20 random restarts on random examples. The 1st and 3rd rows correspond to naturally trained networks, while the 2nd and 4th to adversarially trained ones.
 Figure 12: Sample adversarial examples with $\ell _ { 2 }$ norm bounded by 4. The perturbations are significant enough to cause misclassification by humans too.123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572# LEARNING FROM POSITIVE AND UNLABELED DATA WITH A SELECTION BIAS
Masahiro Kato1,2, Takeshi Teshima1,2, and Junya Honda1,2
1The University of Tokyo, Tokyo, Japan 2RIKEN, Tokyo, Japan {mkato, teshima}@ms.k.u-tokyo.ac.jp, honda@edu.k.u-tokyo.ac.jp
# ABSTRACT
We consider the problem of learning a binary classifier only from positive data and unlabeled data (PU learning). Recent methods of PU learning commonly assume that the labeled positive data are identically distributed as the unlabeled positive data. However, this assumption is unrealistic in many instances of PU learning because it fails to capture the existence of a selection bias in the labeling process. When the data has selection bias, it is difficult to learn the Bayes optimal classifier by conventional methods of PU learning. In this paper, we propose a method to partially identify the classifier. The proposed algorithm learns a scoring function that preserves the order induced by the class posterior under mild assumptions, which can be used as a classifier by setting an appropriate threshold. Through experiments, we show that the method outperforms previous methods for PU learning on various real-world datasets.
# 1 INTRODUCTION
We consider a situation that there are only positive and unlabeled data, and train a binary classifier only from them (PU learning). This problem arises in various practical situations, such as information retrieval and outlier detection (Elkan & Noto, 2008; Ward et al., 2009; Scott & Blanchard, 2009; Blanchard et al., 2010; Li et al., 2009; Nguyen et al., 2011). One of the milestones of PU learning is Elkan & Noto (2008), who proposed a practically useful algorithm with theoretical analysis, and there is subsequent research called unbiased PU learning (du Plessis & Sugiyama, 2014; du Plessis et al., 2015) where an unbiased estimator of the classification risk is minimized.
We focus on the case-control scenario (a.k.a. the problem setting based on two samples of data; Ward et al., 2009; Niu et al., 2016). In this scenario, positive data are obtained separately from unlabeled data, and unlabeled data are sampled from the whole population. As Elkan & Noto (2008) explained, we cannot identify a classifier without an assumption on how positive data are labeled. Therefore “selected completely at random” (SCAR) is traditionally assumed, i.e., the positive labeled data are identically distributed as the positive unlabeled data (Elkan & Noto, 2008; du Plessis et al., 2015). The assumption of SCAR is, however, unrealistic in many instances of PU learning, e.g., a patient’s electronic health record (Bekker & Davis, 2018a) and a recommendation system (Marlin & Zemel, 2009; Schnabel et al., 2016). In these cases, there is a selection bias (Heckman, 1979; Manski, 2008; Angrist & Pischke, 2008); the distribution of the positive data may differ between the labeled data and the unlabeled data.
Several recent related works have proposed alternative assumptions (Bekker & Davis, 2018a;b). However, in order to weaken SCAR, they impose other additional assumptions. In this work, we consider a more natural assumption such that SCAR becomes its special case. We assume that $p ( o = + 1 | x , y = + 1 )$ and $p ( y = + 1 | x )$ induce the same ordering on the input space $\mathcal { X }$ , where $y \in \{ - 1 , + 1 \}$ is the data label and $o = + 1$ (resp. $o = 0$ ) denotes the event that the data is observed (resp. not observed). We call this property the invariance of order. In the real-world application, there are many situations with a selection bias which follows the invariance of order. Among them, we list the following two examples.
# Example 1: (Anomaly Detection)
The goal of anomaly detection is to find anomaly data in an unlabeled dataset based on another dataset that consists only of anomaly data. When the anomaly data is collected, the more likely a datum is an anomaly, the more likely it is noticed and gets labeled.
Example 2: (Face Recognition)
The goal of this task is to identify a user from a set of face images based on some pictures of the user. In this case, the positive data are the face images identified with the user, and the unlabeled data consist of all the unidentified face images. The user may more likely provide pictures in which the face can be seen clearly, while in the unlabeled data there may be many unclear images.
Our problem setting is similar to the problem called learning from instance-dependent noisy labels (Du & Cai, 2015; Bootkrajang, 2016). In this problem setting, positive and negative data are available, but the labels are subject to the noise that flips the label with instance-dependent probability. Besides, there are existing works putting assumption similar to the invariance order (Du & Cai, 2015; Bootkrajang, 2016). We explain the difference between their works and ours around Assumption 1 in Section 2.1. We name our problem setting PU learning with a Selection Bias (PUSB).
In this paper, we propose a novel framework to deal with this problem setting. The experimental results show that our proposed method is appropriate for real-world applications compared to existing approaches for PU learning.
# 2 PROBLEM SETTING OF PU LEARNING WITH A SELECTION BIAS
We consider a binary classification problem to classify $\pmb { x } \in \mathcal { X } \subset \mathbb { R } ^ { d }$ into one of the two classes $\{ - 1 , + 1 \}$ . We assume that there exists a joint distribution $p ( { \pmb x } , y , o )$ , where $y \in \{ - 1 , + 1 \}$ is the class label of $_ { \textbf { \em x } }$ , and $o \in \{ 0 , + 1 \}$ is the observation status of $y$ (observed if $o = + 1$ and unobserved if $o = 0$ ). In other words, $_ { \textbf { \em x } }$ is labeled if $o = + 1$ , and it is unlabeled otherwise.
In PU learning, there are two distinguished sampling schemes called one sample and two samples of data (Niu et al., 2016). They are also called the censoring scenario and case-control scenario, respectively (Elkan & Noto, 2008). In the censoring scenario, a set of unlabeled data is sampled from the marginal density $p ( { \pmb x } )$ . Then, if a data point $_ { \textbf { \em x } }$ is positive, it gets labeled with probability $p ( o = + 1 | x , \bar { y } = + 1 )$ ; if $_ { \textbf { \em x } }$ is negative, it is never labeled. In the case-control scenario, a set of positive data is drawn from the positive conditional density $p ( { \pmb x } | y = + 1 )$ and a set of unlabeled data is drawn from $p ( { \pmb x } )$ . As Niu et al. (2016) stated, the case-control scenario is slightly more general than the censoring scenario setting. It is because the censoring scenario assumes the access to samples generated by $p ( { \pmb x } )$ , $p ( { \pmb x } | o = + 1 )$ , and $p ( { \pmb x } | o = 0 )$ whereas the case-control scenario only assumes the access to samples generated by $p ( { \pmb x } )$ and $p ( { \pmb x } | o = + 1 )$ ). Therefore we focus on the case-control scenario.
Suppose that we have a positive dataset $\{ { \pmb x } _ { i } \} _ { i = 1 } ^ { n }$ and an unlabeled dataset $\{ { \pmb x } _ { i } ^ { \prime } \} _ { i = 1 } ^ { n ^ { \prime } }$
$$\{ \pmb { x } _ { i } \} _ { i = 1 } ^ { n } \stackrel { \mathrm { i . i . d . } } { \sim } p ( \pmb { x } | y = + 1 , o = + 1 ) , \{ \pmb { x } _ { i } ^ { \prime } \} _ { i = 1 } ^ { n ^ { \prime } } \stackrel { \mathrm { i . i . d . } } { \sim } p ( \pmb { x } ) .$$
We assume that negative data are never labeled.
Note that we do not assume SCAR. Therefore, $p ( { \pmb x } | y = + 1 )$ may differ from $p ( { \pmb x } | y = + 1 , o = + 1$ ). In the case they differ, we say that there is a selection bias.
The quantity $\pi = p ( y = + 1 ) $ is called the class-prior. In our problem setting, we assume that $\pi$ is known. For example, in anomaly detection, the percentage of anomaly in the whole batch of products can be reported based on past experiences. Although there are various methods for estimating the class-prior in the traditional framework of the case-control scenario (du Plessis et al., 2016; Ramaswamy et al., 2016; Jain et al., 2016; Kato et al., 2018), we cannot estimate the class-prior in our problem setting under a theoretical guarantee. In Section 5, we show how misspecified class priors affect the performance of a classifier. As we explain later, even if we do not know the class-prior, we only have to change the last step of our algorithm. In summary, our goal is to obtain a classifier $h : \mathcal { X } \{ - 1 , 1 \}$ only from $\{ { \pmb x } _ { i } \} _ { i = 1 } ^ { n }$ , $\{ { \pmb x } _ { i } ^ { \prime } \} _ { i = 1 } ^ { n ^ { \prime } }$ , and $\pi$ under a weaker assumption than SCAR.
# 2.1 IDENTIFICATION STRATEGY
As stated by Elkan & Noto (2008), even if the class prior is given, we cannot estimate $p ( y = + 1 | x )$ only from positive data and unlabeled data without any assumption in PU learning. In the case-control scenario, a standard assumption is SCAR, i.e. $p ( { \pmb x } | y = + 1 , o = + 1 ) = p ( { \pmb x } | y = + 1 , o = 0 )$ , so that $p ( y = + 1 | x )$ can be estimated from the data in principle. However, in many instances of PU learning, the SCAR assumption is unreasonable as discussed before. Therefore, we relax SCAR and accommodate a selection bias. We can see how SCAR makes the class posterior identifiable in the following equation:
$$p ( y = + 1 | x ) = \frac { p ( \pmb { x } , y = + 1 ) } { p ( \pmb { x } ) } = \frac { p ( \pmb { x } | y = + 1 ) \pi } { p ( \pmb { x } ) } \overset { = } \underset { \mathrm { s c a R } } { \underbrace { = } } \frac { p ( \pmb { x } | y = + 1 , o = + 1 ) \pi } { p ( \pmb { x } ) } .$$
Here, $p ( { \pmb x } | y = + 1 , o = + 1 )$ can be estimated from the sample. This estimate can be used to obtain an estimate of $p ( { \pmb x } | y = + 1 )$ and hence that of $p ( y = + 1 | x )$ if we assume SCAR. However, without assuming SCAR, $p ( { \pmb x } | y = + 1 )$ ) may differ from $p ( { \pmb x } | y = + 1 , o = + 1 )$ ), and $p ( y = + 1 | x )$ is not identifiable.
Therefore, instead of estimating $p ( y = + 1 | x )$ , we consider extracting some useful information of $p ( y = + 1 | x )$ to learn a classifier. This kind of approach is known as “partial identification” (Manski, 2008) in statistics and economics. First, we introduce an assumption that is weaker than SCAR.
Assumption 1 (Invariance of Order). For any $\pmb { x } _ { i } , \pmb { x } _ { j } \in \mathcal { X }$ , we have
$$p ( y = + 1 | \boldsymbol { x } _ { i } ) \leq p ( y = + 1 | \boldsymbol { x } _ { j } ) \Leftrightarrow p ( o = + 1 | \boldsymbol { x } _ { i } ) \leq p ( o = + 1 | \boldsymbol { x } _ { j } ) .$$
Although Assumption 1 does not allow one to construct an unbiased estimator of the risk functional, we try to partially identify $p ( y = + 1 | x )$ under this assumption. Our problem setting can be regarded as a generalization of the traditional case-control scenario because SCAR is a special case of the invariance of order.
# 2.2 RELATED WORKS
A similar assumption can be found in the literature of learning from instance-dependent noisy labels (Du & Cai, 2015; Bootkrajang, 2016), which considers a probabilistic label flipping that is proportional to $p ( y = + 1 | x )$ . However, in order to apply methods of learning from noisy labels to PU learning, we need to assume the censoring scenario and these methods cannot be applied to our problem setting based on the case-control scenario. The censoring scenario is a special case of learning from noisy labels where only negative data is contaminated, i.e., some positive labels flip to negative labels. Thus, in the censoring scenario, unlabeled data can be regarded as negative-labeled data contaminated by positive data. On the other hand, in the case-control scenario, unlabeled data is generated from the marginal distribution $p ( { \pmb x } )$ , i.e., we cannot observe samples generated from $p ( { \pmb x } | o = 0 )$ . Therefore, our problem setting, namely the case-control scenario with invariance of order, is different from the existing works of learning from instance-dependent noisy labels. In addition, our method is also applicable to the censoring scenario when the invariance of order holds because the unlabeled data of the case-control scenario can be made from positive and unlabeled data of the censoring scenario.
In Example 1, $p ( y = + 1 | x )$ is the probability that a given input $_ { \textbf { \em x } }$ is anomaly, while $p ( o = + 1 | x )$ is the probability that a given input $_ { \textbf { \em x } }$ gets labeled in the dataset. In Example 2, a positively labeled data is an image $_ { \textbf { \em x } }$ that is known to belong to a user. Here, $p ( o = + 1 | x )$ is the probability that the user provides the picture $_ { \textbf { \em x } }$ as a training datum.
# 3 STRATEGY FOR PARTIAL IDENTIFICATION AND CLASSIFICATION
As discussed in Section 2.1, we cannot estimate $p ( y = + 1 | x )$ when there is a selection bias even if the class prior is given. Our idea of partial identification is based on the following theorem with the density ratio
$$r ( { \pmb x } ) = \frac { p ( { \pmb x } | y = + 1 , o = + 1 ) } { p ( { \pmb x } ) } .$$
# Algorithm 1 Conceptual Algorithm in Population
Input: $p ( { \pmb x } | y = + 1 )$ , $p ( { \pmb x } )$ and the class-pror $\pi$ . Using $p ( { \pmb x } | y = + 1 )$ and $p ( { \pmb x } )$ , calculate $r ( { \pmb x } )$ by minimization of either (4) or (7). Using $r ( { \pmb x } )$ , calculate $\theta _ { \pi }$ in (2). Using the density ratio $r ( { \pmb x } )$ and the threshold $\theta _ { \pi }$ , obtain a classifier $h ( \pmb { x } ) = \mathtt { s i g n } ( r ( \pmb { x } ) - \theta _ { \pi } )$ .
Theorem 1 (Order Preserving Property of the score Function). Suppose that Assumption $I$ holds. Then, for any $\pmb { x } _ { i } , \pmb { x } _ { j } \in \mathcal { X }$ ,
$$p ( y = + 1 | { \boldsymbol x } _ { i } ) \leq p ( y = + 1 | { \boldsymbol x } _ { j } ) \Leftrightarrow r ( { \boldsymbol x } _ { i } ) \leq r ( { \boldsymbol x } _ { j } ) .$$
A proof is provided in Appendix A.
Even though we cannot estimate $p ( y = + 1 | \cdot )$ , Theorem 1 implies that we can still extract the total order in $\mathcal { X }$ induced by $p ( y = + 1 | \cdot )$ if we can estimate $r ( \cdot )$ . Therefore, we propose to estimate $r$ and use it as a score function that captures the total order induced by $p ( y = + 1 | \cdot )$ . After obtaining an estimator of $r$ (denoted by $\hat { r }$ ), we set a threshold $\theta \in \mathbb { R }$ and use $h ( \pmb { x } ) = \mathtt { s i g n } ( r ( \pmb { x } ) - \theta )$ as a classifier. There are various ways of determining the threshold. For instance, we put labels from data with the highest density ratio under a constraint on the number of data to which we can put labels (Hido et al., 2011). Here, we introduce one useful principle for choosing $\theta$ . We consider using a threshold $\theta _ { \pi }$ defined by the following equation,
$$\pi = \int \mathbf { 1 } [ r ( \pmb { x } ) \geq \theta _ { \pi } ] p ( \pmb { x } ) d \pmb { x } .$$
The intuition behind the definition of $\theta _ { \pi }$ is that the proportion of the positive data in the test data points should not deviate so much from the class-prior. This intuition becomes clearer in Section 4.3.
In Section 4, we discuss detailed methods for estimating $r$ and setting $\theta$ based on data. Our approach is summarized in the form of a pseudo-code in Algorithm 1. In the rest of this section, we theoretically justify $\theta _ { \pi }$ defined in (2).
Property of $\theta _ { \pi }$ : Let us consider the case where a classifier is given as $h ( \pmb { x } ) = \mathtt { s i g n } ( r ( \pmb { x } ) - \theta )$ . Then four population quantities, true positives (TP), true negatives (TN), false positives (FP), and false negatives (FN) (Lipton et al., 2014), that depend on $r ( \cdot )$ and $\theta$ is written as follows:
$$\begin{array} { l r } { { T P = \displaystyle \int _ { \{ { \bf x } : r ( { \bf x } ) \geq \theta } \} } p ( y = + 1 | x ) p ( { \bf x } ) d x , } & { { F P = \displaystyle \int _ { \{ { \bf x } : r ( { \bf x } ) \geq \theta } \} } p ( y = - 1 | x ) p ( x ) d x , } \\ { { T N = \displaystyle \int _ { \{ { \bf x } : r ( { \bf x } ) < \theta } \} } p ( y = - 1 | x ) p ( { \bf x } ) d x , } & { { F N = \displaystyle \int _ { \{ { \bf x } : r ( { \bf x } ) < \theta \} } p ( y = + 1 | x ) p ( x ) d x . } } \end{array}$$
Then, the precision and the recall of a classifier are expressed as precision $\begin{array} { r l r } { \mathrm { ~ } } & { { } } & { = \mathrm { ~ \left( \frac { { \cal T } P } { { \cal T } P + { \cal F } P } \right) } } \end{array}$ and $\begin{array} { r } { \mathrm { r e c a l l } = \left( \frac { T P } { T P + F N } \right) } \end{array}$ , respectively. For $\theta _ { \pi }$ , we have the following result.
Theorem 2. If we use $\theta = \theta _ { \pi }$ , then precision $=$ recall holds.
A proof is shown in Appendix B. The threshold $\theta _ { \pi }$ is known as precision–recall breakeven point (BEP) (Sammut & Webb, 2010), which makes the precision and the recall the same. BEP is originally used to evaluate a generic classification model with a score function and a threshold. Besides, we can interpret BEP as a point which balances a prediction result; as explained by Powers (2015), a classifier using BEP as a threshold puts the same cost to the false positives and false negatives. Knowing BEP is also useful for deciding on a threshold which put unbalanced weight on the precision and the recall because we can tell if we are weighing precision more or recall more.
# 4 ALGORITHM
Here, we propose two directions for estimating r(x) = p(x|y=+1,o=+1)p(x) under the assumption of invariance of order, namely minimizing a pseudo classification risk and direct density ratio estimation. We discuss how to set $\theta$ based on the data. A pseudo-code of our algorithm is shown in Algorithm 2.
# Algorithm 2 PUSB
Input: A class-pror sitive dataset . $\{ { \pmb x } _ { i } \} _ { i = 1 } ^ { n }$ , an unlabeled dataset $\{ { \pmb x } _ { i } ^ { \prime } \} _ { i = 1 } ^ { n ^ { \prime } }$ , a test dataset $\{ \pmb { x } _ { i } ^ { \mathrm { t e } } \} _ { i = 1 } ^ { n ^ { \mathrm { t e } } }$ and the $\pi$ Using $\{ { \pmb x } _ { i } \} _ { i = 1 } ^ { n }$ and $\{ { \pmb x } _ { i } ^ { \prime } \} _ { i = 1 } ^ { n ^ { \prime } }$ , estimate $r ( { \pmb x } )$ by any of (5), (6) or (8) and obtain $\hat { r } ( { \pmb x } )$ . Using $\hat { r } ( { \pmb x } )$ , estimate $\theta _ { \pi }$ by (9) and obtain $\hat { \theta } _ { \pi }$ . Using an estimator $\hat { r } ( { \pmb x } )$ and $\hat { \theta }$ , obtain a classifier $h ( \pmb { x } ) = \mathtt { s i g n } ( \hat { r } ( \pmb { x } ) - \hat { \theta } _ { \pi } ) .$
# 4.1 ESTIMATION OF $r$ BY MINIMIZING PSEUDO CLASSIFICATION RISK
First, we introduce the minimization of the pseudo classification risk. The idea is to minimize the classification risk used in traditional PU learning (du Plessis et al., 2014; 2015) as if there is no selection bias. Under a selection bias, we cannot construct unbiased risk function, but the minimizer can be substituted for the density ratio in (1).
Conventional PU risk formulation: Let $\ell : \mathbb { R } \times \{ \pm 1 \} \to \mathbb { R } ^ { + }$ be a loss function, where $\mathbb { R } ^ { + }$ is the set of non-negative real values, and $\mathcal { F }$ be the set of measurable functions from $\mathcal { X }$ to $[ \epsilon , 1 - \epsilon ]$ , where $\epsilon \in ( 0 , 1 / 2 )$ is a small positive value. This constant $\epsilon$ is introduced to make the following optimization problem well-defined.
du Plessis et al. (2015) showed that the classification risk of $f \in { \mathcal { F } }$ in the traditional PU problem setting with SCAR can be expressed as
$$R _ { \mathrm { P U } } ( f ) = \pi \mathbb { E } _ { \mathrm { p } } [ \ell ( f ( X ) , + 1 ) ] - \pi \mathbb { E } _ { \mathrm { p } } [ \ell ( f ( X ) , - 1 ) ] + \mathbb { E } _ { \mathrm { u } } [ \ell ( f ( X ) , - 1 ) ] ,$$
where $\mathbb { E } _ { \mathrm { p } }$ and $\mathbb { E } _ { \mathrm { u } }$ are the expectations over $p ( { \pmb x } | y = + 1 )$ and $p ( { \pmb x } )$ , respectively. When there is no selection bias, we can replace the expectations with the corresponding sample averages to obtain an unbiased estimator of the classification risk.
The pseudo classification risk: In our problem setting, we only have samples from $p ( { \pmb x } | { \pmb y } =$ $+ 1 , o = + 1 \rangle$ and not from $p ( { \pmb x } | y = + 1 )$ . Therefore, we cannot use our sample to obtain an empirical version of $R _ { \mathrm { P U } }$ . However, we still consider the pseudo classification risk of $f \in { \mathcal { F } }$ :
$$\begin{array} { r } { R _ { \mathrm { P U } } ^ { \mathrm { b i a s } } ( f , \ell ) = \pi \mathbb { E } _ { \mathrm { p } } ^ { \mathrm { b i a s } } [ \ell ( f ( X ) , + 1 ) ] - \pi \mathbb { E } _ { \mathrm { p } } ^ { \mathrm { b i a s } } [ \ell ( f ( X ) , - 1 ) ] + \mathbb { E } _ { \mathrm { u } } [ \ell ( f ( X ) , - 1 ) ] , } \end{array}$$
where $\mathbb { E } _ { \mathrm { p . } } ^ { \mathtt { b i a s } }$ is the expectation over $p ( \pmb { x } | y = + 1 , o = + 1 )$ . We call this functional the pseudo classification risk because it is not the true classification risk. An unbiased estimator for the pseudo classification risk can be obtained by replacing the expectations with the corresponding sample averages even if there is a selection bias. For the loss function, we use the logarithmic loss: $\ell ( f ( \pmb { x } ) , + 1 ) ) = - \log ( f ( \pmb { x } ) )$ and $\ell ( f ( \pmb { x } ) , - 1 ) = - \log ( 1 - f ( \pmb { x } ) )$ . In this case, the pseudo classification risk of $f \in { \mathcal { F } }$ becomes
$$R _ { \mathrm { P U } } ^ { \mathrm { b i a s } } ( f ) = - \pi \mathbb { E } _ { \mathrm { p } } ^ { \mathrm { b i a s } } [ \log ( f ( X ) ) ] + \pi \mathbb { E } _ { p } ^ { \mathrm { b i a s } } [ \log ( 1 - f ( X ) ) ] - \mathbb { E } _ { \mathrm { u } } [ \log ( 1 - f ( X ) ) ] .$$
Justification for minimizing the pseudo classification risk: For the pseudo classification risk with the logarithmic loss function, the following theorem justifies its use. Let us denote a minimizer of (4) by $f ^ { * }$ , that is,
$$f ^ { * } \in \arg \operatorname* { m i n } _ { f \in \mathcal { F } } R _ { \mathrm { P U } } ^ { \mathrm { b i a s } } ( f ) .$$
For the minimizer of (4), we show the following theorem.
Theorem 3. It holds almost everywhere that
$$f ^ { * } ( \pmb { x } ) = \left\{ \begin{array} { l l } { \epsilon } & { ( \pmb { x } \notin D _ { 1 } ) , } \\ { \frac { \pi p ( \pmb { x } | y = + 1 , o = + 1 ) } { p ( \pmb { x } ) } } & { ( \pmb { x } \in D _ { 1 } \cap D _ { 2 } ) , } \\ { 1 - \epsilon } & { ( \pmb { x } \notin D _ { 2 } ) , } \end{array} \right.$$
where $D _ { 1 } \ = \ \{ { \pmb x } | \pi p ( { \pmb x } | y = 1 , o = + 1 ) \ \geq \ \epsilon p ( { \pmb x } ) \}$ and $D _ { 2 } \ = \ \{ { \pmb x } | \pi p ( { \pmb x } | y = 1 , o \ = \ + 1 ) \ \leq$ $( 1 - \epsilon ) p ( { \pmb x } ) \}$ .
A proof is provided in Appendix C. Theorem 3 implies that the minimization of the empirical version of the pseudo classification risk allows us to estimate $r$ .
Empirical Estimation: When we train a classifier with training samples, we can naively replace the expectations with the corresponding sample averages. For a hypothesis set $\mathcal { H }$ , which is a set of measurable functions, let us define the following risk minimization problem,
$$\hat { f } _ { 1 } = \underset { f \in \mathcal { H } } { \arg \operatorname* { m i n } } \left[ - \pi \hat { \mathbb { E } } _ { p } ^ { \mathrm { b i a s } } [ \log ( f ( X ) ) ] + \pi \hat { \mathbb { E } } _ { p } ^ { \mathrm { b i a s } } [ \log ( 1 - f ( X ) ) ] - \hat { \mathbb { E } } _ { u } [ \log ( 1 - f ( X ) ) ] + \mathcal { R } ( f ) \right] ,$$
where $\hat { \mathbb { E } } _ { p } ^ { \mathrm { { b i a s } } }$ denotes the averaging operator over positive data with a selection bias, $\hat { \mathbb { E } } _ { u }$ denotes the averaging over the unlabeled data, and $\mathcal { R }$ is a regularization term. du Plessis et al. (2015) showed that, under SCAR, the empirical version of the risk becomes unbiased toward the classification risk.
However, Kiryo et al. (2017) pointed out that unbiased PU learning does not work with deep neural networks. Minimizing an empirical risk of (3) with deep neural networks easily causes over-fitting because the risk is not bounded from below by 0. In order to implement PU learning with deep neural networks, Kiryo et al. (2017) proposed the following non-negative risk,
$$\begin{array} { r } { \hat { \bar { \mathfrak { c } } } _ { 2 } = \underset { f \in \mathcal { H } } { \mathrm { a r g } } \operatorname* { m i n } \left[ - \pi \hat { \mathbb { E } } _ { p } ^ { \mathrm { b i a s } } [ \mathrm { l o g } ( f ( X ) ) ] + \left( \pi \hat { \mathbb { E } } _ { p } ^ { \mathrm { b i a s } } [ \mathrm { l o g } ( 1 - f ( X ) ) ] - \hat { \mathbb { E } } _ { u } [ \mathrm { l o g } ( 1 - f ( X ) ) ] \right) _ { + } + \mathcal { R } ( f ) \right] , } \end{array}$$
where $( \cdot ) _ { + } : = \operatorname* { m a x } \{ 0 , \cdot \}$ . After obtaining $\hat { f }$ , we construct an estimator of the density ratio $r$ by $\begin{array} { r } { \hat { r } = \frac { 1 } { \pi } \hat { f } _ { 1 } } \end{array}$ or $\begin{array} { r } { \hat { r } = \frac { 1 } { \pi } \hat { f } _ { 2 } } \end{array}$ .
# 4.2 ESTIMATION OF $r$ BY DIRECT DENSITY RATIO ESTIMATION
For another approach, we consider estimating the density ratio $\begin{array} { r } { r ( \pmb { x } ) = \frac { p ( \pmb { x } | y = + 1 , o = + 1 ) } { p ( \pmb { x } ) } } \end{array}$ directly. We can estimate the probability density functions of the numerator and the denominator. However, as known as Vapnik’s principle, we should avoid solving more difficult intermediate problems than the target problem. Sugiyama et al. (2012) summarized methods estimating the density ratio directly. Among existing methods, we employ Least-squares importance fitting (LSIF), which uses the squared loss for density-ratio function fitting. The reason for this choice is that there is an algorithm called unconstrained Least-Squares Importance Fitting (uLSIF) with a computational advantage. We can obtain the closed-form solution just by solving the linear equations. Thus, uLSIF is numerically stable when it is regularized properly. Moreover, the leave-one-out cross-validation score for uLSIF can also be computed analytically, which significantly improves the computational efficiency in model selection.
Here, we introduce the formulation of LSIF. Let $s$ be the class of non-negative measurable functions $s : \mathcal { X } \to \mathbb { R } ^ { + }$ . We consider minimizing the following squared error between $s$ and $r$ :
$$R _ { \mathrm { D R } } ( s ) = \mathbb { E } _ { \mathrm { u } } [ ( s ( X ) - r ( X ) ) ^ { 2 } ] = \mathbb { E } _ { \mathrm { u } } [ ( r ( X ) ) ^ { 2 } ] - 2 \mathbb { E } _ { \mathrm { p } } ^ { \mathrm { b i a s } } [ s ( X ) ] + \mathbb { E } _ { \mathrm { u } } [ ( s ( X ) ) ^ { 2 } ] .$$
The first term of the last equation does not affect the result of minimization and we can ignore the term, i.e., the density ratio is estimated through the following minimization problem:
$$s ^ { * } = \underset { s \in \cal S } { \arg \operatorname* { m i n } } R _ { \mathrm { D R } } ( s ) = \underset { s \in \cal S } { \arg \operatorname* { m i n } } \left[ \frac { 1 } { 2 } \mathbb { E } _ { \mathrm { u } } [ ( s ( X ) ) ^ { 2 } ] - \mathbb { E } _ { \mathrm { p } } ^ { \tt b i a s } [ s ( X ) ] \right] .$$
Empirical Estimation: As mentioned above, to minimize the empirical version of (7), we use uLSIF (Kanamori et al., 2009). Given a hypothesis class $\mathcal { H }$ , we obtain $\hat { r }$ by
$$\hat { r } = \underset { s \in \mathcal { H } } { \arg \operatorname* { m i n } } \left[ \frac { 1 } { 2 } \hat { \mathbb { E } } _ { \mathrm { u } } [ ( s ( X ) ) ^ { 2 } ] - \hat { \mathbb { E } } _ { \mathrm { p } } ^ { \mathrm { b i a s } } [ s ( X ) ] + \mathcal { R } ( s ) \right] ,$$
where $\mathcal { R }$ is a regularization term.
# 4.3 ESTIMATION OF $\theta _ { \pi }$
We consider replacing the threshold defined by (2) with samples. By using the test inputs or held-out training data, $\{ \pmb { x } _ { i } ^ { \mathrm { t e } } \} _ { i = 1 } ^ { n ^ { \mathrm { t e } } } \sim p ( \pmb { x } )$ be calcu, we find $\hat { \theta } _ { \pi }$ ed only fromthat satisfies
Table 1: Dataset statistics (Pos. frac.: Positive fraction, Dim: Dimension).
<table><tr><td>Dataset</td><td>#of samples</td><td>Pos.frac.</td><td>Dim.</td></tr><tr><td>mushrooms</td><td>8,124</td><td>0.517</td><td>112</td></tr><tr><td>shuttle</td><td>58.000</td><td>0.786</td><td>9</td></tr><tr><td>pageblocks</td><td>5,473</td><td>0.898</td><td>10</td></tr><tr><td>usps</td><td>9,298</td><td>0.524</td><td>256</td></tr><tr><td>connect-4</td><td>67,557</td><td>0.658</td><td>126</td></tr><tr><td>spambase</td><td>4.601</td><td>0.394</td><td>57</td></tr><tr><td>MNIST</td><td>70.000</td><td>0.511</td><td>784</td></tr><tr><td>CIFAR-10</td><td>60,000</td><td>0.400</td><td>3,072</td></tr></table>
the following equation,
$$\lceil \pi n ^ { \mathrm { t e } } \rceil = \sum _ { i = 1 } ^ { n ^ { \mathrm { t e } } } { \bf 1 } [ \hat { r } ( { \bf x } _ { i } ^ { \mathrm { t e } } ) > \hat { \theta } _ { \pi } ] .$$
Here, we used the knowledge of $\pi$ , the class-prior. This choice of $\hat { \theta } _ { \pi }$ amounts to classifying top- $\pi$ test data as positive after ranking the inputs by $\hat { r }$ .
# 5 EXPERIMENTS
In this section, we report experimental results which were conducted using synthetic data and realworld datasets1). We used seven classification datasets, mushrooms, shuttle, pageblocks, usps, connect-4, spambase, and MNIST, from UCI repository2), $\mathsf { C I F A R } - \mathsf { 1 0 } ^ { 3 } )$ and a document dataset obtained from SwissProt (Boeckmann et al., $2 0 0 3 ) ^ { 4 ) }$ . MNIST and $\mathtt { C I F A R - 1 0 }$ originally have 10 and 10 classes, respectively, and we constructed the positive and negative datasets from them as follows: MNIST was preprocessed in such a way that 0, 2, 4, 6, 8 constitute the positive class, while 1, 3, 5, 7, 9 constitute the negative class; for CIFAR-10, the positive dataset is formed by ‘airplane’, ‘automobile’, ‘ship’ and ‘truck’, and the negative dataset is formed by ‘bird’, ‘cat’, ‘deer’, ‘dog’, ‘frog’ and ‘horse’. Except for the document dataset, we show the details of datasets in Table 1 and made positive data with a selection bias based on estimators of $p ( y = + 1 | x )$ as we show in each experiments. For six datasets of the UCI repository and the CIFAR-10, we made positive datasets with a selection bias artificially, but, for the document dataset, we have an unlabeled dataset and a positive dataset, which is gathered for classifying the labels in the unlabeled dataset.
We call unbiased PU learning proposed by du Plessis et al. (2015) “PU”, unbiased PU learning with a threshold estimated by (9) “PUSB”, uLSIF with a threshold estimated by (9) “DRSB”, nonnegative PU learning “nnPU” and nonnegative PU learning with a threshold estimated by (9) “nnPUSB”.
For the hypothesis class $\mathcal { H }$ in the density ratio estimation (8), we use the linear-in-parameter model:
$$\begin{array} { r } { \mathcal { H } : = \left. \ : s ( \pmb { x } ) = \beta ^ { \top } \varphi ( \pmb { x } ) \right. \beta \in \mathbb { R } ^ { m + 1 } \} , } \end{array}$$
where $\pmb { \varphi } ( \pmb { x } ) = [ 1 , \varphi _ { 1 } ( \pmb { x } ) , . . . , \varphi _ { m } ( \pmb { x } ) ] ^ { \top }$ is a vector of basis functions. For basis functions, we used the Gaussian kernel located at sample points $\varphi _ { \ell } ( \pmb { x } ) = \exp \left( - \| \pmb { x } - \pmb { c } _ { \ell } \| ^ { 2 } / ( 2 \sigma ^ { 2 } ) \right)$ , where $\{ \pmb { c } _ { 1 } , . . . , \pmb { c } _ { m } \} =$ $\left\{ { \pmb x } _ { 1 } , . . . , { \pmb x } _ { n } , { \pmb x } _ { 1 } ^ { \prime } , . . . , { \pmb x } _ { n ^ { \prime } } ^ { \prime } \right\}$ and $m = n + n ^ { \prime }$ . For the hypothesis class $\mathcal { H }$ in the risk minimization of PU learning (5), we use the following model with the sigmoid function:
$$\mathcal { H } : = \left. \left. f ( \pmb { x } ) = \frac { 1 } { 1 + \exp ( - \beta ^ { \top } \varphi ( \pmb { x } ) ) } \right| \beta \in \mathbb { R } ^ { m + 1 } \right. .$$
In this case, the loss is the same as the logistic loss and unbiased PU learning becomes convex. For the hypothesis class $\mathcal { H }$ in the risk minimization of nonnegative PU learning (6), we use deep neural networks. The specifications of deep neural networks are given in the following sections for each dataset. We mainly used the same structure proposed in Kiryo et al. (2017) in order to compare the performances. For the regularization term $\mathcal { R }$ , we used the $\ell _ { 2 }$ norm of the parameters scaled by a positive scalar $\lambda$ . For the linear models, hyperparameters were selected via cross-validation.
 Figure 1: Two Gaussians: The horizontal axis is the value of $_ { \textbf { \em x } }$ and the vertical axis is the probability density. The vertical lines represent the decision boundaries of the classifiers. The distribution of positive data, negative data, unlabeled data and $p ( \pmb { x } | o = + 1 , y = + 1 )$ are plotted.
# 5.1 TEST WITH SYNTHETIC DATA
This experiment shows the classifier given by PUSB. We used samples from a mixture distribution of the following two class-conditional distributions:
$$p ( { \pmb x } | y = + 1 ) = \mathcal { N } ( 1 , 2 ^ { 2 } ) \mathrm { a n d } p ( { \pmb x } | y = - 1 ) = \mathcal { N } ( - 1 , 2 ^ { 2 } ) ,$$
where ${ \mathcal { N } } ( \mu , \sigma ^ { 2 } )$ denotes the univariate normal distribution with mean $\mu$ and variance $\sigma ^ { 2 }$ . A positive dataset with a selection bias was sampled from
$$p ( \pmb { x } | o = + 1 , y = + 1 ) \propto ( p ( y = + 1 | \pmb { x } ) ) ^ { 1 0 } .$$
We generated 1, 000 positive samples and $1 0 , 0 0 0$ unlabeled samples. We made two datasets with different class-priors $\pi = 0 . 3$ and $\pi = 0 . 7$ . Figure 1 shows classifiers constructed by PU and PUSB along with the Bayes optimal classifier $\mathtt { s i g n } ( \bar { p } ( y = + 1 | x ) - 1 / 2 )$ . The classifier of PUSB is closer to the Bayes optimal classifier than that of PU.
# 5.2 TEST WITH BENCHMARK DATA
Here, we investigate the experimental performance in detail.
Linear-in-parameter model: We used the mushrooms, shuttle, pageblocks, usps, connect-4 and spambase datasets. First, we estimated $p ( y = + 1 | x )$ using the logistic regression with the same linear model. Then, we obtained the labeled positive data by labeling some instances of the positive data following
$$p ( o = + 1 | x , y = + 1 ) \propto ( p ( y = + 1 | x ) ) ^ { 2 0 } .$$
Then, we trained a classifier by minimizing the empirical risk of PU learning (4) and the density ratio estimation (7).
For each binary labeled dataset, we made 12 different pairs of positive and unlabeled data with 4 different class-priors, $\{ 0 . 2 , 0 . 4 , 0 . 6 , 0 . 8 \}$ , and 3 different numbers of unlabeled data, $\{ 8 0 0 , 1 6 0 0 , 3 2 0 0 \}$ . The number of positive data was fixed at 400. We used 1000 test data sampled from the same distribution as the unlabeled data. We ran the experiments 100 times and calculated the mean and standard deviation for the test dataset with PU, PUSB, and DRSB. The results are shown in Table 2. The classifiers obtained by our algorithm always show preferable performance to existing methods.
Neural network model: We used the MNIST and CIFAR-10 datasets. For MNIST, a 3-layer multilayer perceptron (MLP) with ReLU activation (Nair & Hinton, 2010) was used. For CIFAR-10, an all convolutional net (Springenberg et al., 2015) was used. Details of the network structure are shown in Appendix D.
Table 2: The error rate of classification in test data $( \% )$ are shown for the different class-priors and the different number of samples. For all experiments, the linear-in-parameter model was used. Best and equivalent methods (under $5 \%$ t-test) are bold.
<table><tr><td colspan="2"></td><td colspan="3">PU</td><td colspan="3">PUSB</td><td colspan="3">DRSB</td></tr><tr><td>Dataset</td><td>π</td><td>800</td><td>1600</td><td>3200</td><td>800</td><td>1600</td><td>3200</td><td>800</td><td>1600</td><td>3,200</td></tr><tr><td>mushrooms</td><td>0.2</td><td>5.1(.076)</td><td>5.0(.055)</td><td>5.5 (.083)</td><td>4.1 (.007)</td><td>3.8 (.007)</td><td>4.0 (.007)</td><td>10.7 (.010)</td><td>9.9 (.011)</td><td>9.9 (.012)</td></tr><tr><td></td><td>0.4</td><td>7.0 (.012)</td><td>6.6(.010)</td><td>6.8(.025)</td><td>6.9 (.012)</td><td>6.7 (.010)</td><td>6.8 (.010)</td><td>15.8 (.014)</td><td>15.0 (.016)</td><td>15.2 (.012)</td></tr><tr><td></td><td>0.6</td><td>10.8 (.020)</td><td>11.3 (.015)</td><td>11.3 (.016)</td><td>8.2(.013)</td><td>8.5 (.010)</td><td>8.3 (.011)</td><td>18.5 (.014)</td><td>18.8(.012)</td><td>18.5 (.013)</td></tr><tr><td></td><td>0.8</td><td>21.1 (.022)</td><td>21.6(.021)</td><td>21.7 (.016)</td><td>8.1(.015)</td><td>8.0 (.012)</td><td>7.6(.014)</td><td>14.2 (.013)</td><td>14.3 (.014)</td><td>14.4(.011)</td></tr><tr><td>shuttle</td><td>0.2</td><td>23.8 (.006)</td><td>23.8 (.007)</td><td>23.8(.007)</td><td>5.2 (.008)</td><td>5.0 (.007)</td><td>5.0 (.007)</td><td>5.1(.008)</td><td>5.1(.008)</td><td>5.1 (.007)</td></tr><tr><td></td><td>0.4</td><td>15.5 (.023)</td><td>15.5 (.019)</td><td>15.0 (.016)</td><td>7.8 (.011)</td><td>7.7 (.011)</td><td>7.6(.012)</td><td>6.7 (.025)</td><td>7.6 (.029)</td><td>7.2 (.027)</td></tr><tr><td></td><td>0.6</td><td>26.1 (.018)</td><td>26.4 (.017)</td><td>26.4(.016)</td><td>11.1 (.015)</td><td>10.8 (.012)</td><td>11.0 (.015)</td><td>7.8 (.028)</td><td>7.4 (.028)</td><td>7.1(.028)</td></tr><tr><td></td><td>0.8</td><td>14.6(.006)</td><td>14.6 (.005)</td><td>14.8 (.007)</td><td>12.3 (.014)</td><td>12.4 (.014)</td><td>12.3 (.012)</td><td>7.9 (.021)</td><td>7.6(.023)</td><td>7.4 (.022)</td></tr><tr><td>pageblocks</td><td>0.2</td><td>39.5 (.009)</td><td>39.6 (.010)</td><td>39.6(.008)</td><td>41.6 (.021)</td><td>42.5 (.022)</td><td>43.7 (.019)</td><td>23.1 (.016)</td><td>23.1 (.015)</td><td>22.2 (.012)</td></tr><tr><td></td><td>0.4</td><td>56.5 (.011)</td><td>56.7 (.011)</td><td>56.6(.008)</td><td>33.7 (.020)</td><td>33.7 (.019)</td><td>33.5 (.024)</td><td>23.6 (.012)</td><td>23.7(.014)</td><td>23.6 (.014)</td></tr><tr><td></td><td>0.6</td><td>22.4 (.023)</td><td>23.4(.033)</td><td>28.1(.028)</td><td>20.9 (.016)</td><td>21.1 (.016)</td><td>21.5 (.020)</td><td>18.7 (.011)</td><td>18.6(.012)</td><td>18.1 (.017)</td></tr><tr><td></td><td>0.8</td><td>19.8 (.003)</td><td>20.0 (.001)</td><td>20.0 (.001)</td><td>13.9 (.022)</td><td>13.6 (.023)</td><td>16.7 (.043)</td><td>15.4 (.011)</td><td>14.8 (.014)</td><td>14.3 (.019)</td></tr><tr><td>usps</td><td>0.2</td><td>9.0 (.011)</td><td>8.5 (.009)</td><td>8.2 (.010)</td><td>8.0 (.009)</td><td>7.7 (.007)</td><td>7.4 (.009)</td><td>18.2 (.016)</td><td>19.6 (.013)</td><td>19.7 (.014)</td></tr><tr><td></td><td>0.4</td><td>10.5 (.012)</td><td>10.3 (.013)</td><td>10.0 (.010)</td><td>10.5 (.013)</td><td>10.2 (.012)</td><td>10.0 (.010)</td><td>30.5 (.029)</td><td>30.2(.022)</td><td>29.9 (.023)</td></tr><tr><td></td><td>0.6</td><td>12.5 (.015)</td><td>12.3 (.015)</td><td>12.1 (.013)</td><td>11.2 (.016)</td><td>10.9 (.015)</td><td>10.6 (.013)</td><td>32.9 (.026)</td><td>33.2(.031)</td><td>33.1(.030)</td></tr><tr><td></td><td>0.8</td><td>19.8 (.020)</td><td>19.8 (.016)</td><td>19.5 (.017)</td><td>10.3 (.016)</td><td>9.8 (.014)</td><td>9.6 (.014)</td><td>25.9 (.028)</td><td>25.3(.027)</td><td>25.8 (.030)</td></tr><tr><td>connect-4</td><td>0.2</td><td>22.3 (0.017)</td><td>21.9 (.014)</td><td>21.6 (.013)</td><td>21.8 (.013)</td><td>21.5 (.012)</td><td>21.2 (.011)</td><td>26.7(.012)</td><td>26.6(.012)</td><td>26.4(.011)</td></tr><tr><td></td><td>0.4</td><td>31.2 (.015)</td><td>31.0 (.015)</td><td>30.7(.016)</td><td>31.2 (.015)</td><td>31.0 (.015)</td><td>30.7 (.016)</td><td>39.4 (.016)</td><td>39.6(.018)</td><td>39.2 (.016)</td></tr><tr><td></td><td>0.6</td><td>32.0 (.017)</td><td>32.1 (.013)</td><td>31.9 (.015</td><td>31.7 (.016)</td><td>31.7 (.013)</td><td>31.4 (.016)</td><td>40.9 (.015)</td><td>41.1 (.017)</td><td>41.0 (.017)</td></tr><tr><td>spambase</td><td>0.8</td><td>33.6(.018)</td><td>33.5 (.016)</td><td>33.4(.017)</td><td>24.2 (.013)</td><td>23.9 (.013)</td><td>23.8(.013)</td><td>29.8 (.011)</td><td>29.6(.013)</td><td>29.5 (.012)</td></tr><tr><td></td><td>0.2</td><td>20.1 (0.002)</td><td>20.1(.002)</td><td>20.1(.003)</td><td>13.6 (.013)</td><td>13.8 (.014)</td><td>14.0 (.014)</td><td>18.1 (.026)</td><td>18.3 (.025)</td><td>17.9 (.023)</td></tr><tr><td></td><td>0.4</td><td>36.2 (.024)</td><td>35.9 (.025)</td><td>30.7 (.024)</td><td>19.0 (.020)</td><td>18.7 (.021)</td><td>18.9 (.018)</td><td>27.4(.042)</td><td>27.8 (.043)</td><td>27.7 (.039)</td></tr><tr><td></td><td>0.6</td><td>40.0 (.001)</td><td>39.9 (.001)</td><td>31.9 (.001</td><td>20.8 (.019)</td><td>20.7(.018)</td><td>20.0 (.017)</td><td>31.2 (.037)</td><td>30.3 (.035)</td><td>31.2 (.035)</td></tr><tr><td></td><td>0.8</td><td>20.0 (.000)</td><td>20.0 (.000)</td><td>20.0 (.000)</td><td>18.0 (.015)</td><td>17.7 (.013)</td><td>17.3 (.013)</td><td>24.5 (.058)</td><td>23.9 (.017)</td><td>24.2(.017)</td></tr></table>
 Figure 2: Experimental results of training deep neural networks. Left: MNIST; Center: $\mathrm { C I F A R } { - } 1 0$ ; Right: RealData: All measures are calculated for test data sampled from the marginal distribution $p ( { \pmb x } )$ . The horizontal axis is the epoch of training the network, the vertical axes of the top figures are the error rates and the vertical axes of the bottom figures are the precision and the recall.
First, we estimated $p ( y = + 1 | x )$ using the logistic regression with the same network structure using the positive and negative datasets in the unlabeled dataset. Next, from the positive dataset, we resampled positive dataset with an observation, which follows
$$p ( o = + 1 | x , y = + 1 ) \propto ( p ( y = + 1 | x ) ) ^ { 1 0 } .$$
Then, we trained a classifier by minimizing (6) with the model defined above. We used 10, 000 test data sampled from the same distribution as the unlabeled data. We ran the experiments 100 times and calculated the mean of the error rate, the standard deviation of the error rate, the mean of recall and the mean of precision for each epoch in training with nnPU and nnPUSB. The results are shown on the left side and center of Figure 2. In the upper row, we show the mean and standard deviation of the error rate. In the lower row, we show the mean of recall and the mean of precision. As shown in Figure 2, the mean of the error rate of our algorithm is lower and the variance is also lower than the existing method. As we discussed in Section 4.3, $\mathrm { F P = F N }$ is also empirically observed.
 Figure 3: Results of the second experiment of Section 5.4 using the RealData dataset with the estimated class prior 0.1095 (the true class prior is 0.0709). The horizontal axes are the epochs of training the network, the vertical axis of the right figure is the error rate and the vertical axis of the left figure is the value of the precision and the recall.
# 5.3 TEST WITH REAL-WORLD DATA
In the previous sections, we artificially made positive data with a selection bias. Here we demonstrate the effectiveness of our algorithm in real-world data with a selection bias. We used a document dataset based on the SwissProt database released by Elkan & Noto (2008). We call this dataset RealData. The dataset originally contained 2,453 labeled positive examples (P) and 4,906 unlabeled examples (U). The unlabeled examples were labeled later by Das et al. (2007). As a result, the dataset is likely to have a natural observation bias in the $\mathrm { \bf P }$ data while it allows an access to the ground-truth labels for all data. Out of the U data, 348 examples are positive and the rest are negative. The class prior is $\pi = 3 4 8 / 4 , 9 0 6 = 0 . 0 7 0 9$ . We used Bag-of-Words to represent the documents as 78, 894-dimensional vectors.
Details of the network structure are shown in Appendix D. We trained a classifier using positive and unlabeled data. Then, after finding a threshold estimated by (9), we evaluated the same evaluation measures as the previous experiments by classifying U, i.e., we regarded the unlabeled data as test data. As shown on the right of Figure 2, the result of our algorithm outperforms the existing method.
# 5.4 TEST FOR UNKNOWN CLASS PRIOR
In order to evaluate how our algorithm works for the case that the class prior is unknown, we empirically tested our algorithm with an estimator of the class prior. We used the RealData dataset in Section 5.3, whose class prior is 0.0709. For the class prior estimator, we used the KM2 method by Ramaswamy et al. (2016), which is considered to be the state-of-the-art method in the case-control scenario under SCAR. The estimated class prior was 0.1095 and the result is shown in Figure 3. We can see from the figure that our method works well with an estimated class prior in so far as RealData dataset is concerned. We also show results for the classifiers trained under misspecified class priors in Appendix E, which also shows that our method works stably for misspecified class priors.
# 6 CONCLUSION
In this paper, we proposed a novel framework for PU learning with a selection bias in positive data. We put the assumption of the invariance of order and showed the density ratio of labeled positive data and unlabeled data has the same order as the class-conditional distribution for inputs. Based on this result, we proposed a method based on partial identification in which we first estimate the density ratio and then use it as a classifier by setting a threshold. We conducted experiments to confirm the effectiveness of our approach. As we showed in the experiments, our method outperforms previous PU methods on real-world data.
# ACKNOWLEDGMENTS
This work was supported by JSPS KAKENHI 16H00881 and the AIP challenge program, Japan.
# REFERENCES
Joshua D. Angrist and Jörn-Steffen Pischke. Mostly Harmless Econometrics: An Empiricist’s Companion. Princeton University Press, December 2008.
Jessa Bekker and Jesse Davis. Learning from positive and unlabeled data under the selected at random assumption. In Proceedings of the Second International Workshop on Learning with Imbalanced Domains: Theory and Applications, volume 94 of Proceedings of Machine Learning Research, pp. 8–22. PMLR, 10 Sep 2018a.
Jessa Bekker and Jesse Davis. Beyond the selected completely at random assumption for learning from positive and unlabeled data. arXiv:1809.03207, 2018b.
Gilles Blanchard, Gyemin Lee, and Clayton Scott. Semi-supervised novelty detection. Journal of Machine Learning Research, 11(Nov):2973–3009, 2010.
Brigitte Boeckmann, Amos Bairoch, Rolf Apweiler, Marie-Claude Blatter, Anne Estreicher, Elisabeth Gasteiger, Maria J Martin, Karine Michoud, Claire O’donovan, Isabelle Phan, et al. The SWISSPROT protein knowledgebase and its supplement trembl in 2003. Nucleic acids research, 31(1): 365–370, 2003.
Jakramate Bootkrajang. A generalised label noise model for classification in the presence of annotation errors. Neurocomputing, 192(C):61–71, 2016.
Sanmay Das, Milton H Saier, and Charles Elkan. Finding transport proteins in a general protein database. In European Conference on Principles of Data Mining and Knowledge Discovery, pp. 54–66. Springer, 2007.
Jun Du and Zhihua Cai. Modelling class noise with symmetric and asymmetric distributions. In AAAI Conference on Artificial Intelligence, AAAI’15, pp. 2589–2595. AAAI Press, 2015.
M. C. du Plessis, Gang. Niu, and Masashi Sugiyama. Analysis of learning from positive and unlabeled data. In NIPS, pp. 703–711, 2014.
Marthinus Christoffel du Plessis and Masashi Sugiyama. Class prior estimation from positive and unlabeled data. IEICE Transactions on Information and Systems, E97-D(5):1358–1362, 2014.
Marthinus Christoffel du Plessis, Gang. Niu, and Masashi Sugiyama. Convex formulation for learning from positive and unlabeled data. In ICML, pp. 1386–1394, 2015.
Marthinus Christoffel du Plessis, Gang Niu, and Masashi Sugiyama. Class-prior estimation for learning from positive and unlabeled data. In ACML, pp. 221–236, 2016.
Charles Elkan and Keith Noto. Learning classifiers from only positive and unlabeled data. In ICDM, pp. 213–220, 2008.
James Heckman. Sample selection bias as a specification error. Econometrica, 47(1):153–61, 1979.
Shohei Hido, Yuta Tsuboi, Hisashi Kashima, Masashi Sugiyama, and Takafumi Kanamori. Statistical outlier detection using direct density ratio estimation. Knowledge and Information Systems, 26(2): 309–336, Feb 2011.
Sergey Ioffe and Christian Szegedy. Batch normalization: Accelerating deep network training by reducing internal covariate shift. In ICML, pp. 448–456, 2015.
Shantanu Jain, Martha White, Michael W Trosset, and Predrag Radivojac. Nonparametric semisupervised learning of class proportions. In NIPS, 2016.
Takafumi. Kanamori, Shohei Hido, and Masashi Sugiyama. A least-squares approach to direct importance estimation. Journal of Machine Learning Research, 10(Jul.):1391–1445, 2009.
Masahiro Kato, Liyuan Xu, Gang Niu, and Masashi Sugiyama. Alternate estimation of a classifier and the class-prior from positive and unlabeled data. arXiv:1809.05710, 2018.
Ryuichi Kiryo, Gang Niu, Marthinus Christoffel du Plessis, and Masashi Sugiyama. Positiveunlabeled learning with non-negative risk estimator. In NIPS, pp. 1675–1685, 2017.
Xiao-Li Li, Philip S Yu, Bing Liu, and See-Kiong Ng. Positive unlabeled learning for data stream classification. In ICDM, pp. 259���270, 2009.
Zachary C. Lipton, Charles Elkan, and Balakrishnan Naryanaswamy. Optimal thresholding of classifiers to maximize F1 measure. In Machine Learning and Knowledge Discovery in Databases, pp. 225–239, 2014.
Charles Manski. Partial Identification in Econometrics. Palgrave-Macmillan, 2 edition, 2008.
Benjamin M. Marlin and Richard S. Zemel. Collaborative prediction and ranking with non-random missing data. In ACM Conference on Recommender Systems, RecSys ’09, pp. 5–12, 2009.
Vinod Nair and Geoffrey E. Hinton. Rectified linear units improve restricted boltzmann machines. In ICML, 2010.
Minh Nhut Nguyen, Xiaoli-Li Li, and See-Kiong Ng. Positive unlabeled leaning for time series classification. In IJCAI, pp. 1421–1426, 2011.
Gang Niu, Marthinus Christoffel du Plessis, Tomoya. Sakai, Y. Ma, and Masashi Sugiyama. Theoretical comparisons of positive-unlabeled learning against positive-negative learning. In NIP, pp. 1199–1207, 2016.
David M. W. Powers. Visualization of tradeoff in evaluation: from precision-recall & PN to LIFT, ROC & BIRD. arXiv:1505.00401, 2015.
Harish Ramaswamy, Clayton Scott, and Ambuj Tewari. Mixture proportion estimation via kernel embeddings of distributions. In ICML, pp. 2052–2060, 2016.
Claude Sammut and Geoffrey I. Webb (eds.). Breakeven Point, pp. 137–138. Springer US, Boston,MA, 2010. ISBN 978-0-387-30164-8. doi: 10.1007/978-0-387-30164-8_88.
Tobias Schnabel, Adith Swaminathan, Ashudeep Singh, Navin Chandak, and Thorsten Joachims. Recommendations as treatments: Debiasing learning and evaluation. In ICML, volume 48, pp. 1670–1679, New York, New York, USA, 20–22 Jun 2016.
Clayton Scott and Gilles Blanchard. Novelty detection: Unlabeled data definitely help. In AISTATS, pp. 464–471, 2009.
J.T. Springenberg, A. Dosovitskiy, T. Brox, and M. Riedmiller. Striving for simplicity: The all convolutional net. In ICLR (workshop track), 2015.
Masashi Sugiyama, Taiji Suzuki, and Takafumi Kanamori. Density Ratio Estimation in Machine Learning. Cambridge University Press, New York, NY, USA, 1st edition, 2012.
Gill Ward, Trevor Hastie, Simon Barry, Jane Elith, and John R Leathwick. Presence-only data and the em algorithm. Biometrics, 65(2):554–563, 2009.
# A PROOF OF THEOREM 1
Proof. We assumed that no negative data can be labeled. As a result, we have $p ( o = + 1 | x , y =$ $- 1 ) = 0$ for arbitrary $x \in \mathcal { X }$ . Therefore,
$$\begin{array} { c } { { p ( o = + 1 | x ) = p ( y = + 1 | x ) p ( o = + 1 | x , y = + 1 ) + p ( y = - 1 | x ) p ( o = + 1 | x , y = - 1 ) } } \\ { { { } } } \\ { { = p ( y = + 1 | x ) p ( o = + 1 | x , y = + 1 ) . } } \end{array}$$
By Bayes’ theorem, we can expand the density ratio in (1) as follows:
$${ \begin{array} { r l } & { \cdot ( \mathbf { x } ) = { \frac { p ( x | o = + 1 , y = + 1 ) } { p ( \mathbf { x } ) } } } \\ & { \quad = { \frac { p ( y = + 1 | x , o = + 1 ) p ( \mathbf { x } | o = + 1 ) } { p ( y = + 1 | o = + 1 ) } } { \frac { 1 } { p ( \mathbf { x } ) } } } \\ & { \quad = p ( y = + 1 | x , o = + 1 ) { \frac { 1 } { p ( y = + 1 | o = + 1 ) } } { \frac { p ( \mathbf { x } | o = + 1 ) } { p ( \mathbf { x } ) } } } \\ & { \quad = { \frac { p ( y = + 1 | x ) p ( o = + 1 | x , y = + 1 ) } { p ( o = + 1 | x ) } } { \frac { 1 } { p ( y = + 1 | o = + 1 ) } } { \frac { p ( o = + 1 ) p ( x | o = + 1 ) } { p ( o = + 1 ) } } . } \end{array} }$$
Because $\begin{array} { r } { \frac { p ( y = + 1 | \pmb { x } ) p ( o = + 1 | \pmb { x } , y = + 1 ) } { p ( o = + 1 | \pmb { x } ) } = 1 } \end{array}$ from (11), this is equivalent to
$$\begin{array} { r } { r ( { \pmb x } ) = C p ( o = + 1 | { \pmb x } ) , } \end{array}$$
where $\begin{array} { r } { C = \frac { 1 } { p ( y = + 1 , o = + 1 ) } } \end{array}$ . Hence, if Assumption 1 holds, for any $\pmb { x } _ { i } , \pmb { x } _ { j } \in \mathcal { X }$
$$p ( y = + 1 | { \boldsymbol { \mathbf { x } } } _ { i } ) \leq p ( y = + 1 | { \boldsymbol { \mathbf { x } } } _ { j } ) \Leftrightarrow r ( { \boldsymbol { \mathbf { x } } } _ { i } ) \leq r ( { \boldsymbol { \mathbf { x } } } _ { j } ) .$$
# B PROOF OF THEOREM 2
Before proving Theorem 2, we consider a threshold defined as follows:
$$\pi = \int \mathbf { 1 } [ p ( y = + 1 | \pmb { x } ) \geq \gamma ] p ( \pmb { x } ) d \pmb { x } .$$
Then, we state the following lemma on the relationship between $\gamma$ and $\theta _ { \pi }$
Lemma 1. The equation $\mathbf { \boldsymbol { x } } \in \mathcal { X }$ $\begin{array} { r } { \ell , ( r ( { \pmb x } ) - \theta _ { \pi } ) ( p ( { \pmb y } = + 1 | { \pmb x } ) - \gamma ) \ge 0 } \end{array}$ holds almost everywhere with respect to $p ( { \pmb x } )$ .
Proof. By (2) and (12), the following equation also hold,
$$\int \mathbf { 1 } [ r ( \pmb { x } ) > \theta _ { \pi } ] p ( \pmb { x } ) d \pmb { x } = \int \mathbf { 1 } [ p ( y = + 1 | \pmb { x } ) > \gamma ] p ( \pmb { x } ) d \pmb { x } .$$
Hence, we can derive
$$\int ( \mathbf { 1 } [ r ( \pmb { x } ) > \theta _ { \pi } ] - \mathbf { 1 } [ p ( y = + 1 | \pmb { x } ) > \gamma ] ) p ( \pmb { x } ) d \pmb { x } = 0 .$$
This is equivalent to
$$\int ( \mathbf { 1 } [ ( r ( x ) - \theta _ { \pi } ) ( p ( y = + 1 | x ) - \gamma ) < 0 ] p ( x ) d x = 0 .$$
From this equation, $( r ( { \pmb x } ) - \theta _ { \pi } ) ( p ( { \pmb y } = + 1 | { \pmb x } ) - \gamma ) \geq 0$ holds almost surely.
Using Lemma 1 we prove Theorem 2.
Proof. $\begin{array} { r } { \pi = \int \mathbf { 1 } [ p ( y = + 1 | \pmb { x } ) \geq \gamma ] p ( \pmb { x } ) d \pmb { x } } \end{array}$ is equivalent to
$$\int p ( y = + 1 | x ) p ( x ) d x = \int \mathbf { 1 } [ p ( y = + 1 | x ) \geq \gamma ] p ( x ) d x ,$$
where the left hand side is equal to
$$\int _ { \{ x | p ( y = + 1 | x ) < \gamma \} } p ( y = + 1 | x ) p ( x ) d x + \int _ { \{ x | p ( y = + 1 | x ) \geq \gamma \} } p ( y = + 1 | x ) p ( x ) d x ,$$
and the right hand side is equal to
$$\int _ { \{ x | p ( y = + 1 | x ) \geq \gamma \} } p ( y = + 1 | x ) p ( x ) d x + \int _ { \{ x | p ( y = + 1 | x ) \geq \gamma \} } p ( y = - 1 | x ) p ( x ) d x .$$
Hence, (12) is equivalent to the following equation,
$$\int _ { \{ x | p ( y = + 1 | x ) < \gamma \} } p ( y = + 1 | x ) p ( x ) d x = \int _ { \{ x | p ( y = + 1 | x ) \geq \gamma \} } p ( y = - 1 | x ) p ( x ) d x .$$
From the definitions of TP, FP, TN, and FN, the left hand side of the above equation is equal to $F P$ and the right hand side of the above equation is equal to $F N$ . Hence, $F P = F N$ . We showed $F P = F N$ for a threshold $\gamma$ , but we can also insist that the same result holds when we use $r ( { \pmb x } )$ as a score function and $\theta _ { \pi }$ as a threshold. According to Lemma 1, the sign of $p ( y = + 1 + x ) - \gamma$ and $r ( { \pmb x } ) - \theta _ { \pi }$ are the same almost everywhere with respect to $p ( { \pmb x } )$ . Therefore,
$$\begin{array} { l } { \displaystyle \int _ { \{ x | p ( y = + 1 | x ) < \gamma \} } p ( y = + 1 | x ) p ( x ) d x = \int _ { \{ x | r ( x ) < \theta _ { \pi } \} } p ( y = + 1 | x ) p ( x ) d x } \\ { \displaystyle \int _ { \{ x | p ( y = + 1 | x ) \geq \gamma \} } p ( y = - 1 | x ) p ( x ) d x = \int _ { \{ x | r ( x ) \geq \theta _ { \pi } \} } p ( y = - 1 | x ) p ( x ) d x . } \end{array}$$
In these equations, the right hand sides mean $F P$ and $F N$ of a score function $r ( { \pmb x } )$ with a threshold $\theta _ { \pi }$ , respectively. Because precision $\begin{array} { r } { \mathbf { \Phi } = \left( \frac { T P } { T P + F P } \right) } \end{array}$ and $\begin{array} { r } { \mathrm { r e c a l l } = \left( \frac { T P } { T P + F N } \right) } \end{array}$ , $F P = F N$ means that precision $=$ recall. □
# C PROOF OF THEOREM 3
Proof. We first consider minimizing $R _ { \mathrm { P U } } ^ { \tt b i a s }$ in the space of all functions from $\mathcal { X }$ to $[ \epsilon , 1 - \epsilon ]$ instead of minimizing it in . Later, we will see that the minimizer matches $f ^ { * }$ as stated in Theorem 3 which belongs to $\mathcal { F }$ . The minimization of
$$R _ { \mathtt { P U } } ^ { \mathtt { b i a s } } ( f ) = \int \big ( - \pi p ( x | y = + 1 , o = + 1 ) ( \log f ( x ) - \log ( 1 - f ( x ) ) ) - \log ( 1 - f ( x ) ) p ( x ) \big ) d x$$
over all functions $f$ taking values in $[ \epsilon , 1 - \epsilon ]$ is reduced to the following point-wise minimization problem
$$\operatorname * { a r g m i n } _ { z \in [ \epsilon , 1 - \epsilon ] } C ( z , x ) : = - \pi p ( x | y = + 1 , o = + 1 ) ( \log z - \log ( 1 - z ) ) - \log ( 1 - z ) p ( x ) .$$
Denoting the solution by $z ^ { * }$ , the Karush-Kuhn-Tucker (KKT) condition of this minimization problem is
$$\begin{array} { l l } & { \pi p ( \pmb { x } | y = + 1 , o = + 1 ) \left( \cfrac { 1 } { z ^ { * } } + \cfrac { 1 } { 1 - z ^ { * } } \right) - \cfrac { p ( \pmb { x } ) } { 1 - z ^ { * } } - \lambda + \mu = 0 , } \\ & { \lambda ( z ^ { * } - 1 - \epsilon ) = 0 , \mu z ^ { * } = 0 , } \\ & { \lambda , \mu \geq 0 , } \\ & { z ^ { * } \in [ \epsilon , 1 - \epsilon ] , } \end{array}$$
where $\lambda$ and $\mu$ are the Lagrange multipliers. The first equation is equivalent to
$$( \mu - \lambda ) ( z ^ { * } ) ^ { 2 } + ( p ( { \pmb x } ) + \lambda - \mu ) z ^ { * } - \pi p ( { \pmb x } | y = + 1 , o = + 1 ) = 0 .$$
We investigate the solution by dividing the KKT condition into the following four cases.
1. If we assume $\lambda = \mu = 0$ , then the KKT condition is reduced to
$$\begin{array} { l } { { z ^ { * } } = \frac { \pi p ( \pmb { x } | y = + 1 , o = + 1 ) } { p ( \pmb { x } ) } , } \\ { { z ^ { * } } \in [ \epsilon , 1 - \epsilon ] . } \end{array}$$
In this case, $z ^ { * } \in [ \epsilon , 1 - \epsilon ]$ is equivalent to $\pmb { x } \in D _ { 1 } \cap D _ { 2 }$ .
2. If we assume $\lambda > 0$ and $\mu = 0$ , the KKT condition is reduced to
$$\begin{array} { l } { z ^ { \ast } = 1 - \epsilon , } \\ { \lambda = \frac { ( 1 - \epsilon ) p ( { \pmb x } ) - \pi p ( { \pmb x } | y = + 1 , o = + 1 ) } { ( 1 - \epsilon ) ^ { 2 } + ( 1 - \epsilon ) } . } \end{array}$$
In this case, $\lambda > 0$ is equivalent to $\pmb { x } \notin D _ { 2 }$ .
3. If we assume $\lambda = 0$ and $\mu > 0$ , the KKT condition is reduced to
$$\begin{array} { l } { { z ^ { * } = \epsilon , } } \\ { { \mu = \frac { p ( { \pmb x } ) \epsilon - \pi p ( { \pmb x } | y = + 1 , o = + 1 ) } { \epsilon ^ { 2 } - \epsilon } . } } \end{array}$$
In this case, $\lambda > 0$ is equivalent to $\pmb { x } \notin D _ { 1 }$
4. If $\lambda , \mu > 0$ , there is no feasible solution.
In summary, the solution for the optimization problem arg $\begin{array} { r } { \operatorname* { m i n } _ { z \in [ \epsilon , 1 - \epsilon ] } C ( z , \pmb { x } ) } \end{array}$ is
$$z ^ { * } = \left\{ \begin{array} { l l } { \epsilon } & { ( x \notin D _ { 1 } ) , } \\ { \frac { \pi p ( x \mid y = + 1 , o = + 1 ) } { p ( x ) } } & { ( x \in D _ { 1 } \cap D _ { 2 } ) , } \\ { 1 - \epsilon } & { ( x \notin D _ { 2 } ) . } \end{array} \right.$$
Finally, we define $f ^ { * } ( x ) : = \arg \operatorname* { m i n } _ { z \in [ \epsilon , 1 - \epsilon ] } C ( z , x )$ . It can be confirmed that $f ^ { * } \in { \mathcal { F } }$ because $p ( { \pmb x } | y = 1 , o = + 1 )$ and $p ( { \pmb x } )$ are measurable and $f ^ { * }$ takes values in $[ \epsilon , 1 - \epsilon ]$ . Therefore, the solution of the original optimization problem
$$\arg \operatorname* { m i n } _ { f \in \mathcal { F } } R _ { \mathtt { P U } } ^ { \mathtt { b i a s } } ( f )$$
is equal to $f ^ { * }$ almost everywhere.
# D NETWORK STRUCTURE USED IN SECTIONS 5.2 AND SECTIONS 5.3
In Section 5.2, we used the MNIST and CIFAR-10 datasets. The model for the MNIST dataset was a 3-layer multilayer perceptron (MLP) with ReLU (Nair & Hinton, 2010) (more specifically, 784-100-1). The model for the CIFAR-10 dataset was an all convolutional net (Springenberg et al., 2015): $( 3 2 \times 3 2 \times 3 )$ $| - [ C ( 3 \times 3 , 9 6 ) ] \times 2 - C ( 3 \times 3 , 9 6 , 2 ) - [ C ( 3 \times 3 , 1 9 2 ) ] \times 2 - C ( 3 \times 3 , 1 9 2 , 2 ) - C ( 3 \times 3 , 1 9 2 , 2 ) + \ldots$ 3, 192) $\begin{array} { r } { - C ( 1 \times 1 , 1 9 2 ) - C ( 1 \times 1 , 1 0 ) - 1 0 0 0 - 1 0 0 0 - 1 , } \end{array}$ where the input is a $3 2 \times 3 2$ RGB image, $C ( 3 \times$ 3, 96) means 96 channels of $3 \times 3$ convolutions followed by ReLU, $[ \cdot ] \times 2$ means there are two such layers, $C ( 3 \times 3 , 9 6 , 2 )$ means a similar layer but with stride 2, etc.; it is one of the best architectures for CIFAR-10. Batch normalization (Ioffe & Szegedy, 2015) was applied before hidden layers.
In Section 5.3, the model for this dataset was a 5-layer multilayer perceptron (MLP) with ReLU (more specifically, 78894-300-300-300-300-1).
# E EXPERIMENTAL RESULTS OF THE FIRST EXPERIMENT OF SECTION 5.4
In the first experiment, we trained a classifier under misspecified class priors, $0 . 0 2 0 9 ( = 0 . 0 7 0 9 -$ 0.0500), $0 . 1 \hat { 2 0 } 9 ( = 0 . 0 7 0 9 + 0 . 0 5 0 0 )$ , $0 . 1 7 0 9 ( = 0 . 0 7 0 9 + 0 . 1 0 0 0 )$ , and $0 . 2 7 0 9 ( = 0 . 0 7 0 9 + 0 . 2 0 0 0 )$ . The results are shown in Figures 4–6. In Figure 4, the test error in each misspecified class priors are shown. In Figure 5, the precision and recall in each misspecified class prior is shown. In both the existing method and our method, misspecified class priors had a bad influence. However, our method was less influenced by the misspecification and showed better performance than the existing method. Besides, the difference between the precision and recall of our algorithm is narrower than that of the existing method as expected. In order to discuss how misspecified class prior affects the precision and recall, we show the difference the recall from the precision and show the values in Figure 6. This result shows how the difference broadens as the class prior is misspecified worse.
 Figure 4: Experimental results of training deep neural networks using the RealData dataset with misspecified class priors (the true class prior is 0.0709). Upper Left: $\pi = 0 . 0 2 0 9$ ; Upper Right: $\pi = 0 . 1 2 0 9$ ; Lower Left: $\pi = 0 . 1 7 0 9$ ; Lower Right: $\pi = 0 . 2 7 0 9$ : All measures are calculated for test data sampled from the marginal distribution $p ( { \pmb x } )$ . The horizontal line is epoch of training the network, the vertical line of the upper is error rate.
 Figure 5: Experimental results of training deep neural networks using the RealData dataset with misspecified class priors (the true class prior is 0.0709). Upper Left: $\pi = 0 . 0 2 0 9$ ; Upper Right: $\pi = 0 . 1 2 0 9$ ; Lower Left: $\pi = 0 . 1 7 0 9$ ; Lower Right: $\pi = 0 . 2 7 0 9$ : All measures are calculated for test data sampled from the marginal distribution $p ( { \pmb x } )$ . The horizontal line is epoch of training the network, the vertical line of the upper is value of the precision and the recall.
 Figure 6: Experimental results of training deep neural networks using the RealData dataset, whose true class prior is 0.0709, with misspecified class priors, 0.0209, 0.1209, 0.1709, and 0.2709.: All measures are calculated for test data sampled from the marginal distribution $p ( { \pmb x } )$ . The horizontal line is epoch of training the network, the vertical line of the right graph is value of the precision − recall.123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223# Intriguing Properties of Contrastive Losses
Ting Chen Google Research iamtingchen@google.com
Calvin Luo Google Research calvinluo@google.com
Lala Li Google Research lala@google.com
# Abstract
We study three intriguing properties of contrastive learning. First, we generalize the standard contrastive loss to a broader family of losses, and we find that various instantiations of the generalized loss perform similarly under the presence of a multi-layer non-linear projection head. Second, we study if instance-based contrastive learning (with a global image representation) can learn well on images with multiple objects present. We find that meaningful hierarchical local features can be learned despite the fact that these objectives operate on global instancelevel features. Finally, we study the phenomenon of feature suppression among competing features shared across augmented views, such as “color distribution” vs “object class”. We construct datasets with explicit and controllable competing features and show that, for contrastive learning, a few bits of easy-to-learn shared features can suppress, and even fully prevent, the learning of other sets of competing features. In scenarios where there are multiple objects in an image, the dominant object would suppress the learning of smaller objects. Existing contrastive learning methods critically rely on data augmentation to favor certain sets of features over others, and could suffer from learning saturation for scenarios where existing augmentations cannot fully address the feature suppression. This poses open challenges to existing contrastive learning techniques 1.
# 1 Introduction
Contrastive learning [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14] has recently achieved great successes in learning visual representations without supervision. As shown in [13, 14], contrastive learning can learn representations that rival supervised learning, and significantly improve the state-of-the-art in semi-supervised learning on ImageNet. One successful use case of contrastive loss for self-supervised learning is to make augmented views of the same example agree [1, 2, 13]. A widely used contrastive loss to encourage agreement is based on cross entropy [15, 3, 4, 13]. Given an augmented view of an example, the contrastive prediction task aims to classify a set of candidates into the positive example (i.e. the other augmented view of the same example) and negative ones via the cross entropy loss.
In this work, to understand the effectiveness and limitation of existing contrastive learning methods, we study three intriguing aspects. First, we propose a generalization of the standard contrastive loss, and systematically study their performance differences. Second, we study if the instance-based contrastive learning, for which the contrastive loss operates on global representation of an input image, can learn well on images with multiple objects present, and whether or not it leads to meaningful local features. Finally, we systematically study the feature suppression phenomenon in contrastive learning. The suppression effect occurs among competing features shared across augmented views. For example, with random cropping as the augmentation, “color distribution” and “object class” are often competing features as they are likely shared between two augmented views. The suppression effect among competing features can significantly degenerate the representation quality, or even completely disable the learning of certain features, as shown in our experiments. Existing methods critically rely on hand-crafted data augmentation to favor certain sets of competing features than others.
Our main findings and contributions are summarized below.
• We propose a generalized contrastive loss, and show that differences between contrastive losses are small with a deep projection head. • We show that the instance-based objective widely used in existing contrastive learning methods can learn on images with multiple objects, and also learn meaningful local features despite operating on global image representation. • We construct three datasets with explicit and controllable competing features to systematically study the feature suppression effect in contrastive learning. • We show that a few bits of easy-to-learn shared features can suppress, and even fully prevent, the learning of other sets of competing features. In scenarios where there are multiple objects in an image, the dominant object would suppress the learning of smaller objects. This poses open challenges to existing contrastive learning.
# 2 Generalized contrastive loss and differences among its instantiations
The common contrastive loss used in most recent work is based on cross entropy [15, 3, 4]. Following the notation in [13], the contrastive loss can be defined between two augmented views $( i , j )$ of the same example for a mini-batch of size of $n$ , and can be written as the following.
$$\mathcal { L } ^ { \mathrm { N T - X e n t } } = - \frac { 1 } { n } \sum _ { i , j \in \mathcal { M B } } \log \frac { \exp ( \sin ( z _ { i } , z _ { j } ) / \tau ) } { \sum _ { k = 1 } ^ { 2 n } \mathbb { 1 } _ { [ k \neq i ] } \exp ( \sin ( z _ { i } , z _ { k } ) / \tau ) }$$
where $z _ { i } , z _ { j }$ are hidden representations of two augmented views of the same example; $\sin ( { \boldsymbol { \mathbf { u } } } , { \boldsymbol { \mathbf { v } } } ) =$ $\pmb { u } ^ { T } \pmb { v } / ( \lVert \pmb { u } \rVert \lVert \pmb { v } \rVert )$ is the cosine similarity between two vectors; $\tau$ is a temperature scalar and $\mathcal { M } \mathcal { B }$ is a randomly sampled mini-batch consisting of augmented pairs of images. In [13], a MLP projection head is introduced between intermediate layer $^ { h }$ (e.g. output of ResNet encoder) and final output $_ { z }$ . It is shown that the projection head is very beneficial and $^ { h }$ is a much better feature representation than $_ { z }$ .
In this work, we generalize the standard contrastive loss to the following form.
$$\boxed { \mathcal { L } _ { \mathrm { g e n e r a l i z e d c o n t r a s t i v e } } = \mathcal { L } _ { \mathrm { a l i g n m e n t } } + \lambda \mathcal { L } _ { \mathrm { d i s t r i b u t i o n } } }$$
Both terms are defined on hidden representations. $\mathcal { L } _ { \mathrm { a l i g n m e n t } }$ encourages representations of augmented views to be consistent, while ${ \mathcal { L } } _ { \mathrm { d i s t r i b u t i o n } }$ encourages representations (or a random subset of them) to match a prior distribution (of high entropy). It is not difficult to see that the standard contrastive loss in Eq. 1 is a special case as it can be re-written as follows (scaled by a constant $\tau$ ).
$$\tau \mathcal { L } ^ { \mathrm { N T - X e n t } } = \underbrace { - \frac { 1 } { n } \sum _ { i , j } \sin ( z _ { i } , z _ { j } ) } _ { \mathcal { L } _ { \mathrm { a l i g n m e n t } } } + \underbrace { \frac { \tau } { n } \sum _ { i } \log \sum _ { k = 1 } ^ { 2 n } \mathbb { 1 } _ { [ k \neq i ] } \exp ( \sin ( z _ { i } , z _ { k } ) / \tau ) } _ { \mathcal { L } _ { \mathrm { d i s t r i b u t i o n } } }$$
This form of factorization in Eq. 3 has been proposed in [16], where the second LogSumExp term is referred to as uniformity since it encourages representation to uniformly distributed in the hypersphere. Different from [16], here we generalize the hypersphere uniform distribution and study a wider set of prior distributions for their effectiveness in learning representations.
SWD for supporting diverse prior distributions. One issue of using more diverse set of priors is we cannot rely on LogSumExp for matching the distribution. To this end, we resort to the theory of optimal transport, via Sliced Wasserstein Distance (SWD) [17, 18, 19]. For two sets of equalsized samples from two 1-D distributions, the optimal transport can be obtained by computing two permutations that order the values of both sets of samples respectively. The 1-D Wasserstein distance can then be computed with $\ell _ { 2 }$ distance between the ordered values. For n-D distributions, we first project the samples to $n$ randomly-generated orthogonal 1-D subspaces, and then compute the sum of 1-D Wasserstein distance across all 1-D subspaces. By adjusting the network weights to minimize the SWD, we are able to reduce the mismatch between the distribution of hidden vectors and a known prior distribution. The detailed algorithm can be found in Algorithm 1. With SWD loss, we are able to use a wider set of priors, and Table 1 summarizes instantiations of the generalized contrastive loss with different prior distributions and distribution matching loss.
Algorithm 1 Sliced Wasserstein Distance (SWD) loss.
<table><tr><td>input: activation vectors H ∈ Rb×d, ,a prior distribution (e.g. Gaussian) sampler S draw prior vectors P ∈ Rb×d using S</td></tr><tr><td></td></tr><tr><td>generate random orthogonal matrix W ∈ Rd×d'</td></tr><tr><td>make projections: H-= HW; P⊥ = PW</td></tr><tr><td>initializeSWDlossl=0</td></tr><tr><td>forj∈{1,2,.,d'} do l =l+ |lsort(H:j)-sort(P:j)|l²</td></tr><tr><td></td></tr><tr><td>end for return l/(dd')</td></tr></table>
Table 1: Instantiations of the generalized contrastive loss, i.e. $\mathcal { L } _ { \mathrm { a l i g n m e n t } } + \lambda \mathcal { L } _ { \mathrm { d i s t r i b u t i o n } }$ , that we use in this work. $\tilde { z }$ denotes $\ell _ { 2 }$ -normalized $z \in \mathbb { R } ^ { d }$ , and is only used for uniform hypersphere prior.
<table><tr><td>Laign</td><td>Prior distribution</td><td>Ldistribution</td></tr><tr><td>nd∑i, |lzi - zj|l²Uniform hypersphere</td><td></td><td>e∑log∑exp(Tzj/T)</td></tr><tr><td>nd∑ij |lz- zjll2Uniform hypersphere</td><td></td><td>SWD(Z, zprior)</td></tr><tr><td>d∑ij|lz-zjll²Uniform hypercube</td><td></td><td>SWD(Z, Zprior)</td></tr><tr><td>nd∑i,j |lzi - zjll2Normal distribution</td><td></td><td>SWD(Z, Zprior)</td></tr></table>
Connection with mutual information. The connection between the standard contrastive loss and mutual information has been shown before [3, 20], where the contrastive loss (a.k.a. InfoNCE loss [3]) is shown to be a lower bound of the mutual information. To connect the generalized contrastive loss to mutual information, we start by the definition of mutual information between two latent variables $U , V$ , which is $I ( U ; V ) = H ( U ) - H ( U | V )$ . Comparing this factorization of mutual information with generalized contrastive loss, it is not difficult to see that: 1) the alignment term $\mathcal { L } _ { \mathrm { a l i g n m e n t } }$ is directly related to $H ( U | V )$ which aims to reduce uncertainty of the other views given one view of the example; and 2) the distribution matching term ${ \mathcal { L } } _ { \mathrm { d i s t r i b u t i o n } }$ can be considered as a proxy to $H ( u )$ for maximizing the entropy in the representation. It is perhaps worth noting that different from mutual information, the generalized contrastive loss (Eq. 2) allows a tunable weight $( \lambda )$ between the alignment and distribution matching term. The weighting scalar $\lambda$ is (inversely) related to the temperature $\tau$ (details in Appendix A.2).
Comparing different instantiations of generalized contrastive loss. Here we ask: Is it essential to use a uniform hypersphere prior for the effectiveness of contrastive loss? How much difference does it make when distinct generalized contrastive losses are used? To answer this question, we conduct experiments following SimCLR settings [13, 14], and use the linear evaluation protocol. Detailed experimental setup can be found in Appendix A.1.
Figure 1 shows linear evaluation results of models trained with different losses under different training epochs. On CIFAR-10, we see little difference in terms of linear evaluation for variants of the generalized contrastive losses, especially when trained longer than 200 epochs. As for ImageNet, there are some discrepancies between different losses, but they disappear when a deeper 3-layer non-linear projection head is used.
 Figure 1: Linear evaluation accuracy of ResNet-50 trained with different losses on CIFAR-10 and ImageNet datasets. Numbers of projection head layers are in parentheses. Differences between variants of generalized contrastive loss are small with a deep projection head. Decoupled NT-Xent loss is introduced in A.2. Numerical results can be found in Appendix A.3.
Furthermore, we find that deep projection head not only reduces the differences among different generalized contrastive losses, but has a similar effect for batch size. With proper learning rate scaling across batch sizes (e.g. square root scaling with LARS optimizer [21]), the impact of batch size on representation quality is small. Table 2 demonstrate this phenomenon for the standard contrastive loss, and more results on other losses can be found in Appendix A.3.
Table 2: Linear eval accuracy of ResNet-50 on ImageNet.
<table><tr><td rowspan="2">Projection head</td><td rowspan="2">Batch size</td><td colspan="4">Epoch</td></tr><tr><td>100</td><td>200</td><td>400</td><td>800</td></tr><tr><td rowspan="3">2 layers</td><td>512</td><td>65.4</td><td>67.3</td><td>68.7</td><td>69.3</td></tr><tr><td>1024</td><td>65.6</td><td>67.6</td><td>68.8</td><td>69.8</td></tr><tr><td>2048</td><td>65.3</td><td>67.6</td><td>69.0</td><td>70.1</td></tr><tr><td rowspan="3">3 layers</td><td>512</td><td>66.6</td><td>68.4</td><td>70.0</td><td>71.0</td></tr><tr><td>1024</td><td>66.8</td><td>68.9</td><td>70.1</td><td>70.9</td></tr><tr><td>2048</td><td>66.8</td><td>69.1</td><td>70.4</td><td>71.3</td></tr><tr><td rowspan="3">4 layers</td><td>512</td><td>66.8</td><td>68.8</td><td>70.0</td><td>70.7</td></tr><tr><td>1024</td><td>67.0</td><td>69.0</td><td>70.4</td><td>70.9</td></tr><tr><td>2048</td><td>67.0</td><td>69.3</td><td>70.4</td><td>71.3</td></tr></table>
# 3 Instance-based objective can learn on images with multiple objects and learn good local features
Most existing contrastive learning methods [13, 10, 22, 4] define their objectives at the instance level where each image is encoded into a single vector representation (e.g. representations of two random crops of the same image instance are treated as a positive pair). In other words, the objective operates on a global representation of its input rather than on some local regions (of its input). We pose two questions regarding instance-based global objective: 1) when there is only a single (dominant) object in the image, the objective seems reasonable as it encourages the model to learn features relevant to object class, but when there are multiple objects present in the image, can instance-based objective still learn well? 2) Since the instance-based objective uses a global summary of its input, can it still learn good local features (e.g. parts of an object, or multiple objects in the same scheme)? To answer these questions, we use SimCLR as representative for the instance-based objective.
# 3.1 SimCLR can learn on images with multiple objects
Commonly used self-supervised learning datasets, such as MNIST, CIFAR-10, ImageNet, are object centered, i.e. the image is mainly occupied by a single (dominant) object. To experiment with multiple objects in a controllable setting, we propose a new dataset setting by composing multiple digits as follows.
MultiDigits dataset. We place MNIST digits ( $2 8 \times 2 8$ size) on a shared canvas $1 1 2 \times 1 1 2$ size). We vary the number of digits placed on the canvas. One factor that could interfere with learning of multiple digits is overlapping digits, therefore we use two placement strategies: random vs in-grid (Figure 2). Random placement of digits incurs no constraint on where digits can be placed on the canvas, whereas in-grid placement puts each digit in one of the $4 \times 4$ grid cells the canvas is divided into, and no two digits can fall in the same cell. In-grid placement ensures no overlapping of digits.
 Figure 2: MultiDigit dataset. More digits lead to more overlapping in random placement.
We first pretrain a ResNet-18 with SimCLR or supervised learning with the same augmentation policy (random cropping and resize) on MultiDigits dataset. To access the representation quality, we then train linear classifiers for images with a single digit of size $2 8 \times 2 8$ on the canvas. Similarly during evaluation, we place only one digit of size $2 8 \times 2 8$ on the canvas.
As shown in Table 3, representations learned using supervised loss maintains its quality when up to 8 digits are placed in the image. After that the representation becomes worse as the canvas gets more crowded. Notably, representations learned using SimCLR display a similar phenomenon. Regardless of placement strategy, top-1 accuracy stays at the same level up to 8 digits, demonstrating that SimCLR can learn from images with multiple objects. In addition, the increased performance gap between the two placement strategies with increased number of digits shows that object overlapping makes it harder for contrastive losses to learn from multiple objects.
Table 3: Top-1 linear evaluation accuracy $( \% )$ for pretrained ResNet-18 on the MultiDigits dataset. We vary the number of digits placed on the canvas during training from 1 to 16. During evaluation only 1 digit is present. As a baseline, a network with random weights gives $18 \%$ top-1 accuracy.
<table><tr><td rowspan="2"></td><td rowspan="2">Placing of digits</td><td colspan="6">Number of digits (size 28 × 28)</td></tr><tr><td>1</td><td>2</td><td>4</td><td>8</td><td>12</td><td>16</td></tr><tr><td rowspan="2">Supervised</td><td>Random</td><td>99.5</td><td>99.5</td><td>99.3</td><td>99.4</td><td>98.9</td><td>98.3</td></tr><tr><td>In-grid</td><td>99.5</td><td>99.6</td><td>99.5</td><td>99.3</td><td>98.6</td><td>92.4</td></tr><tr><td rowspan="2">SimCLR</td><td>Random</td><td>98.9</td><td>98.9</td><td>99.0</td><td>98.9</td><td>98.2</td><td>96.4</td></tr><tr><td>In-grid</td><td>98.3</td><td>98.6</td><td>99.1</td><td>99.2</td><td>99.1</td><td>98.3</td></tr></table>
# 3.2 SimCLR learns local features that exhibit hierarchical properties
To understand the local features learned by SimCLR, we apply K-means on intermediate features of the pretrained ResNet with SimCLR, and see how local regions of an image are grouped together. For good representations, we expect that regions of similar objects or object parts should be grouped together.
Specifically, we take a pretrained Resnet- $5 0 2 \times$ on ImageNet, and run inference on images (from ImageNet validation set and COCO [23]) of size $4 4 8 \times 4 4 8$ . We run K-means with various numbers of clusters on the l2-normalized hidden features from middle layers of the network (e.g. block group 2,3,4 of the ResNet). We also compare SimCLR learned features with supervised learned features, as well as the raw pixel (RGB) features extracted from each $1 4 \times 1 4$ patch.
Figure 3a shows that as the number of clusters increases, the learned representations tend to group image regions based on parts of the object (i.e. facial components of the dog). This phenomenon appears in both SimCLR and supervised learned features, but not with raw pixel features, indicating meaningful local features learned by SimCLR and supervised learning. In Figure 3b, we compare ResNet intermediate features at different layers, and it suggests that earlier layers contain more edge-related features, while later layers contain more object/part features.
 Figure 3: Visualizing features on a ImageNet validation image with K-means clustering. Each row denotes a type of local features used, and each column denotes the number of K-means clusters. Later layers of SimCLR/supervised ResNet tend to group by object parts. More visualization examples can be found in https://contrastive-learning.github.io/intriguing.
 Figure 4: Visualizing features on two images from COCO. Each row denotes a type of local features (SimCLR, Supervised, and raw pixels; both SimCLR and Supervised are trained on ImageNet), and each column denotes the number of K-means clusters. Region grouping by SimCLR/supervised features tend to overlap with object class.
Region grouping results on two COCO images for SimCLR and supervised learning (trained on ImageNet) are shown in Figure 4. Again, region grouping by local features tend to overlap with object class, indicating good local features learned.
# 4 Feature suppression limits the potential of contrastive learning
Contrastive learning requires good design of data augmentation to work well. As shown in [13], without color augmentations that randomly shift color distribution (while maintaining information regarding object class), the quality of learned representations are significantly worse. In other words, the presence of “color distribution” features suppresses their competing feature of “object class”, and is addressed by color augmentation. However, there may be scenarios where the known augmentations cannot fully address this feature suppression effect, and it can thus limit the potential of contrastive learning. Here we quantitatively study the feature suppression phenomenon by constructing datasets with explicit and controllable competing features, and see how well contrastive learning method could learn.

(a) ImageNet images overlaid with MNIST digits. The left most column is original image, and others are augmented views via random crop and color distortion. MNIST digits and ImageNet classes are competing features. We vary the number of unique MNIST digits to control the competing features.

(b) Two MNIST digits randomly placed on a shared canvas (of size $1 1 2 \times 1 1 2 )$ . The two digits can have the same size (upper row) or different sizes (lower row), and digits of different sizes can be considered as competing features. We fix the size of one digit and vary the other.
 Figure 5: Probing datasets with explicit and controllable competing features.
(c) Images (of RGB channels) are concatenated with additional channels of random integer sampled from range of $[ 1 , \log _ { 2 } ( n ) ]$ . The integer, shared between two views, is replicated for spatial dimension and represented as $n$ binary channels. RGB channels and random bits are competing features.
# 4.1 Datasets with explicit and controllable competing features
To construct datasets with controllable competing features, we leverage two strategies: channel addition that adds different feature information in a shared canvas, and channel concatenation that expand the RGB channels to include additional features. With these strategies, we construct three datasets below.
DigitOnImageNet dataset. We overlay MNIST digits on ImageNet images via channel addition/summation (Figure 5a). For each ImageNet image, we assign a unique MNIST digit and replicate it in nine fixed locations before the standard SimCLR augmentations [13] are applied to create augmented views. Therefore the original ImageNet images and added MNIST digits are competing features. Although it is difficult to quantify information in MNIST digits, we can manually control the number of unique MNIST digits used. Ideally, we want the model to learn both set of features so that it could perform well for both MNIST digit and ImageNet object recognition.
MultiDigits dataset (varying the size of one digit). This dataset is modified from MultiDigits introduced above. Here we only consider two digits, and vary the size of one of them (Figure 5b). In this work, we place two digits on a canvas of size $1 1 2 \times 1 1 2$ . We fix the size of one of the digits to be $2 0 \times 2 0$ while varying the other from $2 0 \times 2 0$ to $8 0 \times 8 0$ . Digits of different sizes can be considered as competing features. Ideally, we want the model to learn features for digits of all sizes appeared during training.
RandBit dataset. We concatenate a real image with an image of a random integer in the channel dimension (Figure 5c). The random integer is randomly sampled from range of $[ 1 , \log _ { 2 } ( n ) ]$ where $n$ is a parameter to control. It is replicated across spatial dimension (i.e. all pixel location shares the same value), and it is also represented as $n$ binary bits/channels instead of an integer or floating number to make it easily learnable. Furthermore, unlike RGB channels, these additional channels of random bits will not be altered by augmentation, so they are identical for both augmented views of the same image. The RGB channels and the added channels of random bits are competing features, and this construction allows us to control the amount of information in the added competing feature, which is $n$ bits. Also, we know that the mutual information between two views given this construction is at least $\log _ { 2 } ( n )$ .
 4.2 Easy-to-learn features (MNIST digit) suppress the learning of other features (ImageNet object class) Figure 6: (a) Supervised learning accuracy on ImageNet classification. (b) Linear evaluation of learned features for both MNIST classification and ImageNet classification on the DigitOnImageNet dataset. Batch size of 1024 and 2-layer projection head is used. Different batch sizes and projection head layers have negligible influence on the trade-off between ImageNet vs MNIST accuracy.
On DigitOnImageNet datasets, we vary the number of unique MNIST digits used in the training set, and all MNIST digits are used in the validation/test set. As a baseline, we train supervised ResNet-50 on the created datasets with ImageNet labels, and the number of unique MNIST digits has little impact on the top-1 ImageNet classification accuracy (Figure 6a).
We then train SimCLR on the datasets with different temperatures. As shown in Figure 6b, when we increase the number of unique MNIST digits, the linear evaluation performance of the learned features for MNIST classes increases accordingly, while the accuracy for ImageNet classes decreases dramatically. The trade-off between digit recognition ability and object recognition ability shows that simple features suppress the learning of difficult features, when both are shared between two augmented views. Different batch sizes and projection head depths have negligible influence to the outcome we observe here. Therefore, it is difficult to learn both of the competing features using existing contrastive losses (e.g. SimCLR).
# 4.3 The presence of dominant object suppresses the learning of features of smaller objects
On the MultiDigits dataset, as mentioned, we fix one digit to be size of $2 0 \times 2 0$ while varying the other from $2 0 \times 2 0$ to $8 0 \times 8 0$ , on a canvas of $1 1 2 \times 1 1 2$ . We first pretrain a ResNet-18 with SimCLR or supervised learning with the same augmentation policy (random cropping and resize) and batch size of 1024. To access the representation quality, we then train linear classifiers for each of the digit sizes that appeared during pretraining. For training of the linear classifier, we only place a single digit at a time on the canvas of the same size as during pretraining.
The results are summarized in Table 4. For supervised learning, the learned representations for the smaller digit do not change much as the other digit increases its size, and the model perform well for both small and large digits (accuracy $> 9 9 \%$ ). However, for SimCLR, the learned representations of the smaller digit degenerate significantly when the size of the other digit increases, almost to the level of a random untrained network. The dominant object can be learned very well (accuracy $> 9 9 \%$ ) while suppressing the learning of the smaller object. Although tuning temperature has some effects on reducing the feature suppression, the trend stays unchanged.
Table 4: Top-1 linear evaluation accuracy $( \% )$ for pretrained ResNet-18 on the MultiDigits dataset. We fix the size of 1st digit while increasing the size of the 2nd digit. For SimCLR, results are presented for two temperatures. Accuracies suffered from a significant drop when increasing 2nd digit size are red colored.
<table><tr><td></td><td></td><td colspan="7">2nd digit size (1st digit is kept the same size of 20 × 20)</td></tr><tr><td></td><td></td><td>20×20</td><td>30×30</td><td>40×40</td><td>50×50</td><td>60×60</td><td>70×70</td><td>80×80</td></tr><tr><td rowspan="2">Supervised</td><td>1st digit</td><td>99.1</td><td>99.2</td><td>99.2</td><td>99.2</td><td>99.1</td><td>99.1</td><td>99.0</td></tr><tr><td>2nd digit</td><td>99.1</td><td>99.5</td><td>99.5</td><td>99.6</td><td>99.5</td><td>99.5</td><td>99.6</td></tr><tr><td rowspan="2">SimCLR (t = 0.05)</td><td>1st digit</td><td>97.8</td><td>97.6</td><td>96.2</td><td>96.5</td><td>88.5</td><td>74.5</td><td>39.9</td></tr><tr><td>2nd digit</td><td>97.8</td><td>97.9</td><td>97.8</td><td>98.3</td><td>98.2</td><td>97.7</td><td>98.2</td></tr><tr><td rowspan="2">SimCLR (T = 0.2)</td><td>1st digit</td><td>98.7</td><td>98.8</td><td>98.3</td><td>87.5</td><td>24.9</td><td>19.8</td><td>20.3</td></tr><tr><td>2nd digit</td><td>98.7</td><td>99.2</td><td>99.2</td><td>99.0</td><td>99.1</td><td>98.9</td><td>99.4</td></tr><tr><td rowspan="2">Random net (untrained)</td><td>1st digit</td><td>16.5</td><td>16.7</td><td>16.6</td><td>16.6</td><td>16.6</td><td>16.9</td><td>16.5</td></tr><tr><td>2nd digit</td><td>16.5</td><td>19.1</td><td>21.9</td><td>24.1</td><td>26.5</td><td>28.1</td><td>29.0</td></tr></table>
# 4.4 Extra channels with a few bits of easy-to-learn mutual information suppress the learning of all features in RGB channels
In the RandBit datasets, we add additional channels (identical across pixels) of random bits to MNIST and ImageNet. As mentioned above, SimCLR augmentation is only applied to RGB channels so extra added channels will be shared among two view.
 Figure 7: Linear evaluation of learned features when a few bits of competing features added (on MNIST). Adding a few bits completely disables contrastive learning (across various batch size or losses). Interestingly, it has little effects on a generative model (VAE). The detrimental effects are just as strong for larger datasets such as CIFAR-10 and ImageNet (Appendix B.1).
Figure 7 shows the linear evaluation accuracy of models trained on MNIST (with additional random bits added). We observe that the linear evaluation accuracy quickly drops with a few bits of competing feature added. This detrimental effect on the representation quality persists on bigger datasets like CIFAR-10 and ImageNet as well, and cannot be avoided by using different contrastive losses, batch sizes, or memory mechanism based on momentum contrast (details in Appendix B.1). We believe the fact that just a few bits of easy-to-learn features can completely disable the good representation learning is related to the saturation of the distribution matching loss. As shown in Appendix B.2, the linear increase in bits requires an exponential increase in batch size, which is not sustainable as the required batch size can quickly go beyond the size of the dataset size. In practice, we rely on using data augmentation to remove those uninformative easy-to-learn features so that contrastive learning can learn useful representations. Interestingly, the extra bits do not affect a generative model, variational autoencoder [24, 25], nearly as much, despite other settings such as model size are held the same, prompting a potential direction of addressing the issue.
# 5 Related Work
Our work studies the contrastive loss based on cross entropy loss [15, 3, 4, 13]. This loss is widely used in recent successful contrastive learning methods [3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]. In terms of the contrastive loss, our work is perhaps most related to [16], which shows that formulating contrastive loss as alignment and uniformity in the hypersphere gives similar performance as the standard contrastive loss. We further generalize this factorization, and show other distribution matching losses can be used, and they could achieve similar results. Other than standard contrastive loss that directly utilize negative examples, BYOL [22] demonstrates another way to maintain representation distribution/entropy without directly relying on distribution matching, and SWAV [26] shows clustering-based method equipped with proper data augmentations could also achieve similar performance. We conduct preliminary experiments of BYOL on RandBit and found that it also suffers from feature suppression as generalized contrastive loss. It is expected that SWAV would exhibit similar behaviors on RandBit as those random bits could fuel representations for perfect clustering.
The connection between contrastive loss and mutual information has been studied before [3, 20]. We show that for the generalized contrastive loss, it can also be related to mutual information. Despite the connection between contrastive loss and mutual information, it has been pointed out that mutual information estimation may suffer from certain limitations [27, 28]. Moreover, [29, 12] show that higher mutual information learned by the network does not warrant better representation quality. In our work, we find adding mutual information bits between two views which are irrelevant to downstream tasks can be harmful for the quality of learned representations. Data augmentation plays an important role at favoring certain bits of mutual information than others.
There is a growing number of recent work on the topic of understanding contrastive learning, both theoretically [30, 31, 32, 33, 34] and empirically [16, 12, 35, 36]. However, little work has been done to study the phenomenon of feature suppression. To our knowledge, we are the first one to quantitatively and systematically study this problem. We believe this is still a very open question and could benefit from more future investigation. Finally, the feature suppression effect in unsupervised contrastive learning that we study in this work may also exist in standard supervised learning (“contrastive loss” between examples and class labels), as suggested by [37, 38], though the specific form would be different.
# 6 Conclusion
In this work, we study three intriguing properties of contrastive losses. In particular, our results highlight that feature suppression is still an open challenge in contrastive learning. While there is a plethora of work on improving contrastive learning, few of them directly aim to address feature suppression. This limitation of contrastive learning becomes a bottleneck for scenarios where existing augmentation cannot fully address the feature suppression phenomenon, and learning would saturate at a level of dissatisfaction.
We would also like to point out some limitations of our study. Firstly, we focus mostly on contrastive learning with explicit negatives (e.g. SimCLR and MoCo). We believe other methods based on clustering and/or without negative pairs would exhibit similar phenomenon but we leave that as future work. Secondly, many of our proposed image datasets are not fully realistic despite being composed from some (challenging) natural image datasets such as ImageNet. We admit it is very hard to explore competing features or multiple objects in a controllable fashion on realistic large scale image datasets.
# Acknowledgements
We specially thank Geoffrey Hinton for many inspiring discussions and helpful advice. We would also like to thank David Fleet, Simon Kornblith, Mohammad Norouzi, Kevin Swersky and Katherine Hermann for insightful discussions. In addition, we are thankful to William Chan and Sara Sabour for ideas on implementation of sorting on TPUs. We also thank the anonymous reviewers for their constructive feedback.
References [1] Suzanna Becker and Geoffrey E Hinton. Self-organizing neural network that discovers surfaces in randomdot stereograms. Nature, 355(6356):161–163, 1992. [2] Alexey Dosovitskiy, Jost Tobias Springenberg, Martin Riedmiller, and Thomas Brox. Discriminative unsupervised feature learning with convolutional neural networks. In Advances in neural information processing systems, pages 766–774, 2014. [3] Aaron van den Oord, Yazhe Li, and Oriol Vinyals. Representation learning with contrastive predictive coding. arXiv preprint arXiv:1807.03748, 2018. [4] Zhirong Wu, Yuanjun Xiong, Stella X Yu, and Dahua Lin. Unsupervised feature learning via nonparametric instance discrimination. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pages 3733–3742, 2018. [5] R Devon Hjelm, Alex Fedorov, Samuel Lavoie-Marchildon, Karan Grewal, Phil Bachman, Adam Trischler, and Yoshua Bengio. Learning deep representations by mutual information estimation and maximization. arXiv preprint arXiv:1808.06670, 2018. [6] Philip Bachman, R Devon Hjelm, and William Buchwalter. Learning representations by maximizing mutual information across views. In Advances in Neural Information Processing Systems, pages 15509–15519, 2019. [7] Olivier J Hénaff, Ali Razavi, Carl Doersch, SM Eslami, and Aaron van den Oord. Data-efficient image recognition with contrastive predictive coding. arXiv preprint arXiv:1905.09272, 2019. [8] Yonglong Tian, Dilip Krishnan, and Phillip Isola. Contrastive multiview coding. arXiv preprint arXiv:1906.05849, 2019. [9] Ishan Misra and Laurens van der Maaten. Self-supervised learning of pretext-invariant representations. arXiv preprint arXiv:1912.01991, 2019. [10] Kaiming He, Haoqi Fan, Yuxin Wu, Saining Xie, and Ross Girshick. Momentum contrast for unsupervised visual representation learning. arXiv preprint arXiv:1911.05722, 2019. [11] Junnan Li, Pan Zhou, Caiming Xiong, Richard Socher, and Steven CH Hoi. Prototypical contrastive learning of unsupervised representations. arXiv preprint arXiv:2005.04966, 2020. [12] Yonglong Tian, Chen Sun, Ben Poole, Dilip Krishnan, Cordelia Schmid, and Phillip Isola. What makes for good views for contrastive learning. arXiv preprint arXiv:2005.10243, 2020. [13] Ting Chen, Simon Kornblith, Mohammad Norouzi, and Geoffrey Hinton. A simple framework for contrastive learning of visual representations. arXiv preprint arXiv:2002.05709, 2020. [14] Ting Chen, Simon Kornblith, Kevin Swersky, Mohammad Norouzi, and Geoffrey Hinton. Big selfsupervised models are strong semi-supervised learners. arXiv preprint arXiv:2006.10029, 2020. [15] Kihyuk Sohn. Improved deep metric learning with multi-class n-pair loss objective. In Advances in neural information processing systems, pages 1857–1865, 2016. [16] Tongzhou Wang and Phillip Isola. Understanding contrastive representation learning through alignment and uniformity on the hypersphere. arXiv preprint arXiv:2005.10242, 2020. [17] Julien Rabin, Gabriel Peyré, Julie Delon, and Marc Bernot. Wasserstein barycenter and its application to texture mixing. In International Conference on Scale Space and Variational Methods in Computer Vision, pages 435–446. Springer, 2011. [18] Nicolas Bonneel, Julien Rabin, Gabriel Peyré, and Hanspeter Pfister. Sliced and radon wasserstein barycenters of measures. Journal of Mathematical Imaging and Vision, 51(1):22–45, 2015. [19] Soheil Kolouri, Kimia Nadjahi, Umut Simsekli, Roland Badeau, and Gustavo Rohde. Generalized sliced wasserstein distances. In Advances in Neural Information Processing Systems, pages 261–272, 2019. [20] Ben Poole, Sherjil Ozair, Aaron van den Oord, Alexander A Alemi, and George Tucker. On variational bounds of mutual information. arXiv preprint arXiv:1905.06922, 2019. [21] Yang You, Igor Gitman, and Boris Ginsburg. Large batch training of convolutional networks. arXiv preprint arXiv:1708.03888, 2017. [22] Jean-Bastien Grill, Florian Strub, Florent Altché, Corentin Tallec, Pierre H. Richemond, Elena Buchatskaya, Carl Doersch, Bernardo Avila Pires, Zhaohan Daniel Guo, Mohammad Gheshlaghi Azar, Bilal Piot, Koray Kavukcuoglu, Rémi Munos, and Michal Valko. Bootstrap your own latent: A new approach to selfsupervised learning, 2020. [23] Tsung-Yi Lin, Michael Maire, Serge Belongie, James Hays, Pietro Perona, Deva Ramanan, Piotr Dollár, and C Lawrence Zitnick. Microsoft coco: Common objects in context. In European conference on computer vision, pages 740–755. Springer, 2014. [24] Diederik P Kingma and Max Welling. Auto-encoding variational bayes. arXiv preprint arXiv:1312.6114, 2013. [25] Danilo Jimenez Rezende, Shakir Mohamed, and Daan Wierstra. Stochastic backpropagation and approximate inference in deep generative models. arXiv preprint arXiv:1401.4082, 2014. [26] Mathilde Caron, Ishan Misra, Julien Mairal, Priya Goyal, Piotr Bojanowski, and Armand Joulin. Unsupervised learning of visual features by contrasting cluster assignments. arXiv preprint arXiv:2006.09882, 2020. [27] David McAllester and Karl Stratos. Formal limitations on the measurement of mutual information. In International Conference on Artificial Intelligence and Statistics, pages 875–884, 2020. [28] Jiaming Song and Stefano Ermon. Understanding the limitations of variational mutual information estimators. arXiv preprint arXiv:1910.06222, 2019. [29] Michael Tschannen, Josip Djolonga, Paul K Rubenstein, Sylvain Gelly, and Mario Lucic. On mutual information maximization for representation learning. arXiv preprint arXiv:1907.13625, 2019. [30] Sanjeev Arora, Hrishikesh Khandeparkar, Mikhail Khodak, Orestis Plevrakis, and Nikunj Saunshi. A theoretical analysis of contrastive unsupervised representation learning. arXiv preprint arXiv:1902.09229, 2019. [31] Yao-Hung Hubert Tsai, Yue Wu, Ruslan Salakhutdinov, and Louis-Philippe Morency. Demystifying self-supervised learning: An information-theoretical framework. arXiv preprint arXiv:2006.05576, 2020. [32] Christopher Tosh, Akshay Krishnamurthy, and Daniel Hsu. Contrastive learning, multi-view redundancy, and linear models. arXiv preprint arXiv:2008.10150, 2020. [33] Yuandong Tian, Lantao Yu, Xinlei Chen, and Surya Ganguli. Understanding self-supervised learning with dual deep networks. arXiv preprint arXiv:2010.00578, 2020. [34] Jason D Lee, Qi Lei, Nikunj Saunshi, and Jiacheng Zhuo. Predicting what you already know helps: Provable self-supervised learning. arXiv preprint arXiv:2008.01064, 2020. [35] Nanxuan Zhao, Zhirong Wu, Rynson WH Lau, and Stephen Lin. What makes instance discrimination good for transfer learning? arXiv preprint arXiv:2006.06606, 2020. [36] Senthil Purushwalkam and Abhinav Gupta. Demystifying contrastive self-supervised learning: Invariances, augmentations and dataset biases. arXiv preprint arXiv:2007.13916, 2020. [37] Katherine L Hermann and Andrew K Lampinen. What shapes feature representations? exploring datasets, architectures, and training. arXiv preprint arXiv:2006.12433, 2020. [38] Harshay Shah, Kaustav Tamuly, Aditi Raghunathan, Prateek Jain, and Praneeth Netrapalli. The pitfalls of simplicity bias in neural networks. arXiv preprint arXiv:2006.07710, 2020. [39] Kaiming He, Xiangyu Zhang, Shaoqing Ren, and Jian Sun. Deep residual learning for image recognition. In Proceedings of the IEEE conference on computer vision and pattern recognition, pages 770–778, 2016.123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214# Alpha-IoU: A Family of Power Intersection over Union Losses for Bounding Box Regression
Jiabo $\mathbf { H e } ^ { 1 , 3 , * }$ , Sarah Erfani1, Xingjun $\mathbf { M } \mathbf { a } ^ { 2 , \dagger }$ , James Bailey1, Ying $\mathbf { C } \mathbf { h } \mathbf { i } ^ { 3 , \dagger }$ , Xian-Sheng $\mathbf { H } \mathbf { u } \mathbf { a } ^ { 3 }$
1School of Computing and Information Systems, The University of Melbourne 2School of Computer Science, Fudan University 3DAMO Academy, Alibaba Group {jiaboh@student., sarah.erfani@, baileyj@}unimelb.edu.au danxjma@gmail.com, {xinyi.cy, xiansheng.hxs}@alibaba-inc.com
# Abstract
Bounding box (bbox) regression is a fundamental task in computer vision. So far, the most commonly used loss functions for bbox regression are the Intersection over Union (IoU) loss and its variants. In this paper, we generalize existing IoUbased losses to a new family of power IoU losses that have a power IoU term and an additional power regularization term with a single power parameter $\alpha$ We call this new family of losses the $\alpha$ -IoU losses and analyze properties such as order preservingness and loss/gradient reweighting. Experiments on multiple object detection benchmarks and models demonstrate that $\alpha$ -IoU losses, 1) can surpass existing IoU-based losses by a noticeable performance margin; 2) offer detectors more flexibility in achieving different levels of bbox regression accuracy by modulating $\alpha$ ; and 3) are more robust to small datasets and noisy bboxes.
# 1 Introduction
Bounding box (bbox) regression localizes an object in an image/video by predicting a bbox for the object, which is fundamental to object detection, localization, and tracking. For example, the most advanced object detectors often consist of a bbox regression branch and a classification branch with the bbox regression branch generating bboxes to localize objects for classification. In this work, we explore more effective loss functions for bbox regression in the context of object detection.
Whilst early works in object detection use $\ell _ { n }$ -norm losses [11] for bbox regression, recent works directly adopt the localization performance metric, i.e., Intersection over Union (IoU), as the localization loss [28, 39]. Compared with $\ell _ { n }$ -norm losses, the IoU loss is invariant to bbox scales, thus helping train better detectors. However, the IoU loss suffers from the gradient vanishing problem when the predicted bboxes are not overlapping with the ground truth, which tends to slow down convergence and result in inaccurate detectors. This has motivated the design of several improved IoU-based losses including Generalized IoU (GIoU), Distance-IoU (DIoU) and Complete IoU (CIoU). GIoU introduces a penalty term into the IoU loss to alleviate the gradient vanishing problem [32], while DIoU and CIoU consider the central point distance and aspect ratio between predicted bboxes and their ground truth in penalty terms [43].
In this paper, we present a new family of IoU losses obtained by applying power transformations to existing IoU-based losses. We first apply the Box-Cox transformation [2] to the IoU loss $\mathcal { L } _ { \mathrm { I o U } } =$ $1 - I o U$ and generalize it to a power IoU loss: $\mathcal { L } _ { \alpha \mathrm { - I o U } } = ( 1 - I o U ^ { \alpha } ) / \alpha , ~ \alpha > 0$ , denoted as $\alpha$ -IoU. We further simplify $\alpha$ -IoU to $\mathcal { L } _ { \alpha - \mathrm { I o U } } = 1 - I o U ^ { \alpha }$ for $\alpha \nrightarrow 0$ and extend it to a more general form with an additional power regularization term (see equation (3)). This allows us to generalize existing IoU-based losses, including GIoU, DIoU, and CIoU, to a new family of power IoU losses (see equation (4)) for more accurate bbox regression as well as object detection.
We show that, relative to ${ \mathcal { L } } _ { \mathrm { I o U } }$ , ${ \mathcal { L } } _ { \alpha - { \mathrm { I o U } } }$ with $\alpha > 1$ up-weights both the loss and gradient of high IoU objects, leading to improved bbox regression accuracy. When $0 < \alpha < 1$ , it down-weights high IoU objects which we find hurts regression accuracy. The power parameter $\alpha$ can serve as a knob to adapt $\alpha$ -IoU losses to meeting different levels of bbox regression accuracy (precision measured under different IoU thresholds), with $\alpha > 1$ for high regression accuracy (i.e., high IoU thresholds) by focusing more on those high IoU objects. We also empirically show that $\alpha$ is not overly sensitive to different models or datasets, with $\alpha = 3$ performing consistently well in most cases. The family of $\alpha$ -IoU losses can be easily applied for improving state-of-the-art detectors under both clean and noisy bbox settings without introducing additional parameters to these models (making any modifications to training algorithms), nor increasing their training/inference time.
In summary, our main contributions are as follows:
• We propose a new family of power IoU losses called $\alpha$ -IoU for accurate bbox regression and object detection. $\alpha$ -IoU presents a unified power generalization of existing IoU-based losses. • We analyze a set of properties of $\alpha$ -IoU, including order preservingness and loss/gradient reweighting, to show that a proper choice of $\alpha$ (i.e., $\alpha > 1$ ) can help improve bbox regression accuracy by adaptively up-weighting the loss and gradient of high IoU objects. • We empirically show, on multiple benchmark object detection datasets and models, that $\alpha$ -IoU losses can consistently outperform existing IoU-based losses and provide more robustness for small datasets and noisy bboxes.
# 2 Related Work
Object Detection Models. There exist two mainstream types of detection models: anchor-based and anchor-free detectors. Anchor-based detectors can be further divided into two-stage and onestage models. Two-stage anchor-based detectors (e.g., R-CNN series [11, 31, 14, 3], HTC [5], and TSD [33]) are firstly proposed in object detection tasks, which are composed of region proposal networks (RPNs) and classifiers. RPNs generate a large number of foreground and background region proposals, followed by networks to classify objects in the proposals. Towards real-time object detection, one-stage anchor-based detectors (e.g., YOLO series [29, 30, 1], RetinaNet [21], and SSD [24]) are developed to predict bboxes and categories at the same time, thus no longer need RPNs. Anchor boxes with prior scales and aspect ratios should be defined before training anchor-based detectors. Techniques have been proposed to mitigate the sensitivity of these models to hand-picked anchor boxes, for example, attention-based fusion networks [31] and clustering algorithms [30]. These techniques learn prior anchors from the training set for every sliding window or grid cell.
Recently, anchor-free detectors such as CornerNet [16], CenterNet1 [8], ExtremeNet [45], and CentripetalNet [7], have also been proposed to get rid of anchor priors. These models first predict locations of keypoints (corners, centroids, or extreme points), then group them into the same bboxes if they are geometrically aligned. There also exist other models that generate pixel-wise results. For example, CenterNet2 estimates pixel-level categories of objects along with their sizes and offsets [44]. FCOS generates pixel-wise classification, centerness, and bbox (top, down, left, right) results using multi-head CNNs [34], followed by the Adaptive Training Sample Selection (ATSS) [40] as an improvement on automatically selecting positive and negative samples. In addition, transformers (e.g., DETR series [4, 46]) have also been developed for object detection without anchor generation or non-maximum suppression (NMS), achieving the performance on par with the above CNN-based detectors. In this work, we propose a new family of generalized IoU losses to improve the performance of these detectors without any architectural modifications, which is orthogonal to the above research.
Bounding Box Regression Losses. Anchor-based detectors regress offsets between ground-truth bboxes and their closest anchors, while anchor-free detectors predict keypoints of objects with some frameworks also generating the sizes of the bboxes. The predicted offsets or keypoints (w/ or w/o bbox sizes) are then mapped back to the pixel space for generating the bboxes. Localization losses usually compare the generated bboxes with their ground truth. Early works adopt $\ell _ { n }$ -norm losses [11] for bbox regression, which have been found sensitive to varying bbox scales. Recent works replace them with the IoU loss and its variants such as BIoU, GIoU, DIoU and CIoU for bbox regression, as IoU is the metric for localization and it is scale-invariant [28, 39]. The Bounded IoU (BIoU) loss maximizes the IoU overlap between the region of interest (RoI) and the ground truth based on a set of IoU upper bounds [35]. GIoU is proposed to address the problem of gradient vanishing on non-overlapping examples, which are examples having non-overlapping predicted bboxes with the ground truth (IoU is zero) [32]. DIoU and CIoU [43] losses further consider the overlapping area, central point distance, and aspect ratio in IoU and the regularization terms. These regularization terms can help improve the convergence speed as well as the final detection performance. There are also losses designed to focus more on high IoU objects, for example, the Rectified IoU (RIoU) loss [36], and the Focal and Efficient IoU (Focal-EIoU) loss [41]. These loss functions increase gradients of those examples that are in high bbox regression accuracy. However, RIoU and Focal-EIoU are neither concise nor generalized compared with other IoU-based losses. In this paper, we apply a power transformation to generalize the above vanilla IoU loss and regularized IoU-based losses for both their IoU and regularization terms. The new family of generalized losses improve bbox regression accuracy by adaptively reweighting the loss and gradient of high and low IoU objects.
There are also works on AutoML-based loss function search for computer vision tasks [23, 18, 17]. Despite their advantage in saving human efforts, these methods are very expensive in searching qualified loss functions (e.g., days of searching time on multiple GPUs), and probably with limited performance improvement based on existing losses [23]. We will empirically compare with one of these losses in our experiments.
# 3 $\alpha$ -IoU Losses for Bounding Box Regression
# 3.1 Preliminaries
We study the problem of bbox regression in object detection. Let $\pmb { X } \in \mathbb { R } ^ { d _ { x } }$ be the input space and $\pmb { Y } \in \mathbb { R } ^ { \tilde { d } _ { y } }$ be the annotation space, with $d _ { x }$ and $d _ { y }$ denoting the input and annotation dimensions, respectively. Given a dataset $D = \{ ( { \bf x } _ { i } , { \bf y } _ { i } ) \} _ { i = 1 } ^ { n }$ of $n$ training examples with each $( { \pmb x } _ { i } , { \pmb y } _ { i } ) \in$ $( X \times Y )$ , the task is to learn a function $f$ (represented by a detector network) that maps the input space to the annotation space $f : X \to Y$ . In object detection, each $\pmb { y } _ { i } = ( c _ { i , k } , B _ { i , k } ) _ { k = 1 } ^ { m _ { i } }$ , where $m _ { i }$ is the total number of objects in $\mathbf { \Delta } _ { \mathbf { \mathcal { X } } _ { i } }$ , $c _ { i , k }$ is the category of the $k ^ { t h }$ object in $\mathbf { \Delta } _ { \mathbf { \mathcal { X } } _ { i } }$ and $B _ { i , k }$ is its bbox.
The bbox regression performance is measured by the Intersection over Union (IoU) metric between the predicted bbox $B$ and the ground truth $B ^ { g t }$ $\ d ^ { 3 } \ d ^ { g t } \colon \bar { I o U } = | B \cap B ^ { g t } | / | B \cup B ^ { g t } |$ . Positive examples (both true and false positives) are determined from the set of predictions according to an IoU threshold, based on which the Average Precision (AP) over all categories of objects can be calculated. E.g., $\mathrm { { A P } _ { 5 0 } }$ measures the AP of objects localized by bboxes with an IoU that is above the threshold 0.5. The final performance of a detector is commonly evaluated by the mean Average Precision (mAP) across multiple IoU thresholds. For instance, the popular metric $\mathrm { m A P _ { 5 0 : 9 5 } }$ measures the mAP of examples across the set of IoU thresholds ranging from 0.5 to 0.95 with a stride of 0.05.
# 3.2 $\alpha$ -IoU Losses
The vanilla IoU loss is defined as $\mathcal { L } _ { \mathrm { I o U } } = 1 - I o U .$ . We first apply the Box-Cox transformation3 [2] and generalize the IoU loss to an $\alpha$ -IoU loss:
$$\mathcal { L } _ { \alpha \cdot \mathrm { I o U } } = \frac { 1 - I o U ^ { \alpha } } { \alpha } , \alpha > 0 .$$
By modulating the parameter $\alpha$ in $\alpha$ -IoU, one can derive most of the IoU terms in existing losses, e.g., $\log ( I o U )$ , $I o U$ and $I o U ^ { 2 }$ . When $\alpha 0$ , we obtain $\begin{array} { r } { \operatorname* { l i m } _ { \alpha \to 0 } \mathcal { L } _ { \alpha \mathrm { { \cdot } I o U } } = - \mathrm { l o g } ( I o U ) = \mathcal { L } _ { \mathrm { l o g } ( \mathrm { I o U } ) } } \end{array}$ [39] (see the proof in Appendix A). We recover the IoU loss with $\alpha = 1$ : $\mathcal { L } _ { \mathrm { 1 - I o U } } = 1 - I o U = \mathcal { L } _ { \mathrm { I o U } }$ And $\mathcal { L } _ { \mathrm { 2 - I o U } } = \textstyle { \frac { 1 } { 2 } } ( 1 - I o \dot { U } ^ { 2 } ) = \textstyle { \frac { 1 } { 2 } } \mathcal { L } _ { \mathrm { I o U } ^ { 2 } }$ , when $\alpha = 2$ . We can also extend the above $\alpha$ -IoU formula to loss functions with multiple IoU terms (e.g. RIoU [36]) by using multiple $\alpha$ values.
 Figure 1: Correlation between IoU and $\mathcal { L } _ { \alpha \mathrm { { - I o U } } } ~ = ~ 1 - ~ I o U ^ { \alpha }$ (left) and its absolute gradient $| \nabla _ { \mathrm { I o U } } \mathcal { L } _ { \alpha - \mathrm { I o U } } |$ (right) with different $\alpha ~ \in ~ [ 0 . 5 , 3 ]$ . According to both plots, ${ \mathcal { L } } _ { \alpha - { \mathrm { I o U } } }$ reweights all objects adaptively and distinctively for $0 < \alpha < 1$ vs. $\alpha > 1$ $\langle \alpha = 1$ marks the IoU loss).
We simplify the above $\alpha$ -IoU formula for $\alpha > 0$ and $\alpha \nrightarrow 0$ , as in this case, the denominator $\alpha$ in equation (1) is just a positive constant in the objective. This gives us two cases of the $\alpha$ -IoU loss for $\alpha 0$ and $\alpha \not 0$ , respectively:
$$\mathcal { L } _ { \alpha \mathrm { - I o U } } = \left\{ { { - \mathrm { l o g } ( I o U ) , ~ \alpha \to 0 } , } \atop { 1 - I o U ^ { \alpha } , ~ \alpha \to 0 . } \right.$$
Here, we are more interested in the case $\alpha \nrightarrow 0$ as most state-of-the-art IoU-based losses have an $\alpha \geq 1$ . We then extend the above $\alpha$ -IoU loss for $\alpha \not 0$ to a more general form by introducing a power penalty/regularization term into the formula:
$${ \mathcal { L } } _ { \alpha - \mathrm { I o U } } = 1 - I o U ^ { \alpha _ { 1 } } + { \mathcal { P } } ^ { \alpha _ { 2 } } ( B , B ^ { g t } ) ,$$
where $\alpha _ { 1 } > 0$ , $\alpha _ { 2 } > 0$ , and $\mathcal { P } ^ { \alpha _ { 2 } } ( B , B ^ { g t } )$ denotes any penalty term computed based on $B$ and $B ^ { g t }$ . This simple extension allows a straightforward generalization of existing IoU-based losses to their $\alpha$ -IoU versions. In Appendix B.2.1, we empirically show that ${ \mathcal { L } } _ { \alpha - { \mathrm { I o U } } }$ is not sensitive to $\alpha _ { 2 }$ . We thus maintain the power consistency between the IoU term and the penalty term and take $\alpha _ { 1 } = \alpha _ { 2 }$ as a simple choice when training the detectors.
With the above $\alpha$ -IoU formula, we can now generalize the commonly used IoU-based losses including $\mathcal { L } _ { \mathrm { I o U } } , \mathcal { L } _ { \mathrm { G I o U } } , \mathcal { L } _ { \mathrm { D I o U } }$ , and ${ \mathcal { L } } _ { \mathrm { C I o U } }$ using the same power parameter $\alpha$ for the IoU and penalty terms:
$$\begin{array} { r l r } & { } & { \mathcal { L } _ { \mathrm { I o U } } = 1 - I o U \Longrightarrow \mathcal { L } _ { \alpha \mathrm { \cdot I o U } } = 1 - I o U ^ { \alpha } , } \\ & { } & { \mathcal { L } _ { \mathrm { G I o U } } = 1 - I o U + \frac { \left| C \setminus ( B \cup B ^ { g t } ) \right| } { \left| C \right| } \Longrightarrow \mathcal { L } _ { \alpha \mathrm { \cdot G I o U } } = 1 - I o U ^ { \alpha } + ( \frac { \left| C \setminus ( B \cup B ^ { g t } ) \right| } { \left| C \right| } ) ^ { \alpha } , } \\ & { } & { \mathcal { L } _ { \mathrm { D I o U } } = 1 - I o U + \frac { \rho ^ { 2 } ( b , b ^ { g t } ) } { c ^ { 2 } } \Longrightarrow \mathcal { L } _ { \alpha \mathrm { \cdot D I o U } } = 1 - I o U ^ { \alpha } + \frac { \rho ^ { 2 \alpha } ( b , b ^ { g t } ) } { c ^ { 2 \alpha } } , \ ~ } \\ & { } & { \mathcal { L } _ { \mathrm { C I o U } } = 1 - I o U + \frac { \rho ^ { 2 } ( b , b ^ { g t } ) } { c ^ { 2 } } + \beta v \Longrightarrow \mathcal { L } _ { \alpha \mathrm { \cdot C I o U } } = 1 - I o U ^ { \alpha } + \frac { \rho ^ { 2 \alpha } ( b , b ^ { g t } ) } { c ^ { 2 \alpha } } + ( \beta v ) ^ { \alpha } , } \end{array}$$
where $C$ in ${ \mathcal { L } } _ { \mathrm { G I o U } }$ denotes the smallest convex shape enclosing $B$ and $B ^ { g t }$ ; $^ { b }$ and $\mathbf { \delta } _ { b } \mathbf { \mathcal { I } ^ { t } }$ in ${ \mathcal { L } } _ { \mathrm { D I o U } }$ denote central points of $B$ and $B ^ { g t }$ with $\rho ( \cdot )$ being the Euclidean distance and $c$ being the diagonal length of the smallest enclosing box; and in ${ \mathcal { L } } _ { \mathrm { C I o U } }$ , $\begin{array} { r } { v = \frac { 4 } { \pi ^ { 2 } } ( a r c t a n \frac { w ^ { g t } } { h ^ { g t } } - a r c t a n \frac { w } { h } ) ^ { 2 } } \end{array}$ , $\begin{array} { r } { \beta = \frac { v } { ( 1 - I o U ) + v } } \end{array}$ . They give us the family of power IoU losses for bbox regression with their original versions recovered at $\alpha = 1$ . Note that the above $\alpha$ -IoU generalization can be easily extended to more complex loss functions that have multiple IoU or penalty terms (e.g., $\mathcal { L } _ { \alpha - \mathrm { C I o U } } )$ ). Next, we will analyze the properties of $\alpha$ -IoU losses when $\alpha$ takes different values.
# 3.3 Properties of $\alpha$ -IoU Losses
Here, we focus on the vanilla $\alpha$ -IoU formula $\mathcal { L } _ { \alpha - \mathrm { I o U } } = 1 - I o U ^ { \alpha }$ to analyze its properties, as the penalty terms may affect these properties differently. Figure 1 illustrates the correlation between IoU and ${ \mathcal { L } } _ { \alpha - { \mathrm { I o U } } }$ (left) and the magnitude of its gradient w.r.t. IoU, i.e., $| \nabla _ { \mathrm { I o U } } \mathcal { L } _ { \alpha - \mathrm { I o U } } |$ (right). One key observation is that the IoU loss (i.e., $\alpha = 1$ ) has a linear correlation with IoU and the gradient is a constant, while ${ \mathcal { L } } _ { \alpha - { \mathrm { I o U } } }$ reweights objects adaptively (according to their IoU values) following different reweighting schemes with $0 < \alpha < 1$ versus $\alpha > 1$ .
The power transformation in ${ \mathcal { L } } _ { \alpha - { \mathrm { I o U } } }$ preserves key properties of ${ \mathcal { L } } _ { \mathrm { I o U } }$ as a performance metric, including non-negativity, identity of indiscernibles, symmetry, and triangle inequality [32]. Furthermore, we analyze the following important properties of ${ \mathcal { L } } _ { \alpha - { \mathrm { I o U } } }$ with detailed derivations deferred to Appendix A. We first let $B _ { i }$ and $B _ { j }$ be two predicted bboxes by two different models $M _ { i }$ and $M _ { j }$ respectively, and $B _ { i }$ and $B _ { j }$ correspond to the same ground truth $B ^ { g t }$ with $I o U ( B _ { i } , B ^ { g t } ) < I o U ( \bar { B _ { j } } , B ^ { g t } )$ . Then we have the first property of ${ \mathcal { L } } _ { \alpha }$ -IoU:
Property 1 (Order Preservingness). ${ \mathcal { L } } _ { \alpha }$ -IoU preserves the orders of both IoU and $\mathcal { L } _ { I o U }$ : I ${ } ^ { \circ } o \bar { U } ( B _ { i } , B ^ { g t } ) \ < I o U ( B _ { j } , B ^ { g t } ) ^ { - } \iff \ \mathcal { L } _ { I o U } ( B _ { i } , B ^ { g t } ) > \ \mathcal { L } _ { I o U } ( B _ { j } , B ^ { g t } ) \iff \ \mathcal { L } _ { \alpha \cdot I o U } ( B _ { i } , B ^ { g t } ) >$ $\mathcal { L } _ { \alpha - I o U } ( B _ { j } , B ^ { g t } )$ .
The above property indicates that both ${ \mathcal { L } } _ { \alpha - { \mathrm { I o U } } }$ and ${ \mathcal { L } } _ { \mathrm { I o U } }$ are monotonically decreasing functions w.r.t. $I o U$ . As ${ \mathcal { L } } _ { \alpha - { \mathrm { I o U } } }$ preserves the order of ${ \mathcal { L } } _ { \mathrm { I o U } }$ strictly, it is guaranteed that arg $\mathrm { m i n } _ { B } \mathcal { L } _ { \alpha \mathrm { - I o U } } ( B , B ^ { g t } )$ is identical to arg $\operatorname* { m a x } _ { B } I o U ( B , B ^ { g t } )$ and arg $\mathrm { m i n } _ { B } \bar { \mathcal { L } } _ { \mathrm { I o U } } ( \bar { B , B ^ { g t } } )$ . In other words, the optimal solution arg $\operatorname* { m a x } _ { B } I o U ( B , \bar { B ^ { g t } } )$ can be obtained by minimizing either ${ \mathcal { L } } _ { \alpha - { \mathrm { I o U } } }$ or ${ \mathcal { L } } _ { \mathrm { I o U } }$ . Following this, the adaptive relative loss reweighting scheme of ${ \mathcal { L } } _ { \alpha - { \mathrm { I o U } } }$ can be characterized by the second property:
Property 2 (Relative Loss Reweighting). Compared with $\mathcal { L } _ { I o U }$ , $\mathcal { L } _ { \alpha - I o U }$ adaptively reweights the relative loss of all objects by $w _ { \mathcal { L } _ { r } } = \mathcal { L } _ { \alpha \cdot I o U } / \mathcal { L } _ { I o U } = 1 + ( I o U - I o U ^ { \alpha } ) / ( 1 - I o U )$ , with $w _ { \mathscr { L } _ { r } } ( I o U =$ $0 ) = 1$ , and $\begin{array} { r } { \operatorname* { l i m } _ { I o U \to 1 } w _ { \mathcal { L } _ { r } } = \alpha } \end{array}$ .
The second property indicates that ${ \mathcal { L } } _ { \alpha - { \mathrm { I o U } } }$ will adaptively down-weight and up-weight the relative loss of all objects according to their IoUs when $0 < \alpha < 1$ and $\alpha > 1$ , respectively. We further note that, when $\alpha > 1$ , the reweighting factor $w _ { \mathcal { L } _ { r } }$ increases monotonically with the increase of IoU $( w _ { \boldsymbol { L } _ { r } }$ grows from 1 to $\alpha$ ) while decreasing monotonically with the increase of IoU when $0 < \alpha < 1 ( w _ { \mathcal { L } _ { r } }$ decays from 1 to $\alpha$ ). We will empirically show that the up-weighting scheme of ${ \mathcal { L } } _ { \alpha - { \mathrm { I o U } } }$ with $\alpha > 1$ can help the model focus more on high IoU objects to improve both the localization (i.e., predict more high IoU objects) and detection (i.e., more accurate at high APs) performance4. Similarly, we can obtain the third property of adaptive relative gradient reweighting owned by ${ \mathcal { L } } _ { \alpha - { \mathrm { I o U } } }$ as follows:
Property 3 (Relative Gradient Reweighting). Compared with $\mathcal { L } _ { I o U ; }$ , $\mathcal { L } _ { \alpha - I o U }$ adaptively reweights the relative gradient of all objects by $\begin{array} { r } { w _ { \bar { \nabla } _ { r } } = \bar { | } \nabla _ { I o U } \mathcal { L } _ { \alpha - I o U } | / | \nabla _ { I o U } \mathcal { L } _ { I o U } | = \alpha I o U ^ { \bar { \alpha } - 1 } } \end{array}$ , with the turning point at $I o U = \alpha ^ { \frac { 1 } { 1 - \alpha } } \in ( 0 , \frac { 1 } { e } )$ when $0 < \alpha < 1$ and $I o U = \alpha ^ { \frac { 1 } { 1 - \alpha } } \in ( \textstyle { \frac { 1 } { e } } , 1 )$ when $\alpha > 1$ .
When $\alpha > 1$ , the above reweighting factor $w _ { \nabla _ { r } }$ increases monotonically with the increase of IoU, while decreasing monotonically with the increase of IoU when $0 \textless \alpha \textless 1$ . This relative gradient reweighting scheme is also adaptive to IoU, with the turning point from up-weighting to down-weighting at $\overline { { I o U } } = \alpha ^ { \frac { 1 } { 1 - \alpha } } \in ( 0 , \frac { 1 } { e } )$ when $0 \textless \alpha \textless 1$ , and from down-weighting to upweighting at $I o U = \alpha ^ { \frac { 1 } { 1 - \alpha } } \in ( \frac { 1 } { e } , 1 )$ when $\alpha > 1$ . The gradient reweighting scheme is bounded by $w _ { \nabla _ { r } } ( I o U = 1 ) = \alpha$ , i.e., $0 \leq w _ { \nabla _ { r } } \leq \alpha$ when $\alpha > 1$ , and $w _ { \nabla _ { r } } \geq \alpha$ when $0 < \alpha < 1$ . This relative gradient reweighting scheme allows the model to learn objects with adaptive speeds (i.e., different gradients) according to their IoUs. Theoretically, when $\alpha = 2$ , $| \nabla _ { \mathrm { I o U } } \mathcal { L } _ { \alpha - \mathrm { I o U } } | > | \overline { { \nabla } } _ { \mathrm { I o U } } \mathcal { L } _ { \mathrm { I o U } } |$ for $I o U \in ( 0 . 5 , 1 ]$ , which accelerates the learning of all positive IoU objects at $\mathrm { { A P } _ { 5 0 } }$ . However, we empirically show that $\alpha$ -IoU losses with $\alpha = 3$ perform more competitively than those with $\alpha = 2$ in most cases. It is probable that $\alpha \cdot$ -IoU losses with $\alpha = 3$ further up-weight the relative loss of objects with $I o U \in ( 0 . 5 , 1 ]$ , although $\alpha$ -IoU losses with $\alpha = 2$ also beat existing baselines (see Figure 6). This property is both data-agnostic and model-agnostic, so we recommend $\alpha = 3$ or $\alpha \in [ 2 , 3 ]$ in practical use for other datasets and models.
The above loss and gradient reweighting schemes can also be inferred from Figure 1, with detailed proofs in Appendix A. To summarize, ${ \mathcal { L } } _ { \alpha - { \mathrm { I o U } } }$ trains better detectors than ${ \mathcal { L } } _ { \mathrm { I o U } }$ for the following reasons. First, the same optimal IoU can be achieved by ${ \mathcal { L } } _ { \alpha - { \mathrm { I o U } } }$ as that by ${ \mathcal { L } } _ { \mathrm { I o U } }$ (Property 1). Second, ${ \mathcal { L } } _ { \alpha - { \mathrm { I o U } } }$ with $\alpha > 1$ focuses more on high IoU objects by up-weighting their relative loss (Property
2). Third, ${ \mathcal { L } } _ { \alpha - { \mathrm { I o U } } }$ with $\alpha > 1$ helps detectors learn faster on high IoU objects (here $I o U \in ( \alpha ^ { \frac { 1 } { 1 - \alpha } } , 1 ] )$ through up-weighting their relative gradient (Property 3). In Appendix A, we also provide an analysis of the absolute loss and gradient reweighting properties (Property 4 and 5), showing the additions of $\alpha$ -IoU to IoU. Specifically, when $\alpha > 1$ , ${ \mathcal { L } } _ { \alpha - { \mathrm { I o U } } }$ adds an absolute loss weight to ${ \mathcal { L } } _ { \mathrm { I o U } }$ (i.e., $w _ { \mathscr { L } _ { a } } = \mathscr { L } _ { \alpha \mathrm { - I o U } } - \mathscr { L } _ { \mathrm { I o U } } = I o U - I o U ^ { \alpha } > 0$ for $I o U \in ( 0 , 1 ) )$ , which creates more space for optimization on all levels of objects (Property 4). Likewise, ${ \mathcal { L } } _ { \alpha - { \mathrm { I o U } } }$ puts an absolute gradient weight for high IoU objects (i.e., $\bar { w } _ { \nabla _ { a } } = | \bar { \nabla } _ { \mathrm { I o U } } \mathcal { L } _ { \alpha \mathrm { - I o U } } | - | \nabla _ { \mathrm { I o U } } \mathcal { L } _ { \mathrm { I o U } } | = \alpha I o U ^ { \alpha - 1 } - 1 \bar { > } 0$ for $I o U \in ( \alpha ^ { \frac { 1 } { 1 - \alpha } } , 1 ] )$ such that the learning of high IoU objects is accelerated (Property 5). Both of the absolute and relative properties of ${ \mathcal { L } } _ { \alpha - { \mathrm { I o U } } }$ are adaptive to the IoU values of the objects. Such reweighting schemes will provide more flexibility in achieving different levels of bbox regression accuracies (AP measured under different IoU thresholds).
Learning Dynamics of ${ \mathcal { L } } _ { \alpha \mathbf { - } \mathbf { I 0 } \mathbf { U } }$ . Training with ${ \mathcal { L } } _ { \alpha - { \mathrm { I o U } } }$ is a dynamic process and should be interpreted based on both the absolute and relative properties. With $\alpha > 1$ , easy examples will be learned first with increasing speed towards $I o U = 1$ , while hard examples will be learned gradually and accelerated later on as their IoU improves. We will empirically show in Figure 3 that up-weighting the loss and gradient of high IoU objects can boost the training at the later stage. As a comparison, we will also show that $\alpha$ -IoU losses with $0 < \alpha < 1$ tend to degrade the final performance in Section 4.4. Reducing the loss and gradient of high IoU objects ends up with more poorly localized objects.
# 4 Experiments
# 4.1 Datasets and Training Setup
We conduct all experiments on two popular benchmarks, i.e., PASCAL VOC [9] and MS COCO [22]. On the PASCAL VOC benchmark, we train all models on the trainval set $2 0 0 7 + 2 0 1 2$ (containing 16, 551 images from 20 categories) and evaluate them on the test set 2007 (containing 4, 952 images) [9]. On the MS COCO benchmark, we train all models on the training set 2017 (containing 118K images from 80 categories) and evaluate them on the val set 2017 (containing 5K images) [22]. We train all state-of-the-art models with the original implementation released by the authors. Specifically, we follow the original implementation’s training protocol with default parameters and the number of training epochs with different losses [31, 32, 43, 4]. Implementation details of all models are given in Appendix B.1. All experiments are run with NVIDIA V100 GPUs. Code is available at https://github.com/Jacobi93/Alpha-IoU.
# 4.2 Results and Analysis
We first validate the effectiveness of $\alpha$ -IoU losses in training both anchor-based and anchor-free models on the two datasets. We choose YOLOv5s (i.e., YOLOv5 small) and YOLOv5x (i.e., YOLOv5 extra large) as one-stage anchor-based models, and DETR (ResNet-50) as an anchor-free model. Both $\alpha$ -IoU losses (i.e., ${ \mathcal { L } } _ { \alpha - { \mathrm { I o U } } }$ and $\mathcal { L } _ { \alpha - \mathrm { D I o U } } )$ are generalized from existing baselines following equation (4). From Table 1, we can observe that $\alpha$ -IoU losses surpass existing losses consistently across multiple models and datasets in terms of both mAP and $\mathrm { m A P _ { 7 5 : 9 5 } }$ , especially at the high bbox regression accuracy $\mathrm { m A P _ { 7 5 : 9 5 } }$ . The superiority of $\alpha$ -IoU losses is more pronounced at high accuracy levels, which might reach more than $6 0 \%$ relative improvement at $\mathsf { A P } _ { 9 5 }$ . Interestingly, $\alpha$ -IoU losses tend to help more of light models (e.g., YOLOv5s with 7.3M parameters and 17 GFLOPs) than heavy models (e.g., YOLOv5x with $8 7 . 7 \mathbf { M }$ parameters and 218.8 GFLOPs). This indicates that $\alpha$ -IoU losses hold more advantage while training light models in computing-resource-limited scenarios, such as mobile devices, autonomous vehicles, and robots.
The consistent improvements on both PASCAL VOC and MS COCO demonstrate the stability of $\alpha$ -IoU losses across different datasets. In addition, we also verify its robustness to extremely small training sets in Appendix B.2.2, where $\alpha$ -IoU losses beat existing losses at various scales, i.e., from 4K $2 5 \%$ trainval set of PASCAL VOC $2 0 0 7 { + } 2 0 1 2 ,$ ) to 118K (the entire training set of MS COCO 2017) samples. It is possible that $\alpha$ -IoU losses may not perform well if measured by a single low AP metric. For example, there may be less than $0 . 5 \%$ performance drop at $\mathrm { { A P } _ { 5 0 } }$ when $\alpha = 3$ , however, this is compensated by the significant boost at high APs. With some examples from the test set of PASCAL VOC 2007 (Figure 4) and the val set of MS COCO 2017 (Figure 5), we show that $\alpha$ -IoU losses are able to localize objects more accurately than the baselines with more true positives and fewer false positives.
Table 1: The performance of YOLOv5s, YOLOv5x and DETR models trained using different localization losses on PASCAL VOC and MS COCO benchmarks. Results are obtained on the test set of PASCAL VOC 2007 and the val set of MS COCO 2017. mAP denotes $\mathrm { m A P _ { 5 0 : 9 5 } }$ ; $\mathrm { m A P _ { 7 5 : 9 5 } }$ denotes the mean AP over $\mathsf { A P } _ { 7 5 }$ , $\mathbf { A P } _ { 8 0 } , \cdot \cdot \cdot , \mathbf { A P } _ { 9 5 }$ . "rela. improv." stands for the relative improvement. $\alpha = 3$ is used for all $\alpha$ -IoU losses in all experiments.
<table><tr><td rowspan="2">Method</td><td rowspan="2">Loss</td><td rowspan="2"></td><td colspan="5">PASCAL VOC</td><td colspan="2"></td><td colspan="5">MS COCO</td></tr><tr><td>AP50</td><td>AP75</td><td>AP85 AP95</td><td></td><td>mAP</td><td>mAP75:95l</td><td>AP50</td><td>AP75</td><td>AP85</td><td>AP95</td><td>mAP</td><td>mAP75:95</td></tr><tr><td rowspan="5">YOLOv5s</td><td rowspan="5">LIoU Lα-loU rela. improv.</td><td>78.81 78.62</td><td>58.04 58.78</td><td>35.07 38.16</td><td>2.34 3.64</td><td>52.74 53.61</td><td>32.45 34.46</td><td>55.51</td><td>38.59</td><td>23.58</td><td></td><td>2.07</td><td>36.29</td><td>21.82</td></tr><tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>55.25</td><td>39.69</td><td>25.85</td><td>3.35</td><td>37.01</td><td>23.66</td></tr><tr><td></td><td>-0.24%</td><td>1.27%</td><td>8.81%</td><td>55.56%</td><td>1.65%</td><td>6.21%</td><td>-0.47%</td><td>2.85%</td><td>9.63%</td><td>61.84%</td><td>1.98%</td><td>8.43%</td></tr><tr><td>LDIoU</td><td>78.19</td><td>57.77</td><td>34.89</td><td>2.36</td><td>52.30</td><td>32.17</td><td>55.67</td><td>39.01</td><td>23.56</td><td>2.03</td><td>36.36</td><td>21.95</td></tr><tr><td>Lα-DIoU rela. improv.</td><td>78.33 0.18%</td><td>59.24 38.46</td><td>3.50</td><td></td><td>53.76</td><td>34.66</td><td>55.84</td><td>39.49</td><td>25.49</td><td>3.30</td><td>36.74</td><td>23.34</td></tr><tr><td rowspan="6">YOLOv5x</td><td colspan="10">LIoU</td><td rowspan="6">8.19%</td><td colspan="10">62.56%</td></tr><tr><td></td><td>85.24</td><td>2.54%</td><td>10.23%</td><td>48.31%</td><td>2.79% 63.95</td><td>7.72%</td><td></td><td>0.31%</td><td>1.23%</td><td></td><td></td><td>1.05%</td><td>6.32%</td></tr><tr><td>Lα-IoU</td><td>84.83</td><td>70.08 70.20</td><td>53.08 53.75</td><td>10.88 13.74</td><td>64.25</td><td>46.78 48.06</td><td></td><td>67.36 67.72</td><td>52.15 52.61</td><td>38.22 38.62</td><td>9.31 9.76</td><td>48.42 48.67</td><td>34.42 34.72</td></tr><tr><td>rela. improv.</td><td>-0.48%</td><td>0.17%</td><td>1.26%</td><td>26.29%</td><td>0.47%</td><td></td><td>2.73%</td><td>0.53%</td><td>0.88%</td><td>1.05%</td><td>4.83%</td><td>0.52%</td><td>0.87%</td></tr><tr><td>LDIoU</td><td>85.04</td><td>71.05</td><td>53.71</td><td>11.11</td><td>64.21</td><td>47.30</td><td></td><td>67.54</td><td>52.03</td><td>38.02</td><td>8.58</td><td>48.38</td><td>34.16</td></tr><tr><td>La-DloU rela.improv.</td><td>84.90</td><td>71.34</td><td>54.23</td><td>13.85</td><td>64.49</td><td>48.40</td><td></td><td></td><td>52.65</td><td>39.28</td><td>10.29</td><td>48.81</td><td>35.42</td></tr><tr><td rowspan="8">DETR</td><td rowspan="8">LIoU</td><td>-0.16%</td><td>0.41%</td><td>0.97%</td><td></td><td>24.66%</td><td>0.44%</td><td>2.32%</td><td>67.42 -0.18%</td><td>1.19%</td><td>3.31%</td><td></td><td>19.93%</td><td>0.89%</td><td>3.68%</td></tr><tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td></td><td>76.50</td><td>53.85</td><td>29.54</td><td>1.62</td><td>49.78</td><td>28.82</td><td>59.38</td><td>41.67</td><td>26.13</td><td></td><td>3.52</td><td>39.23</td><td>24.37</td></tr><tr><td>La-loU rela.improv.</td><td>76.22 -0.37%</td><td>55.03 2.19%</td><td>32.30 9.34%</td><td>2.28 40.74%</td><td>51.12 2.69%</td><td>31.08 7.84%</td><td>59.61 0.39%</td><td>42.65 2.35%</td><td>28.57 9.34%</td><td></td><td>5.09 44.60%</td><td>40.18 2.42%</td><td>26.44 8.49%</td></tr><tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>LDIoU</td><td>76.26 76.44</td><td>54.09</td><td>29.23</td><td>1.56</td><td>49.91</td><td>28.68</td><td></td><td>59.28</td><td>41.62</td><td>26.09</td><td>3.54</td><td>39.25</td><td>24.48</td></tr><tr><td>La-DloU rela. improv.</td><td>0.24%</td><td>54.89 1.48%</td><td>31.48 7.70%</td><td>2.44</td><td>50.96 2.10%</td><td>30.60 6.69%</td><td>59.38</td><td>42.34 1.73%</td><td></td><td>28.23</td><td>5.36</td><td>39.94 1.76%</td><td>26.05</td></tr><tr><td></td><td></td><td></td><td></td><td>56.41%</td><td></td><td></td><td>0.17%</td><td></td><td></td><td>8.20%</td><td>51.41%</td><td></td><td>6.41%</td></tr></table>
 Figure 2: IoU distributions between predicted bboxes and their ground truth after NMS.
 Figure 3: Validation mAPs $( \mathrm { m A P _ { 5 0 : 9 5 } } )$ across 300 training epochs.
We further analyze the bbox regression accuracy by showing the IoU distributions between the predicted bboxes and their ground truth for YOLOv5s trained using different losses on PASCAL VOC. After NMS with the IoU threshold being 0.5, we visualize the number of positively predicted bboxes under different IoU thresholds from 0.5 to 0.9 in Figure 2, showing that $\alpha$ -IoU losses detect more positive objects than baseline losses across all IoU thresholds. Particularly, $\alpha$ -IoU losses detect approximately $1 \%$ more positive objects than the baselines when $I o U \ge 0 . 5$ , and $1 1 \%$ more high IoU objects when $I o U \ge 0 . 9$ . This demonstrates that $\alpha$ -IoU boosts both the precisions and recalls of detectors. $\alpha$ -IoU is extremely advantageous in pushing low IoU objects to high IoU objects by up-weighting their loss, thus outperforming baseline losses significantly at the high accuracy level and contributing to the improvement of the final detection performance (Table 1).
Moreover, Figure 3 shows that $\alpha$ -IoU losses are able to boost the late training stage (e.g., after 200 epochs) through up-weighting the gradient of high IoU objects, while almost having no negative impact on the early training stage (e.g., the first 100 epochs). When $\alpha > 1$ , the relative gradient weight is $0 \leq w _ { \nabla _ { r } } < 1$ for $0 \leq I o U < \alpha ^ { \frac { 1 } { 1 - \alpha } }$ , while $1 \leq w _ { \nabla _ { r } } \leq \alpha$ for $\alpha ^ { \frac { 1 } { 1 - \alpha } } \leq \hat { I o U } \leq 1$ , as analyzed in Property 3 and illustrated in Figure 1 (right). This property helps tune down the gradients of low IoU objects at the early training stage, which has a smoothing effect (reduces the high variance in parameter update caused by hard examples) that helps stabilize the model training when gradients are large at the early stage. On the other hand, the gradient up-weighting is well-bounded by $w _ { \nabla _ { r } } \leq \alpha$ , which makes up-weighting relatively safe for high IoU objects, as the original loss and gradient are small for these examples, so is the learning rate.
 Figure 4: Example results on the test set of PASCAL VOC 2007 using YOLOv5s trained by ${ \mathcal { L } } _ { \mathrm { I o U } }$ (top row) and ${ \mathcal { L } } _ { \alpha - { \mathrm { I o U } } }$ with $\alpha = 3$ (bottom row). ${ \mathcal { L } } _ { \alpha - { \mathrm { I o U } } }$ performs better than ${ \mathcal { L } } _ { \mathrm { I o U } }$ because it can localize objects more accurately (image 1 and 2), thus can detect more true positive objects (image 3 to 5) and fewer false positive objects (image 6 and 7).
 Figure 5: Example results on the val set of MS COCO 2017 using YOLOv5s trained by ${ \mathcal { L } } _ { \mathrm { I o U } }$ (top row) and ${ \mathcal { L } } _ { \alpha - { \mathrm { I o U } } }$ with $\alpha = 3$ (bottom row). ${ \mathcal { L } } _ { \alpha }$ -IoU performs better than ${ \mathcal { L } } _ { \mathrm { I o U } }$ because it can localize objects more accurately (image 1), thus can detect more true positive objects (image 2 to 5) and fewer false positive objects (image 4 to 7). Note that ${ \mathcal { L } } _ { \alpha - { \mathrm { I o U } } }$ detects both more true positive and fewer false positive objects in image 4 and 5 than ${ \mathcal { L } } _ { \mathrm { I o U } }$ .
We also conduct an experiment to compare our $\alpha$ -IoU with a set of existing IoU-based losses in training a popular two-stage anchor-based model, Faster R-CNN (ResNet-50-FPN). In Table 2, results at the top are reproduced using the MMDetection toolbox [6] while those in the middle are reported results in the original papers [43, 41, 23]. Results at the bottom are obtained by replacing existing losses with their $\alpha$ -IoU versions (i.e., improve based on top results using MMDetection). The results on MS COCO demonstrate that $\alpha$ -IoU losses are quite competitive compared with existing baselines in terms of both mAP and $\mathrm { m A P _ { 7 5 : 9 5 } }$ . Note that the Autoloss searches both the classification loss and the localization loss, thus taking a huge amount of searching time [23]. In contrast, $\alpha$ -IoU losses only need an easy modification of the localization loss and win the Autoloss without causing any additional computational overhead.
# 4.3 Robustness to Noisy Bounding Boxes
It happens quite often that people annotate inaccurate bboxes in images/videos as the ground truth, even with computer-assisted annotation tools. However, there is little work on the robustness of localization losses to noisy bboxes, even though a number of methods have been proposed for robust learning with noisy labels, anchors, and bboxes [27, 26, 12, 10, 15, 37, 38, 25, 19, 20]. Here, we fill this gap by conducting a set of experiments to evaluate the robustness of different localization losses to noisy bboxes. We show that $\alpha$ -IoU is more robust to noisy bboxes as they focus less on the low IoU objects, creating a suppression effect on the learning of the noisy bbox examples. Considering that open datasets like PASCAL VOC and MS COCO are carefully annotated, we synthesize a set of common noisy bboxes by perturbing normalized bboxes in the entire training set. The perturbations follow a uniform noise distribution in $[ - \eta w , \eta w ]$ at horizontal coordinates $\scriptstyle { \dot { x } }$ and $w$ ) and $[ - \eta h , \eta h ]$ at vertical coordinates $y$ and $h$ ), where $\eta$ is the noise rate [20]. We then constrain all the noisy bboxes by the following boundary conditions:
$$0 < w < 1 , ~ 0 < h < 1 , ~ \frac { 1 } { 2 } w \leq x \leq 1 - \frac { 1 } { 2 } w , ~ \frac { 1 } { 2 } h \leq y \leq 1 - \frac { 1 } { 2 } h .$$
Table 2: The performance of Faster R-CNN (ResNet-50-FPN) with $1 \times$ schedule and single scale training on MS COCO using different localization losses. Results are obtained on the val set of MS COCO 2017. mAP denotes $\mathrm { m A P _ { 5 0 : 9 5 } }$ ; $\mathrm { m A P _ { 7 5 : 9 5 } }$ denotes the mean AP over $\mathsf { A P } _ { 7 5 }$ , $\mathbf { A P } _ { 8 0 } , \cdot \cdot \cdot , \mathbf { A P } _ { 9 5 }$ . $\mathsf { A P } _ { s }$ , $\mathsf { A P } _ { m }$ , and $\mathsf { A P } _ { l }$ denote the AP for small, medium, and large objects, respectively. † marks the reproduced results from the MMDetection toolbox [6], while ∗ marks the results in the original papers. "–" represents the missing results in papers. $\alpha = 3$ is used for all $\alpha$ -IoU losses in all experiments. The top two best results in every column are boldfaced.
<table><tr><td>Loss</td><td>AP50</td><td>AP75</td><td>AP80</td><td>AP85</td><td>AP90</td><td>AP95</td><td>mAP</td><td>mAP75:95|</td><td>APs</td><td>APm</td><td>APt</td></tr><tr><td>+e1</td><td>58.13</td><td>40.45</td><td>33.56</td><td>23.39</td><td>11.09</td><td>1.24</td><td>37.37</td><td>21.95</td><td>21.20</td><td>40.96</td><td>48.13</td></tr><tr><td>LIoU</td><td>58.12</td><td>41.23</td><td>34.03</td><td>24.43</td><td>12.42</td><td>1.61</td><td>37.88</td><td>22.74</td><td>21.61</td><td>41.63</td><td>49.11</td></tr><tr><td>LGIoU</td><td>58.18</td><td>41.00</td><td>33.52</td><td>24.13</td><td>11.97</td><td>1.51</td><td>37.62</td><td>22.43</td><td>21.49</td><td>41.07</td><td>48.90</td></tr><tr><td>+LBIoU</td><td>58.05</td><td>40.57</td><td>33.54</td><td>23.85</td><td>11.10</td><td>1.19</td><td>37.43</td><td>22.05</td><td>21.57</td><td>41.00</td><td>48.17</td></tr><tr><td>*LIoU</td><td>/</td><td>40.79</td><td>/</td><td></td><td>1</td><td>1</td><td>37.93</td><td></td><td>21.58</td><td>40.82</td><td>50.14</td></tr><tr><td>*LGIoU</td><td>1</td><td>41.11</td><td></td><td></td><td>1</td><td></td><td>38.02</td><td></td><td>21.45</td><td>41.06</td><td>50.21</td></tr><tr><td>*LDIoU</td><td>1</td><td>41.11</td><td></td><td></td><td>1</td><td>1</td><td>38.09</td><td>1</td><td>21.66</td><td>41.18</td><td>50.32</td></tr><tr><td>*LCIoU</td><td>1</td><td>41.96</td><td></td><td></td><td></td><td></td><td>38.65</td><td></td><td>21.32</td><td>41.83</td><td>51.51</td></tr><tr><td>*LFocal-EIoU</td><td>59.10</td><td>42.40</td><td></td><td></td><td></td><td></td><td>38.90</td><td></td><td>21.20</td><td>41.10</td><td>50.20</td></tr><tr><td>*Autoloss</td><td>58.60</td><td>41.80</td><td>1</td><td>一</td><td>1</td><td>1</td><td>38.50</td><td>1</td><td>22.00</td><td>42.20</td><td>50.20</td></tr><tr><td>Lα-IoU</td><td>58.81</td><td>41.94</td><td>34.81</td><td>25.36</td><td>13.27</td><td>1.81</td><td>38.96</td><td>23.44</td><td>22.14</td><td>42.11</td><td>50.36</td></tr><tr><td>La-GloU</td><td>59.01</td><td>42.00</td><td>35.13</td><td>25.14</td><td>13.09</td><td>2.03</td><td>39.18</td><td>23.46</td><td>22.05</td><td>42.19</td><td>50.08</td></tr><tr><td>Lα-DIoU</td><td>59.27</td><td>42.18</td><td>35.25</td><td>25.47</td><td>13.32</td><td>1.95</td><td>39.43</td><td>23.65</td><td>22.10</td><td>42.10</td><td>50.43</td></tr><tr><td>La-CloU</td><td>59.09</td><td>41.92</td><td>35.01</td><td>25.08</td><td>13.04</td><td>1.98</td><td>39.25</td><td>23.41</td><td>21.94</td><td>41.88</td><td>50.01</td></tr></table>
Table 3: The performance of YOLOv5s trained using different localization losses on simulated noisy trainval sets of PASCAL VOC $2 0 0 7 { + } 2 0 1 2$ under noise rates $\eta = 0 . 1 , 0 . 2$ , and 0.3. Results are obtained on the clean test set of PASCAL VOC 2007. mAP denotes $\mathrm { m A P _ { 5 0 : 9 5 } }$ ; $\mathrm { m A P _ { 7 5 : 9 5 } }$ denotes the mean AP over $\mathsf { A P } _ { 7 5 }$ , $\mathbf { A P } _ { 8 0 } , \cdot \cdot \cdot , \mathbf { A P } _ { 9 5 }$ . "rela. improv." stands for the relative improvement. $\alpha = 3$ is used for all $\alpha$ -IoU losses in all experiments.
<table><tr><td>Noise</td><td>Loss</td><td>AP50</td><td>AP55</td><td>AP60</td><td>AP65</td><td>AP70</td><td>AP75</td><td>AP80</td><td>AP85</td><td>AP90</td><td>AP95</td><td>mAP</td><td>mAP75:95</td></tr><tr><td rowspan="6">0.1</td><td>LIoU La-IoU</td><td>74.48 74.67</td><td>71.57 71.94</td><td>68.08 68.73</td><td>63.29 64.27</td><td>56.55 57.75</td><td>47.12 48.50</td><td>33.06 36.88</td><td>17.53 21.25</td><td>4.16 6.30</td><td>0.26 0.28</td><td>43.61 45.06</td><td>20.43</td></tr><tr><td>rela. improv.</td><td>0.26%</td><td>0.52%</td><td>0.95%</td><td>1.55%</td><td>2.12%</td><td>2.93%</td><td>11.55%</td><td>21.22%</td><td>51.44%</td><td>7.69%</td><td>3.32%</td><td>22.64 10.85%</td></tr><tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>LDIoU</td><td>74.09</td><td>71.46</td><td>67.88</td><td>63.09</td><td>56.18</td><td>46.71</td><td>32.67</td><td>17.50</td><td>4.43</td><td>0.23</td><td>43.42</td><td>20.31</td></tr><tr><td>La-DloU</td><td>74.38</td><td>71.95</td><td>68.10</td><td>63.52</td><td>57.18</td><td>48.47</td><td>35.90</td><td>20.89</td><td>6.37</td><td>0.33</td><td>44.71</td><td>22.39</td></tr><tr><td>rela. improv.</td><td>0.39%</td><td>0.69%</td><td>0.32%</td><td>0.68%</td><td>1.78%</td><td>3.77%</td><td>9.89%</td><td>19.37%</td><td>43.79%</td><td>43.48%</td><td>2.97%</td><td>10.26%</td></tr><tr><td rowspan="6">0.2</td><td>LIoU La-loU</td><td>67.82</td><td>63.93</td><td>58.22</td><td>50.11</td><td>39.31</td><td>26.33</td><td>13.51</td><td>4.55</td><td>0.66</td><td>0.05</td><td>32.45</td><td>9.02</td></tr><tr><td></td><td>68.20</td><td>64.21</td><td>58.77</td><td>51.59</td><td>40.66</td><td>29.20</td><td>16.11</td><td>6.06</td><td>1.31</td><td>0.10</td><td>33.62</td><td>10.56</td></tr><tr><td>rela. improv.</td><td>0.56%</td><td>0.44%</td><td>0.94%</td><td>2.95%</td><td>3.43%</td><td>10.90%</td><td>19.25%</td><td>33.19%</td><td>98.48%</td><td>100%</td><td>3.61%</td><td>17.03%</td></tr><tr><td>LDIoU</td><td>67.39</td><td>62.94</td><td>57.29</td><td>49.25</td><td>39.40</td><td>27.13</td><td>13.78</td><td>4.52</td><td>0.68</td><td>0.02</td><td>32.24</td><td>9.23</td></tr><tr><td>La-DloU</td><td>68.26</td><td>64.49</td><td>59.59</td><td>51.99</td><td>41.19</td><td>29.12</td><td>15.77</td><td>5.84</td><td>1.25</td><td>0.21</td><td>33.77</td><td>10.44</td></tr><tr><td>rela.improv.</td><td>1.29%</td><td>2.46%</td><td>4.01%</td><td>5.56%</td><td>4.54%</td><td>7.34%</td><td>14.44%</td><td>29.20%</td><td>83.82%</td><td>950%</td><td>4.75%</td><td>13.14%</td></tr><tr><td rowspan="6">0.3</td><td>LIoU La-IoU</td><td>56.54</td><td>49.69</td><td>40.67</td><td>30.80</td><td>19.99</td><td>11.13</td><td>4.81</td><td>1.43</td><td>0.31</td><td>0.04</td><td>21.54</td><td>3.54</td></tr><tr><td></td><td>58.59</td><td>51.58</td><td>43.23</td><td>32.93</td><td>22.27</td><td>12.52</td><td>5.91</td><td>2.16</td><td>0.73</td><td>0.12</td><td>23.00</td><td>4.29</td></tr><tr><td>rela. improv.</td><td>3.63%</td><td>3.80%</td><td>6.29%</td><td>6.92%</td><td>11.41%</td><td>12.49%</td><td>22.87%</td><td>51.05%</td><td>135%</td><td>200%</td><td>6.78%</td><td>20.99%</td></tr><tr><td>LDIoU</td><td>56.84</td><td>49.82</td><td>41.50</td><td></td><td>20.80</td><td>11.22</td><td>4.84</td><td>1.51</td><td>0.46</td><td></td><td></td><td></td></tr><tr><td></td><td>58.45</td><td>51.94</td><td>43.9</td><td>32.06 33.78</td><td>22.57</td><td>12.89</td><td>6.34</td><td>2.42</td><td>0.65</td><td>0.07</td><td>21.91 23.31</td><td>3.62 4.49</td></tr><tr><td>La-DIoU rela. improv.</td><td>2.83%</td><td>4.26%</td><td>5.78%</td><td>5.36%</td><td>8.51%</td><td>14.88%</td><td>30.99%</td><td>60.26%</td><td>41.30%</td><td>0.16 129%</td><td>6.39%</td><td>24.09%</td></tr></table>
We test $\eta = 0 . 1 , 0 . 2 , 0 . 3$ in our experiments, with the average IoU between the noisy bboxes and their clean versions dropping to 0.833, 0.710, and 0.613, respectively. Examples of the synthesized noisy bboxes can be found in Appendix B.4. As shown in Table 3, $\alpha$ -IoU improves the baseline losses (i.e., ${ \mathcal { L } } _ { \mathrm { I o U } }$ and ${ \mathcal { L } } _ { \mathrm { { D I o U } } } ,$ ) considerably in these noisy scenarios. We gain increasing relative improvements from $\mathrm { { A P } _ { 5 0 } }$ to $\mathsf { A P } _ { 9 5 }$ , which accumulate to a more significant improvement in $\mathrm { m A P _ { 7 5 : 9 5 } }$ . Note that $\alpha$ -IoU losses also outperform the baselines at $\mathrm { { A P } _ { 5 0 } }$ across all noisy scenarios, which is not always the case when bboxes are clean (Table 1). Furthermore, $\alpha$ -IoU losses are noticeably more robust against more severe noises. For instance, the relative improvement of $\mathcal { L } _ { \alpha \mathrm { - D I o U } }$ over ${ \mathcal { L } } _ { \mathrm { D I o U } }$ increases from $2 . 9 7 \% / 1 0 . 2 6 \%$ to $6 . 3 9 \% / 2 4 . 0 9 \%$ according to $\mathrm { m A P / m A P _ { 7 5 : 9 5 } }$ when the noise rate $\eta$ rises from 0.1 to 0.3. These results confirm the advantage of $\alpha$ -IoU losses in noisy bbox scenarios.
 Figure 6: The performance of YOLOv5 models trained using $\alpha$ -IoU with different $\alpha$ values and evaluated on the clean test set of PASCAL VOC 2007. Black dashed lines denote baselines (i.e., the family of $\alpha$ -IoU with $\alpha = 1$ ) while red dashed lines denote the family of $\alpha$ -IoU with $\alpha = 3$ .
# 4.4 Sensitivity to power parameter $\alpha$
Here, we evaluate the performance of $\alpha$ -IoU with varying $\alpha$ values $( \alpha \in [ 0 . 5 , 5 ] )$ ) via a set of experiments with ${ \mathcal { L } } _ { \alpha - { \mathrm { I o U } } }$ and $\mathcal { L } _ { \alpha - \mathrm { D I o U } }$ . The results are shown in Figure 6 for YOLOv5s on PASCAL VOC in both clean and various noisy bbox scenarios. It is evident that $\alpha$ -IoU losses with $\alpha \in [ 2 , 4 ]$ perform competitively well across all scenarios, with $\alpha = 3$ performing the best in most cases. When $\alpha > 3$ , $\alpha$ -IoU losses tend to perform worse on low APs than the baselines (i.e., $\alpha$ -IoU with $\alpha = 1 \AA$ ), although the performance at high APs gains more improvement. We also test an extreme case with $\alpha = 1 0$ , in which the performance drops by $5 . 6 1 \% / 1 \dot { 0 } . 9 2 \% / 2 3 . 8 8 \% / 3 1 . 8 2 \%$ on average compared with $\alpha = 3$ under noise rates $\eta = 0 / 0 . 1 / 0 . 2 / 0 . 3$ , respectively. More specifically, it becomes worse than the baselines according to either mAP or $\mathrm { m A P _ { 7 5 : 9 5 } }$ . This indicates that a proper choice of $\alpha$ is crucial for $\alpha$ -IoU losses. Our recommendation is to tune $\alpha \in [ 2 , 3 ]$ for most applications or directly use $\alpha = 3$ when tuning is too expensive. Note that $\alpha \in [ 3 , 4 ]$ may be a better choice when high levels of bbox regression accuracy is desired, e.g., $\mathrm { m A P _ { 7 5 : 9 5 } }$ is the preferred performance metric. It is possible that $\alpha < 1$ is a better choice for certain applications, although $\alpha$ -IoU losses with $\alpha < 1$ perform consistently worse than the baselines in our experiments.
# 5 Conclusions
In this paper, we proposed a unified formula $\alpha$ -IoU to generalize existing IoU-based losses to a new family of power IoU losses. By modulating the power parameter $\alpha$ , $\alpha$ -IoU offers the flexibility to achieve different levels of bbox regression accuracy when training an object detector. We analyzed the order preservingness and the loss/gradient reweighting properties of $\alpha$ -IoU, and showed that $\alpha$ -IoU can improve bbox regression accuracy through up-weighting the loss and gradient of high IoU objects. Experiments with multiple detection models and benchmark datasets demonstrated that $\alpha$ -IoU losses can consistently outperform existing IoU-based losses, especially at the high Average Precisions (APs). $\alpha$ -IoU has the potential to be widely applied in real-world object detection applications as 1) it improves existing IoU-based losses, 2) it benefits light models, 3) it is extremely advantageous on small datasets, and 4) it is more robust to noisy bboxes. For future work, we will explore new generalization formulas for other metric-derived loss functions [13], such as Dice, Hausdorff distance, and Chamfer distance losses.
# Societal Impacts
The proposed loss functions can help train high-performance object detectors for impactful applications such as self-driving, face recognition and video surveillance. While not our initial intention, these models could potentially be manipulated by adversaries or unauthorized users for malicious purposes. This could compromise the safety or privacy of certain individuals. We believe strict regulations should be established to prevent such illegitimate exploitations.
# References
[1] A. Bochkovskiy, C.-Y. Wang, and H.-Y. M. Liao. Yolov4: Optimal speed and accuracy of object detection. arXiv preprint arXiv:2004.10934, 2020. [2] G. E. Box and D. R. Cox. An analysis of transformations. Journal of the Royal Statistical Society: Series B (Methodological), 26(2):211–243, 1964. [3] Z. Cai and N. Vasconcelos. Cascade r-cnn: Delving into high quality object detection. In CVPR, pages 6154–6162, 2018. [4] N. Carion, F. Massa, G. Synnaeve, N. Usunier, A. Kirillov, and S. Zagoruyko. End-to-end object detection with transformers. In ECCV, pages 213–229. Springer, 2020. [5] K. Chen, J. Pang, J. Wang, Y. Xiong, X. Li, S. Sun, W. Feng, Z. Liu, J. Shi, W. Ouyang, et al. Hybrid task cascade for instance segmentation. In CVPR, pages 4974–4983, 2019. [6] K. Chen, J. Wang, J. Pang, Y. Cao, Y. Xiong, X. Li, S. Sun, W. Feng, Z. Liu, J. Xu, et al. Mmdetection: Open mmlab detection toolbox and benchmark. arXiv preprint arXiv:1906.07155, 2019. [7] Z. Dong, G. Li, Y. Liao, F. Wang, P. Ren, and C. Qian. Centripetalnet: Pursuing high-quality keypoint pairs for object detection. In CVPR, pages 10519–10528, 2020. [8] K. Duan, S. Bai, L. Xie, H. Qi, Q. Huang, and Q. Tian. Centernet: Keypoint triplets for object detection. In ICCV, pages 6569–6578, 2019. [9] M. Everingham, L. Van Gool, C. K. Williams, J. Winn, and A. Zisserman. The pascal visual object classes (voc) challenge. IJCV, 88(2):303–338, 2010. [10] J. Gao, J. Wang, S. Dai, L.-J. Li, and R. Nevatia. Note-rcnn: Noise tolerant ensemble rcnn for semi-supervised object detection. In ICCV, pages 9508–9517, 2019. [11] R. Girshick. Fast r-cnn. In ICCV, pages 1440–1448, 2015. [12] B. Han, Q. Yao, X. Yu, G. Niu, M. Xu, W. Hu, I. W. Tsang, and M. Sugiyama. Co-teaching: Robust training of deep neural networks with extremely noisy labels. In NeurIPS, 2018. [13] J. He, S. Erfani, S. Wijewickrema, S. O’Leary, and K. Ramamohanarao. Learning non-unique segmentation with reward-penalty dice loss. In IJCNN, pages 1–8. IEEE, 2020. [14] K. He, G. Gkioxari, P. Dollár, and R. Girshick. Mask r-cnn. In ICCV, pages 2961–2969, 2017. [15] M. Khodabandeh, A. Vahdat, M. Ranjbar, and W. G. Macready. A robust learning approach to domain adaptive object detection. In ICCV, pages 480–490, 2019. [16] H. Law and J. Deng. Cornernet: Detecting objects as paired keypoints. In ECCV, pages 734–750, 2018. [17] H. Li, T. Fu, J. Dai, H. Li, G. Huang, and X. Zhu. Autoloss-zero: Searching loss functions from scratch for generic tasks. arXiv preprint arXiv:2103.14026, 2021. [18] H. Li, C. Tao, X. Zhu, X. Wang, G. Huang, and J. Dai. Auto seg-loss: Searching metric surrogates for semantic segmentation. arXiv preprint arXiv:2010.07930, 2020. [19] H. Li, Z. Wu, C. Zhu, C. Xiong, R. Socher, and L. S. Davis. Learning from noisy anchors for one-stage object detection. In CVPR, pages 10588–10597, 2020. [20] J. Li, C. Xiong, R. Socher, and S. Hoi. Towards noise-resistant object detection with noisy annotations. arXiv preprint arXiv:2003.01285, 2020. [21] T.-Y. Lin, P. Goyal, R. Girshick, K. He, and P. Dollár. Focal loss for dense object detection. In ICCV, pages 2980–2988, 2017. [22] T.-Y. Lin, M. Maire, S. Belongie, J. Hays, P. Perona, D. Ramanan, P. Dollár, and C. L. Zitnick. Microsoft coco: Common objects in context. In ECCV, pages 740–755. Springer, 2014. [23] P. Liu, G. Zhang, B. Wang, H. Xu, X. Liang, Y. Jiang, and Z. Li. Loss function discovery for object detection via convergence-simulation driven search. arXiv preprint arXiv:2102.04700, 2021. [24] W. Liu, D. Anguelov, D. Erhan, C. Szegedy, S. Reed, C.-Y. Fu, and A. C. Berg. Ssd: Single shot multibox detector. In ECCV, pages 21–37. Springer, 2016. [25] X. Ma, H. Huang, Y. Wang, S. Romano, S. Erfani, and J. Bailey. Normalized loss functions for deep learning with noisy labels. In ICML, pages 6543–6553. PMLR, 2020. [26] X. Ma, Y. Wang, M. E. Houle, S. Zhou, S. Erfani, S. Xia, S. Wijewickrema, and J. Bailey. Dimensionality-driven learning with noisy labels. In ICML, pages 3355–3364. PMLR, 2018. [27] N. Natarajan, I. S. Dhillon, P. K. Ravikumar, and A. Tewari. Learning with noisy labels. NeurIPS, 26:1196–1204, 2013. [28] M. A. Rahman and Y. Wang. Optimizing intersection-over-union in deep neural networks for image segmentation. In ISVC, pages 234–244. Springer, 2016. [29] J. Redmon and A. Farhadi. Yolo9000: better, faster, stronger. In CVPR, pages 7263–7271, 2017. [30] J. Redmon and A. Farhadi. Yolov3: An incremental improvement. arXiv preprint arXiv:1804.02767, 2018. [31] S. Ren, K. He, R. Girshick, and J. Sun. Faster r-cnn: Towards real-time object detection with region proposal networks. arXiv preprint arXiv:1506.01497, 2015. [32] H. Rezatofighi, N. Tsoi, J. Gwak, A. Sadeghian, I. Reid, and S. Savarese. Generalized intersection over union: A metric and a loss for bounding box regression. In CVPR, pages 658–666, 2019. [33] G. Song, Y. Liu, and X. Wang. Revisiting the sibling head in object detector. In CVPR, pages 11563–11572, 2020. [34] Z. Tian, C. Shen, H. Chen, and T. He. Fcos: Fully convolutional one-stage object detection. In ICCV, pages 9627–9636, 2019. [35] L. Tychsen-Smith and L. Petersson. Improving object localization with fitness nms and bounded iou loss. In CVPR, pages 6877–6885, 2018. [36] K. Wang and L. Zhang. Single-shot two-pronged detector with rectified iou loss. In Proceedings of the 28th ACM International Conference on Multimedia, pages 1311–1319, 2020. [37] Y. Wang, X. Ma, Z. Chen, Y. Luo, J. Yi, and J. Bailey. Symmetric cross entropy for robust learning with noisy labels. In ICCV, pages 322–330, 2019. [38] Z. Wang, L. Liu, and D. Tao. Deep streaming label learning. In ICML, pages 9963–9972. PMLR, 2020. [39] J. Yu, Y. Jiang, Z. Wang, Z. Cao, and T. Huang. Unitbox: An advanced object detection network. In Proceedings of the 24th ACM international conference on Multimedia, pages 516–520, 2016. [40] S. Zhang, C. Chi, Y. Yao, Z. Lei, and S. Z. Li. Bridging the gap between anchor-based and anchor-free detection via adaptive training sample selection. In CVPR, pages 9759–9768, 2020. [41] Y.-F. Zhang, W. Ren, Z. Zhang, Z. Jia, L. Wang, and T. Tan. Focal and efficient iou loss for accurate bounding box regression. arXiv preprint arXiv:2101.08158, 2021. [42] Z. Zhang and M. R. Sabuncu. Generalized cross entropy loss for training deep neural networks with noisy labels. In NeurIPS, 2018. [43] Z. Zheng, P. Wang, W. Liu, J. Li, R. Ye, and D. Ren. Distance-iou loss: Faster and better learning for bounding box regression. In AAAI, pages 12993–13000, 2020. [44] X. Zhou, D. Wang, and P. Krähenbühl. Objects as points. arXiv preprint, arXiv:1904.07850, 2019. [45] X. Zhou, J. Zhuo, and P. Krahenbuhl. Bottom-up object detection by grouping extreme and center points. In CVPR, pages 850–859, 2019. [46] X. Zhu, W. Su, L. Lu, B. Li, X. Wang, and J. Dai. Deformable detr: Deformable transformers for end-to-end object detection. arXiv preprint arXiv:2010.04159, 2020.123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344# BEYOND FULLY-CONNECTED LAYERS WITH QUATERNIONS: PARAMETERIZATION OF HYPERCOMPLEX MULTIPLICATIONS WITH $1 / n$ PARAMETERS
Aston Zhang†, Yi Tay‡∗, Shuai Zhang, Alvin Chan/ Anh Tuan Luu/,◦, Siu Cheung $\mathbf { H u i } ^ { \mathrm { q } }$ , Jie $\mathbf { F u } ^ { \bullet }$ †Amazon Web Services AI ‡Google Research ETH Zurich¨ /NTU, Singapore ◦VinAI •Mila, Universite de Montr ´ eal ´ az@astonzhang.com
# ABSTRACT
Recent works have demonstrated reasonable success of representation learning in hypercomplex space. Specifically, “fully-connected layers with quaternions” (quaternions are 4D hypercomplex numbers), which replace real-valued matrix multiplications in fully-connected layers with Hamilton products of quaternions, both enjoy parameter savings with only $1 / 4$ learnable parameters and achieve comparable performance in various applications. However, one key caveat is that hypercomplex space only exists at very few predefined dimensions (4D, 8D, and 16D). This restricts the flexibility of models that leverage hypercomplex multiplications. To this end, we propose parameterizing hypercomplex multiplications, allowing models to learn multiplication rules from data regardless of whether such rules are predefined. As a result, our method not only subsumes the Hamilton product, but also learns to operate on any arbitrary $n \mathbf { D }$ hypercomplex space, providing more architectural flexibility using arbitrarily $1 / n$ learnable parameters compared with the fully-connected layer counterpart. Experiments of applications to the LSTM and transformer models on natural language inference, machine translation, text style transfer, and subject verb agreement demonstrate architectural flexibility and effectiveness of the proposed approach.
# 1 INTRODUCTION
A quaternion is a 4D hypercomplex number with one real component and three imaginary components. The Hamilton product is the hypercomplex multiplication of two quaternions. Recent works in quaternion space and Hamilton products have demonstrated reasonable success (Parcollet et al., 2018b; 2019; Tay et al., 2019). Notably, the Hamilton product enjoys a parameter saving with $1 / 4$ learnable parameters as compared with the real-valued matrix multiplication. It also enables effective representation learning by modeling interactions between real and imaginary components.
One of the attractive properties of quaternion models is its high applicability and universal usefulness to one of the most ubiquitous layers in deep learning, i.e., the fully-connected (or feedforward) layer. Specifically, “fully-connected layers with quaternions” replace real-valued matrix multiplications in fully-connected layers with Hamilton products of quaternions, enjoying parameter savings with only $1 / 4$ learnable parameters and achieving comparable performance with their fully-connected layer counterparts (Parcollet et al., 2018b; 2019; Tay et al., 2019).
The fully-connected layer is one of the most dominant components in existing deep learning literature (Goodfellow et al., 2016; Zhang et al., 2020). Its pervasiveness cannot be understated, given its centrality to many core building blocks in neural network research. Given widespread adoptions of fully-connected layers, e.g., within LSTM networks (Hochreiter & Schmidhuber, 1997) and transformer models (Vaswani et al., 2017), having flexibility to balance between parameter savings and effectiveness could be extremely useful to many real-world applications.
Unfortunately, hypercomplex space only exists at 4D (quaternions), 8D (octonions), and 16D (sedenions), which generalizes the 2D complex space (Rishiyur, 2006). Moreover, custom operators are required at each hypercomplex dimensionality. For instance, the Hamilton product is the hypercomplex multiplication in 4D hypercomplex space. Thus, no operator in such predefined hypercomplex space is suitable for applications that prefer reducing parameters to $1 / n$ , where $n \neq 4 , 8 , 1 6$ .
In view of the architectural limitation due to the very few choices of those existing hypercomplex space, we propose parameterization of hypercomplex multiplications, i.e., learning the real and imaginary component interactions from data in a differentiable fashion. Essentially, our method can operate on an arbitrary $n \mathbf { D }$ hypercomplex space, aside from subsuming those predefined hypercomplex multiplication rules, facilitating using up to arbitrarily $1 / n$ learnable parameters while maintaining expressiveness. In practice, the hyperparameter $n$ can be flexibly specified or tuned by users based on applications.
Concretely, our prime contribution is a new module that parameterizes and generalizes the hypercomplex multiplication by learning the real and imaginary component interactions, i.e., multiplication rules, from data. Our method, which we call the parameterized hypercomplex multiplication layer, is characterized by a sum of Kronecker products that generalize the vector outer products to higher dimensions in real space. To demonstrate applicability, we equip two well-established models (the LSTM and transformer) with our proposed method. We conduct extensive experiments on different tasks, i.e., natural language inference for LSTM networks and machine translation for transformer models. Additionally, we perform further experiments on text style transfer and subject verb agreement tasks. All in all, our method has demonstrated architectural flexibility through different experimental settings, where it generally can use a fraction of the learnable parameters with minimal degradation or slight improvement in performance.
The overall contributions of this work are summarized as follows:
We propose a new parameterization of hypercomplex multiplications: the parameterized hypercomplex multiplication (PHM) layer. This layer has $1 / n$ learnable parameters compared with the fully-connected layer counterpart, where $n$ can be flexibly specified by users. The key idea behind PHM layers is to learn the interactions between real and imaginary components, i.e., multiplication rules, from data using a sum of Kronecker products. We demonstrate the applicability of the PHM layers by leveraging them in two dominant neural architectures: the LSTM and transformer models. We empirically show architectural flexibility and effectiveness of PHM layers by conducting extensive experiments on five natural language inference tasks, seven machine translation datasets, together with text style transfer and subject verb agreement tasks.
# 2 BACKGROUND ON QUATERNIONS AND HAMILTON PRODUCTS
We begin by introducing the background for the rest of the paper. Concretely, we describe quaternion algebra along with Hamilton products, which is at the heart of our proposed approach.
Quaternion A quaternion $Q \in \mathbb { H }$ is a hypercomplex number with one real component and three imaginary components as follows:
$$Q = Q _ { r } + Q _ { x } { \bf i } + Q _ { y } { \bf j } + Q _ { z } { \bf k } ,$$
whereby $\mathbf { i j k } = \mathbf { i } ^ { 2 } = \mathbf { j } ^ { 2 } = \mathbf { k } ^ { 2 } = { \mathbf { - } } 1$ . In (2.1), noncommutative multiplication rules hold: $\mathbf { i } \mathbf { j } =$ $\mathbf { k } , \mathbf { j } \mathbf { k } = \mathbf { i } , \mathbf { k } \mathbf { i } = \mathbf { j } , \mathbf { j } \mathbf { i } = - \mathbf { k } , \mathbf { k } \mathbf { j } = - \mathbf { i } , \mathbf { i } \mathbf { k } = - \mathbf { j } .$ Here, $Q _ { r }$ is the real component, $Q _ { x } , Q _ { y } , Q _ { z }$ are real numbers that represent the imaginary components of the quaternion $Q$ .
Addition The addition of two quaternions is defined as
$$Q + P = Q _ { r } + P _ { r } + ( Q _ { x } + P _ { x } ) \mathbf { i } + ( Q _ { y } + P _ { y } ) \mathbf { j } + ( Q _ { z } + P _ { z } ) \mathbf { k } ,$$
here $Q$ and $P$ with subscripts denote the real and imaginary components of quaternions $Q$ and
Scalar Multiplication Any scalar $\alpha$ multiplies across all the components:
$$\alpha Q = \alpha Q _ { r } + \alpha Q _ { x } { \bf i } + \alpha Q _ { y } { \bf j } + \alpha Q _ { z } { \bf k } .$$
Hamilton Product The Hamilton product, which represents the multiplication of two quaternions $Q$ and $P$ , is defined as
$$\begin{array} { r l } & { Q \otimes P = ( Q _ { r } P _ { r } - Q _ { x } P _ { x } - Q _ { y } P _ { y } - Q _ { z } P _ { z } ) + ( Q _ { x } P _ { r } + Q _ { r } P _ { x } - Q _ { z } P _ { y } + Q _ { y } P _ { z } ) \mathbf { i } } \\ & { \qquad + ( Q _ { y } P _ { r } + Q _ { z } P _ { x } + Q _ { r } P _ { y } - Q _ { x } P _ { z } ) \mathbf { j } + ( Q _ { z } P _ { r } - Q _ { y } P _ { x } + Q _ { x } P _ { y } + Q _ { r } P _ { z } ) \mathbf { k } . } \end{array}$$
The multiplication rule in (2.2) forges interactions between real and imaginary components of $Q$ and $P$ . The benefits of Hamilton products have been demonstrated in recent works where the matrix multiplication in fully-connected layers is replaced with the Hamilton product: this reduces $7 5 \%$ parameters with comparable performance (Parcollet et al., 2018b; 2019; Tay et al., 2019).
# 3 PARAMETERIZATION OF HYPERCOMPLEX MULTIPLICATIONS
The following introduces our proposed parameterized hypercomplex multiplication layer and elaborates on how it parameterizes and generalizes multiplications in hypercomplex space, such as subsuming the multiplication rules of Hamilton products in (2.2).
# 3.1 FULLY-CONNECTED (FC) LAYERS
Before we delve into our proposed method, recall the fully-connected (FC) layer that transforms an input $\mathbf { x } \in \mathbb { R } ^ { d }$ into an output $\mathbf { \hat { y } } \in \mathbb { R } ^ { k }$ by
$$\begin{array} { r } { \mathbf { y } = \operatorname { F C } ( \mathbf { x } ) = \mathbf { W } \mathbf { x } + b , } \end{array}$$
where the weight matrix of parameters $\mathbf { W } \in \mathbb { R } ^ { k \times d }$ and the bias vector of parameters $\mathbf { b } \in \mathbb { R } ^ { k }$ . The FC layer in (3.1) is fundamental to many modern and traditional neural network architectures. Note that the degree of freedom for the weight parameters $\mathbf { W }$ in (3.1) is $k d$ . Since W dominates parameterization, the parameter size of the FC layer in (3.1) is $\mathcal { O } ( k d )$ .
# 3.2 PARAMETERIZED HYPERCOMPLEX MULTIPLICATION (PHM) LAYERS
We propose the parameterized hypercomplex multiplication (PHM) layer that transforms an input $\mathbf { x }$ into an output y by
$$\mathbf { y } = \mathbf { P H M } ( \mathbf { x } ) = \mathbf { H x } + b ,$$
where the same notation from (3.1) is used but the replaced parameter $\mathbf { H } \in \mathbb { R } ^ { k \times d }$ is constructed by a sum of Kronecker products. For context, the Kronecker product is a generalization of the vector outer product to higher dimensions in real space. For any matrix $\mathbf { X } \in \mathbb { R } ^ { m \times n }$ and $\mathbf { Y } \in \mathbb { R } ^ { p \times q }$ , the Kronecker product $\mathbf { X } \otimes \mathbf { Y }$ is a block matrix:
$$\mathbf { X } \otimes \mathbf { Y } = \left[ \overset { x _ { 1 1 } \mathbf { Y } } { \mathop { : } } \quad \cdots \quad \overset { x _ { 1 n } \mathbf { Y } } { \mathop { : } } \right] \in \mathbb { R } ^ { m p \times n q } ,$$
where $x _ { i j }$ is the element of $\mathbf { X }$ at its $i ^ { \mathrm { { t h } } }$ row and $j ^ { \mathrm { t h } }$ column. Note that the symbol $\otimes$ between two matrices is the Kronecker product while the same symbol between two quaternions means the Hamilton product.
Now let us revisit (3.2) to explain $\mathbf { H }$ . Suppose that both $k$ and $d$ are divisible by a user-defined hyperparameter $n \in \mathbb { Z } _ { > 0 }$ . For $i = 1 , \ldots , n$ , denote by each parameter matrix $\mathbf { A } _ { i } \in \mathbb { R } ^ { n \times n }$ and $\mathbf { S } _ { i } \in \mathbb { R } ^ { \frac { k } { n } \times \frac { d } { n } }$ . The parameter $\mathbf { H }$ in (3.2) is a sum of $n$ Kronecker products:
$$\mathbf { H } = \sum _ { i = 1 } ^ { n } \mathbf { A } _ { i } \otimes \mathbf { S } _ { i } .$$
 Figure 1: Illustration of the PHM layer. It uses a sum of Kronecker products of matrices $\mathbf { A } _ { i }$ and $\mathbf { S } _ { i }$ $( i = 1 , 2 )$ ) to construct $\mathbf { H }$ in (3.2) (here $n = 2 , k = 6 , d = 8 )$ . Best viewed in color.
 Figure 2: PHM layers can learn to perform rotations in 3D real space and Hamilton products in quaternion space on artificial datasets.
As illustrated in Figure 1, it is the parameter matrices $\mathbf { A } _ { i }$ and $\mathbf { S } _ { i }$ $( i = 1 , \ldots , n )$ that determine the degree of freedom for $\mathbf { H }$ , which is $\bar { k } d / n + n ^ { 3 }$ . Since H dominates parameterization, the parameter size of the PHM in (3.2) is $\mathcal { O } ( k d / n )$ , where $k d \gtrapprox n ^ { 4 }$ is assumed: this condition is mild for realworld problems, such as in our experiments (e.g., $d = 5 1 2$ , $k = 2 0 4 8$ , $n = 2 , 4 , 8 , 1 6 )$ ). Thus, for the same input and output sizes, the parameter size of a PHM layer is approximately $1 / n$ of that of an FC layer under mild assumptions.
The benefit of parameterization reduction of PHM layers is due to reusing elements of both parameter matrices $\mathbf { A } _ { i }$ and $\mathbf { S } _ { i }$ in the Kronecker product. As an alternative perspective, we can equivalently reconstruct $\mathbf { H }$ in (3.3) by reusing parameter matrices in real-valued matrix multiplications, followed by more operations. Due to limited space, this more complicated perspective is offered in Appendix A. Though simply setting $\mathbf { H } = \mathbf { A } _ { 1 } \otimes \mathbf { S } _ { 1 }$ can further save parameters, it does not generalize hypercomplex multiplications hence is out of scope.
To show that PHM layers can learn to perform pre-defined multiplication-related operations in practice, we perform experiments to learn rotations in 3D real space using the PHM layer. Using a rotation matrix $\mathbf { W } \in \mathbb { R } ^ { 3 \times 3 }$ we create an artificial dataset $\{ ( \mathbf { x } _ { i } \mathbf { \bar { \epsilon } } ) \mathbf { R } ^ { 3 } , \mathbf { y } _ { i } \mathbf { \bar { \epsilon } } \mathbb { R } ^ { 3 } ) \}$ , where $\mathbf { y } _ { i }$ is generated via the 3D rotation of the input: $\mathbf { y } _ { i } = \mathbf { W } \mathbf { x } _ { i }$ . Figure 2(a) shows that the loss converges to zero: the PHM layer can learn a single rotation of an object in 3D real space.
In the following, we show how the proposed PHM layer subsumes and generalizes both hypercomplex multiplications and real-valued matrix multiplications.
# 3.3 SUBSUMING HYPERCOMPLEX MULTIPLICATIONS
First, we explore how the PHM layer connects to the hypercomplex multiplication. For the sake of illustration, let us take the Hamilton product of two quaternions $Q$ and $P$ in (2.2) as an example,
which can be rewritten as
$$\left[ { \begin{array} { c c c c } { Q _ { r } } & { - Q _ { x } } & { - Q _ { y } } & { - Q _ { z } } \\ { Q _ { x } } & { Q _ { r } } & { - Q _ { z } } & { Q _ { y } } \\ { Q _ { y } } & { Q _ { z } } & { Q _ { r } } & { - Q _ { x } } \\ { Q _ { z } } & { - Q _ { y } } & { Q _ { x } } & { Q _ { r } } \end{array} } \right] \left[ { \begin{array} { c } { P _ { r } } \\ { P _ { x } } \\ { P _ { y } } \\ { P _ { z } } \end{array} } \right] ,$$
where the 4 output elements are the real values for the quaternion unit basis $[ 1 , \mathbf { i } , \mathbf { j } , \mathbf { k } ] ^ { \top }$ . Note that for models leveraging Hamilton products of quaternions (Parcollet et al., 2018b; 2019; Tay et al., 2019), the components $Q _ { r } , Q _ { x } , Q _ { y } , Q _ { z }$ of (3.4) are learnable parameters while the components $P _ { r } , P _ { x } , P _ { y } , P _ { z }$ are the layer inputs. In practice, such a layer usually has more than 4 inputs $( d > 4 )$ . To apply the Hamilton product, all the inputs are evenly split into 4 segments $( P _ { r } , P _ { x } , P _ { y } , P _ { z } )$ of the right input vector of (3.4). Then each component in the left matrix of (3.4) can be a block matrix (i) where all the elements take the same value; (ii) whose shape is aligned with the input length $d$ and the output length $k$ of the layer. It is noteworthy that the left $4 \times 4$ matrix of (3.4) can be rewritten as a sum of 4 Kronecker products:

According to (3.5), when $n = 4$ , the PHM layer can be learned to express the Hamilton product of quaternions. Specifically, matrices $\mathbf { A } _ { 1 } , \dotsc , \mathbf { A } _ { 4 }$ in (3.3) parameterize the four matrices composed of $- 1 , 0 , 1$ in (3.5) that reflect interactions between real and imaginary components of quaternions, which are the rule of Hamilton products. The single-element “matrices” $\mathbf { S } _ { 1 } , \ldots , \mathbf { S } _ { 4 }$ in (3.3) are equal to the learnable components $Q _ { r } , Q _ { x } , Q _ { y } , Q _ { z }$ in (3.4). Figure 2(b) shows that PHM layers can learn the rule of Hamilton products on artificial data. Likewise, hypercomplex multiplications of octonions or sedenions can also be learned by the PHM layer when $n$ is set to 8 or 16.
# 3.4 SUBSUMING REAL-VALUED MATRIX MULTIPLICATIONS
Next, we show how the PHM layer subsumes the matrix multiplication in real space. In other words, the PHM layer is a generalization of the FC layer via the hyperparameter $n$ . To explain, referring to (3.2), when $n = 1$ , $\mathbf { \bar { H } } = \mathbf { A _ { 1 } } \otimes \mathbf { S } _ { 1 } = a \mathbf { S } _ { 1 }$ , where the scalar $a$ is the single element of the $1 \times 1$ matrix ${ \bf A } _ { 1 }$ and $\mathbf { S } _ { 1 } \in \mathbb { R } ^ { k \times d }$ . Since learning $a$ and $\mathbf { S } _ { 1 }$ separately is equivalent to learning their multiplication jointly, scalar $a$ can be dropped, which is learning the single weight matrix in an FC layer. Therefore, a PHM layer is degenerated to an FC layer when $n = 1$ .
# 3.5 GENERALIZING HYPERCOMPLEX MULTIPLICATIONS
Though parameter reusing by component-wise partitioning in quaternion space has demonstrated success (Parcollet et al., 2018b; Zhu et al., 2018; Parcollet et al., 2019; Tay et al., 2019), one key problem is that hypercomplex space only exists at very few predefined dimensionalities, such as 4D (quaternions), 8D (octonions), and 16D (sedenions). Within the context of hypercomplex space, specialized multiplication rules, such as the Hamilton product, have to be devised and encoded in the network as a fixed inductive bias. As described in Section 1, the very few choices over existing hypercomplex space restricts the flexibility of networks that leverage hypercomplex multiplication.
In sharp contrast to relying on predefined mathematical rules over limited dimensionality choices, the PHM layer treats the dimensionality $n$ (number of Kronecker products) as a tunable hyperparameter and learns such specialized multiplication rules from data, as manifested in the parameterized matrices $\mathbf { A } _ { i }$ $( i = 1 , \ldots , n )$ in (3.3). On one hand, the PHM layer can express hypercomplex multiplications when $\mathbf { A } _ { i }$ are set to reflect those predefined multiplication rules in hypercomplex space. On the other hand, the PHM layer can be seen as a trainable and parameterized form of $n \mathbf { D }$ hypercomplex multiplications, where $n$ can be values other than 4, 8, or 16. Thus, the PHM layer generalizes multiplications in hypercomplex space. Since $n$ can be 1, the PHM layer also offers a neat way to bridging multiplication between both real space and hypercomplex space.
# 4 NEURAL MODELS WITH PHM LAYERS
To demonstrate the applicability of the PHM layers, we develop the PHM-LSTM and PHMtransformer by equipping two popular neural network models, LSTMs and transformers, with PHM layers.
# 4.1 PHM-LSTM
Recurrent neural networks such as LSTMs (Hochreiter & Schmidhuber, 1997) are gated recurrent networks where the gating functions are parameterized by linear transformations. We introduce the PHM-LSTM, which replaces such linear transformations in LSTMs with PHM layers:
$$\begin{array} { r } { \mathbf { y } _ { t } = \mathrm { P H M } \left( \mathbf { x } _ { t } \right) + \mathrm { P H M } \left( \mathbf { h } _ { t - 1 } \right) + b } \\ { \mathbf { f } _ { t } , \mathbf { i } _ { t } , \mathbf { o } _ { t } , \mathbf { x } _ { t } ^ { \prime } = \phi ( \mathbf { y } _ { t } ) \qquad } \\ { \mathbf { c } _ { t } = \sigma _ { s } ( \mathbf { f } _ { t } ) \mathbf { c } _ { t - 1 } + \sigma _ { s } ( \mathbf { i } _ { t } ) \sigma _ { t } ( \mathbf { x } _ { t } ^ { \prime } ) \qquad } \\ { \mathbf { h } _ { t } = \mathbf { o } _ { t } \odot \mathbf { c } _ { t } , \qquad } \end{array}$$
where $\sigma _ { s }$ is the sigmoid activation function, $\sigma _ { t }$ is the tanh activation function, $\phi : \mathbb { R } ^ { 1 \times d } \mathbb { R } ^ { 4 \times \frac { d } { 4 } }$ is a four-way split on the last dimension, and $\mathbf { c } _ { t } , \mathbf { h } _ { t }$ are the cell state and the hidden state of the PHM-LSTM unit at any time step $t$ .
# 4.2 PHM-TRANSFORMER
The transformer is a stacked neural network architecture that aggressively exploits linear transformations (Vaswani et al., 2017). Each self-attention layer comprises of $\mathbf { Q }$ (query), K (key), V (value) linear transformations, along with multiple heads. Each transformer block also has a position-wise feed-forward network composed of two FC layers. Since a large majority of the transformer parameters stem from linear transformations or FC layers, we introduce the PHM-transformer to replace all the linear transformations or FC layers with PHM layers. The single-head self-attention module is rewritten as:
$$\begin{array} { r l } { { \mathbf { Q } , \mathbf { K } , \mathbf { V } = \Phi ( \mathrm { P H M } ( \mathbf { X } ) ) } } \\ & { \quad \quad \quad \mathbf { A } = \mathrm { s o f t m a x } ( \frac { \mathbf { Q } \mathbf { K } ^ { \top } } { \sqrt { d _ { k } } } ) \mathbf { V } , } \end{array}$$
where $d _ { k }$ is the key dimension, $\Phi : \mathbb { R } ^ { 1 \times d } \mathbb { R } ^ { 3 \times \frac { d } { 3 } }$ is a three-way split on the last dimension, $\mathbf { X }$ is the input sequence, and $\mathbf { A }$ is the self-attentive representation. For multi-head attention, using PHM layers also enables weight sharing not only among the linear transformations of $\mathbf { Q } , \mathbf { K } , \mathbf { V }$ but also among the linear transformation of multiple heads:
$$\mathbf { X } = \mathrm { P H M } ( [ \mathbf { H } _ { 1 } ; \ldots ; \mathbf { H } _ { N _ { h } } ] ) ,$$
where $N _ { h }$ is the number of heads and $( ; )$ is the column-wise concatenation. Finally, the position-wise feed-forward network is now defined as
$$\mathbf { Y } = \operatorname { P H M } ( \operatorname { R e L U } ( \operatorname { P H M } ( \mathbf { X } ) ) ) ,$$
which transforms $\mathbf { X }$ with two PHM layers.
# 5 EXPERIMENTS
For context, in the field of representation learning using hypercomplex multiplications, quaternion convolutional neural networks (Zhu et al., 2018), quaternion recurrent neural networks (Parcollet et al., 2018a), and quaternion transformers (Tay et al., 2019) have all compared themselves with only real-valued counterparts. Therefore, to be consistent with the rest of the literature, we evaluate PHM-LSTMs and PHM-transformers that are equipped with PHM layers, and compare them with quaternion LSTMs, quaternion transformers, real-valued LSTMs, or real-valued transformers. Both quaternion LSTMs and quaternion transformers replace linear transformations with Hamilton products of quaternions.
Table 1: Experimental results of natural language inference (accuracy) on five different datasets. The PHM-LSTM reduces the parameters of the standard LSTM model and improves or partially matches performance on four out of five datasets.
<table><tr><td>Model</td><td>#Params</td><td>MNLI</td><td>QNLI</td><td>SNLI</td><td>DNLI</td><td>SciTail</td></tr><tr><td>LSTM</td><td>721K 180K (-75.0%)</td><td>71.82 /71.89</td><td>84.44</td><td>84.18</td><td>85.16</td><td>74.36</td></tr><tr><td>Quaternion LSTM</td><td></td><td>71.57 / 72.19</td><td>84.73</td><td>84.21</td><td>86.45</td><td>75.58</td></tr><tr><td>PHM-LSTM (n = 2)</td><td>361K (-49.9%)</td><td>71.82 / 72.08</td><td>84.39</td><td>84.38</td><td>85.77</td><td>77.47</td></tr><tr><td>PHM-LSTM(n = 5)</td><td>146K (-79.7%)</td><td>71.80 /71.77</td><td>83.87</td><td>84.58</td><td>86.47</td><td>74.64</td></tr><tr><td>PHM-LSTM (n = 10)</td><td>81K (-88.7%)</td><td>71.59 / 71.59</td><td>84.25</td><td>84.40</td><td>86.21</td><td>77.84</td></tr></table>
To demonstrate the architectural flexibility and effectiveness, we evaluate different settings of PHMLSTMs and PHM-transformers to show that allowing for flexible choices of the hyperparameter $n$ in the PHM layer may lead to more effective performance. Details of the setup for the experiments are provided in Appendix B.
# 5.1 NATURAL LANGUAGE INFERENCE
The task of natural language inference is to determine the logical relationship between two text sequences (MacCartney, 2009). It is a fundamental task pertaining to language understanding. To this end, they serve as a suitable benchmark for evaluating recurrent models.
We run experiments on five datasets: (i) MultiNLI (Williams et al., 2017), (ii) QNLI (Quora) (Wang et al., 2017), (iii) SNLI (Bowman et al., 2015), (iv) Dialogue NLI (Welleck et al., 2018), and (v) SciTail (Science Entailment) (Khot et al., 2018). Table 1 reports the results on all these datasets. All in all, such results show that the PHM layer can not only reduce the parameters but also improve performance with flexible choices of $n$ (four out of five datasets show reasonable improvement or partially match). The only exception is on the QNLI dataset, where the performance drop is marginal $( < 1 \% )$ ). This is still decent considering the parameter saving: the parameterization cost of the PHM-LSTM is in the order of $\mathcal { O } ( 1 / n )$ of that of the standard LSTM, where settings of $n = 5$ and $n = 1 0$ do not take values of power of 2. As detailed in Appendix B, since we use the 300D GloVe (Pennington et al., 2014) embeddings to represent input tokens, we choose multiples of 5 instead of 4 for ease of divisibility. It is also noteworthy that on the SNLI, Dialogue NLI, and SciTail datasets, all the PHM-LSTM variants outperform the standard LSTM model. We think that the element reusing properties of the Kronecker product operation, in addition to learning to share such reused components amongst recurrent gating functions, may contribute to both effective and efficient representations.
# 5.2 MACHINE TRANSLATION
Machine translation is concerned with translating between source-target language pairs. To this end, sequence transduction models are central to this problem domain. In this experiment, the key goal is to compare PHM-transformers against the standard and quaternion transformer models.
We run experiments on seven datasets: (i) IWSLT’15 English-Vietnamese (En-Vi), (ii) IWSLT’17 English-Indonesian (En-Id), (iii) IWSLT’14 German-English (De-En), (iv) IWSLT’14 RomanianEnglish (Ro-En), (v) WMT’18 English-Estonian (En-Et), (vi) Setimes English-Macedonian (EnMk), and (vii) WMT’18 English-Romanian (En-Ro).
Table 2 reports our results of the machine translation tasks. Overall, these empirical results with different settings demonstrate architectural flexibility and effectiveness of the hypercomplex multiplication parameterization. First and foremost, across six out of seven benchmarks, the PHMtransformer at $n = 4$ makes reasonable gains over the quaternion transformer, signifying that parameterization of hypercomplex multiplications by learning from data can be more effective than predefining Hamilton product rules mathematically. Second, though increasing $n$ leads to more parameter savings, we observe that increasing $n$ all the way to 16 does not cause significant degradation in performance on datasets such as En-Vi. Third, for most datasets, even with significant parameter savings, we find that the decrease in the BLEU score is mostly manageable $\approx 1 - 3$ BLEU points). However, we also note a rare occurrence where $n = 1 6$ results in a significant decrease in the BLEU score, such as on the En-Id dataset. Fourth, on several datasets, the PHM-transformer model improves the performance of the standard transformer model. For example, on datasets such as $\mathrm { E n - V i }$ and En-Et, the PHM-transformer model enjoys a performance boost of about 0.8 BLEU point with $n = 2$ . Finally, by re-scaling with a factor of 2 (doubling the hidden size), we are able to improve the performance on three datasets: En-Vi, En-Id, and En-Mk.
Table 2: Experimental results of machine translation (BLEU) on seven different datasets. Symbol $\dagger$ represents re-scaling the parameters with a factor of 2 by doubling the hidden size. The PHMtransformer does not lose much performance despite enjoying parameter savings. Re-scaling can lead to improvement in performance.
<table><tr><td>Model</td><td>#Params</td><td>En-Vi</td><td>En-Id</td><td>De-En</td><td>Ro-En</td><td>En-Et</td><td>En-Mk</td><td>En-Ro</td></tr><tr><td>Transformer (Tm)</td><td>44M</td><td>28.43</td><td>47.40</td><td>36.68</td><td>34.60</td><td>14.17</td><td>13.96</td><td>22.79</td></tr><tr><td>Quaternion Tm</td><td>11M (-75.0%)</td><td>28.00</td><td>42.22</td><td>32.83</td><td>30.53</td><td>13.10</td><td>13.67</td><td>18.50</td></tr><tr><td>PHM-Tm n = 2</td><td>22M (-50.0%)</td><td>29.25</td><td>46.32</td><td>35.52</td><td>33.40</td><td>14.98</td><td>13.60</td><td>21.73</td></tr><tr><td>PHM-Tm n = 4</td><td>11M (-75.0%)</td><td>29.13</td><td>44.13</td><td>35.53</td><td>32.74</td><td>14.11</td><td>13.01</td><td>21.19</td></tr><tr><td>PHM-Tm n =8</td><td>5.5M (-87.5%)</td><td>29.34</td><td>40.81</td><td>34.16</td><td>31.88</td><td>13.08</td><td>12.95</td><td>21.66</td></tr><tr><td>PHM-Tm n = 16</td><td>2.9M (-93.4%)</td><td>29.04</td><td>33.48</td><td>33.89</td><td>31.53</td><td>12.15</td><td>11.97</td><td>19.63</td></tr><tr><td>PHM-Tm+ n =2</td><td>44M</td><td>29.54</td><td>49.05</td><td>34.32</td><td>33.88</td><td>14.05</td><td>14.41</td><td>22.18</td></tr><tr><td>PHM-Tm+ n=4</td><td>22M (-50.0%)</td><td>29.17</td><td>46.24</td><td>34.86</td><td>33.80</td><td>14.43</td><td>13.78</td><td>21.91</td></tr><tr><td>PHM-Tm+ n=8</td><td>11M (-75.0%)</td><td>29.47</td><td>43.49</td><td>34.71</td><td>32.59</td><td>13.75</td><td>13.78</td><td>21.43</td></tr></table>
Table 3: Training time (seconds per 100 steps) and inference time (seconds to decode test sets) with beam size of 4 and length penalty of 0.6 on the IWSLT’14 German-English dataset.
<table><tr><td>Model</td><td>Transformer (Tm)</td><td>Quaternion Tm</td><td>PHM-Tm (n = 4)</td><td>PHM-Tm (n = 8)</td></tr><tr><td>Training time</td><td>7.61</td><td>8.11</td><td>7.92</td><td>7.70</td></tr><tr><td>Inference time</td><td>336</td><td>293</td><td>299</td><td>282</td></tr></table>
Table 3 reports the training and inference time for transformer variants. We observe that the PHMtransformer with $n = 8$ has the fastest inference speed amongst all the variants, primarily due to a significant reduction of parameters. All in all, the training speed is also approximately comparable. This ascertains that the PHM layer does not increase much computational cost in practice.
# 5.3 TEXT STYLE TRANSFER
We continue to experiment with sequence transduction for text style transfer. The goal of this task is to convert text of a certain style to another style. We use the Modern Shakespeare corpus1 in the experiments. Table 4 reports the results on this text style transfer task. We observe that the best performance is achieved with the PHM-transformer $( n = 4$ ). Notably, all except the $n = 1 6$ variant increases or matches the performance of the standard transformer model. This ascertains architectural flexibility and effectiveness of the proposed PHM layer. This not only enables parameter savings but also improves the performance of the transformer.
# 5.4 SUBJECT VERB AGREEMENT
We conduct additional experiments on the subject-verb agreement task (Linzen et al., 2016). The task predicts if the sentence, e.g., ‘The keys to the cabinet is followed by a plural or a singular. The used dataset can be found online (Linzen et al., 2016). Table 5 reports the results on the subject-verb agreement task. Results are promising, demonstrating that all variants with PHM layers outperform the standard and quaternion transformer models. The best performance peaks at $n = 8$ , despite a parameter saving to up to $1 / 8$ .
Table 4: Experimental results of text style transfer. The PHM-transformer may reduce the parameters of the standard transformer model and improve performance.
<table><tr><td>Model</td><td>#Params</td><td>BLEU</td></tr><tr><td>Transformer (Tm)</td><td>44M</td><td>11.65</td></tr><tr><td>PHM-Tm (n = 2) PHM-Tm (n = 4) PHM-Tm (n = 8)</td><td>22M (-50.0%) 11M (-75.0%) 5.5M (-87.5%) 2.9M (-93.4%)</td><td>12.20 12.42 11.66</td></tr></table>
Table 5: Experimental results of subject verb agreement. The PHM-transformer may reduce the parameters of the standard transformer model and improve performance.
<table><tr><td>Model</td><td>#Params</td><td>Acc</td></tr><tr><td>Transformer (Tm) Quaternion Tm</td><td>400K 100K</td><td>94.80 94.70</td></tr><tr><td>PHM-Tm (n = 2) PHM-Tm (n = 4) PHM-Tm (n = 8)</td><td>200K (-50.0%) 101K (-74.8%) 56K (-86.0%)</td><td>95.14 95.05 95.62</td></tr></table>
# 6 RELATED WORK
While neural networks have been a well-established line of research, progress on hypercomplex representations for deep learning is still in its infancy and most works on this topic are new (Gaudet & Maida, 2017; Parcollet et al., 2018a;b; Zhu et al., 2018; Tay et al., 2019). The hypercomplex Hamilton product provides a greater extent of expressiveness, similar to the complex multiplication, albeit with a 4-fold increase in interactions between real and imaginary components. In the case of quaternion representations, due to parameter savings in the Hamilton product, models also enjoy a $7 5 \%$ reduction in the parameter size (Parcollet et al., 2018a; Tay et al., 2019). A striking caveat is that all quaternions are fundamentally limited to 4D hypercomplex space, which restricts architectural flexibility. The other options would be to scale to octonion (8D) or sedenion (16D) space, given the predefined multiplication rules in such space. To the best of our knowledge, there is no work that attempts to generalize arbitrary $n \mathbf { D }$ hypercomplex multiplications to allow for architectural flexibility, where $n$ can be specified or tuned by users.
Our work can also be interpreted as a form of soft parameter sharing, albeit learned from data. Quaternion networks (Zhu et al., 2018; Parcollet et al., 2018b; 2019) are known to possess weight sharing properties via the Hamilton product operation and have demonstrated reasonable success despite having fewer parameters. To the best of our knowledge, there has been no work that attempts to parameterize the hypercomplex Hamilton product for neural networks, i.e., enabling end-to-end learning of real and imaginary component interactions from data.
# 7 CONCLUSION
We proposed parameterized hypercomplex multiplication (PHM) layers that learn and generalize hypercomplex multiplications. In practice, the PHM layer has $1 / n$ learnable parameters compared with the fully-connected layer counterpart, where $n$ can be flexibly specified by users. PHM layers are applicable to dominant models such as LSTMs and transformers. We evaluated these models equipped by PHM layers on comprehensive tasks to show architectural flexibility and effectiveness of the hypercomplex multiplication parameterization.
Acknowledgements. We thank the anonymous reviewers for the insightful comments on this paper. This work was partially supported by the Ministry of Education (MoE) of Singapore under the Academic Research Fund (AcRF) Tier 1 Grant RG135/18.
# REFERENCES
Samuel R Bowman, Gabor Angeli, Christopher Potts, and Christopher D Manning. A large annotated corpus for learning natural language inference. arXiv preprint arXiv:1508.05326, 2015.
Chase Gaudet and Anthony Maida. Deep quaternion networks. arXiv preprint arXiv:1712.04604, 2017.
Ian Goodfellow, Yoshua Bengio, and Aaron Courville. Deep Learning. MIT Press, 2016. http: //www.deeplearningbook.org.
Sepp Hochreiter and Jurgen Schmidhuber. Long short-term memory. ¨ Neural computation, 9(8): 1735–1780, 1997.
Tushar Khot, Ashish Sabharwal, and Peter Clark. Scitail: A textual entailment dataset from science question answering. In Thirty-Second AAAI Conference on Artificial Intelligence, 2018.
Tal Linzen, Emmanuel Dupoux, and Yoav Goldberg. Assessing the ability of lstms to learn syntaxsensitive dependencies. Transactions of the Association for Computational Linguistics, 4:521– 535, 2016.
Bill MacCartney. Natural language inference. Citeseer, 2009.
Titouan Parcollet, Mirco Ravanelli, Mohamed Morchid, Georges Linares, Chiheb Trabelsi, Renato \` De Mori, and Yoshua Bengio. Quaternion recurrent neural networks. In International Conference on Learning Representations, 2018a.
Titouan Parcollet, Ying Zhang, Mohamed Morchid, Chiheb Trabelsi, Georges Linares, Renato \` De Mori, and Yoshua Bengio. Quaternion convolutional neural networks for end-to-end automatic speech recognition. arXiv preprint arXiv:1806.07789, 2018b.
Titouan Parcollet, Mohamed Morchid, and Georges Linares. Quaternion convolutional neural net- \` works for heterogeneous image processing. In ICASSP 2019-2019 IEEE International Conference on Acoustics, Speech and Signal Processing (ICASSP), pp. 8514–8518. IEEE, 2019.
Ankur P Parikh, Oscar Tackstr ¨ om, Dipanjan Das, and Jakob Uszkoreit. A decomposable attention ¨ model for natural language inference. arXiv preprint arXiv:1606.01933, 2016.
Jeffrey Pennington, Richard Socher, and Christopher Manning. Glove: Global vectors for word representation. In Proceedings of the 2014 conference on empirical methods in natural language processing (EMNLP), pp. 1532–1543, 2014.
Adityan Rishiyur. Neural networks with complex and quaternion inputs. arXiv preprint cs/0607090, 2006.
Yi Tay, Aston Zhang, Luu Anh Tuan, Jinfeng Rao, Shuai Zhang, Shuohang Wang, Jie Fu, and Siu Cheung Hui. Lightweight and efficient neural natural language processing with quaternion networks. arXiv preprint arXiv:1906.04393, 2019.
Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N Gomez, Łukasz Kaiser, and Illia Polosukhin. Attention is all you need. In Advances in neural information processing systems, pp. 5998–6008, 2017.
Zhiguo Wang, Wael Hamza, and Radu Florian. Bilateral multi-perspective matching for natural language sentences. arXiv preprint arXiv:1702.03814, 2017.
Sean Welleck, Jason Weston, Arthur Szlam, and Kyunghyun Cho. Dialogue natural language inference. arXiv preprint arXiv:1811.00671, 2018.
Adina Williams, Nikita Nangia, and Samuel R Bowman. A broad-coverage challenge corpus for sentence understanding through inference. arXiv preprint arXiv:1704.05426, 2017.
Aston Zhang, Zachary C. Lipton, Mu Li, and Alexander J. Smola. Dive into Deep Learning. 2020. https://d2l.ai.
Xuanyu Zhu, Yi Xu, Hongteng Xu, and Changjian Chen. Quaternion convolutional neural networks. In Proceedings of the European Conference on Computer Vision (ECCV), pp. 631–647, 2018.
 Figure 3: Illustration of reconstructing $\mathbf { H }$ in (3.2) by reusing parameter matrices $\mathbf { B } _ { i }$ $( i \ = \ 1 , 2 )$ ) and $\mathbf { T } _ { j } ~ ( j ~ = ~ 1 , \ldots , 4 )$ in real-valued matrix multiplications, followed by more operations (here $n = 2 , k = 6 , d = 8 )$ . Best viewed in color.
# A RECONSTRUCTING THE PARAMETER MATRIX
In the paper, the parameter matrix $\mathbf { H }$ in (3.2) is constructed by a sum of $n$ Kronecker products. In the following, we will provide an alternative perspective and show how to equivalently reconstruct $\mathbf { H }$ by reusing parameter matrices in real-valued matrix multiplications, followed by more operations.
# A.1 METHOD
The key idea is to operate on partitioned weight blocks and learn a dynamic diffusion of weights. There are two key parameter blocks $\mathbf { B }$ and $\mathbf { T }$ that are central to our approach. Intuitively, $\textbf { B } \in$ $\mathbb { R } ^ { n \times n \times n }$ controls the weight diffusion process and learns the soft interactions between $\mathbf { T }$ partitions. Here, $n$ is a user defined hyperparameter.
Suppose that both $d$ and $k$ are divisible by $n \in \mathbb { Z } _ { > 0 }$ . For $i = 1 , \ldots , n$ and $j = 1 , \dotsc , \frac { d } { n }$ , denote by each partitioned parameter block $\mathbf { T } _ { j } \in \mathbb { R } ^ { n \times \frac { k } { n } }$ , and $\mathbf { B } _ { i } \in \mathbb { R } ^ { n \times n }$ is the weight diffusion matrix assigned to each partitioned parameter block via real-valued matrix multiplication $\mathbf { B } _ { i } \mathbf { T } _ { j }$ . The parameter $\mathbf { H }$ in (3.2) is now constructed by column-wise concatenation (;):
$${ \bf H } = [ s ( { \bf B } _ { 1 } ) ; s ( { \bf B } _ { 2 } ) ; \ldots ; s ( { \bf B } _ { n } ) ] ,$$
where each segment $s ( \mathbf { B } _ { i } )$ is also formed by column-wise concatenation:
$$s ( \mathbf { B } _ { i } ) = [ \psi ( \mathbf { B } _ { i } \mathbf { T } _ { 1 } ) ; \psi ( \mathbf { B } _ { i } \mathbf { T } _ { 2 } ) ; \ldots ; \psi ( \mathbf { B } _ { i } \mathbf { T } _ { \frac { d } { n } } ) ] .$$
In (A.2), function $\psi : \mathbb { R } ^ { p \times q } \mathbb { R } ^ { p q }$ , where $\psi ( \mathbf { X } )$ flattens the matrix $\mathbf { X } \in \mathbb { R } ^ { p \times q }$ by concatenating each row of $\mathbf { X }$ then transposes the concatenated row vector into a column vector of dimension $p q$ It is easy to see that, $\psi ( \mathbf { B } _ { i } \mathbf { T } _ { j } ) \in \mathbb { R } ^ { k }$ , $s ( \mathbf { B } _ { i } ) \in \mathbb { R } ^ { k \times { \frac { d } { n } } }$ , thus $\mathbf { H } \in \mathbb { R } ^ { k \times d }$ .
It is the partitioned parameter blocks $\mathbf { B } _ { i }$ $( i = 1 , \ldots , n )$ and $\begin{array} { r } { \mathbf { T } _ { j } \left( j = 1 , \ldots , \frac { d } { n } \right) } \end{array}$ that determine the degree of freedom for $\mathbf { H }$ , which is $k d / n + n ^ { 3 }$ . As illustrated in Figure 3, the reuse of parameter matrices $\mathbf { B } _ { 1 } , \ldots , \mathbf { B } _ { n }$ and $\mathbf { T } _ { 1 } , \ldots , \mathbf { T } _ { \frac { d } { n } }$ in real-valued matrix multiplications in (A.2) may reduce the degree of freedom for $\mathbf { H }$ .
# A.2 SUBSUMING HYPERCOMPLEX MULTIPLICATIONS
Similarly, we show how the PHM layer with the reconstructed $\mathbf { H }$ in (A.1) also subsumes the hypercomplex multiplication. Taking the Hamilton product of two quaternions $Q$ and $P$ as an example, it can be rewritten as
$$( \begin{array} { l l l l l } & & & { } & & { } & { 0 } \\ { 1 } & { 0 } & { 0 } & { 0 } \\ { 0 } & { 1 } & { 0 } & { 0 } \\ { 0 } & { 0 } & { 1 } & { 0 } \\ { 0 } & { 0 } & { 0 } & { 1 } \end{array} ) \underbrace { [ \begin{array} { l l l l l } { Q _ { x } } \\ { Q _ { x } } \\ { \vdots } \\ { Q _ { y } } \\ { 1 } \\ { 0 } \end{array} ] } _ { \mathbf { B } _ { 2 } } \underbrace { [ \begin{array} { l l l l l } { 0 } & { - 1 } & & { 0 } & { 0 } \\ { 1 } & { 0 } & { 0 } & { 0 } \\ { 0 } & { 0 } & { 0 } & { 1 } \\ { 0 } & { 0 } & { - 1 } & { 0 } \end{array} ] } _ { \mathbf { B } _ { 2 } } \underbrace { [ \begin{array} { l l l l l } { Q _ { x } } \\ { Q _ { x } } \\ { \vdots } \\ { Q _ { y } } \\ { 1 } \end{array} ] } _ { \mathbf { B } _ { 3 } } \underbrace { [ \begin{array} { l l l l l } { 0 } & { 0 } & { - 1 } & { 0 } \\ { 0 } & { 0 } & { 0 } & { - 1 } \\ { Q _ { x } } \\ { 1 } & { 0 } & { 0 } & { 0 } \end{array} ] } _ { \mathbf { B } _ { 3 } } \underbrace { [ \begin{array} { l } { Q _ { x } } \\ { Q _ { x } } \\ { Q _ { y } } \\ { \vdots } \\ { Q _ { z } } \end{array} ] } _ { \mathbf { B } _ { 4 } } \underbrace { [ \begin{array} { l l l l l } { 0 } & { 0 } & { 0 } & { - 1 } \\ { 0 } & { 0 } & { 1 } & { 0 } \\ { 0 } & { - 1 } & { 0 } & { 0 } \\ { 0 } & { 0 } & { 0 } & { 0 } \end{array} ] } _ { \mathbf { B } _ { 4 } } \underbrace { [ \begin{array} { l } { Q _ { x } } \\ { Q _ { x } } \\ { Q _ { y } } \\ { \vdots } \\ { Q _ { z } } \end{array} ] } _ { \mathbf { B } _ { 2 } } \underbrace { [ \begin{array} { l } { Q _ { y } } \\ { P _ { x } } \\ { P _ { y } } \\ { \vdots } \\ { P _ { z } } \end{array} ] } _ { \mathbf { B } _ { 2 } } \underbrace [ \begin{array} { l l l l } \end{array}$$
where the 4 output elements are the real values for the quaternion unit basis $[ 1 , \mathbf { i } , \mathbf { j } , \mathbf { k } ] ^ { \top }$ . According to (A.3), when $n = 4$ , the PHM layer with the reconstructed parameter matrix can also be learned to exactly express the Hamilton product of quaternions. Likewise, hypercomplex multiplications of octonions or sedenions can also be learned by the PHM layer when $n$ is set to 8 or 16.
# A.3 SUBSUMING REAL-VALUED MATRIX MULTIPLICATIONS
Now we show how the PHM layer with the reconstructed $\mathbf { H }$ in (A.1) also subsumes the matrix multiplication in real space. Referring to (3.2), when $n = 1$ , $\mathbf { H } = b \mathbf { W }$ , where the scalar $b$ is the single element of the $1 \times 1$ matrix $\mathbf { B } _ { 1 }$ and elements of $\mathbf { W } \in \mathbb { R } ^ { k \times d }$ come from the concatenation of $\mathbf { T } _ { 1 } , \ldots , \mathbf { T } _ { d } \in \mathbb { R } ^ { 1 \times k }$ . Since learning $b$ and W separately is equivalent to learning their multiplication jointly, the scalar $b$ can be dropped, which is learning the single weight matrix in an FC layer. Therefore, a PHM layer is degenerated to an FC layer when $n = 1$ .
# B SETUP FOR EXPERIMENTS
We describe the setup for the experiments as follows.
# B.1 NATURAL LANGUAGE INFERENCE
We implement 300D unidirectional encoders with shared parameters for both premises and hypotheses. We take the concatenation of max and mean pooled representations as the input to a two-layer 300D multilayer perceptron for prediction. Our model is trained with the the Adam optimizer with a learning rate of 0.0004 and a batch size of 256. Word embeddings are initialized with GloVe (Pennington et al., 2014) and are fixed. No cross sentence attention (Parikh et al., 2016) is used, mainly to observe the effectiveness of standalone encoders. For PHM-LSTM, we use $n = \{ 2 , 5 , 1 0 \}$ . Note that in this task, since word embeddings are 300D, we select multiples of 5 instead of 4 for ease of divisibility.
# B.2 MACHINE TRANSLATION
For the IWSLT’15 English-Vietnamese (En-Vi), IWSLT’17 English-Indonesian (En-Id), IWSLT’14 German-English (De-En), and IWSLT’14 Romanian-English (Ro-En) datasets, we run with 50K steps; while for WMT’18 English-Estonian (En-Et), Setimes English-Macedonian (En-Mk), and WMT’18 English-Romanian (En-Ro) datasets, models are trained for 100K steps. For the En-Vi, En-Id, En-Et, En-Mk, and En-Ro datasets, we specify that transformers have 4 layers, 8 heads, and a hidden size 512. For the De-En and Ro-En datasets, we specify that transformers have 2 layers, 4 heads, and a hidden size 256. We use beam size of 5 and $\alpha = 0 . 6$ (length penalty) for decoding. For all PHM models, we benchmark several settings for the hyperparameter $\bar { n } = \{ 2 , 4 , 8 , 1 6 \}$ .
# B.3 TEXT STYLE TRANSFER
For the used Modern Shakespeare corpus2 in the experiments, the key goal here is to convert modern writing into Shakespeare writing. This dataset comprises of 18, 395 parallel sentences for training, 1, 218 parallel sentences for evaluation (development set), and 1, 462 parallel sentences for testing. We still specify that transformers have 4 layers, 8 heads, and a hidden size 512. Similar to machine translation, we experiment with $n = \{ 2 , 4 , 8 , 1 6 \}$ . We train all the models for 10K steps.
# B.4 SUBJECT VERB AGREEMENT
In contrast to the previous experimental settings, we use a smaller transformer architecture with 10K training steps. Specifically, transformers here have 2 layers, 4 heads, and a hidden size 128. Since the hidden size is smaller than those in the previous experimental settings, we experiment with $n = \{ 2 , 4 , 8 \}$ .123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529# Not All Attention Is All You Need
Anonymous Author(s) Affiliation Address email
# Abstract
1 Beyond the success story of pre-trained language models (PrLMs) in recent natu 2 ral language processing, they are susceptible to over-fitting due to unusual large 3 model size. To this end, dropout serves as a therapy. However, existing methods 4 like random-based, knowledge-based and search-based dropout are more general 5 but less effective onto self-attention based models, which are broadly chosen as 6 the fundamental architecture of PrLMs. In this paper, we propose a novel dropout 7 method named AttendOut to let self-attention empowered PrLMs capable of more 8 robust task-specific tuning. We demonstrate that state-of-the-art models with elab 9 orate training design may achieve much stronger results. We verify the universal 10 ity of our approach on extensive natural language processing tasks.
# 11 1 Introduction
12 Self-attention network (SAN) empowered models like Transformer [1] have achieved remarkable 13 success in recent natural language processing, which have been broadly chosen as basic architec 14 ture in a series successful pre-trained language models (PrLMs) such as BERT [2], RoBERTa [3], 15 ALBERT [4], ELECTRA [5], DeBERTa [6] and GPT [7]. 16 SAN has drawn a great deal of curiosity on its conceptually simple but powerful attention mecha 17 nism. However, SAN still remains a black box and more and more works attempt to unveil its inner 18 principle, where the biggest mystery lies in its attention matrix. Our work is inspired by several 19 recent discoveries which turn our views up and down. [8, 9] show that fixed Gaussian or even ran 20 dom alignment attention matrix may rival standard SAN, while more recently, [10, 11] prove that 21 SAN may encounter a rank collapse with deepening of layers. A more concrete explanation is in 22 formation diffusion [12], which states that the input vectors are progressively assimilating through 23 continuously making self-attention. We attribute these problems to the sever co-adaption [13] be 24 tween attention elements, a form of over-fitting onto SAN. As a result, self-attention empowered 25 PrLMs hardly bring into their full play, especially for the fine-tuning stage, where task-specific data 26 is always with limited capacity. 27 Dropout [13] serves as a therapy to deal with the problem, by randomly shutting down a set of units 28 during training stage. When specified on self-attention, dropout is equivalent to adding attention 29 mask to the attention matrix. However, random-based dropout methods like vanilla Dropout [13] or 30 DropConnect [14] are all subject to a pre-defined distribution like Bernoulli or Gaussian, longing for 31 exhaustive grid search for an optimal probability. Thereby a variety of works attempt to utilize man 32 ual attention mask to obtain a more informative attention matrix [15, 16], whereas all these methods 33 require prior knowledge on model or data, which could be costly or unavailable. More recently, the 34 rise of Neural Architecture Search [17, 18] gives birth to search-based dropout [19], which automat 35 ically chooses an optimal dropout pattern based on additional validation performances. However, 36 the huge search space brings heavy consumption and more importantly, the obtained dropout pattern 37 is still fixed with a pre-defined probability, which is static and sample-independent, ignoring the 38 dynamics within different samples. In this paper, we focus on task-specific tuning of self-attention 39 empowered PrLMs and propose a novel dropout method named AttendOut onto attention layers, 40 which leverages self-attention to dynamically generate dropout patterns for each attention layer as 41 well as each sample through an end-to-end manner. We demonstrate that the previous state-of-the-art 42 models with elaborate training design may achieve much stronger results. We verify the universality 43 of our approach on extensive natural language processing tasks. Guided by AttendOut, we pro 44 pose another two attention regularizers to enable simple but effective performance boost with no 45 additional cost.
 Figure 1: A diagram of different dropout methods, where $p$ refers to the dropout probabilities while $R$ refers to the reward in reinforcement learning.
# 46 2 Related Work
47 Dropout is proposed to alleviate over-fitting problem in DNNs. Apart from vanilla Dropout [13] 48 and DropConnect [14] which randomly shut down a subset of activations or hidden weights, there 49 are a variety of dropout methods proposed, e.g. Alpha Dropout [20], Variational Dropout [21, 22], 50 Adversarial Dropout [23], Energy-based Dropout [24]. However, random-based dropout encounters 51 slow experiment cycle due to inevitable grid search. Inspired by Neural Architecture Search [17, 18], 52 [19] proposes AutoDropout to automate the process of designing dropout patterns. A similar line of 53 work is dynamic tuning of dropout, which further allows adaptive dropout probabilities under differ 54 ent training moments. [25] proposes Concrete Dropout with continuous relaxation under Concrete 55 distribution, [26] proposes Learnable Bernoulli Dropout under discrete Bernoulli distribution using 56 Augment-REINFORCE-Merge estimator [27], while [28] proposes Context Dropout by optimizing 57 the evidence lower bound. 58 With self-attention network continuously stands out, dropout is being explored onto self-attention 59 based models. LayerDrop [29] randomly removes entire SAN blocks, while DropHead [30], Head 60 Mask [31] randomly remove certain attention heads. UniDrop [32] unifies these dropout methods, 61 which facilitates text classification and machine translation tasks. Additionally, prior knowledge is 62 shown highly effective for guiding attention dropout as in SG-Net [15] and SIT [16], which inten 63 tionally discard syntax-unrelated attention units with the help of structural clues.
# 64 3 Preliminaries
65 In this section, we provide the preliminaries for the proposed approach. We first review the details 66 of self-attention proposed in [1]. Based on the specific architecture, we elaborate the concerned 67 attention dropout.
# 3.1 Self-Attention
69 Generally, a standard SAN block is mainly composed of an attention layer and several feed-forward 70 layers (actually there are residual connection, layer normalization, etc. as well). The input of it is a 71 sentence or batch of sentences of length $n$ , which is first embedded through an embedding layer. The 72 embedded input $E$ may go through three linear projections $W _ { Q }$ , $W _ { K }$ and $W _ { V }$ referring to query, key 73 and value layers respectively, and then obtain three matrices $Q$ , $K$ and $V$ referring to the query, key 74 and value components of self-attention. Subsequently, a dot-product of $Q$ and $K$ is taken and then 75 normalized using Sof tmax function to obtain the attention matrix $A$ . Then another dot-product of 76 $A$ and $V$ follows. The mentioned calculation can be formalized as follow:
$$A t t e n t i o n ( Q , K , V ) = S o f t m a x \left( \frac { Q \cdot K ^ { T } } { \sqrt { d _ { k } } } \right) \cdot V$$
where 77 $\sqrt { d _ { k } }$ is a scaling factor. Finally, the self-attention layer ends up with a linear projection $W _ { O }$ 78 to output.
79 During the aforementioned process, we highlight a key phases, that is the attention matrix $A$ , which 80 is a dot-product of $n \times n$ from two separate linear projections $W _ { Q }$ and $W _ { K }$ . $A$ is viewed as a feature 81 map which stores the node-to-node significance in different scores. Various works show that there 82 hides implicit but highly needed semantic clues.
# 3.2 Dropout on Self-Attention
84 Our dropout will apply to the attention matrix of the concerned attention layer. We first define two 85 specific dropouts onto Eq. 1, where both implementations are just as simple as in standard dropout 86 via a mask matrix $M$ .
Weights Dropout. Weights dropout is applied to the attention matrix after Sof tmax function by default, which is formulated as:
$${ \cal A } t t e n t i o n ( Q , K , V ) = \left( S o f t m a x \left( { \frac { Q \cdot K ^ { T } } { \sqrt { d _ { k } } } } \right) \odot { \cal M } \right) \cdot V$$
9 where $M$ is a binary matrix with elements in $\{ 0 , 1 \}$ and $\odot$ refers to element-wise multiplication.
90 Scores Dropout. Different from weights dropout, scores dropout is applied before Sof tmax func 91 tion, which is formulated as:
$$A t t e n t i o n ( Q , K , V ) = S o f t m a x \left( \frac { Q \cdot K ^ { T } } { \sqrt { d _ { k } } } + M \right) \cdot V$$
92 Since the outer Sof tmax, we conduct an addition instead of multiplication, where elements in $M$ 93 are set to 0 for kept units and $- i n f$ for removed ones. Note that the Sof tmax takes a similar 94 function as the scaling factor of $1 / p$ in vanilla Dropout [13], which balances the expectation of the 95 network. 96 Weights dropout is commonly used in self-attention based models, while scores dropout is less 97 explored, which is our focus in this paper. For scores dropout, we need to pay attention to a special 98 case, when all attentions are shut down, that is, all elements in $M$ equal to $- i n f$ at the same time. 99 Such case can be formulated as follow:
$$A t t e n t i o n ( Q , K , V ) = S o f t m a x \left( M \right) \cdot V$$
100 Note that Sof tmax $( M )$ obtains to a constant matrix, where each unit equals to $1 / n$ . In this case, 101 the attention matrix is fixed and consequently the $W _ { Q }$ , $W _ { K }$ and dot-product in between are skipped.
# 102 4 Methodology
103 In this paper, we propose Attention differentiable dropOut (AttendOut), which contributes technique 104 novelty in the following way: (1) dynamic and task-specific tuned; (2) end-to-end trained; (3) gra 105 dient optimized dropout method onto self-attention empowered PrLMs. We elaborate our approach 106 with two parts, in which the first is composition, while the second is training algorithm.
# 4.1 Elements of AttendOut
108 Our training architecture is composed of three modules, A-Net (Attacker), D-Net (Defender) and 109 G-Net (Generator). D-Net and A-Net are two identical models and trained simultaneously through 110 standard gradient descent, while G-Net is a learnable dropout maker and trained through policy 111 gradient. Now we elaborate each of them. 112 Defender - Attacker As suggested, defender and attacker are two competitors playing a game 113 with each other on specific criteria, e.g. training accuracy, training loss. Specifically, D-Net and A 114 Net are two identical self-attention empowered PrLMs, e.g. BERT, RoBERTa. However, they follow 115 different dropout strategies. D-Net receives regular dropout as default in specific models, while A 116 Net receives additional dropout decision from G-Net onto its corresponding attention layers. 117 Generator G-Net acts as a dropout maker through generating a mask matrix for each attention 118 layer during training stage. As aforementioned, the common dropout strategies rely on randomness, 119 which intends to shut down the co-adaption but not powerful enough. However, our dropout maker 120 is an agent which is able to intelligently choose and learn dropout patterns for each sample. Specif 121 ically, after training for a fixed number of steps, we conduct evaluation for both A-Net and D-Net. 122 When A-Net obtains a higher score than D-Net, which means attacker wins the game, G-Net will be 123 rewarded positively. When defender wins, G-Net will be punished with a negative reward. In con 124 sequence, G-Net learns appropriate dropout patterns through the game between D-Net and A-Net, 125 while assisting A-Net to win the game. On the other hand, A-Net needs to be stronger when training 126 under such powerful dropout, which makes it much more robust from over-fitting. Compared to 127 search-based dropout, G-Net is triggered by the difference between two model derivatives with and 128 without dropout, instead of the final feedback on validation set, which makes it end-to-end-possible 129 and sample-dependent. 130 The design of G-Net is the most delicate part, which is also a self-attention based model with iden 131 tical number of layers with D-Net and A-Net. However, we make several improvements. 1) G-Net 132 only exports the attention scores from attention layers with no extra output layers, from which we 133 apply Gumbel [33, 34] to sample the actions to obtain the dropout mask. 2) G-Net only makes 134 one-head attention and share one group of parameters for all attention layers. 3) G-Net is excluded 135 of feed-forward layers, which may obscure the impact of self-attention [11, 10].
# 4.2 Training with AttendOut
37 The core of training with AttendOut is to find a way to optimize G-Net, which receives signals from 38 the difference between D-Net and A-Net. Supposing there is a list of dropout actions by G-Net:
$$a _ { 1 : T } = \{ a _ { 1 } , a _ { 2 } , a _ { 3 } , \cdot \cdot \cdot , a _ { T } \}$$
139 where $T$ refers to the number of samples, for each action $a _ { t }$ , G-Net may achieve a reward $r _ { t }$ . The 140 optimization objective is to maximize the overall rewards of list $a _ { 1 : T }$ , denoted as $R$ , that is:
$$J ( \theta _ { G } ) = E _ { P ( a _ { 1 : T } ; \theta _ { G } ) } [ R ]$$
where 141 $\begin{array} { r } { R = \sum _ { t = 1 } ^ { T } r _ { t } } \end{array}$ . Since $R$ is non-differentiable, we use policy gradient to update $\theta _ { G }$
$$\nabla _ { \theta _ { G } } J ( \theta _ { G } ) = \sum _ { t = 1 } ^ { T } E _ { P ( a _ { 1 : T } ; \theta _ { G } ) } [ \nabla _ { \theta _ { G } } \log P ( a _ { t } | a _ { ( t - 1 ) : 1 } ; \theta _ { G } ) r _ { t } ]$$
142 The above equation could be approximated as:
$$\frac { 1 } { m } \sum _ { k = 1 } ^ { m } \sum _ { t = 1 } ^ { T } \nabla _ { \theta _ { G } } \log P ( a _ { t } | a _ { ( t - 1 ) : 1 } ; \theta _ { G } ) r _ { t }$$
143 For a model with $n$ attention layers, each dropout decision is composed of $n$ inner decisions of each 144 layer. Additionally, each attention layer contains an attention matrix of $l \times l$ , namely $l ^ { 2 }$ elements 145 dropped or kept. Thus, we denote a dropout unit as $d ^ { i j }$ , where $i$ refers to the $i ^ { t h }$ layer while $j$ refers 146 to the $j ^ { t h }$ element of the attention matrix. 147 However, $n l ^ { 2 }$ dropout units bring a huge space, which makes it impossible to calculate the joint prob 148 ability. To this end, we introduce the independence assumption that each dropout unit is independent 149 with each other. Under the relaxation, we can make the following probability likelihood:
$$\log P ( a _ { t } | a _ { ( t - 1 ) : 1 } ; \theta _ { G } ) = \frac { 1 } { n l ^ { 2 } } \sum _ { i , j } \log P ( d _ { t } ^ { i j } | d _ { ( t - 1 ) : 1 } ^ { i j } ; \theta _ { G } )$$
where the summation 150 $\textstyle \sum _ { i = 1 } ^ { n } \sum _ { j = 1 } ^ { l ^ { 2 } }$ is briefly denoted as $\textstyle \sum _ { i , j }$
151 Thus, the final gradient could be formalized as:
$$\nabla _ { \theta _ { G } } J ( \theta _ { G } ) = \frac { 1 } { m } \frac { 1 } { n l ^ { 2 } } \sum _ { k = 1 } ^ { m } \sum _ { t = 1 } ^ { T } \sum _ { i , j } \nabla _ { \theta _ { G } } \log P ( d _ { t } ^ { i j } | d _ { ( t - 1 ) : 1 } ^ { i j } ; \theta _ { G } ) ( r _ { t } - b )$$
152 where $b$ is a baseline function of moving average [35]. Note that we do not apply additional regular 153 izers like L0 and L1 penalty, which impose unnecessary bias. 154 Algorithm 1 summarizes the overall procedure of training PrLMs with AttendOut. We first initialize 155 all three networks. Note that D-Net and A-Net should be kept identical at the beginning of each 156 training step. A straightforward strategy is to choose the better one to cover the other. To add 157 randomness, we sample from D-Net and A-Net based on their evaluation performances, with higher 158 probability for the better one. Then for each step, D-Net and A-Net are fed with the same mini-batch 159 data and updated via standard gradient descent, meanwhile each batch will be cached. After training 160 for $T$ steps, which we denote as a dropout step, both D-Net and A-Net are evaluated on additional 161 validation samples, which could be development set data, noisy training data or a small split of train 162 ing data. In this paper, we simply use development set. For efficiency, we make random sampling 163 on it to retrieve $T$ samples for evaluation. Based on the evaluation scores, G-Net is rewarded with 164 $\{ r _ { 1 } , r _ { 2 } , r _ { 3 } , \cdot \cdot \cdot , r _ { T } \}$ and updated via Eq. 5. At the end of each dropout step, the cached samples 165 will be released and D-Net and A-Net will be re-initialized.
# Algorithm 1 AttendOut
Input: Attacker $A$ , Defender $D$ , Generator $G$ , dropout step $T$ 1: initialize $\theta _ { D }$ , $\theta _ { A }$ , $\theta _ { G }$ , where $\theta _ { D } = \theta _ { A }$ 2: for each training step do 3: $\theta _ { D } \theta _ { D } ^ { \prime }$ 4: dropout $A$ with $G$ via Eq. 3 5: $\theta _ { A } \theta _ { A } ^ { \prime }$ 6: for each $T$ steps do 7: evaluate $D$ and $A$ and reward $G$ 8: $\theta _ { G } \theta _ { G } ^ { \prime }$ via Eq. 5 9: initialize $\theta _ { D }$ , $\theta _ { A }$ for next step 10: end for 11: end for 167 Resource Usage We notice that training PrLMs with AttendOut may sacrifice time and memory 168 cost. The detailed resource usage is shown in Appendix. Taking RoBERTa as an example, the 169 algorithm requires two RoBERTa models as well as a smaller self-attention based generator, which 170 is $\mathrm { { \bar { 1 } / 3 } }$ of RoBERTa size. Considering cached samples, roughly speaking, AttendOut requires twice 171 graphic memory as well as twice training time compared to a single model, which is a middle speed 172 line between random-based dropout and neural architecture search (Dropout [13] $<$ AttendOut $\ll$ 173 AutoDropout [19]). However, AttendOut contributes to remarkable performance gain compared to 174 other attention dropout methods. 175 Pre-training Our approach is both feasible for both fine-tuning and pre-training stage of PrLMs 176 but expensive for the latter. However, we try to serve for the most delicate part of concerned issue, 177 since pre-training is generally done on large-scale data with modest training epochs, which makes it 178 less susceptible from over-fitting.
 Figure 2: Architecture of G-Net.
Table 1: Results (test / dev) of GLUE sub-tasks.
<table><tr><td>Model</td><td>SST-2 Acc</td><td>MRPC F1</td><td>QNLI Acc</td><td>MNLI-mm Acc</td><td>CoLA Mcc</td></tr><tr><td>BERT</td><td>92.9 / 92.2</td><td>86.6 / 86.3</td><td>89.7 /88.9</td><td>83.3 /84.0</td><td>51.2 / 58.8</td></tr><tr><td>+ AtendOut</td><td>93.6 / 93.8</td><td>88.1 / 87.5</td><td>90.2 / 91.1</td><td>84.2 /84.6</td><td>57.4 / 60.9</td></tr><tr><td>RoBERTa</td><td>95.4 / 94.4</td><td>90.5 /90.2</td><td>92.9 /92.0</td><td>86.1 /86.6</td><td>61.3 / 62.5</td></tr><tr><td>+ AtendOut</td><td>96.2 / 95.1</td><td>91.2 / 90.9</td><td>93.3 /93.0</td><td>87.3 /87.8</td><td>63.0 / 63.8</td></tr></table>
Table 2: Results of IMDB, CoNLL03, PTB and SWAG respectively.
<table><tr><td>Model</td><td>IMDB Acc</td><td>CoNLL03 F1</td><td>PTB F1</td><td>SWAG Acc</td></tr><tr><td>BERT</td><td>92.2</td><td>94.1</td><td>95.4</td><td>81.1</td></tr><tr><td>+ AttendOut</td><td>92.9</td><td>94.7</td><td>96.5</td><td>81.6</td></tr><tr><td>RoBERTa</td><td>93.6</td><td>94.5</td><td>96.6</td><td>83.8</td></tr><tr><td>+ AttendOut</td><td>94.2</td><td>95.2</td><td>97.3</td><td>84.1</td></tr></table>
# 179 5 Experimental Setup
180 We demonstrate the universal effectiveness of AttendOut on extensive natural language processing 181 tasks. For all mentioned tasks, we apply our method on BERT [2] and its stronger variant RoBERTa 182 [3]. Our implementations are based on PyTorch using transformers [36]. For further training details, 183 please refer to Appendix. 184 Our experiments include: (1) natural language understanding: General Language Understanding 185 Evaluation (GLUE) benchmark [37], a collection of nine natural language understanding tasks (here 186 we experiment on five of them, SST-2, MRPC, QNLI, MNLI-mm and CoLA; (2) document clas 187 sification: IMDB [38], a sentiment analysis dataset where about $15 \%$ of the documents are longer 188 than 512 word-pieces; (3) named entity recognition: CoNLL2003 [39]; (4) part-of-speech tag 189 ging: English Penn Treebank (PTB) [40]; (5) multiple choices question answering: SWAG [41]. 190 We report both test and development results for GLUE sub-tasks since the large bias between them, 191 while development results only for all the other tasks. 192 Note that we only adjust the dropout steps and keep all other parameters the same for strict fair 193 comparison. For example, the parameters we use in RoBERTa are identical with what we use in 194 training with AttendOut including both D-Net and A-Net.
# 6 Results
# 6.1 Significance Analysis
97 Pictorially in Table 1, RoBERTa is strong enough as it outperforms BERT by a big margin, while 98 AttendOut empowered RoBERTa still outperforms it on all five GLUE sub-tasks. For small-scale 99 datasets, which are more likely to over-fit, AttendOut helps unfold remarkable performance gain 00 $( 1 2 . 1 \% \ / \ 3 . 5 \%$ over BERT on CoLA, $1 . 7 \% / 1 . 4 \%$ over BERT on MRPC). However, for large 01 scale one like MNLI, which tends to be more stable, AttendOut still produces considerable boost, 02 $( 1 . 4 \% / 1 . 4 \%$ over RoBERTa, $1 . 1 \% / 0 . 7 \%$ over BERT). 203 Furthermore, AttendOut is shown universally effective as in Table 2. For POS Tagging, BERT 204 and RoBERTa have achieved very strong baselines, while AttendOut empowered ones are even 205 stronger, $3 . 1 \%$ over BERT on PTB). Similar results are seen on document classification and NER. 206 For SWAG, however, AttendOut seems weakly effective $\mathbf { 0 . 6 \% }$ over BERT, $0 . 4 \%$ over RoBERTa).
 Figure 3: Dropout probabilities on specific attention layers over training steps.
 Figure 4: Convergence over training epochs.
# 207 6.2 Visual Analysis
Dropout Patterns Another concerned issue is the dropout proportions by AttendOut. Figure 3 depicts the patterns on several datasets. We may find several interesting phenomenons. First, the overall patterns largely differ from datasets, which is fair since AttendOut is sample-dependent. However, we may observe something in common. Overall, the lower layers take higher dropout probabilities. For example on QNLI, the first layer almost remains steady with the probability of 0.55 during the training process, while the fourth one continuously decays in a higher rate. Intuitively, the first three layers undertake a similar trend in each dataset, while there might be an up and down for the fourth one as in SST-2 and CoLA. Especially for CoLA, we see unusual high dropout probabilities in the final period (around 0.9), which are close to complete dropout. We notice that CoLA is a small set with 8500 training samples, on which SAN model is more inclined to suffer from over-fitting. Therefore, PrLM on CoLA encounters more intensive dropout through AttendOut.
219 Convergence Figure 4 depicts the accuracy trends of RoBERTa on SST-2, QNLI, MNLI respec 220 tively. Due to a stronger dropout module, the one with AttendOut tends to fall behind (SST-2, 221 MNLI) at the beginning of training. However, model becomes stronger since the second epoch 222 (SST-2, QNLI). Especially on MNLI, RoBERTa obtains better results in the first two epochs and it 223 drops in the last one, while with AttendOut, the performance is steadily rising for all three epochs.
# 7 Ablation Study
In this section, we conduct further experiments to demonstrate the effectiveness of AttendOut. Due to space limitation, we conduct corresponding experiments on development sets only.
# 7.1 Attention Dropout
Vanilla Dropout We conduct comparison with vanilla Dropout [13], in which we dropout the attention matrix for all layers with Bernoulli distribution of $p$ . Here, we choose the dropout probabilities in {0.1, 0.2}.
Table 3: Comparison of AttendOut, vanilla Dropout and LayerDrop.
<table><tr><td>Model</td><td>CoLA</td><td>QNLI</td><td>MNLI-mm</td></tr><tr><td>RoBERTa</td><td>62.5</td><td>92.0</td><td>86.6</td></tr><tr><td>+ Vanilla</td><td>61.3</td><td>92.2</td><td>86.9</td></tr><tr><td>+ AttendOut</td><td>63.8</td><td>93.1</td><td>87.8</td></tr><tr><td>+ LayerDrop</td><td>62.1</td><td>92.6</td><td>87.1</td></tr><tr><td>+ Attn.LayerDrop</td><td>64.2</td><td>92.7</td><td>87.3</td></tr></table>
Table 4: Comparison of AttendOut and scheduled Bernoulli dropout.
<table><tr><td>Model</td><td>CoLA</td><td>QNLI</td><td>SWAG</td></tr><tr><td>RoBERTa</td><td>62.5</td><td>92.0</td><td>83.8</td></tr><tr><td>+ Scheduler</td><td>63.3</td><td>92.6</td><td>83.6</td></tr><tr><td>+ AttendOut</td><td>63.8</td><td>93.1</td><td>84.1</td></tr></table>
231 LayerDrop We also compare with LayerDrop [29], which focuses on skipping the entire encoder 232 blocks, Inspired of it, we design another strategy which randomly skips attention layers via Eq. 4. 233 For fair enough comparison, we set the dropout probabilities to 0.2 for both methods, following the 234 settings in [29]. 235 Intuitively in Table 3, vanilla Dropout with fixed probability does not produce noticeable gain $( 1 . 9 \%$ 236 bellow RoBERTa on CoLA). However, AttendOut shows powerful advantage $4 . 1 \%$ , $1 . 0 \%$ and $1 . 0 \%$ 237 over vanilla Dropout on CoLA, QNLI and MNLI), which stresses the necessity of dynamic dropout 238 patterns rather than fixed static one. On the other hand, both layer-level regularizers are effective, 239 while attention LayerDrop performs stronger and more stable on all the three. Especially on CoLA, 240 it outperforms RoBERTa by 1.7 points, while LayerDrop meets a performance drop, which demon 241 strates that removing the attention layers act as a more effective regularizer than removing the entire 242 SAN block as for self-attention based models.
# 243 7.2 Pattern Approximation
244 Guided by AttendOut, we design a dropout scheduler, in which we utilize piece-wise linearity to 245 approximate the real curves as depicted in Figure 3. Taking QNLI as an example, we initialize 246 the dropout probabilities to 0.6 for all attention layers and set a a specific slope for each of them. 247 Note that here the corresponding mask matrices are randomly-generated and subject to Bernoulli 248 distribution. In AttendOut, however, the distribution are learned dynamically through self-attention 249 of G-Net. 250 As shown in Table 4, RoBERTa with scheduled Bernoulli dropout works surprisingly well on both 251 CoLA and QNLI, which outperforms RoBERTa by 0.8 and 0.6 points respectively, closer to At 252 tendOut, even if the strategy here is random-based and much looser. The guided scheduled dropout 253 helps unfold the correctness of the dynamic dropout patterns learned by AttendOut as well as the 254 self-attention based dropout maker.
# 255 8 Conclusion
This paper focuses on the co-adaption problem of deep self-attention networks, and presents a novel dropout method onto self-attention empowered pre-trained language models. Extensive experiments on multiple natural language processing tasks demonstrate that our proposed approach is universal and qualified to enable more robust task-specific tuning, which contributes to much stronger stateof-the-arts. We probe into the learned dropout patterns on different tasks, which empirically guide us to the very needed dynamic attention dropout design.
262 References 263 [1] Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N. Gomez, Lukasz 264 Kaiser, and Illia Polosukhin. Attention is all you need. In Isabelle Guyon, Ulrike von Luxburg, Samy 265 Bengio, Hanna M. Wallach, Rob Fergus, S. V. N. Vishwanathan, and Roman Garnett, editors, Advances 266 in Neural Information Processing Systems 30: Annual Conference on Neural Information Processing 267 Systems 2017, December 4-9, 2017, Long Beach, CA, USA, pages 5998–6008, 2017. 268 [2] Jacob Devlin, Ming-Wei Chang, Kenton Lee, and Kristina Toutanova. BERT: pre-training of deep bidi 269 rectional transformers for language understanding. In Jill Burstein, Christy Doran, and Thamar Solorio, 270 editors, Proceedings of the 2019 Conference of the North American Chapter of the Association for Com 271 putational Linguistics: Human Language Technologies, NAACL-HLT 2019, Minneapolis, MN, USA, June 272 2-7, 2019, Volume 1 (Long and Short Papers), pages 4171–4186. Association for Computational Linguis 273 tics, 2019. 274 [3] Yinhan Liu, Myle Ott, Naman Goyal, Jingfei Du, Mandar Joshi, Danqi Chen, Omer Levy, Mike Lewis, 275 Luke Zettlemoyer, and Veselin Stoyanov. Roberta: A robustly optimized BERT pretraining approach. 276 CoRR, abs/1907.11692, 2019. 277 [4] Zhenzhong Lan, Mingda Chen, Sebastian Goodman, Kevin Gimpel, Piyush Sharma, and Radu Soricut. 278 ALBERT: A lite BERT for self-supervised learning of language representations. In 8th International 279 Conference on Learning Representations, ICLR 2020, Addis Ababa, Ethiopia, April 26-30, 2020. Open 280 Review.net, 2020. 281 [5] Kevin Clark, Minh-Thang Luong, Quoc V. Le, and Christopher D. Manning. ELECTRA: pre-training 282 text encoders as discriminators rather than generators. In 8th International Conference on Learning Rep 283 resentations, ICLR 2020, Addis Ababa, Ethiopia, April 26-30, 2020. OpenReview.net, 2020. 284 [6] Pengcheng He, Xiaodong Liu, Jianfeng Gao, and Weizhu Chen. {DEBERTA}: {DECODING}- 285 {enhanced} {bert} {with} {disentangled} {attention}. In International Conference on Learning Repre 286 sentations, 2021. 287 [7] Alec Radford, Karthik Narasimhan, Tim Salimans, and Ilya Sutskever. Improving language understanding 288 by generative pre-training. 2018. 289 [8] Weiqiu You, Simeng Sun, and Mohit Iyyer. Hard-coded gaussian attention for neural machine translation. 290 In Dan Jurafsky, Joyce Chai, Natalie Schluter, and Joel R. Tetreault, editors, Proceedings of the 58th 291 Annual Meeting of the Association for Computational Linguistics, ACL 2020, Online, July 5-10, 2020, 292 pages 7689–7700. Association for Computational Linguistics, 2020. 293 [9] Yi Tay, Dara Bahri, Donald Metzler, Da-Cheng Juan, Zhe Zhao, and Che Zheng. Synthesizer: Rethinking 294 self-attention in transformer models. CoRR, abs/2005.00743, 2020. 295 [10] Sinong Wang, Belinda Z. Li, Madian Khabsa, Han Fang, and Hao Ma. Linformer: Self-attention with 296 linear complexity. CoRR, abs/2006.04768, 2020. 297 [11] Yihe Dong, Jean-Baptiste Cordonnier, and Andreas Loukas. Attention is not all you need: Pure attention 298 loses rank doubly exponentially with depth. CoRR, abs/2103.03404, 2021. 299 [12] Saurabh Goyal, Anamitra Roy Choudhury, Saurabh Raje, Venkatesan T. Chakaravarthy, Yogish Sabhar 300 wal, and Ashish Verma. Power-bert: Accelerating BERT inference via progressive word-vector elimi 301 nation. In Proceedings of the 37th International Conference on Machine Learning, ICML 2020, 13-18 302 July 2020, Virtual Event, volume 119 of Proceedings of Machine Learning Research, pages 3690–3699. 303 PMLR, 2020. 304 [13] Nitish Srivastava, Geoffrey E. Hinton, Alex Krizhevsky, Ilya Sutskever, and Ruslan Salakhutdinov. 305 Dropout: a simple way to prevent neural networks from overfitting. J. Mach. Learn. Res., 15(1):1929– 306 1958, 2014. 307 [14] Li Wan, Matthew D. Zeiler, Sixin Zhang, Yann LeCun, and Rob Fergus. Regularization of neural networks 308 using dropconnect. In Proceedings of the 30th International Conference on Machine Learning, ICML 309 2013, Atlanta, GA, USA, 16-21 June 2013, volume 28 of JMLR Workshop and Conference Proceedings, 310 pages 1058–1066. JMLR.org, 2013. 311 [15] Zhuosheng Zhang, Yuwei Wu, Junru Zhou, Sufeng Duan, Hai Zhao, and Rui Wang. Sg-net: Syntax 312 guided machine reading comprehension. In The Thirty-Fourth AAAI Conference on Artificial Intelligence, 313 AAAI 2020, The Thirty-Second Innovative Applications of Artificial Intelligence Conference, IAAI 2020, 314 The Tenth AAAI Symposium on Educational Advances in Artificial Intelligence, EAAI 2020, New York, NY, 315 USA, February 7-12, 2020, pages 9636–9643. AAAI Press, 2020.
[16] Hongqiu Wu, Hai Zhao, and Min Zhang. Code summarization with structure-induced transformer. arXiv preprint arXiv:2012.14710, 2020. [17] Barret Zoph and Quoc V. Le. Neural architecture search with reinforcement learning. In 5th International Conference on Learning Representations, ICLR 2017, Toulon, France, April 24-26, 2017, Conference Track Proceedings. OpenReview.net, 2017. [18] Hanxiao Liu, Karen Simonyan, and Yiming Yang. DARTS: differentiable architecture search. In 7th International Conference on Learning Representations, ICLR 2019, New Orleans, LA, USA, May 6-9, 2019. OpenReview.net, 2019. [19] Hieu Pham and Quoc V. Le. Autodropout: Learning dropout patterns to regularize deep networks. CoRR, abs/2101.01761, 2021. [20] Günter Klambauer, Thomas Unterthiner, Andreas Mayr, and Sepp Hochreiter. Self-normalizing neural networks. In Isabelle Guyon, Ulrike von Luxburg, Samy Bengio, Hanna M. Wallach, Rob Fergus, S. V. N. Vishwanathan, and Roman Garnett, editors, Advances in Neural Information Processing Systems 30: Annual Conference on Neural Information Processing Systems 2017, December 4-9, 2017, Long Beach, CA, USA, pages 971–980, 2017. [21] Avrim Blum, Nika Haghtalab, and Ariel D. Procaccia. Variational dropout and the local reparameterization trick. In Corinna Cortes, Neil D. Lawrence, Daniel D. Lee, Masashi Sugiyama, and Roman Garnett, editors, Advances in Neural Information Processing Systems 28: Annual Conference on Neural Information Processing Systems 2015, December 7-12, 2015, Montreal, Quebec, Canada, pages 2575–2583, 2015. [22] Dmitry Molchanov, Arsenii Ashukha, and Dmitry P. Vetrov. Variational dropout sparsifies deep neural networks. In Doina Precup and Yee Whye Teh, editors, Proceedings of the 34th International Conference on Machine Learning, ICML 2017, Sydney, NSW, Australia, 6-11 August 2017, volume 70 of Proceedings of Machine Learning Research, pages 2498–2507. PMLR, 2017. [23] Sungrae Park, Jun-Keon Park, Su-Jin Shin, and Il-Chul Moon. Adversarial dropout for supervised and semi-supervised learning. In Sheila A. McIlraith and Kilian Q. Weinberger, editors, Proceedings of the Thirty-Second AAAI Conference on Artificial Intelligence, (AAAI-18), the 30th innovative Applications of Artificial Intelligence (IAAI-18), and the 8th AAAI Symposium on Educational Advances in Artificial Intelligence (EAAI-18), New Orleans, Louisiana, USA, February 2-7, 2018, pages 3917–3924. AAAI Press, 2018. [24] Hojjat Salehinejad and Shahrokh Valaee. Edropout: Energy-based dropout and pruning of deep neural networks. CoRR, abs/2006.04270, 2020. [25] Yarin Gal, Jiri Hron, and Alex Kendall. Concrete dropout. In Isabelle Guyon, Ulrike von Luxburg, Samy Bengio, Hanna M. Wallach, Rob Fergus, S. V. N. Vishwanathan, and Roman Garnett, editors, Advances in Neural Information Processing Systems 30: Annual Conference on Neural Information Processing Systems 2017, December 4-9, 2017, Long Beach, CA, USA, pages 3581–3590, 2017. [26] Shahin Boluki, Randy Ardywibowo, Siamak Zamani Dadaneh, Mingyuan Zhou, and Xiaoning Qian. Learnable bernoulli dropout for bayesian deep learning. In Silvia Chiappa and Roberto Calandra, editors, The 23rd International Conference on Artificial Intelligence and Statistics, AISTATS 2020, 26-28 August 2020, Online [Palermo, Sicily, Italy], volume 108 of Proceedings of Machine Learning Research, pages 3905–3916. PMLR, 2020. [27] Mingzhang Yin and Mingyuan Zhou. ARM: augment-reinforce-merge gradient for stochastic binary networks. In 7th International Conference on Learning Representations, ICLR 2019, New Orleans, LA, USA, May 6-9, 2019. OpenReview.net, 2019. [28] Xinjie Fan, Shujian Zhang, Korawat Tanwisuth, Xiaoning Qian, and Mingyuan Zhou. Contextual dropout: An efficient sample-dependent dropout module. CoRR, abs/2103.04181, 2021. [29] Angela Fan, Edouard Grave, and Armand Joulin. Reducing transformer depth on demand with structured dropout. In 8th International Conference on Learning Representations, ICLR 2020, Addis Ababa, Ethiopia, April 26-30, 2020. OpenReview.net, 2020. [30] Wangchunshu Zhou, Tao Ge, Furu Wei, Ming Zhou, and Ke Xu. Scheduled drophead: A regularization method for transformer models. In Trevor Cohn, Yulan He, and Yang Liu, editors, Proceedings of the 2020 Conference on Empirical Methods in Natural Language Processing: Findings, EMNLP 2020, Online Event, 16-20 November 2020, pages 1971–1980. Association for Computational Linguistics, 2020.
369 [31] Zewei Sun, Shujian Huang, Xinyu Dai, and Jiajun Chen. Alleviating the inequality of attention heads for 370 neural machine translation. CoRR, abs/2009.09672, 2020. 371 [32] Zhen Wu, Lijun Wu, Meng Qi, Yingce Xia, Shufang Xie, Tao Qin, Xinyu Dai, and Tie-Yan Liu. Unidrop: 372 A simple yet effective technique to improve transformer without extra cost. In Proceedings of the The 2021 373 Conference of the North American Chapter of the Association for Computational Linguistics - Human 374 Language Technologies, Volume 1 (Long Papers), 2021. 375 [33] Chris J. Maddison, Daniel Tarlow, and Tom Minka. $\mathbf { A } ^ { * }$ sampling. In Zoubin Ghahramani, Max Welling, 376 Corinna Cortes, Neil D. Lawrence, and Kilian Q. Weinberger, editors, Advances in Neural Information 377 Processing Systems 27: Annual Conference on Neural Information Processing Systems 2014, December 378 8-13 2014, Montreal, Quebec, Canada, pages 3086–3094, 2014. 379 [34] Xinwei Geng, Longyue Wang, Xing Wang, Bing Qin, Ting Liu, and Zhaopeng Tu. How does selective 380 mechanism improve self-attention networks? In Dan Jurafsky, Joyce Chai, Natalie Schluter, and Joel R. 381 Tetreault, editors, Proceedings of the 58th Annual Meeting of the Association for Computational Linguis 382 tics, ACL 2020, Online, July 5-10, 2020, pages 2986–2995. Association for Computational Linguistics, 383 2020. 384 [35] Ronald J. Williams. Simple statistical gradient-following algorithms for connectionist reinforcement 385 learning. Mach. Learn., 8:229–256, 1992. 386 [36] Thomas Wolf, Lysandre Debut, Victor Sanh, Julien Chaumond, Clement Delangue, Anthony Moi, Pier 387 ric Cistac, Tim Rault, Rémi Louf, Morgan Funtowicz, Joe Davison, Sam Shleifer, Patrick von Platen, 388 Clara Ma, Yacine Jernite, Julien Plu, Canwen Xu, Teven Le Scao, Sylvain Gugger, Mariama Drame, 389 Quentin Lhoest, and Alexander M. Rush. Transformers: State-of-the-art natural language processing. 390 In Proceedings of the 2020 Conference on Empirical Methods in Natural Language Processing: System 391 Demonstrations, pages 38–45, Online, October 2020. Association for Computational Linguistics. 392 [37] Alex Wang, Amanpreet Singh, Julian Michael, Felix Hill, Omer Levy, and Samuel R. Bowman. GLUE: 393 A multi-task benchmark and analysis platform for natural language understanding. In 7th International 394 Conference on Learning Representations, ICLR 2019, New Orleans, LA, USA, May 6-9, 2019. OpenRe 395 view.net, 2019. 396 [38] Andrew L. Maas, Raymond E. Daly, Peter T. Pham, Dan Huang, Andrew Y. Ng, and Christopher Potts. 397 Learning word vectors for sentiment analysis. In Dekang Lin, Yuji Matsumoto, and Rada Mihalcea, 398 editors, The 49th Annual Meeting of the Association for Computational Linguistics: Human Language 399 Technologies, Proceedings of the Conference, 19-24 June, 2011, Portland, Oregon, USA, pages 142–150. 400 The Association for Computer Linguistics, 2011. 401 [39] Erik F. Tjong Kim Sang and Fien De Meulder. Introduction to the conll-2003 shared task: Language 402 independent named entity recognition. In Walter Daelemans and Miles Osborne, editors, Proceedings 403 of the Seventh Conference on Natural Language Learning, CoNLL 2003, Held in cooperation with HLT 404 NAACL 2003, Edmonton, Canada, May 31 - June 1, 2003, pages 142–147. ACL, 2003. 405 [40] Mitchell P. Marcus, Beatrice Santorini, and Mary Ann Marcinkiewicz. Building a large annotated corpus 406 of english: The penn treebank. Comput. Linguistics, 19(2):313–330, 1993. 407 [41] Rowan Zellers, Yonatan Bisk, Roy Schwartz, and Yejin Choi. SWAG: A large-scale adversarial dataset 408 for grounded commonsense inference. In Ellen Riloff, David Chiang, Julia Hockenmaier, and Jun’ichi 409 Tsujii, editors, Proceedings of the 2018 Conference on Empirical Methods in Natural Language Process 410 ing, Brussels, Belgium, October 31 - November 4, 2018, pages 93–104. Association for Computational 411 Linguistics, 2018.
# 412 Checklist
1. For all authors...
(a) Do the main claims made in the abstract and introduction accurately reflect the paper’s contributions and scope? [Yes] (b) Did you describe the limitations of your work? [Yes] See Section 4.2. (c) Did you discuss any potential negative societal impacts of your work? [N/A] (d) Have you read the ethics review guidelines and ensured that your paper conforms to them? [Yes]
2. If you are including theoretical results...
(a) Did you state the full set of assumptions of all theoretical results? [Yes] See Section 4.2. (b) Did you include complete proofs of all theoretical results? [No]
3. If you ran experiments...
(a) Did you include the code, data, and instructions needed to reproduce the main experimental results (either in the supplemental material or as a URL)? [Yes] See supplemental material. (b) Did you specify all the training details (e.g., data splits, hyperparameters, how they were chosen)? [Yes] See Section 4.2 and appendix. (c) Did you report error bars (e.g., with respect to the random seed after running experiments multiple times)? [No] (d) Did you include the total amount of compute and the type of resources used (e.g., type of GPUs, internal cluster, or cloud provider)? [Yes] See Section 4.2 and appendix.
4. If you are using existing assets (e.g., code, data, models) or curating/releasing new assets...
(a) If your work uses existing assets, did you cite the creators? [Yes] See Section 5. (b) Did you mention the license of the assets? [N/A] (c) Did you include any new assets either in the supplemental material or as a URL? [No] (d) Did you discuss whether and how consent was obtained from people whose data you’re using/curating? [N/A] (e) Did you discuss whether the data you are using/curating contains personally identifiable information or offensive content? [No]
5. If you used crowdsourcing or conducted research with human subjects...
(a) Did you include the full text of instructions given to participants and screenshots, if applicable? [N/A] (b) Did you describe any potential participant risks, with links to Institutional Review Board (IRB) approvals, if applicable? [N/A] (c) Did you include the estimated hourly wage paid to participants and the total amount spent on participant compensation? [N/A]123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396# Multiple Descent: Design Your Own Generalization Curve
Lin Chen Simons Institute for the Theory of Computing University of California, Berkeley CA 94720 lin.chen@berkeley.edu
Yifei Min Department of Statistics and Data Science Yale University CT 06511 yifei.min@yale.edu
# Mikhail Belkin
Halıcıoglu Data Science Institute˘ University of California, San Diego CA 92093 mbelkin@ucsd.edu
Amin Karbasi School of Engineering and Applied Science Yale University CT 06511 amin.karbasi@yale.edu
# Abstract
This paper explores the generalization loss of linear regression in variably parameterized families of models, both under-parameterized and over-parameterized. We show that the generalization curve can have an arbitrary number of peaks, and moreover, locations of those peaks can be explicitly controlled. Our results highlight the fact that both classical U-shaped generalization curve and the recently observed double descent curve are not intrinsic properties of the model family. Instead, their emergence is due to the interaction between the properties of the data and the inductive biases of learning algorithms.
# 1 Introduction
The main goal of machine learning methods is to provide an accurate out-of-sample prediction, known as generalization. For a fixed family of models, a common way to select a model from this family is through empirical risk minimization, i.e., algorithmically selecting models that minimize the risk on the training dataset. Given a variably parameterized family of models, the statistical learning theory aims to identify the dependence between model complexity and model performance. The empirical risk usually decreases monotonically as the model complexity increases, and achieves its minimum when the model is rich enough to interpolate the training data, resulting in zero (or near-zero) training error. In contrast, the behaviour of the test error as a function of model complexity is far more complicated. Indeed, in this paper we show how to construct a model family for which the generalization curve can be fully controlled (away from the interpolation threshold) in both under-parameterized and over-parameterized regimes. Classical statistical learning theory supports a U-shaped curve of generalization versus model complexity [31, 33]. Under such a framework, the best model is found at the bottom of the U-shaped curve, which corresponds to appropriately balancing under-fitting and over-fitting the training data. From the view of the bias-variance trade-off, a higher model complexity increases the variance while decreasing the bias. A model with an appropriate level of complexity achieves a relatively low bias while still keeping the variance under control. On the other hand, a model that interpolates the training data is deemed to over-fit and tends to worsen the generalization performance due to the soaring variance.
Although classical statistical theory suggests a pattern of behavior for the generalization curve up to the interpolation threshold, it does not describe what happens beyond the interpolation threshold, commonly referred to as the over-parameterized regime. This is the exact regime where many modern machine learning models, especially deep neural networks, achieved remarkable success. Indeed, neural networks generalize well even when the models are so complex that they have the potential to interpolate all the training data points [61, 10, 32, 34].
Modern practitioners commonly deploy deep neural networks with hundreds of millions or even billions of parameters. It has become widely accepted that large models achieve performance superior to small models that may be suggested by the classical U-shaped generalization curve [13, 38, 55, 35, 36]. This indicates that the test error decreases again once model complexity grows beyond the interpolation threshold, resulting in the so called double-descent phenomenon described in [9], which has been broadly supported by empirical evidence [49, 48, 29, 30] and confirmed empirically on modern neural architectures by Nakkiran et al. [46]. On the theoretical side, this phenomenon has been recently addressed by several works on various model settings. In particular, Belkin et al. [11] proved the existence of double-descent phenomenon for linear regression with random feature selection and analyzed the random Fourier feature model [50]. Mei and Montanari [44] also studied the Fourier model and computed the asymptotic test error which captures the double-descent phenomenon. Bartlett et al. [8], Tsigler and Bartlett [56] analyzed and gave explicit conditions for “benign overfitting” in linear and ridge regression, respectively. Caron and Chretien [16] provided a finite sample analysis of the nonlinear function estimation and showed that the parameter learned through empirical risk minimization converges to the true parameter with high probability as the model complexity tends to infinity, implying the existence of double descent. Liu et al. [42] studied the high dimensional kernel ridge regression in the under- and over-parameterized regimes and showed that the risk curve can be double descent, bell-shaped, and monotonically decreasing.
Among all the aforementioned efforts, one particularly interesting question is whether one can observe more than two descents in the generalization curve. d’Ascoli et al. [21] empirically showed a samplewise triple-descent phenomenon under the random Fourier feature model. Similar triple-descent was also observed for linear regression [47]. More rigorously, Liang et al. [41] presented an upper bound on the risk of the minimum-norm interpolation versus the data dimension in Reproducing Kernel Hilbert Spaces (RKHS), which exhibits multiple descent. However, a multiple-descent upper bound without a properly matching lower bound does not imply the existence of a multiple-descent generalization curve. In this work, we study the multiple descent phenomenon by addressing the following questions:
• Can the existence of a multiple descent generalization curve be rigorously proven? • Can an arbitrary number of descents occur? • Can the generalization curve and the locations of descents be designed?
In this paper, we show that the answer to all three of these questions is yes. Further related work is presented in Section 2.
Our Contribution. We consider the linear regression model and analyze how the risk changes as the dimension of the data grows. In the linear regression setting, the data dimension is equal to the dimension of the parameter space, which reflects the model complexity. We rigorously show that the multiple descent generalization curve exists under this setting. To our best knowledge, this is the first work proving a multiple descent phenomenon.
Our analysis considers both the underparametrized and overparametrized regimes. In the overparametrized regime, we show that one can control where a descent or an ascent occurs in the generalization curve. This is realized through our algorithmic construction of a feature-revealing process. To be more specific, we assume that the data is in $\mathbb { R } ^ { D }$ , where $D$ can be arbitrarily large or even essentially infinite. We view each dimension of the data as a feature. We consider a linear regression problem restricted on the first $d$ features, where $d < D$ . New features are revealed by increasing the dimension of the data. We then show that by specifying the distribution of the newly revealed feature to be either a standard Gaussian or a Gaussian mixture, one can determine where an ascent or a descent occurs. In order to create an ascent when a new feature is revealed, it is sufficient that the feature follows a Gaussian mixture distribution. In order to have a descent, it is sufficient that the new feature follows a standard Gaussian distribution. Therefore, in the overparametrized regime, we can fully control the occurrence of a descent and an ascent. As a comparison, in the underparametrized regime, the generalization loss always increases regardless of the feature distribution. Generally speaking, we show that we are able to design the generalization curve.
On the one hand, we show theoretically that the generalization curve is malleable and can be constructed in an arbitrary fashion. On the other hand, we rarely observe complex generalization curves in practice, besides carefully curated constructions. Putting these facts together, we arrive at the conclusion that realistic generalization curves arise from specific interactions between properties of typical data and the inductive biases of algorithms. We should highlight that the nature of these interactions is far from being understood and should be an area of further investigations.
# 2 Related Work
Our work is directly related to the recent line of research in the theoretical understanding of the double descent [11, 34, 60, 44] and the multiple descent phenomenon [41, 39]. Here we briefly discuss some other work that is closely related to this paper.
Least Square Regression. In this paper we focus on the least square linear regression with no regularization. For the regularized least square regression, De Vito et al. [22] proposed a selection procedure for the regularization parameter. Advani and Saxe [1] analyzed the generalization of neural networks with mean squared error under the asymptotic regime where both the sample size and model complexity tend to infinity. Richards et al. [52] proved for least square regression in the asymptotic regime that as the dimension-to-sample-size ratio $d / n$ grows, an additional peak can occur in both the variance and bias due to the covariance structure of the features. As a comparison, in this paper the sample size is fixed and the model complexity increases. Rudi and Rosasco [53] studied kernel ridge regression and gave an upper bound on the number of the random features to reach certain risk level. Our result shows that there exists a natural setting where by manipulating the random features one can control the risk curve.
Over-Parameterization and Interpolation. The double descent occurs when the model complexity reaches and increases beyond the interpolation threshold. Most previous works focused on proving an upper bound or optimal rate for the risk. Caponnetto and De Vito [15] gave the optimal rate for least square ridge regression via careful selection of the regularization parameter. Belkin et al. [12] showed that the optimal rate for risk can be achieved by a model that interpolates the training data. In a series of work on kernel regression with regularization parameter tending to zero (a.k.a. kernel ridgeless regression), Rakhlin and Zhai [51] showed that the risk is bounded away from zero when the data dimension is fixed with respect to the sample size. Liang and Rakhlin [40] then considered the case when $d \asymp n$ , showed empirically the multiple descent phenomenon and proved a risk upper bound that can be small given favorable data and kernel assumptions. Instead of giving a bound, our paper presents an exact computation of risk in the cases of underparametrized and overparametrized linear regression, and proves the existence of the multiple descent phenomenon. Wyner et al. [59] analyzed AdaBoost and Random Forest from the perspective of interpolation. There has also been a line of work on wide neural networks [4–6, 23, 3, 58, 14, 2, 18, 62, 54].
Sample-wise Double Descent and Non-monotonicity. There has also been recent development beyond the model-complexity double-descent phenomenon. For example, regarding sample-wise non-monotonicity, Nakkiran et al. [46] empirically observed the epoch-wise double-descent and sample-wise non-monotonicity for neural networks. Chen et al. [19] and Min et al. [45] identified and proved the sample-wise double descent under the adversarial training setting, and Javanmard et al. [37] discovered double-descent under adversarially robust linear regression. Loog et al. [43] showed that empirical risk minimization can lead to sample-wise non-monotonicity in the standard linear model setting under various loss functions including the absolute loss and the squared loss, which covers the range from classification to regression. We also refer the reader to their discussion of the earlier work on non-monotonicity of generalization curves. Dar et al. [20] demonstrated the double descent curve of the generalization errors of subspace fitting problems. Fei et al. [28] studied the risk-sample tradeoff in reinforcement learning.
# 3 Preliminaries and Problem Formulation
Notation. For $x \in \mathbb { R } ^ { D }$ and $d \leq D$ , we let $x [ 1 : d ] \in \mathbb { R } ^ { d }$ denote a $d$ -dimensional vector with $x [ 1 : d ] _ { i } = x _ { i }$ for all $1 \ \leq \ i \ \leq \ d$ . For a matrix $A \ \in \ \mathbb { R } ^ { n \times d }$ , we denote its Moore-Penrose pseudoinverse by $A ^ { + } \in \mathbb { R } ^ { d \times n }$ and denote its spectral norm by $\textstyle \| A \| \triangleq \operatorname* { s u p } _ { x \neq 0 } { \frac { \| A x \| _ { 2 } } { \| x \| _ { 2 } } }$ kAxk2 , where k · k2 is the Euclidean norm for vectors. If $v$ is a vector, its spectral norm $\lVert v \rVert$ agrees with the Euclidean norm $\lVert \boldsymbol { v } \rVert _ { 2 }$ . Therefore, we write $\lVert v \rVert$ for $\lVert \boldsymbol { v } \rVert _ { 2 }$ to simplify the notation. We use the big $\mathrm { o }$ notation $\mathcal { O }$ and write variables in the subscript of $\mathcal { O }$ if the implicit constant depends on them. For example, ${ \mathcal { O } } _ { n , d , \sigma } ( 1 )$ is a constant that only depends on $n , d ,$ , and $\sigma$ . If $f ( \sigma )$ and $g ( \sigma )$ are functions of $\sigma$ , write $f ( \sigma ) \sim g ( \sigma )$ if $\begin{array} { r } { \operatorname* { l i m } \frac { f ( \sigma ) } { g ( \sigma ) } = 1 } \end{array}$ . It will be given in the context how we take the limit.
Distributions. Let ${ \mathcal { N } } ( \mu , \sigma ^ { 2 } )$ $( \mu , \sigma \in \mathbb { R } )$ and $\mathcal { N } ( \boldsymbol { \mu } , \boldsymbol { \Sigma } )$ $\mathbf { \mathcal { \mu } } _ { \mathbf { \lambda } } ( \mathbf { \mathcal { \mu } } _ { \mathbf { \lambda } } \mathbf { \mathbb { R } } ^ { n }$ , $\Sigma \in \mathbb { R } ^ { n \times n }$ ) denote the univariate and multivariate Gaussian distributions, respectively, where $\boldsymbol { \mu } \in \mathbb { R } ^ { n }$ and $\boldsymbol { \Sigma } \in \mathbb { R } ^ { n \times n }$ is a positive semi-definite matrix. We define a family of trimodal Gaussian mixture distributions as follows
$$\mathcal { N } _ { \sigma , \mu } ^ { \mathrm { m i x } } \triangleq \frac 1 3 { N ( 0 , \sigma ^ { 2 } ) + \frac { 1 } { 3 } } { N ( - \mu , \sigma ^ { 2 } ) + \frac { 1 } { 3 } } { N ( \mu , \sigma ^ { 2 } ) } .$$
For an illustration, please see Fig. 1.
 Figure 1: Density functions of the $\mathcal { N } ( 0 , 1 )$ and $\mathcal { N } _ { \sigma , 1 } ^ { \mathrm { m i x } }$ feature. A new entry is independently sampled from the 1-dimensional distribution being either a standard Gaussian or trimodal Gaussian mixture. Smaller $\sigma$ leads to higher concentration around each modes.
Let $\chi ^ { 2 } ( k , \lambda )$ denote the noncentral chi-squared distribution with $k$ degrees of freedom and the non-centrality parameter $\lambda$ . For example, if $X _ { i } \sim \mathcal { N } ( \mu _ { i } , 1 )$ (for $i = 1 , 2 , \ldots , k )$ are independent Gaussian random variables, we have ${ \textstyle \sum _ { i = 1 } ^ { k } X _ { i } ^ { 2 } \sim \chi ^ { 2 } ( k , \lambda ) }$ , where $\begin{array} { r } { \lambda = \sum _ { i = 1 } ^ { k } \mu _ { i } ^ { 2 } } \end{array}$ . We also denote by $\chi ^ { 2 } ( k )$ the (central) chi-squared distribution with $k$ degrees and the $F$ -distribution by $F ( d _ { 1 } , d _ { 2 } )$ where $d _ { 1 }$ and $d _ { 2 }$ are the degrees of freedom.
Problem Setup. Let $x _ { 1 } , \ldots , x _ { n } \in \mathbb { R } ^ { D }$ be column vectors that represent the training data of size $n$ and let $\boldsymbol { x } _ { \mathrm { t e s t } } \boldsymbol { \bar { \in } } \mathbb { R } ^ { D }$ be a column vector that represents the test data. We assume that they are all independently drawn from a distribution
$$x _ { 1 } , \ldots , x _ { n } , x _ { \mathrm { t e s t } } \overset { i i d } { \sim } \mathcal { D } .$$
Let us consider a linear regression problem on the first $d$ features, where $d \leq D$ for some arbitrary large $D$ . Here, $d$ can be viewed as the number of features revealed. Then the feature vectors are $\tilde { x } _ { 1 } , \ldots , \tilde { x } _ { n }$ , where $\widetilde { x } _ { i } = x _ { i } [ 1 : d ] \in \mathbb { R } ^ { d }$ denotes the first $d$ entries of $x _ { i }$ . The corresponding response variable $y _ { i }$ satisfies
$$y _ { i } = \tilde { x } _ { i } ^ { \top } \beta + \varepsilon _ { i } , \quad i = 1 , \ldots , n ,$$
where the noise $\varepsilon _ { i } \sim \mathcal { N } ( 0 , \eta ^ { 2 } )$ . We use the same setup as in [34] (see Equations (1) and (2) in [34]). Moreover, in another closely related work [41], if the kernel is set to the linear kernel, it is equivalent to our setup.
Next, we introduce the estimate $\hat { \beta }$ of $\beta$ and its excess generalization loss. Let $\varepsilon = ( \varepsilon _ { 1 } , \ldots , \varepsilon _ { n } ) ^ { \top } \in \mathbb { R } ^ { n }$ denote the noise vector. The design matrix $A$ equals $[ \tilde { x } _ { 1 } , \ldots , \tilde { x } _ { n } ] ^ { \top } \in \mathbb { R } ^ { n \times d }$ . Let $x = x _ { \mathrm { t e s t } } [ 1 : d ]$ denote the first $d$ features of the test data. For the underparametrized regime where $d < n$ , the least square solution on the training data is $A ^ { + } ( A \beta + \varepsilon )$ . For the overparametrized regime where $d > n$ , $A ^ { + } ( A \beta + \varepsilon )$ is the minimum-norm solution. In both regimes we consider the solution ${ \hat { \boldsymbol { \beta } } } \triangleq A ^ { + } ( A \beta + \varepsilon )$ . The excess generalization loss on the test data is then given by
$$\begin{array} { r l } & { L _ { d } \triangleq \mathbb { E } [ ( y - x ^ { \top } \hat { \beta } ) ^ { 2 } - ( y - x ^ { \top } \beta ) ^ { 2 } ] } \\ & { \quad = \mathbb { E } [ ( x ^ { \top } ( \hat { \beta } - \beta ) ) ^ { 2 } ] } \\ & { \quad = \mathbb { E } [ ( x ^ { \top } ( ( A ^ { + } A - I ) \beta + A ^ { + } \varepsilon ) ) ^ { 2 } ] } \\ & { \quad = \mathbb { E } [ ( x ^ { \top } ( A ^ { + } A - I ) \beta ) ^ { 2 } ] + \mathbb { E } [ ( x ^ { \top } A ^ { + } \varepsilon ) ^ { 2 } ] } \\ & { \quad = \mathbb { E } [ ( x ^ { \top } ( A ^ { + } A - I ) \beta ) ^ { 2 } ] + \eta ^ { 2 } \mathbb { E } ( A ^ { \top } ) ^ { + } x ^ { 2 } , } \end{array}$$
where $y = x ^ { \top } \beta + \varepsilon _ { \mathrm { t e s t } }$ and $\varepsilon _ { \mathrm { t e s t } } \sim \mathcal { N } ( 0 , \eta ^ { 2 } )$ . We call the term $\mathbb { E } \left[ ( x ^ { \top } ( A ^ { + } A - I ) \beta ) ^ { 2 } \right]$ the bias and call the term $\eta ^ { 2 } \mathbb { E } \left\| ( A ^ { \top } ) ^ { + } x \right\| ^ { 2 }$ the variance.
The next remark shows that in the underparametrized regime, the bias vanishes. The vanishing bias in the underparametrized regime is also observed by Hastie et al. [34] and shown in their Proposition 2.
Remark 1. In the underparametrized regime, if $\mathcal { D }$ is a continous distribution (our construction presented later satisfies this condition), the matrix $A$ has independent column almost surely. In this case, we have $A ^ { + } A = I$ and therefore the bias $\mathbb { E } \left[ ( x ^ { \top } ( A ^ { + } A - I ) \beta ) ^ { 2 } \right]$ vanishes irrespective of $\beta$ . In other words, in the underparametrized regime, $L _ { d }$ equals $\eta ^ { 2 } \mathbb { E } \| ( A ^ { \top } ) ^ { + } x \| ^ { 2 }$ .
According to Remark 1, we have $L _ { d } = \eta ^ { 2 } \mathbb { E } \| ( A ^ { \top } ) ^ { + } x \| ^ { 2 }$ in the underparametrized regime. It also holds in the overparametrized regime when $\beta = 0$ . Without loss of generality, we assume $\eta = 1$ in the underparametrized regime (for all $\beta$ ). In the overparametrized regime, we also assume $\eta = 1$ for the $\beta = 0$ case. In this case, we have
$$L _ { d } = \mathbb { E } \| ( A ^ { \top } ) ^ { + } x \| ^ { 2 } .$$
We assume a general $\eta$ (i.e., not necessarily being 1) in the overparametrized regime when $\beta$ is non-zero.
We would like to study the change in the loss caused by the growth in the number of features revealed. Recall $L _ { d } = \mathbb { E } \| ( A ^ { \top } ) ^ { + } x \| ^ { 2 }$ . Once we reveal a new feature, which adds a new row $b ^ { \top }$ to $A ^ { \top }$ and a new component $a _ { 1 }$ to $x$ , we have $L _ { d + 1 } = \mathbb { E } { \left. \left[ \binom { A ^ { \top } } { b ^ { \top } } \right] ^ { + } \left[ \frac { x } { a _ { 1 } } \right] \right. } ^ { 2 } .$
Local Maximum and Multiple Descent. Throughout the paper, we say that a local maximum occurs at a dimension $d \geq 1$ if $L _ { d - 1 } < L _ { d }$ and $L _ { d } > L _ { d + 1 }$ . Intuitively, a local maximum occurs if there is an increasing stage of the generalization loss, followed by a decreasing stage, as the dimension $d$ grows. Additionally, we define $L _ { 0 } \triangleq - \infty$ . If the generalization loss exhibits a single descent, based on our definition, a unique local maximum occurs at $d = 1$ . For a double-descent generalization curve, a local maximum occurs at two different dimensions. In general, if we observe local maxima at multiple dimensions, we say there is a multiple descent.
# 4 Underparametrized Regime
First, we present our main theorem for the underparametrized regime below, whose proof is deferred to the end of Section 4. It states that the generalization loss $L _ { d }$ is always non-decreasing as $d$ grows. Moreover, it is possible to have an arbitrarily large ascent, i.e., $L _ { d + 1 } - L _ { d } > C$ for any $C > 0$ .
Theorem 1 (Proof in Section 4.1). If $d < n$ , we have $L _ { d + 1 } \ge L _ { d }$ irrespective of the data distribution Moreover, for any $C > 0$ , there exists a distribution $\mathcal { D }$ such that $L _ { d + 1 } - L _ { d } > C$ .
Remark 2 ( $\mathcal { D }$ can be a product distribution). The first part of Theorem 1 holds irrespective of the data distribution. For the second part of the theorem ( i.e., for any $C > 0$ there exists a distribution such that $L _ { d + 1 } - L _ { d } > C )$ to hold, one extremely simple and elegant choice of the distribution $\mathcal { D }$ is a product distribution $\mathcal { D } = \mathcal { D } _ { 1 } \times \cdot \cdot \cdot \times \mathcal { D } _ { D }$ such that $x _ { i , j } \stackrel { i i d } { \sim } \mathcal { D } _ { j }$ for all $1 \leq i \leq n$ , where $\mathcal { D } _ { j }$ is a Gaussian mixture $\mathcal { N } _ { \sigma _ { j } , 1 } ^ { \mathrm { m i x } }$ for some $\sigma _ { j } > 0$ . Since the second part of Theorem 1 is of independent interest, the result is summarized by Theorem 4.
Remark 3 (Kernel regression on Gaussian data). In light of Remark 2, $\mathcal { D }$ can be chosen to be a product distribution that consists $\mathcal { N } _ { \sigma _ { j } } ^ { \mathrm { m i x } }$ . Note that one can simulate $\mathcal { N } _ { \sigma , 1 } ^ { \mathrm { m i x } }$ with $\mathcal { N } ( 0 , 1 )$ through the inverse transform sampling. To see this, let $F _ { \mathcal { N } ( 0 , 1 ) }$ and $F _ { \mathrm { \mathcal { N } _ { \sigma , 1 } ^ { \mathrm { m i x } } } }$ be the cdf of $\mathcal { N } ( 0 , 1 )$ and $\mathcal { N } _ { \sigma , 1 } ^ { \mathrm { m i x } }$ , respectively. If $X \sim \mathcal { N } ( 0 , 1 )$ , we have $F _ { \mathcal { N } ( 0 , 1 ) } ( X ) \sim \mathrm { U n i f } ( ( 0 , 1 ) )$ and therefore $\varphi _ { \sigma } ( X ) \triangleq$ $F _ { \mathcal { N } _ { \sigma , 1 } ^ { \mathrm { m i x } } } ^ { - 1 } ( F _ { \mathcal { N } ( 0 , 1 ) } ( X ) ) \sim \mathcal { N } _ { \sigma , 1 } ^ { \mathrm { m i x } }$ . In fact, we can use a multivariate Gaussian $\mathcal { D } ^ { \prime } = \mathcal { N } ( 0 , I _ { D \times D } )$ and a sequence of non-linear kernels $k ^ { [ 1 : d ] } ( x , x ^ { \prime } )$ , $\langle \phi ^ { [ 1 : d ] } ( x ) , \phi ^ { [ 1 : d ] } ( x ^ { \prime } ) \rangle$ , where the feature map is $\phi ^ { [ 1 : d ] } ( x ) \ \triangleq \ [ \phi _ { 1 } ( x _ { 1 } ) , \phi _ { 2 } ( x _ { 2 } ) , \ldots , \phi _ { d } ( x _ { d } ) ] ^ { \top } \ \in \ \mathbb { R } ^ { d }$ . Here is a simple rule for defining $\phi _ { j }$ : if $\mathcal { D } _ { j } = \mathcal { N } _ { \sigma _ { j } } ^ { \mathrm { m i x } }$ , we set $\phi _ { j }$ to $\varphi _ { \sigma _ { j } }$ . Thus, the problem becomes a kernel regression problem on the standard Gaussian data.
The first part of Theorem 1, which says that $L _ { d }$ is increasing (or more precisely, non-decreasing), agrees with Figure 1 of [11] and Proposition 2 of [34]. In [34], they proved that the risk increases with $\gamma = d / n$ . Note that, at first glance, Theorem 1 may look counterintuitive since it does not obey the classical U-shaped generalization curve. However, we would like to emphasize that the U-shaped curve does not always occur. In Figure 1 and Proposition 2 of these two papers respectively, there is no U-shaped curve. The intuition behind Theorem 1 is that in the underparametrized setting, the bias is always zero and as $d$ approaches $n$ , the variance keeps increasing.
Coming to the second part of Theorem 1, we now discuss how we will construct such a distribution $\mathcal { D }$ inductively to satisfy $L _ { d + 1 } - L _ { d } > C$ . We fix $d$ . Again, denote the first $d$ features of $x _ { \mathrm { t e s t } }$ by $x \triangleq x _ { \mathrm { t e s t } } [ 1 : d ]$ . Let us add an additional component to the training data $x _ { 1 } [ 1 : d ] , \dotsc , x _ { n } [ 1 : d ]$ and test data $x$ so that the dimension $d$ is incremented by 1. Let $b _ { i } \in \mathbb { R }$ denote the additional component that we add to the vector $x _ { i }$ (so that the new vector is given as $[ x _ { i } [ 1 : d ] ^ { \top } , b _ { i } ] ^ { \top }$ . Similarly, let $a _ { 1 } \in \mathbb { R }$ denote the additional component that we add to the test vector $x$ . We form the column vector $b = [ b _ { 1 } , \ldots , b _ { n } ] ^ { \top } \in \mathbb { R } ^ { n }$ that collects all additional components that we add to the training data.
We consider the change in the generalization loss as follows
$$L _ { d + 1 } - L _ { d } = \mathbb { E } \left[ \left. \left[ \mathbf { \Sigma } _ { b } ^ { A } \right] ^ { + } \left[ \mathbf { \Sigma } _ { a _ { 1 } } ^ { x } \right] \right. ^ { 2 } - \left. ( A ^ { + } ) ^ { \top } x \right. ^ { 2 } \right] .$$
Note that the components $b _ { 1 } , \ldots , b _ { n } , a _ { 1 }$ are i.i.d. The proof of Theorem 1 starts with Lemma 2 which relates the pseudo-inverse of $[ A , b ] ^ { \top }$ to that of $A ^ { \top }$ . In this way, we can decompose $\left\| \left[ \binom { A ^ { \top } } { b ^ { \top } } \right] ^ { + } \left[ \binom { x } { a _ { 1 } } \right] \right\| ^ { 2 }$ into multiple terms for further careful analysis in the proofs hereinafter.
Lemma 2 (Proof in Appendix B.1). Let $A \in \mathbb { R } ^ { n \times d }$ and $0 \neq b \in \mathbb { R } ^ { n \times 1 }$ , where $n \geq d + 1$ Additionally, let $P = A A ^ { + }$ and $\begin{array} { r } { Q = b b ^ { + } = \frac { b b ^ { \top } } { \| b \| ^ { 2 } } } \end{array}$ bb>2 , and define z , b>(I−P )b2 . If $z \neq 0$ and the columnwise partitioned matrix $[ A , b ]$ has linearly independent columns, we have
$$\begin{array} { r l } & { \left[ \boldsymbol { A } ^ { \top } \right] ^ { + } = \left[ \left( I - \frac { b b ^ { \top } } { \| b \| ^ { 2 } } \right) \left( I + \frac { \boldsymbol { A } \boldsymbol { A } ^ { + } b \boldsymbol { b } ^ { \top } } { \| b \| ^ { 2 } - b ^ { \top } \boldsymbol { A } \boldsymbol { A } ^ { + } b } \right) ( \boldsymbol { A } ^ { + } ) ^ { \top } , \frac { ( I - \boldsymbol { A } \boldsymbol { A } ^ { + } ) \boldsymbol { b } } { \| b \| ^ { 2 } - b ^ { \top } \boldsymbol { A } \boldsymbol { A } ^ { + } \boldsymbol { b } } \right] } \\ & { = \left[ ( I - \boldsymbol { Q } ) ( I + \frac { P Q } { 1 - \mathrm { t r } ( P Q ) } ) ( \boldsymbol { A } ^ { + } ) ^ { \top } , \frac { ( I - P ) \boldsymbol { b } } { b ^ { \top } ( I - P ) \boldsymbol { b } } \right] } \\ & { = \left[ ( I - Q ) ( I + \frac { P Q } { z } ) ( \boldsymbol { A } ^ { + } ) ^ { \top } , \frac { ( I - P ) \boldsymbol { b } } { b ^ { \top } ( I - P ) \boldsymbol { b } } \right] . } \end{array}$$
In our construction of $\mathcal { D }$ , the components $\mathcal { D } _ { j }$ are all continuous distributions. The matrix $I - P$ is an orthogonal projection matrix and therefore $\operatorname { i r a n k } ( I - P ) = n - d .$ . As a result, it holds almost surely that $b \neq 0$ , $z \neq 0$ , and $[ A , b ]$ has linearly independent columns. Thus the assumptions of Lemma 2 are satisfied almost surely. In the sequel, we assume that these assumptions are always fulfilled.
Theorem 3 guarantees that if $L _ { d } = \mathbb { E } \left\| ( A ^ { + } ) ^ { \top } x \right\| ^ { 2 }$ is finite and the $( d + 1 )$ -th features $b _ { 1 } , \ldots , b _ { n } , a _ { 1 }$ are i.i.d. sampled from $\mathcal { N } ( 0 , 1 )$ or $\mathcal { N } _ { \sigma , 1 } ^ { \mathrm { m i x } }$ , $L _ { d + 1 } = \mathbb { E } \| [ { \binom { A ^ { \top } } { b ^ { \top } } } ^ { + } [ { \binom { x } { a _ { 1 } } } ] \| ^ { 2 }$ is also finite.
Theorem 3 (Proof in Appendix B.2). Let $z$ be as defined in Lemma 2. If $b _ { 1 } , \ldots , b _ { n } , a _ { 1 }$ are i.i.d. and follow a distribution with mean zero, conditioned on $A$ and $x$ , we have
$$\mathbb { E } _ { b , a _ { 1 } } \left[ \left. \left[ \boldsymbol { \mathsf { A } } ^ { \top } \right] ^ { + } \left[ \boldsymbol { \mathsf { x } } _ { 1 } \right] \right. ^ { 2 } \right] \leq \mathbb { E } _ { b , a _ { 1 } } \left[ \frac { 1 } { z } \left. ( \boldsymbol { A } ^ { + } ) ^ { \top } \boldsymbol { \mathsf { x } } \right. ^ { 2 } + \frac { a _ { 1 } ^ { 2 } } { b ^ { \top } ( I - P ) b } \right] .$$
In particular, if $d + 2 < n$ and $b _ { 1 } , \dots , b _ { n } , a _ { 1 } \overset { i i d } { \sim } \mathcal { N } ( 0 , 1 )$ , conditioned on $A$ and $x$ , we have
$$\begin{array} { r l } & { \mathbb { E } _ { b , a _ { 1 } } \left[ \left. \left[ \boldsymbol { \mathsf { A } } ^ { \top } \right] ^ { + } \left[ \boldsymbol { \mathsf { x } } _ { 1 } \right] \right. ^ { 2 } \right] \leq \frac { ( n - 2 ) \left. ( \boldsymbol { \mathsf { A } } ^ { + } ) ^ { \top } \boldsymbol { \mathsf { x } } \right. ^ { 2 } + 1 } { n - d - 2 } . } \end{array}$$
$d + 2 < n$ and $b _ { 1 } , \dots , b _ { n } , a _ { 1 } \overset { i i d } { \sim } \mathcal { N } _ { \sigma , 1 } ^ { \mathrm { m i x } }$ , conditioned on $A$ and $x$ , we have
$$\mathbb { E } _ { b , a _ { 1 } } \| [ \binom { A ^ { \top } } { b ^ { \top } } ^ { + } [ \frac { x } { a _ { 1 } } ] \| ^ { 2 } \leq \frac { ( n - 2 + \sqrt { d } ) \| ( A ^ { + } ) ^ { \top } x \| ^ { 2 } + 2 / ( 3 \sigma ^ { 2 } ) + 1 } { n - d - 2 } .$$
Using Theorem 3, we can show inductively (on $d$ ) that $L _ { d }$ is finite for every $d$ . Provided that we are able to guarantee finite $L _ { 1 }$ , Theorem 3 implies that $L _ { d }$ is finite for every $d$ if the components are always sampled from $\mathcal { N } ( 0 , 1 )$ or $\mathcal { N } _ { \sigma , 1 } ^ { \mathrm { m i x } }$ .
Making a large $L _ { d }$ can be achieved by adding an entry sampled from $\mathcal { N } _ { \sigma , 1 } ^ { \mathrm { m i x } }$ when the data dimension increases from $d - 1$ to $d$ in the previous step. Theorem 4 shows that adding a $\mathcal { N } _ { \sigma , 1 } ^ { \mathrm { m i x } }$ feature can increase the loss by arbitrary amount, which in turn implies the second part of Theorem 1.
Theorem 4 (Proof in Appendix B.4). For any $\sigma > 0$ such that if $\mathbf { \dot { \cdot } } b _ { 1 } , \dots , b _ { n } , a _ { 1 } \overset { i i d } { \sim } \mathcal { N } _ { \sigma , 1 } ^ { \operatorname* { m i x } }$ , we have $C > 0$ and $\mathbb { E } \left\| ( A ^ { + } ) ^ { \top } x \right\| ^ { 2 } < + \infty$ , there exists $a$
$$\begin{array} { r } { \mathbb { E } \left[ \left. \left[ \boldsymbol { \mathsf { A } } ^ { \top } \right] ^ { + } \left[ \boldsymbol { \mathsf { x } } _ { 1 } \right] \right. ^ { 2 } - \left. ( \boldsymbol { \mathsf { A } } ^ { + } ) ^ { \top } \boldsymbol { \mathsf { x } } \right. ^ { 2 } \right] > C . } \end{array}$$
We are now ready to prove Theorem 1.
# 4.1 Proof of Theorem 1
Proof. We follow the notation convention in (3):
$$\begin{array} { r } { L _ { d + 1 } - L _ { d } = \mathbb { E } \left[ \left. \left[ \boldsymbol { \mathsf { A } } ^ { \top } \right] ^ { + } \left[ \boldsymbol { \mathsf { a } } _ { 1 } \right] \right. ^ { 2 } - \left. ( \boldsymbol { A } ^ { \top } ) ^ { + } \boldsymbol { \mathsf { x } } \right. ^ { 2 } \right] . } \end{array}$$
Recall d < n and the matrix B0 , $B ^ { \prime } \triangleq { \left[ \begin{array} { l } { A ^ { \top } } \\ { b ^ { \top } } \end{array} \right] }$ is of size $( d + 1 ) \times n$ . Both matrices $B ^ { \prime }$ and $B \triangleq A ^ { \intercal }$ are fat matrices. As a result, if $x ^ { \prime } \triangleq { \left[ \begin{array} { l } { x } \\ { a _ { 1 } } \end{array} \right] }$ , we have
$$\| B ^ { \prime + } x ^ { \prime } \| ^ { 2 } = \operatorname* { m i n } _ { z : B ^ { \prime } z = x ^ { \prime } } \| z \| ^ { 2 } , \quad \| B ^ { + } x \| ^ { 2 } = \operatorname* { m i n } _ { z : B z = x } \| z \| ^ { 2 } .$$
Since $\{ z \mid B ^ { \prime } z = x ^ { \prime } \} \subseteq \{ z \mid B z = x \}$ , we get $\| B ^ { \prime + } x ^ { \prime } \| ^ { 2 } \geq \| B ^ { + } x \| ^ { 2 }$ . Therefore, we obtain $L _ { d + 1 } \ge L _ { d }$ . The second part follows from Theorem 4.
Remark 4. Remark 2 and the proof of Theorem 4 indicate that $\mathcal { D } = \mathcal { D } _ { 1 } \times \cdot \cdot \cdot \times \mathcal { D } _ { D }$ is a product distribution. The construction in the proof also shows that the generalization curve is determined by the specific choice of the $\mathcal { D } _ { i }$ ’s. Note that permuting the order of $\mathcal { D } _ { i }$ ’s is equivalent to changing the order by which the features are being revealed (i.e., permuting the entries of the data $x _ { i }$ ’s). Therefore, given the same data points $x _ { 1 } , \cdot \cdot \cdot , x _ { n } \in \mathbb { R } ^ { D }$ , one can create different generalization curves simply by changing the order of the feature-revealing process.
 Figure 2: Illustration of the multiple descent phenomenon for the generalization loss $L _ { d }$ versus the dimension of data $d$ in the overparametrized regime starting from $d = n { + } 8$ . One can fully control the generalization curve to increase or decrease as specified by the sequence $\Delta = \{ \downarrow , \uparrow , \downarrow , \downarrow , \uparrow , \downarrow , . . . \}$ . Adding a new feature with Gaussian mixture distribution increases the loss, while adding one with Gaussian distribution decreases the loss.
# 5 Overparametrized Regime
In this section, we study the multiple decent phenomenon in the overparametrized regime. Note that as stated in Section 3, we consider the minimum-norm solution here. We first consider the case where the model $\beta = 0$ and $L _ { d }$ is as defined in (2). Then we discuss the setting $\beta \neq 0$ .
As stated in the following theorem, we require $d \ge n + 8$ . This is merely a technical requirement and we can still say that $d$ starts at roughly the same order as $n$ . In other words, the result covers almost the entire spectrum of the overparametrized regime.
Theorem 5 (Overparametrized regime, $\beta ~ = ~ 0 ,$ . Let $\begin{array} { l l l } { n } & { < } & { D ~ - ~ 9 } \end{array}$ . Given any sequence $\Delta _ { n + 8 } , \Delta _ { n + 9 } , . . . , \Delta _ { D - 1 }$ where $\Delta _ { d } \in \{ \uparrow , \downarrow \}$ , there exists a distribution $\mathcal { D }$ such that for every $n + 8 \leq d \leq D - 1$ , we have
$$L _ { d + 1 } \left\{ \stackrel { > } { _ { < } } L _ { d } , \quad i f \Delta _ { d } = \uparrow \right.$$
In Theorem 5, the sequence $\Delta _ { n + 8 } , \Delta _ { n + 9 } , \cdot \cdot \cdot , \Delta _ { D - 1 }$ is just used to specify the increasing/decreasing behavior of the $L _ { d }$ sequence for $d > n + 8$ . Compared to Theorem 1 for the underparametrized regime, where $L _ { d }$ always increases, Theorem 5 indicates that one is able to fully control both ascents and descents in the overparametrized regime. Fig. 2 is an illustration.
We now present tools for proving Theorem 5. Lemma 6 gives the pseudo-inverse of $A$ when $d > n$ . Lemma 6 (Proof in Appendix C.1). Let $A \in \mathbb { R } ^ { n \times d }$ and $b \in \mathbb { R } ^ { n \times 1 }$ , where $n \leq d$ . Assume that matrix $A$ and the columnwise partitioned matrix $B \triangleq [ A , b ]$ have linearly independent rows. Let $G \triangleq ( A A ^ { \top } ) ^ { - 1 } \in \mathbb { R } ^ { n \times n }$ and $\begin{array} { r } { u \triangleq \frac { b ^ { \intercal } G } { 1 + b ^ { \intercal } G b } \in \mathbb { R } ^ { 1 \times n } } \end{array}$ . We have
$$\left[ \begin{array} { l } \boldsymbol { A } ^ { \top } \right] ^ { + } = \left[ ( \boldsymbol { I } - b \boldsymbol { u } ) ^ { \top } ( \boldsymbol { A } ^ { + } ) ^ { \top } , \boldsymbol { u } ^ { \top } \right] . \end{array}$$
Lemma 7 establishes finite expectation for several random variables. These finite expectation results are necessary for Theorem 8 and Theorem 9 to hold. Technically, they are the dominating random variables needed in Lebesgue’s dominated convergence theorem. Lemma 7 indicates that to guarantee these finite expectations, it suffices to set the first $n + 8$ distributions to the standard normal distribution and then set $\mathcal { D } _ { n + 8 } , \ldots , \mathcal { D } _ { D }$ to either a Gaussian or a Gaussian mixture distribution. In fact, in Theorem 8 and Theorem 9, we always add a Gaussian distribution or a Gaussian mixture.
Lemma 7 (Proof in Appendix C.2). Let $\mathcal { D } = \mathcal { D } _ { 1 } \times \cdot \cdot \cdot \times \mathcal { D } _ { D }$ be a product distribution where
Let $\mathcal { D } _ { [ 1 : d ] }$ denote $\mathcal { D } _ { 1 } \times \cdots \times \mathcal { D } _ { d }$ . Assume that every row of $A \in \mathbb { R } ^ { n \times d }$ and $x \in \mathbb { R } ^ { d \times 1 }$ are i.i.d. and follow $\mathcal { D } _ { [ 1 : d ] }$ . For any $d$ such that $n + 8 \leq d \leq D$ , all of the followings hold:
$$\begin{array} { r l r } & { \mathbb E [ \| ( A ^ { + } ) ^ { \top } x \| ^ { 2 } ] < + \infty , } & { \mathbb E [ \lambda _ { \operatorname* { m a x } } ^ { 2 } ( ( A A ^ { \top } ) ^ { - 1 } ) ] < + \infty , } \\ & { \mathbb E [ \lambda _ { \operatorname* { m a x } } ( ( A A ^ { \top } ) ^ { - 1 } ) \| ( A ^ { + } ) ^ { \top } x \| ^ { 2 } ] < + \infty , } & { \mathbb E [ \lambda _ { \operatorname* { m a x } } ^ { 2 } ( ( A A ^ { \top } ) ^ { - 1 } ) \| ( A ^ { + } ) ^ { \top } x \| ^ { 2 } ] < + \infty . } \end{array}$$
Theorems 8 and 9 are the key technical results for constructing multiple descent in the overparametrized regime. One can create a descent $( L _ { d + 1 } < L _ { d } )$ by adding a Gaussian feature (Theorem 8) and create an ascent $( L _ { d + 1 } > L _ { d } )$ by adding a Gaussian mixture feature (Theorem 9).
Theorem 8 (Proof in Appendix C.3). If E $\bar { \mathsf { x } } [ \| ( A ^ { \top } A ) ^ { + } x \| ^ { 2 } ] > 0$ and all equations in (4) hold, there exists $\sigma > 0$ such that i $f a _ { 1 } , b _ { 1 } , \ldots , b _ { n } \stackrel { i i d } { \sim } { \mathcal { N } } ( 0 , \sigma ^ { 2 } )$ , we have
$$L _ { d + 1 } - L _ { d } = \mathbb { E } \| [ { \binom { A ^ { \top } } { b ^ { \top } } } ^ { + } [ { \binom { x } { a _ { 1 } } } ] \| ^ { 2 } - \mathbb { E } \| ( A ^ { + } ) ^ { \top } x \| ^ { 2 } < 0 .$$
Theorem 9 shows that adding a Gaussian mixture feature can make $L _ { d + 1 } > L _ { d }$ .
Theorem 9 (Proof in Appendix C.4). Assume $\sigma > 0$ such that $i f a _ { 1 } , b _ { 1 } , \ldots , b _ { n } \stackrel { i i d } { \sim } \mathcal { N } _ { \sigma , \mu } ^ { \mathrm { m i x } }$ , we have $\mathbb { E } \| ( A ^ { + } ) ^ { \top } x \| ^ { 2 } < + \infty$ . For any $C > 0$ , there exist $\mu$
$$L _ { d + 1 } - L _ { d } = \mathbb { E } \| [ { \binom { A ^ { \top } } { b ^ { \top } } } ^ { + } [ { \binom { x } { a _ { 1 } } } ] \| ^ { 2 } - \mathbb { E } \| ( A ^ { + } ) ^ { \top } x \| ^ { 2 } > C .$$
The proof of Theorem 5 immediately follows from Theorem 8 and Theorem 9.
Proof of Theorem 5. We construct the product distribution $\begin{array} { r } { \mathcal { D } = \prod _ { d = 1 } ^ { D } \mathcal { D } _ { d } } \end{array}$ . We set $\mathcal { D } _ { d } = \mathcal { N } ( 0 , 1 )$ for $d = 1 , \dotsc , n + 8$ . For $n + 8 < d \leq D$ , $\mathcal { D } _ { d }$ is either $\textstyle \mathcal { N } ( 0 , \sigma _ { d } ^ { 2 } )$ dor $\sqrt { \operatorname * { m i x } _ { \sigma _ { d } , \mu _ { d } } }$ depending on $\Delta _ { d }$ being either $\downarrow \mathrm { o r } \uparrow$ .
First we show that for each step $d$ , the assumption $\mathbb { E } [ \| ( A ^ { \top } A ) ^ { + } x \| ^ { 2 } ] > 0$ of Theorem 8 is satisfied. If $\mathbb { E } [ \| ( A ^ { \top } A ) ^ { + } x \| ^ { 2 } ] = 0$ , we know that $( A ^ { \top } A ) ^ { + } x = 0$ almost surely. Since $\mathcal { D }$ is a continuous distribution, the matrix $A$ has full row rank almost surely. Therefore, $\operatorname { r a n k } ( ( A ^ { \top } A ) ^ { + } ) = \operatorname { r a n k } ( A ^ { \top } A ) = n$ almost surely. Thus $\dim \ker ( A ^ { \top } A ) ^ { + } = d - n \leq d - 1$ almost surely, which implies $x \not \in \ker ( A ^ { \top } A ) ^ { + }$ . In other words, $( A ^ { \top } A ) ^ { + } x \neq 0$ almost surely. We reach a contradiction. Moreover, by Lemma 7, the assumption $\mathbb { E } \| ( A ^ { + } ) ^ { \top } x \| ^ { 2 } < + \infty$ of Theorem 9 is also satisfied.
If $\Delta _ { d - 1 } = \downarrow$ , by Theorem 8, there exists $\sigma _ { d } > 0$ such that if $\mathcal { D } _ { d } = \mathcal { N } ( 0 , \sigma _ { d } ^ { 2 } )$ , then $L _ { d } < L _ { d - 1 }$ . Similarly if $\Delta _ { d - 1 } = \uparrow$ , by Theorem 9, there exists $\sigma _ { d }$ and $\mu _ { d }$ such that $\mathcal { D } _ { d } = \mathcal { N } _ { \sigma _ { d } , \mu _ { d } } ^ { \mathrm { m i x } }$ N mixσd,µd guarantees $L _ { d } > L _ { d - 1 }$ .
Gaussian $\beta$ setting. In what follows, we study the case where the model $\beta$ is non-zero. In particular, we consider a setting where each entry of $\beta$ is i.i.d. $\mathcal { N } ( 0 , \rho ^ { 2 } )$ . Recalling (1), define the biases
$$\begin{array} { r } { \mathcal { E } _ { d } \triangleq ( x ^ { \top } ( A ^ { + } A - I ) \beta ) ^ { 2 } , \quad \mathcal { E } _ { d + 1 } \triangleq \left( [ x ^ { \top } , a _ { 1 } ] ( [ A , b ] ^ { + } [ A , b ] - I ) \left[ \beta \right] \right) ^ { 2 } , } \end{array}$$
and the expected risks
$$\begin{array} { r } { L _ { d } ^ { \mathrm { e x p } } \triangleq \mathbb E [ \mathcal { E } _ { d } ] + \eta ^ { 2 } \mathbb E \| ( A ^ { \top } ) ^ { + } x \| ^ { 2 } , \quad L _ { d + 1 } ^ { \mathrm { e x p } } \triangleq \mathbb E [ \mathcal { E } _ { d + 1 } ] + \eta ^ { 2 } \mathbb E \| [ [ A ^ { \top } ] ^ { + } [ a _ { 1 } ] ] ^ { 2 } , } \end{array}$$
where $\beta \sim \mathcal { N } ( 0 , \rho ^ { 2 } I _ { d } )$ and $\beta _ { 1 } \sim \mathcal { N } ( 0 , \rho ^ { 2 } )$ . The second term in $\boldsymbol { L } _ { d } ^ { \mathrm { e x p } }$ and $L _ { d + 1 } ^ { \mathrm { e x p } }$ is the variance term. Note that ${ \cal L } _ { d } ^ { \mathrm { e x p } }$ is the expected value of $L _ { d }$ in (1) and averages over $\beta$ . Theorem 10 shows that one d can add a Gaussian mixture feature in order to make $L _ { d + 1 } ^ { \mathrm { e x p } } > L _ { d } ^ { \mathrm { e x p } }$ , and add a Gaussian feature in order to make Lexpd+1 $L _ { d + 1 } ^ { \exp } < L _ { d } ^ { \exp }$ .
Theorem 10 (Proof in Appendix C.5). Let $a _ { 1 } , \beta _ { 1 } \in \mathbb { R } ,$ , $x \in \mathbb { R } ^ { d \times 1 }$ , $\beta \in \mathbb { R } ^ { d \times 1 }$ , $A \in \mathbb { R } ^ { n \times d }$ and $b \in \mathbb { R } ^ { n \times 1 }$ , where $n \leq d$ . Assume that $x , a _ { 1 } , \beta _ { 1 } , \beta , A , b$ are jointly independent, $[ \beta ^ { \top } , \beta _ { 1 } ] ^ { \top } \sim$ $\mathcal { N } ( 0 , \rho ^ { 2 } I _ { d + 1 } )$ . Moreover, assume that the matrix $[ A , b ]$ has linearly independent rows almost surely. The following statements hold:
$f a _ { 1 } , b _ { 1 } , \ldots , b _ { n } \stackrel { i i d } { \sim } \mathcal { N } _ { \sigma , \mu } ^ { \mathrm { m i x } } ,$ , for any $C > 0$ , there exist $\mu , \sigma$ such that $L _ { d + 1 } ^ { \mathrm { e x p } } - L _ { d } ^ { \mathrm { e x p } } > C$ (b) If $\cdot _ { a _ { 1 } , b _ { 1 } , . . . , b _ { n } } \stackrel { i i d } { \sim } \mathcal { N } ( 0 , \sigma ^ { 2 } )$ , there exists $\sigma > 0$ such that for all
$$\rho \leq \eta \sqrt { \frac { \mathbb { E } [ \| ( A ^ { \top } A ) ^ { + } x \| ^ { 2 } ] } { \mathbb { E } \| A ^ { + \top } x \| ^ { 2 } + 1 } } ,$$
we hav e $L _ { d + 1 } ^ { \exp } < L _ { d } ^ { \exp }$
Theorem 10 indicates that for $\beta$ obeying a normal distribution, one can still construct a generalization curve as desired by adding a Gaussian or Gaussian mixture feature properly. We make this construction explicit for any desired generalization curve in (the proof of) Theorem 11. Similar to the construction in the underparametrized regime (for all $\beta$ ) and overparametrization regime (for $\beta = 0$ ), the distribution $\mathcal { D }$ can be made a product distribution.
Theorem 11 (Overparametrized regime, $\beta$ being Gaussian). Let $n < D - 9$ . Given any sequence $\Delta _ { n + 8 } , \Delta _ { n + 9 } , . . . , \Delta _ { D - 1 }$ where $\Delta _ { d } \in \{ \uparrow , \downarrow \}$ , there exists $\rho > 0$ and a distribution $\mathcal { D }$ such that for $\beta \sim \mathcal { N } ( 0 , \rho ^ { 2 } )$ and every $n + 8 \leq d \leq D - 1$ , we have
$$\begin{array} { r } { L _ { d + 1 } ^ { \mathrm { e x p } } \left\{ { \stackrel { > } { \sim } } L _ { d } ^ { \mathrm { e x p } } , \quad i f \Delta _ { d } = \uparrow \right. } \\ { \left. < L _ { d } ^ { \mathrm { e x p } } , \quad i f \Delta _ { d } = \downarrow . \right. } \end{array}$$
Proof of Theorem $I I$ . Define the design matrix $A _ { d } \triangleq [ x _ { 1 } [ 1 : d ] , \dots , x _ { n } [ 1 : d ] ] ^ { \intercal } \in \mathbb { R } ^ { n \times d }$ . Similar to the proof of Theorem 5, we construct the product distribution $\begin{array} { r } { \mathcal { D } = \prod _ { d = 1 } ^ { D } \mathcal { D } _ { d } } \end{array}$ . We set $\mathcal { D } _ { d } = \mathcal { N } ( 0 , 1 )$ for $d = 1 , \ldots , n + 8$ . For $n + 8 < d \leq D$ , $\mathcal { D } _ { d }$ is either $\textstyle \mathcal { N } ( 0 , \sigma _ { d } ^ { 2 } )$ or $\sqrt { \operatorname* { m i x } _ { \sigma _ { d } , \mu _ { d } } }$ depending on $\Delta _ { d }$ being either $\downarrow$ or $\uparrow$ .
If $\Delta _ { d - 1 } = \uparrow$ , by Theorem 10, there exists $\sigma _ { d }$ and $\mu _ { d }$ such that $\mathcal { D } _ { d } = \mathcal { N } _ { \sigma _ { d } , \mu _ { d } } ^ { \mathrm { m i x } }$ guarantees $L _ { d } ^ { \exp } > L _ { d - 1 } ^ { \exp }$ $\Delta _ { d - 1 } = \downarrow$
$$\rho _ { d } \triangleq \eta \sqrt { \frac { \mathbb { E } [ \| ( A _ { d - 1 } ^ { \top } A _ { d - 1 } ) ^ { + } x _ { \mathrm { t e s t } } [ 1 : d - 1 ] \| ^ { 2 } ] } { \mathbb { E } \| A _ { d - 1 } ^ { + \top } x _ { \mathrm { t e s t } } [ 1 : d - 1 ] \| ^ { 2 } + 1 } } .$$
By Theorem 10, there exists $\sigma _ { d } > 0$ such that if $\rho \leq \rho _ { d }$ and $\mathcal { D } _ { d } = \mathcal { N } ( 0 , \sigma _ { d } ^ { 2 } )$ , then $L _ { d } ^ { \exp } < L _ { d - 1 } ^ { \exp }$ . We
$$\rho = \operatorname* { m i n } _ { \substack { d : \Delta _ { d - 1 } = \downarrow } } \rho _ { d } .$$
# 6 Conclusion
Our work proves that the expected risk of linear regression can manifest multiple descents when the number of features increases and sample size is fixed. This is carried out through an algorithmic construction of a feature-revealing process where the newly revealed feature follows either a Gaussian distribution or a Gaussian mixture distribution. Notably, the construction also enables us to control local maxima in the underparametrized regime and control ascents/descents freely in the overparametrized regime. Overall, this allows us to design the generalization curve away from the interpolation threshold.
We believe that our analysis of linear regression in this paper is a good starting point for explaining non-monotonic generalization curves observed in machine learning studies. Extending these results to more complex problem setups would be a meaningful future direction.
# Funding Transparency Statement
LC: Funding in direct support of this work: postdoctoral research fellowship by the Simons Institute for the Theory of Computing, University of California, Berkeley, and Google PhD Fellowship by Google. Additional revenues related to this work: internships at Google.
MB acknowledges support from NSF IIS-1815697, and the support of the NSF and the Simons Foundation for the Collaboration on the Theoretical Foundations of Deep Learning through awards DMS-2031883 and #814639.
AK: Funding in direct support of this work: NSF (IIS-1845032) and ONR (N00014-19-1-2406).
# References
[1] M. S. Advani and A. M. Saxe. High-dimensional dynamics of generalization error in neural networks. arXiv preprint arXiv:1710.03667, 2017. [2] M. S. Advani, A. M. Saxe, and H. Sompolinsky. High-dimensional dynamics of generalization error in neural networks. Neural Networks, 132:428–446, 2020. [3] Z. Allen-Zhu, Y. Li, and Z. Song. A convergence theory for deep learning via overparameterization. In International Conference on Machine Learning, pages 242–252, 2019. [4] S. Arora, S. S. Du, W. Hu, Z. Li, R. R. Salakhutdinov, and R. Wang. On exact computation with an infinitely wide neural net. In Advances in Neural Information Processing Systems, pages 8141–8150, 2019. [5] S. Arora, S. S. Du, W. Hu, Z. Li, and R. Wang. Fine-grained analysis of optimization and generalization for overparameterized two-layer neural networks. In ICML, pages 477–502, 2019. [6] S. Arora, S. S. Du, Z. Li, R. Salakhutdinov, R. Wang, and D. Yu. Harnessing the power of infinitely wide deep nets on small-data tasks. In International Conference on Learning Representations, 2019. [7] J. K. Baksalary and O. M. Baksalary. Particular formulae for the moore–penrose inverse of a columnwise partitioned matrix. Linear algebra and its applications, 421(1):16–23, 2007. [8] P. L. Bartlett, P. M. Long, G. Lugosi, and A. Tsigler. Benign overfitting in linear regression. Proceedings of the National Academy of Sciences, 2020. [9] M. Belkin, D. Hsu, S. Ma, and S. Mandal. Reconciling modern machine learning and the bias-variance trade-off. stat, 1050:28, 2018. [10] M. Belkin, S. Ma, and S. Mandal. To understand deep learning we need to understand kernel learning. In International Conference on Machine Learning, pages 541–549, 2018. [11] M. Belkin, D. Hsu, and J. Xu. Two models of double descent for weak features. arXiv preprint arXiv:1903.07571, 2019. [12] M. Belkin, A. Rakhlin, and A. B. Tsybakov. Does data interpolation contradict statistical optimality? In The 22nd International Conference on Artificial Intelligence and Statistics, pages 1611–1619, 2019. [13] Y. Bengio, R. Ducharme, P. Vincent, and C. Jauvin. A neural probabilistic language model. Journal of machine learning research, 3(Feb):1137–1155, 2003. [14] Y. Cao and Q. Gu. Generalization bounds of stochastic gradient descent for wide and deep neural networks. In Advances in Neural Information Processing Systems, pages 10836–10846, 2019. [15] A. Caponnetto and E. De Vito. Optimal rates for the regularized least-squares algorithm. Foundations of Computational Mathematics, 7(3):331–368, 2007. [16] E. Caron and S. Chretien. A finite sample analysis of the double descent phenomenon for ridge function estimation. arXiv preprint arXiv:2007.12882, 2020. [17] M. Caron, P. Bojanowski, A. Joulin, and M. Douze. Deep clustering for unsupervised learning of visual features. In Proceedings of the European Conference on Computer Vision (ECCV), pages 132–149, 2018. [18] L. Chen and S. Xu. Deep neural tangent kernel and laplace kernel have the same rkhs. In ICLR, 2021. [19] L. Chen, Y. Min, M. Zhang, and A. Karbasi. More data can expand the generalization gap between adversarially robust and standard models. In International Conference on Machine Learning, pages 1670–1680. PMLR, 2020. [20] Y. Dar, P. Mayer, L. Luzi, and R. G. Baraniuk. Subspace fitting meets regression: The effects of supervision and orthonormality constraints on double descent of generalization errors. In ICML, 2020. [21] S. d’Ascoli, L. Sagun, and G. Biroli. Triple descent and the two kinds of overfitting: Where & why do they appear? arXiv preprint arXiv:2006.03509, 2020. [22] E. De Vito, A. Caponnetto, and L. Rosasco. Model selection for regularized least-squares algorithm in learning theory. Foundations of Computational Mathematics, 5(1):59–85, 2005. [23] S. Du, J. Lee, H. Li, L. Wang, and X. Zhai. Gradient descent finds global minima of deep neural networks. In International Conference on Machine Learning, pages 1675–1685, 2019. [24] Y. Fei and Y. Chen. Exponential error rates of sdp for block models: Beyond grothendieck’s inequality. IEEE Transactions on Information Theory, 65(1):551–571, 2018. [25] Y. Fei and Y. Chen. Hidden integrality of sdp relaxations for sub-gaussian mixture models. In Conference On Learning Theory, pages 1931–1965. PMLR, 2018. [26] Y. Fei and Y. Chen. Achieving the bayes error rate in stochastic block model by sdp, robustly. In Conference on Learning Theory, pages 1235–1269. PMLR, 2019. [27] Y. Fei and Y. Chen. Achieving the bayes error rate in synchronization and block models by sdp, robustly. IEEE Transactions on Information Theory, 66(6):3929–3953, 2020. [28] Y. Fei, Z. Yang, Y. Chen, Z. Wang, and Q. Xie. Risk-sensitive reinforcement learning: Nearoptimal risk-sample tradeoff in regret. arXiv preprint arXiv:2006.13827, 2020. [29] M. Geiger, S. Spigler, S. d’Ascoli, L. Sagun, M. Baity-Jesi, G. Biroli, and M. Wyart. Jamming transition as a paradigm to understand the loss landscape of deep neural networks. Physical Review E, 100(1):012115, 2019. [30] M. Geiger, A. Jacot, S. Spigler, F. Gabriel, L. Sagun, S. d’Ascoli, G. Biroli, C. Hongler, and M. Wyart. Scaling description of generalization with number of parameters in deep learning. Journal of Statistical Mechanics: Theory and Experiment, 2020(2):023401, 2020. [31] S. Geman, E. Bienenstock, and R. Doursat. Neural networks and the bias/variance dilemma. Neural computation, 4(1):1–58, 1992. [32] B. Ghorbani, S. Mei, T. Misiakiewicz, and A. Montanari. Linearized two-layers neural networks in high dimension. arXiv preprint arXiv:1904.12191, 2019. [33] T. Hastie, R. Tibshirani, and J. Friedman. The elements of statistical learning: data mining, inference, and prediction. Springer Science & Business Media, 2009. [34] T. Hastie, A. Montanari, S. Rosset, and R. J. Tibshirani. Surprises in high-dimensional ridgeless least squares interpolation. arXiv preprint arXiv:1903.08560, 2019. [35] K. He, X. Zhang, S. Ren, and J. Sun. Deep residual learning for image recognition. In Proceedings of the IEEE conference on computer vision and pattern recognition, pages 770– 778, 2016. [36] Y. Huang, Y. Cheng, A. Bapna, O. Firat, D. Chen, M. Chen, H. Lee, J. Ngiam, Q. V. Le, Y. Wu, et al. Gpipe: Efficient training of giant neural networks using pipeline parallelism. In Advances in neural information processing systems, pages 103–112, 2019. [37] A. Javanmard, M. Soltanolkotabi, and H. Hassani. Precise tradeoffs in adversarial training for linear regression. In Conference on Learning Theory, 2020. [38] A. Krizhevsky, I. Sutskever, and G. E. Hinton. Imagenet classification with deep convolutional neural networks. In Advances in neural information processing systems, pages 1097–1105, 2012. [39] Y. Li and Y. Wei. Minimum $\ell _ { 1 }$ -norm interpolators: Precise asymptotics and multiple descent. arXiv preprint arXiv:2110.09502, 2021. [40] T. Liang and A. Rakhlin. Just interpolate: Kernel “ridgeles” regression can generalize. Annals of Statistics, page to appear, 2019. [41] T. Liang, A. Rakhlin, and X. Zhai. On the multiple descent of minimum-norm interpolants and restricted lower isometry of kernels. In COLT, 2020. [42] F. Liu, Z. Liao, and J. Suykens. Kernel regression in high dimensions: Refined analysis beyond double descent. In International Conference on Artificial Intelligence and Statistics, pages 649–657. PMLR, 2021. [43] M. Loog, T. Viering, and A. Mey. Minimizers of the empirical risk and risk monotonicity. In Advances in Neural Information Processing Systems, pages 7478–7487, 2019. [44] S. Mei and A. Montanari. The generalization error of random features regression: Precise asymptotics and double descent curve. arXiv preprint arXiv:1908.05355, 2019. [45] Y. Min, L. Chen, and A. Karbasi. The curious case of adversarially robust models: More data can help, double descend, or hurt generalization. arXiv preprint arXiv:2002.11080, 2020. [46] P. Nakkiran, G. Kaplun, Y. Bansal, T. Yang, B. Barak, and I. Sutskever. Deep double descent: Where bigger models and more data hurt. arXiv preprint arXiv:1912.02292, 2019. [47] P. Nakkiran, P. Venkat, S. Kakade, and T. Ma. Optimal regularization can mitigate double descent. arXiv preprint arXiv:2003.01897, 2020. [48] B. Neal, S. Mittal, A. Baratin, V. Tantia, M. Scicluna, S. Lacoste-Julien, and I. Mitliagkas. A modern take on the bias-variance tradeoff in neural networks. arXiv preprint arXiv:1810.08591, 2018. [49] B. Neyshabur, R. Tomioka, and N. Srebro. In search of the real inductive bias: On the role of implicit regularization in deep learning. In ICLR (Workshop), 2015. [50] A. Rahimi and B. Recht. Random features for large-scale kernel machines. In Advances in neural information processing systems, pages 1177–1184, 2008. [51] A. Rakhlin and X. Zhai. Consistency of interpolation with laplace kernels is a high-dimensional phenomenon. In Conference on Learning Theory, pages 2595–2623, 2019. [52] D. Richards, J. Mourtada, and L. Rosasco. Asymptotics of ridge (less) regression under general source condition. arXiv preprint arXiv:2006.06386, 2020. [53] A. Rudi and L. Rosasco. Generalization properties of learning with random features. In Advances in Neural Information Processing Systems, pages 3215–3225, 2017. [54] G. Song, R. Xu, and J. Lafferty. Convergence and alignment of gradient descent with random back propagation weights. arXiv preprint arXiv:2106.06044, 2021. [55] C. Szegedy, W. Liu, Y. Jia, P. Sermanet, S. Reed, D. Anguelov, D. Erhan, V. Vanhoucke, and A. Rabinovich. Going deeper with convolutions. In Proceedings of the IEEE conference on computer vision and pattern recognition, pages 1–9, 2015. [56] A. Tsigler and P. L. Bartlett. Benign overfitting in ridge regression. arXiv preprint arXiv:2009.14286, 2020. [57] D. von Rosen. Moments for the inverted wishart distribution. Scandinavian Journal of Statistics, pages 97–109, 1988. [58] C. Wei, J. D. Lee, Q. Liu, and T. Ma. Regularization matters: Generalization and optimization of neural nets vs their induced kernel. In Advances in Neural Information Processing Systems, pages 9712–9724, 2019. [59] A. J. Wyner, M. Olson, J. Bleich, and D. Mease. Explaining the success of adaboost and random forests as interpolating classifiers. The Journal of Machine Learning Research, 18(1): 1558–1590, 2017. [60] J. Xu and D. J. Hsu. On the number of variables to use in principal component regression. In Advances in Neural Information Processing Systems, pages 5094–5103, 2019. [61] C. Zhang, S. Bengio, M. Hardt, B. Recht, and O. Vinyals. Understanding deep learning requires rethinking generalization. In ICLR, 2017. [62] D. Zou, Y. Cao, D. Zhou, and Q. Gu. Gradient descent optimizes over-parameterized deep relu networks. Machine Learning, 109(3):467–492, 2020.
# Checklist
1. For all authors...
(a) Do the main claims made in the abstract and introduction accurately reflect the paper’s contributions and scope? [Yes] (b) Did you describe the limitations of your work? [Yes] (c) Did you discuss any potential negative societal impacts of your work? [N/A] (d) Have you read the ethics review guidelines and ensured that your paper conforms to them? [Yes]
2. If you are including theoretical results...
(a) Did you state the full set of assumptions of all theoretical results? [Yes] (b) Did you include complete proofs of all theoretical results? [Yes]
3. If you ran experiments...
(a) Did you include the code, data, and instructions needed to reproduce the main experimental results (either in the supplemental material or as a URL)? [N/A] (b) Did you specify all the training details (e.g., data splits, hyperparameters, how they were chosen)? [N/A] (c) Did you report error bars (e.g., with respect to the random seed after running experiments multiple times)? [N/A] (d) Did you include the total amount of compute and the type of resources used (e.g., type of GPUs, internal cluster, or cloud provider)? [N/A]
4. If you are using existing assets (e.g., code, data, models) or curating/releasing new assets...
(a) If your work uses existing assets, did you cite the creators? [N/A] (b) Did you mention the license of the assets? [N/A] (c) Did you include any new assets either in the supplemental material or as a URL? [N/A] (d) Did you discuss whether and how consent was obtained from people whose data you’re using/curating? [N/A] (e) Did you discuss whether the data you are using/curating contains personally identifiable information or offensive content? [N/A]
5. If you used crowdsourcing or conducted research with human subjects...
(a) Did you include the full text of instructions given to participants and screenshots, if applicable? [N/A] (b) Did you describe any potential participant risks, with links to Institutional Review Board (IRB) approvals, if applicable? [N/A] (c) Did you include the estimated hourly wage paid to participants and the total amount spent on participant compensation? [N/A]123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267# STOCHASTIC VARIATIONAL VIDEO PREDICTION
Mohammad Babaeizadeh1, Chelsea Finn2, Dumitru Erhan3, Roy Campbell1, and Sergey Levine2,3
1University of Illinois at Urbana-Champaign 2University of California, Berkeley 3Google Brain
mb2@uiuc.edu, cbfinn@eecs.berkeley.edu, dumitru@google.com, rhc@illinois.edu, svlevine@eecs.berkeley.edu
# ABSTRACT
Predicting the future in real-world settings, particularly from raw sensory observations such as images, is exceptionally challenging. Real-world events can be stochastic and unpredictable, and the high dimensionality and complexity of natural images require the predictive model to build an intricate understanding of the natural world. Many existing methods tackle this problem by making simplifying assumptions about the environment. One common assumption is that the outcome is deterministic and there is only one plausible future. This can lead to low-quality predictions in real-world settings with stochastic dynamics. In this paper, we develop a stochastic variational video prediction (SV2P) method that predicts a different possible future for each sample of its latent variables. To the best of our knowledge, our model is the first to provide effective stochastic multi-frame prediction for real-world videos. We demonstrate the capability of the proposed method in predicting detailed future frames of videos on multiple real-world datasets, both action-free and action-conditioned. We find that our proposed method produces substantially improved video predictions when compared to the same model without stochasticity, and to other stochastic video prediction methods. Our SV2P implementation will be open sourced upon publication.
# 1 INTRODUCTION
Understanding the interaction dynamics of objects and predicting what happens next is one of the key capabilities of humans which we heavily rely on to make decisions in everyday life (Bubic et al., 2010). A model that can accurately predict future observations of complex sensory modalities such as vision must internally represent the complex dynamics of real-world objects and people, and therefore is more likely to acquire a representation that can be used for a variety of visual perception tasks, such as object tracking and action recognition (Srivastava et al., 2015; Lotter et al., 2017; Denton & Birodkar, 2017). Furthermore, such models can be inherently useful themselves, for example, to allow an autonomous agent or robot to decide how to interact with the world to bring about a desired outcome (Oh et al., 2015; Finn & Levine, 2017).
However, modeling future distributions over images is a challenging task, given the high dimensionality of the data and the complex dynamics of the environment. Hence, it is common to make various simplifying assumptions. One particularly common assumption is that the environment is deterministic and that there is only one possible future (Chiappa et al., 2017; Srivastava et al., 2015; Boots et al., 2014; Lotter et al., 2017). Models conditioned on the actions of an agent frequently make this assumption, since the world is more deterministic in these settings (Oh et al., 2015; Finn et al., 2016). However, most real-world prediction tasks, including the action-conditioned settings, are in fact not deterministic, and a deterministic model can lose many of the nuances that are present in real physical interactions. Given the stochastic nature of video prediction, any deterministic model is obliged to predict a statistic of all the possible outcomes. For example, deterministic models trained with a mean squared error loss function generate the expected value of all the possibilities for each pixel independently, which is inherently blurry (Mathieu et al., 2016).
 Figure 1: Importance of stochasticity in video prediction. In each video, a random shape follows a random direction (first row). Given only the first frame, the deterministic model from Finn et al. (2016) predicts the average of all the possibilities. The third row is the output of SV2P with latent sampled from approximated posterior which predicts the correct motion. Last two rows are stochastic outcomes using random latent values sampled from assumed prior. As observed, these outcomes are random but within the range of possible futures. Second sample of Figure 1c shows a case where the model predicts the average of more than one outcome.
Our main contribution in this paper is a stochastic variational method for video prediction, named SV2P, that predicts a different plausible future for each sample of its latent random variables. We also provide a stable training procedure for training a neural network based implementation of this method. To the extent of our knowledge, SV2P is the first latent variable model to successfully predict multiple frames in real-world settings. Our model also supports action-conditioned predictions, while still being able to predict stochastic outcomes of ambiguous actions, as exemplified in our experiments. We evaluate SV2P on multiple real-world video datasets, as well as a carefully designed toy dataset that highlights the importance of stochasticity in video prediction (see Figure 1). In both our qualitative and quantitative comparisons, SV2P produces substantially improved video predictions when compared to the same model without stochasticity, with respect to standard metrics such as PSNR and SSIM. The stochastic nature of SV2P is most apparent when viewing the predicted videos. Therefore, we highly encourage the reader to check the project website https://goo.gl/iywUHc to view the actual videos of the experiments. The TensorFlow (Abadi et al., 2016) implementation of this project will be open sourced upon publication.
# 2 RELATED WORK
A number of prior works have addressed video frame prediction while assuming deterministic environments (Ranzato et al., 2014; Srivastava et al., 2015; Vondrick et al., 2015; Xingjian et al., 2015; Boots et al., 2014; Lotter et al., 2017). In this work, we build on the deterministic video prediction model proposed by Finn et al. (2016), which generates the future frames by predicting the motion flow of dynamically masked out objects extracted from the previous frames. Similar transformationbased models were also proposed by De Brabandere et al. (2016); Liu et al. (2017). Prior work has also considered alternative objectives for deterministic video prediction models to mitigate the blurriness of the predicted frames and produce sharper predictions (Mathieu et al., 2016; Vondrick & Torralba, 2017). Despite the adversarial objective, Mathieu et al. (2016) found that injecting noise did not lead to stochastic predictions, even for predicting a single frame. Oh et al. (2015); Chiappa et al. (2017) make sharp video predictions by assuming deterministic outcomes in video games given the actions of the agents. However, this assumption does not hold in real-world settings, which almost always have stochastic dynamics.
Auto-regressive models have been proposed for modeling the joint distribution of the raw pixels (Kalchbrenner et al., 2017). Although these models predict sharp images of the future, their training and inference time is extremely high, making them difficult to use in practice. Reed et al. (2017) proposed a parallelized multi-scale algorithm that significantly improves the training and prediction time but still requires more than a minute to generate one second of $6 4 \times 6 4$ video on a GPU. Our comparisons suggest that the predictions from these models are sharp, but noisy, and that our method produces substantially better predictions, especially for longer horizons.
Another approach for stochastic prediction uses generative adversarial networks (GANs) (Goodfellow et al., 2014), which have been used for video generation and prediction (Tulyakov et al., 2017; Li et al., 2017). Vondrick et al. (2016); Chen et al. (2017) applied adversarial training to predict video from a single image. Although GANs generate sharp images, they tend to suffer from modecollapse (Goodfellow, 2016), particularly in conditional generation settings (Zhu et al., 2017).
Variational auto-encoders (VAEs) (Kingma & Welling, 2014) also have been explored for stochastic prediction tasks. Walker et al. (2016) uses conditional VAEs to predict dense trajectories from pixels. Xue et al. (2016) predicts a single stochastic frame using cross convolutional networks in a VAElike architecture. Shu et al. (2016) uses conditional VAEs and Gaussian mixture priors for stochastic prediction. Both of these works have been evaluated solely on synthetic datasets with simple moving sprites and no object interaction. Real images significantly complicate video prediction due to the diversity and variety of stochastic events that can occur. Fragkiadaki et al. (2017) compared various architectures for multimodal motion forecasting and one-frame video prediction, including variational inference and straightforward sampling from the prior. Unlike these prior models, our focus is on designing a multi-frame video prediction model to produce stochastic predictions of the future. Multi-frame prediction is dramatically harder than single-frame prediction, since complex events such as collisions require multiple frames to fully resolve, and single-frame predictions can simply ignore this complexity. We believe, our approach is the first latent variable model to successfully demonstrate stochastic multi-frame video prediction on real world datasets.
# 3 STOCHASTIC VARIATIONAL VIDEO PREDICTION (SV2P)
In order to construct our stochastic variational video prediction model, we first formulate a probabilistic graphical model that explains the stochasticity in the video. Since our goal is to perform conditional video prediction, the predictions are conditioned on a set of $c$ context frames $\mathbf { x } _ { 0 } , \ldots , \mathbf { x } _ { c - 1 }$ (e.g., if we are conditioning on one frame, $c = 1 \AA$ ), and our goal is to sample from $p ( \mathbf { x } _ { c : T } | \mathbf { x } _ { 0 : c - 1 } )$ , where $\mathbf { x } _ { i }$ denotes the $\mathrm { i ^ { \mathrm { t h } } }$ frame of the video (Figure 2).
Video prediction is stochastic as a consequence of the latent events that are not observable from the context frames alone. For example, when a robot’s arm pushes a toy on a table, the unknown weight of that toy affects how it moves. We therefore introduce a vector of latent variables $\mathbf { z }$ into our model, distributed according to a prior $\mathbf { z } \sim p ( \mathbf { z } )$ , and build a model $p ( \mathbf { x } _ { c : T } | \mathbf { x } _ { 0 : c - 1 } , \mathbf { z } )$ . This model is still stochastic but uses a more general representation, such as a conditional Gaussian, to explain just the noise in the image, while $\mathbf { z }$ accounts for the more complex stochastic phenomena. We can then factorize this model to $\begin{array} { r } { \prod _ { t = c } ^ { T } p _ { \theta } \big ( \mathbf { x } _ { t } | \mathbf { x } _ { 0 : t - 1 } , \mathbf { z } \big ) } \end{array}$ Learning then involves training the parameters of these factors $\theta$ , which we assume to be shared between all the time steps.
At inference time we need to estimate values for the true posterior $p ( \mathbf { z } | \mathbf { x } _ { 0 : T } )$ , which is intractable due its dependency on $p ( \mathbf { x } _ { 0 : T } )$ . We
 Figure 2: Probabilistic graphical model of stochastic variational video prediction, assuming time-invariant latent. The generative model predicts the next frame conditioned on the previous frames and latent variables (solid lines), while the variational inference model approximates the posterior given all the frames (dotted lines).
overcome this problem by approximating the posterior with an inference network $q _ { \phi } ( \mathbf { z } | \mathbf { x } _ { 0 : T } )$ that outputs the parameters of a conditionally Gaussian distribution $\mathcal { N } ( \mu _ { \phi } ( \mathbf { x } _ { 0 : T } ) , \sigma _ { \phi } ( \mathbf { x } _ { 0 : T } ) )$ . This network is trained using the reparameterization trick (Kingma & Welling, 2014), according to:
 Figure 3: Architecture of SV2P. At training time, the inference network (top) estimates the posterior $\bar { q _ { \phi } ( \mathbf { z } | \mathbf { x } _ { 0 : T } ) } = \mathcal { N } \big ( \mu ( \mathbf { x } _ { 0 : T } ) , \sigma ( \mathbf { x } _ { 0 : T } ) \big )$ . The latent value ${ \mathbf z } \sim q _ { \phi } ( { \mathbf z } | { \mathbf x } _ { 0 : T } )$ is passed to the generative network along with the (optional) action. The generative network (from Finn et al. (2016)) predicts the next frame given the previous frames, latent values, and actions. At test time, $\mathbf { z }$ is sampled from the assumed prior $\mathcal { N } ( \mathbf { 0 } , \bar { \mathbf { I } } )$ .
$$\mathbf { z } = \mu _ { \phi } ( \mathbf { x } _ { 0 : T } ) + \sigma _ { \phi } ( \mathbf { x } _ { 0 : T } ) \times \epsilon , \epsilon \sim \mathcal { N } ( \mathbf { 0 } , \mathbf { I } )$$
Here, $\theta$ and $\phi$ are the parameters of the generative model and inference network, respectively. To learn these parameters, we can optimize the variational lower bound, as in the variational autoencoder (VAE) (Kingma & Welling, 2014):
$$\mathcal { L } ( \mathbf { x } ) = - \mathbb { E } _ { q _ { \phi } ( \mathbf { z } | \mathbf { x } _ { 0 : T } ) } \left[ \log p _ { \theta } ( \mathbf { x } _ { t : T } | \mathbf { x } _ { 0 : t - 1 } , \mathbf { z } ) \right] + D _ { K L } \big ( q _ { \phi } ( \mathbf { z } | \mathbf { x } _ { 0 : T } ) | | p ( \mathbf { z } ) \big )$$
where $D _ { K L }$ is the Kullback-Leibler divergence between the approximated posterior and assumed prior $p ( \mathbf { z } )$ which in our case is the standard Gaussian $\mathcal { N } ( \mathbf { 0 } , \mathbf { I } )$ .
In Equation 2, the first term on the RHS represents the reconstruction loss while the second term represents the divergence of the variational posterior from the prior on the latent variable. It is important to emphasize that the approximated posterior is conditioned on all of the frames, including the future frames $\mathbf { x } _ { t : T }$ . This is feasible during training, since $\mathbf { x } _ { t : T }$ is available at the training time, while at test time we can sample the latents from the assumed prior. Since the aim in our method is to recover latent variables that correspond to events which might explain the variability in the videos, we found that it is in fact crucial to condition the inference network on future frames. At test time, the latent variables are simply sampled from the prior which corresponds to a smoothing-like inference process. In principle, we could also perform a filtering-like inference procedure of the form $q _ { \phi } ( \mathbf { z } | \mathbf { x } _ { 0 : t - 1 } )$ for time step $t$ to infer the most likely latent variables based only on the conditioning frames, instead of sampling from the prior, which could produce more accurate predictions at test time. However, it would be undesirable to use a filtering process at training time: in order to incentivize the forward prediction network to make use of the latent variables, they must contain some information that is useful for predicting future frames that is not already present in the context frames. If they are predicted entirely from the context frames, no such information is present, and indeed we found that a purely filtering-based model simply ignores the latent variables.
So far, we’ve assumed that the latent events are constant over the entire video. We can relax this assumption by conditioning prediction on a time-variant latent variable $\mathbf { z } _ { t }$ that is sampled at every time step from $p ( \mathbf { z } )$ . The generative model then becomes $\begin{array} { r } { p ( \mathbf { z } _ { t } ) \prod _ { t = c } ^ { T } p _ { \theta } \big ( \mathbf { x } _ { t } | \mathbf { x } _ { 0 : t - 1 } , \mathbf { z } _ { t } \big ) } \end{array}$ and, assuming a fixed posterior, the inference model will be approximated by $q _ { \phi } \big ( \mathbf { z } _ { t } | \mathbf { x } _ { 0 : T } \big )$ , where the model parameters $\phi$ are shared across time. In practice, the only difference between these two formulations is the frequency of sampling $\mathbf { z }$ from $p ( \mathbf { z } )$ and $q _ { \phi } ( \mathbf { z } | \mathbf { x } _ { 0 : T } )$ . In the time-invariant version, we sample $\mathbf { z }$ once per video, whereas with the time-variant latent, sampling happens every frame. The main benefit of time-variant latent variable is better generalization beyond $T$ , since the model does not have to encode all the events of the video in one vector $\mathbf { z }$ . We provide an empirical comparison of these formulations in Section 5.2.
 Figure 4: Three phases of training. In the first phase, the inference network is turned off and only the generative network is being trained, resulting in deterministic predictions. The inference network is used in the second phase without a KL-loss. The last phase includes $D _ { K L } \big ( q _ { \phi } ( \mathbf { z } | \mathbf { x } _ { 0 : T } ) | | p ( \mathbf { z } ) \big )$ to enable accurate sampling latent from $p ( \mathbf { z } )$ . (a) the KL-loss $( b )$ the reconstruction loss (c) Training stability. This graph compares reconstruction loss at the end of five training sessions on the BAIR robot pushing dataset, with and without following all the steps of the training procedure. The proposed training is quite stable and results in lower error compared to na¨ıve training.
In action-conditioned settings, we modify the generative model to be conditioned on action vector $\mathbf { a } _ { t }$ . This results in $\begin{array} { r } { p ( \mathbf { z } _ { t } ) \prod _ { t = c } ^ { T } p _ { \boldsymbol \theta } ( \mathbf { x } _ { t } | \mathbf { x } _ { 0 : t - 1 } , \mathbf { z } _ { t } , \mathbf { a } _ { t } ) } \end{array}$ as generative model while keeping the posterior approximation intact. Conditioning the outcome on actions can decrease future variability; however it will not eliminate it if the environment is inherently stochastic or the actions are ambiguous. In this case, the model is still capable of predicting stochastic outcomes in a narrower range of possibilities.
# 3.1 MODEL ARCHITECTURE
To model the approximated posterior $q _ { \phi } ( \mathbf { z } | \mathbf { x } _ { 0 : T } )$ we used a deep convolutional neural network as shown in the top row of Figure 3. Since we assumed a diagonal Gaussian distribution for $q _ { \phi } ( \mathbf { z } | \mathbf { x } _ { 0 : T } )$ , this network outputs the mean $\mu _ { \phi } \big ( \mathbf { x } _ { 0 : T } \big )$ and standard deviation $\log \sigma _ { \phi } ( \mathbf { x } _ { 0 : T } )$ of the approximated posterior. Hence the entire inference network is convolutional, the predicted parameters are $8 \times 8$ single channel response maps. We assume each entry in this response maps is pairwise independent, forming the latent vector $\mathbf { z }$ . The latent value is then sampled using Equation 1. As discussed before, this sampling happens every frame for time-varying latent, and once per video in time-invariant case.
For $p ( \mathbf { x } _ { t } | \mathbf { x } _ { 0 : t - 1 } , \mathbf { z } )$ , we used the CDNA architecture proposed by Finn et al. (2016), which is a deterministic convolutional recurrent network that predicts the next frame $\mathbf { x } _ { t }$ given the previous frame $\mathbf { x } _ { t - 1 }$ and an optional action $\mathbf { a } _ { t }$ . This model constructs the next frames by predicting the motions of segments of the image (i.e., objects) and then merging these predictions via masking. Although this model directly outputs pixels, it is partially-appearance invariant and can generalize to unseen objects (Finn et al., 2016). To condition on the latent value, we modify the CDNA architecture by stacking $\mathbf { z } _ { t }$ as an additional channel on tiled action $\mathbf { a } _ { t }$ .
# 3.2 TRAINING PROCEDURE
Our model can be trained end-to-end. However, our experiments show that na¨ıve training usually results in the model ignoring the latent variables and converging to a suboptimal deterministic solution (Figure 4). Therefore, we train the model end-to-end in three phases, as follows:
1. Training the generative network: In this phase, the inference network has been disabled and the latent value $\mathbf { z }$ will be randomly sampled from $\mathcal { N } ( \mathbf { 0 } , \mathbf { I } )$ . The intuition behind this phase is to train the generative model to predict the future frames deterministically (i.e. modeling $\mathbf { \bar { \rho } } _ { p _ { \theta } ( \mathbf { x } _ { t } | \mathbf { x } _ { 0 : t - 1 } ) } ) $ . 2. Training the inference network: In the second phase, the inference network is trained to estimate the approximate posterior $q _ { \phi } ( \mathbf { z } | \mathbf { x } _ { 0 : T } )$ ; however, the KL-loss is set to 0. This means that the model can use the latent value without being penalized for diverging from $p ( \mathbf { z } )$ . As seen in Figure 4, this phase results in very low reconstruction error, however it is not usable at the test time since $D _ { K L } \mathbf { \bar { ( } } q _ { \phi } ( \mathbf { z } | \mathbf { x } _ { 0 : T } ) | | p ( \mathbf { z } ) \rrangle \gg 0$ and sampling $\mathbf { z }$ from the assumed prior will be inaccurate.
3. Divergence reduction: In the last phase, the KL-loss is added, resulting in a sudden drop of KLdivergence and an increase of reconstruction error. The reconstruction loss converging to a value lower than the first phase and KL-loss converging to zero are indicators of successful training. This means that $\mathbf { z }$ can be sampled from $p ( \mathbf { z } )$ at test time for effective stochastic prediction.
To gradually transition from the second phase to the third, we add a multiplier to KL-loss that is set to zero during the first two phases and then increased slowly in the last phase. This is similar to the $\beta$ hyper-parameter in Higgins et al. (2016) and Bowman et al. (2016) that is used to balance latent channel capacity and independence constraints with reconstruction accuracy.
We found that this training procedure is quite stable and the model almost always converges to the desired parameters. To demonstrate this stability, we trained the model with and without the proposed training procedure, five times each. Figure 4 shows the average and standard deviation of reconstruction loss at the end of these training sessions. Na¨ıve training results in a slightly better error compared to Finn et al. (2016), but with high variance. When following the proposed training algorithm, the model consistently converges to a much lower reconstruction error.
# 4 STOCHASTIC MOVEMENT DATASET
To highlight the importance of stochasticity in video prediction, we created a toy video dataset with intentionally stochastic motion. Each video in this dataset is four frames long. The first frame contains a random shape (triangle, rectangle or circle) with random size and color, centered in the frame, which then randomly moves to one of the eight directions (up, down, left, right, up-left, upright, down-left, down-right). Each frame is $6 4 \times 6 4 \times 3$ and the background is static gray. The main intuition behind this design is that, given only the first frame, a model can figure out the shape, color, and size of the moving object, but not its movement direction.
We train Finn et al. (2016) and SV2P to predict the future frames, given only the first frame. Figure 1 shows the video predictions from these two models. Since Finn et al. (2016) is a deterministic model with mean squared error as loss, it predicts the average of all possible outcomes, as expected. In contrast, SV2P predicts different possible futures for each sample of the latent variable $\mathbf { z } \sim \mathcal { N } ( \mathbf { 0 } , \mathbf { I } )$ . In our experiments, all the videos predicted by SV2P are within the range of plausible futures (e.g. we never saw the shape moves in any direction other than the original eight). However, in some cases, SV2P still predicts the average of more than one future, as it can be seen in the first random sample of Figure 1c. The main reason for this problem seems to be overlapping posterior distributions in latent space which can cause some latent values (sampled from $p ( \mathbf { z } ) _ { , } ^ { \dag }$ ) to be ambiguous.
To demonstrate that the inference network is working properly and that the latent variable does indeed learn to store the information necessary for stochastic prediction (i.e., the direction of movement), we include predicted futures when ${ \mathbf z } \sim q _ { \phi } ( { \mathbf x } _ { 0 : T } )$ . By estimating the correct parameters of the latent distribution, using the inference network, the model always generates the right outcome. However, this cannot be used in practice, since the inference network requires access to all the frames, including the ones in the future. Instead, $\mathbf { z }$ will be sampled from assumed prior $p ( \mathbf { z } )$ .
# 5 EXPERIMENTS
To evaluate SV2P, we test it on three real-world video datasets by comparing it to the CDNA model (Finn et al., 2016), as a deterministic baseline, as well as a baseline that outputs the last seen frame as the prediction. We compare SV2P with an auto-regressive stochastic model, video pixel networks (VPN) (Kalchbrenner et al., 2017). We use the parallel multi-resolution implementation of VPN from Reed et al. (2017), which is an order of magnitude faster than the original VPN, but still requires more than a minute to generate one second of $6 4 \times 6 4$ video. In all of these experiments, we plot the results of sampling the latent once per video (SV2P time-invariant latent) and once per frame (SV2P time-variant latent). We strongly encourage readers to view https://goo.gl/iywUHc for videos of the results which are more illustrative than printed frames.
# 5.1 DATASETS
We quantitatively and qualitatively evaluate SV2P on following real-world datasets:
• BAIR robot pushing dataset (Ebert et al., 2017): This dataset contains action-conditioned videos collected by a Sawyer robotic arm pushing a variety of objects. All of the videos in this datasets have similar table top settings with static background. Each video also has recorded actions taken by the robotic arm which correspond to the commanded gripper pose. An interesting property of this dataset is the fact that the arm movements are quite unpredictable in the absence of actions (compared to the robot pushing dataset (Finn et al., 2016) which the arm moves to the center of the bin). For this dataset, we train the models to predict the next ten frames given the first two, both in action-conditioned and action-free settings.
• Human3.6M (Ionescu et al., 2014): Humans and animals are one of the most interesting sources of stochasticity in natural videos, which behave in complex ways as a consequence of unpredictable intentions. To study human motion prediction, we use the Human3.6M dataset which consists of actors performing various actions in a room. We used the pre-processing and testing format of Finn et al. (2016): a $1 0 \ : \mathrm { H z }$ frame rate and 10-frame prediction given the previous ten. The videos from this datasets contains various actions performed by humans (walking, talking on the phone, . . . ). Similar to Finn et al. (2016), we included videos from all the performed actions in training dataset while keeping all the videos from an specific actor out for testing.
• Robotic pushing prediction (Finn et al., 2016): We use the robot pushing prediction dataset to compare SV2P with another stochastic prediction method, video pixel networks (VPNs) (Kalchbrenner et al., 2017). VPNs demonstrated excellent results on this dataset in prior work, and therefore robot pushing dataset provides a strong point of comparison. However, in contrast to our method, VPNs do not include latent stochastic variables that represent random events, and rely on an expensive auto-regressive architecture. In this experiment, the models have been trained to predict the next ten frames, given the first two. Similar to BAIR robot pushing dataset, this dataset also contains actions taken by the robotic arm which are the pose of the commanded gripper.
# 5.2 QUANTITATIVE COMPARISON
In our quantitative evaluation, we aim to understand whether the range of possible futures captured by our stochastic model includes the true future. Models that are more stochastic do not necessarily score better on average standard metrics such as PSNR (Huynh-Thu & Ghanbari, 2008) and SSIM (Wang et al., 2004). However, if we are interested primarily in understanding whether the true outcome is within the set of predictions, we can instead evaluate the score of the best sample from multiple random priors. We argue that this is a better metric for stochastic models, since it allows us to understand if uncertain futures contain the true outcome. Figure 5 illustrates how this metric changes with different numbers of samples. By predicting more possible futures, the probability of predicting the true outcome increases, and therefore it is more likely to get a sample with higher PSNR compared to the ground truth. Of course, as with all video prediction metrics, it is imperfect, and is only suitable for understanding the performance of the model when combined with a visual examination of the qualitative results in Section 5.3.
 Figure 5: Stochasticity of SV2P predictions on the action-free BAIR dataset. Each line presents the sample with highest PSNR compared to ground truth, after multiple sampling. The number on the right indicates the number of random samples. As can be seen, SV2P predicts highly stochastic videos and, on average, only three samples is enough to predict outcomes with higher quality compared to Finn et al. (2016).
To use this metric, we sample 100 latent values from prior $\mathbf { z } \sim \mathcal { N } ( \mathbf { 0 } , \mathbf { I } )$ and use them to predict 100 videos and show the result of the sample with
highest PSNR. For a fair comparison to VPN, we use the same best out of 100 samples for our stochastic baseline. Since even the fast implementation of VPN is quite slow, we limit the comparison with VPN to only last dataset with 256 test samples.
 Figure 6: Quantitative comparison of the prediction methods. The stochastic models have been sampled 100 times and the results with the best PSNR have been displayed. For SV2P, we demonstrate the results of both time-variant and time-invariant latent sampling. Repeat shows the results of the lower bound prediction by repeating the last seen frame as the prediction. In the last column, we compare the results of video pixel networks (VPN). All the models, including Finn et al. (2016), have been trained up to the frame marked by vertical separator and the results beyond this line display their generalization. The plots are the average SSIM and PSNR over the test set and shadow is the $9 5 \%$ confidence interval. In all of these graphs, higher is better.
Figure 6 displays the quantitative comparison of the predictions on all of the datasets. In this graph, the top row is a PSNR comparison and the bottom row is SSIM, while each column represents a different dataset. To evaluate the generalization of the models beyond what they have been trained for, we generate more frames than what the models observed during training time. The length of the training sequences is marked by a vertical separator in all of the graphs, and the results beyond this line represent extrapolation to longer sequences.
Overall, SV2P with both time-variant and time-invariant latent sampling outperform all of the other baselines, by predicting higher quality videos with higher PSNR and SSIM. Time-varying latent sampling is more stable beyond the time horizon used during training (Figure 6b). One possible explanation for this behaviour is that the time-invariant latent has to include the information required for predicting all the frames and therefore, beyond training time, it collapses. This issue is mitigated by a time-variant latent variable which takes a different value at each time step. However, this stability is not always the case as it is more evident in late frames of Figure 6a.
One other interesting observation is that the time-invariant model outperforms the time-variant model in the Human3.6M dataset. In this dataset, the most important latent event – the action performed by the actor – is consistent across the whole video which is easier to capture using timeinvariant latent.
# 5.3 QUALITATIVE COMPARISON
We can better understand the performance of the proposed model by visual examination of the qualitative results. We highlight some of the most important and observable differences in predictions by different models in Figures 8-11 1. In all of these figures, the $\mathbf { X }$ -axis is time (i.e., each row is one video). The first row is the ground truth video, and the second row is the result of Finn et al. (2016). The result of sampling the latent from approximated posterior is provided in the third row. For stochastic methods, we show the best (highest PSNR) and worst (lowest PSNR) predictions out of 100 samples (as discussed in Section 5.2), as well as two random predicted videos from our model.
Figure 8 illustrates two examples from the BAIR robot pushing dataset in the action-free setting. As a consequence of the high stochasticity in the movement of the arm in absence of actions, Finn et al. (2016) only blurs the arm out, while SV2P predicts varied but coherent movements of the arm. Note that, although each predicted movements of the arm is random, it is still in the valid range of possible outcomes (i.e., there is no sudden jump of the arm nor random movement of the objects). The proposed model also learned how to move objects in cases where they have been pushed by the predicted movements of the arm, as can be seen in the zoomed images of both samples.
In the action-conditioned setting (Figure 9), the differences are more subtle: the range of possible outcomes is narrower, but we can still observe stochasticity in the behavior of the pushed objects. Interactions between the arm and objects are uncertain due to ambiguity in depth, friction, and mass, and SV2P is able to capture some of this variation. Since these variations are subtle and occupy a smaller part of the images, we illustrate this with zoomed insets in Figure 9. Some examples of varied object movements can be found in last three rows of right example of Figure 9. SV2P also generates sharper outputs, compared to Finn et al. (2016) as is evident in the left example of Figure 9.
 Figure 7: Quantitative comparison of the predicted frames on Human3.6M dataset using confidence of object detection as quality metric. The y-axis demonstrates the average confidence of Huang et al. (2016) in detecting humans in predicted frames. Based on this metric, SV2P predicts images with more meaningful semantics compared to to Finn et al. (2016).
Please note that the approximate posterior $q _ { \phi } ( \mathbf { z } | \mathbf { x } _ { 0 : T } )$ is still trained with the evidence lower bound (ELBO), which means that the posterior must compress the information of the future events. Perfect reconstruction of high-quality images from posterior distributions over latent states is an open problem, and the results in our experiments compare favorably to those typically observed even in single-image VAEs (e.g. see Xue et al. (2016)). This is why the model cannot reconstruct all the future frames perfectly, even though when latent values are sampled from $q _ { \phi } ( \mathbf { z } | \mathbf { x } _ { 0 : T } )$ .
Figure 10 displays two examples from the Human3.6M dataset. In absence of actions, Finn et al. (2016) manages to separate the foreground from background, but cannot predict what happens next accurately. This results in distorted or blurred foregrounds. On the other hand, SV2P predicts a variety of different outcomes, and moves the actor accordingly. Note that PSNR and SSIM are measuring reconstruction loss with respect to the ground truth and they may not generally present a better prediction. For some applications, a prediction with lower PSNR/SSIM might have higher quality and be more interesting. A good example is the prediction with the worst PSNR in Figure 10- right, where the model predicts that the actor is spinning in his chair with relatively high quality. However, this output has the lowest PSNR compared to the ground truth.
However, pixel-wise metrics such as PSNR and SSIM may not be the best measures for semantic evaluation of predicted frames. Therefore, we use the confidence of an object detector to show the predicted frames contain useful semantic information. For this purpose, we use the open-sourced implementation of Huang et al. (2016) to compare the quality of predicted frames in Human3.6M dataset. As it can be seen in Figure 7, SV2P predicted frames which the human inside can be detected with higher confidence, compared to Finn et al. (2016).
Finally, Figure 11 demonstrates results on the Google robot pushing dataset. The qualitative and quantitative results in Figure 11 and 6 both indicate that SV2P produces substantially better predictions than VPNs. The quantitative results suggest that our best-of-100 metric is a reasonable measure of performance: the VPN predictions are more noisy, but simply increasing noise is not sufficient to increase the quality of the best sample. The stochasticity in our predictions is more coherent, corresponding to differences in object or arm motion, while much of the stochasticity in the VPN predictions resembles noise in the image, as well as visible artifacts when predicting for substantially longer time horizons.
# 6 CONCLUSION
We proposed stochastic variational video prediction (SV2P), an approach for multi-step video prediction based on variational inference. Our primary contributions include an effective stochastic prediction method with latent variables, a network architecture that succeeds on natural videos, and a training procedure that provides for stable optimization. The source code for our method will be released upon acceptance. We evaluated our proposed method on three real-world datasets in actionconditioned and action-free settings, as well as one toy dataset which has been carefully designed to highlight the importance of the stochasticity in video prediction. Both qualitative and quantitative results indicate higher quality predictions compared to other deterministic and stochastic baselines.
SV2P can be expanded in numerous ways. First, the current inference network design is fully convolutional, which exposes multiple limitations, such as unmodeled spatial correlations between the latent variables. The model could be improved by incorporating the spatial correlation induced by the convolutions into the prior, using a learned structured prior in place of the standard spherical Gaussian. Time-variant posterior approximation to reflect the new information that is revealed as the video progresses, is another possible SV2P improvement. However, as discussed in Section 3, this requires incentivizing the inference network to incorporate the latent information at training time. This would allow time-variant latent distributions which is more aligned with generative neural models for time-series(Johnson et al., 2016; Gao et al., 2016; Krishnan et al., 2017).
Another exciting direction for future research would be to study how stochastic predictions can be used to act in the real world, producing model-based reinforcement learning methods that can execute risk-sensitive behaviors from raw image observations. Accounting for risk in this way could be especially important in safety-critical settings, such as robotics.
# ACKNOWLEDGEMENT
The authors would like to thank Matt Johnson for providing feedback on an early draft of the paper, and Alex Lee for fixing bugs in the deterministic version of the model. This material is based upon work supported by the National Science Foundation under award no. 1725729 and was partially done while author was interning at Google Brain.
# REFERENCES
Mart´ın Abadi, Paul Barham, Jianmin Chen, Zhifeng Chen, Andy Davis, Jeffrey Dean, Matthieu Devin, Sanjay Ghemawat, Geoffrey Irving, Michael Isard, et al. Tensorflow: A system for largescale machine learning. In OSDI, volume 16, pp. 265–283, 2016.
Byron Boots, Arunkumar Byravan, and Dieter Fox. Learning predictive models of a depth camera & manipulator from raw execution traces. In International Conference on Robotics and Automation (ICRA), 2014.
Samuel R. Bowman, Luke Vilnis, Oriol Vinyals, Andrew M. Dai, Rafal Jozefowicz, and Samy ´ Bengio. Generating sentences from a continuous space. In Proceedings of the 20th SIGNLL Conference on Computational Natural Language Learning, CoNLL 2016, Berlin, Germany, August 11-12, 2016, pp. 10–21, 2016. URL http://aclweb.org/anthology/K/K16/ K16-1002.pdf.
Andreja Bubic, D Yves Von Cramon, and Ricarda I Schubotz. Prediction, cognition and the brain. Frontiers in human neuroscience, 4, 2010.
Baoyang Chen, Wenmin Wang, Jinzhuo Wang, Xiongtao Chen, and Weimian Li. Video imagination from a single image with transformation generation. arXiv preprint arXiv:1706.04124, 2017.
 Figure 8: Comparing the results of SV2P with Finn et al. (2016) (second row) on action-free BAIR robot pushing dataset. Fourth and fifth rows are the predictions with minimum and maximum PSNR out of 100 random outputs with time-invariant latent sampling. The last two rows are random predicted outcomes. The numbers on top indicate the predicted frame number. In lack of actions and therefore high stochasticity, Finn et al. (2016) only blurs the robotic arm out while the proposed method predicts sharper frames on each sampling. SV2P also predicts the interaction dynamics between random movements of the arm and the objects.
 Figure 9: Similar comparison as Figure 8 this time action-conditioned with time-variant latent sampling. SV2P predicts sharper and slightly variant outcomes compared to Finn et al. (2016). This is mostly evident in zoomed in objects which have been pushed by the arm.
 Figure 10: Prediction results on the action-free Human3.6M dataset. SV2P predicts a different outcome on each sampling given the latent. In the left example, the model predicts walking as well as stopping which result in different outputs in predicted future frames. Similarly, the right example demonstrates various outcomes including spinning.
 Figure 11: Comparing the results of video pixel networks (VPN) (Kalchbrenner et al., 2017; Reed et al., 2017) with SV2P on the robotic pushing dataset. We use the same best PSNR out of 100 random samples for both methods. Besides stochastic movements of the pushed objects, another source of stochasticity is the starting lag in movements of the robotic arm. SV2P generates sharper images compared to Finn et al. (2016) (notice the pushed objects in zoomed images) with less noise compared to Reed et al. (2017) (look at the accumulated noise in later frames).
Silvia Chiappa, Sebastien Racani ´ ere, Daan Wierstra, and Shakir Mohamed. Recurrent environment \` simulators. In Proceedings of the International Conference on Learning Representations (ICLR), 2017.
Bert De Brabandere, Xu Jia, Tinne Tuytelaars, and Luc Van Gool. Dynamic filter networks. In Neural Information Processing Systems (NIPS), 2016.
Emily Denton and Vighnesh Birodkar. Unsupervised learning of disentangled representations from video. arXiv preprint arXiv:1705.10915, 2017.
Frederik Ebert, Chelsea Finn, Alex X. Lee, and Sergey Levine. Self-Supervised Visual Planning with Temporal Skip Connections. Conference on Robot Learning (CoRL), 2017.
Chelsea Finn and Sergey Levine. Deep visual foresight for planning robot motion. In International Conference on Robotics and Automation (ICRA), 2017.
Chelsea Finn, Ian Goodfellow, and Sergey Levine. Unsupervised learning for physical interaction through video prediction. In Advances in Neural Information Processing Systems, 2016.
Katerina Fragkiadaki, Jonathan Huang, Alex Alemi, Sudheendra Vijayanarasimhan, Susanna Ricco, and Rahul Sukthankar. Motion prediction under multimodality with conditional stochastic networks. CoRR, abs/1705.02082, 2017.
Yuanjun Gao, Evan W Archer, Liam Paninski, and John P Cunningham. Linear dynamical neural population models through nonlinear embeddings. In Advances in Neural Information Processing Systems, pp. 163–171, 2016.
Ian Goodfellow. Nips 2016 tutorial: Generative adversarial networks. arXiv preprint arXiv:1701.00160, 2016.
Ian Goodfellow, Jean Pouget-Abadie, Mehdi Mirza, Bing Xu, David Warde-Farley, Sherjil Ozair, Aaron Courville, and Yoshua Bengio. Generative adversarial nets. In Advances in neural information processing systems, 2014.
Irina Higgins, Loic Matthey, Arka Pal, Christopher Burgess, Xavier Glorot, Matthew Botvinick, Shakir Mohamed, and Alexander Lerchner. beta-vae: Learning basic visual concepts with a constrained variational framework. International Conference on Learning Representations (ICLR), 2016.
Jonathan Huang, Vivek Rathod, Chen Sun, Menglong Zhu, Anoop Korattikara, Alireza Fathi, Ian Fischer, Zbigniew Wojna, Yang Song, Sergio Guadarrama, et al. Speed/accuracy trade-offs for modern convolutional object detectors. arXiv preprint arXiv:1611.10012, 2016.
Quan Huynh-Thu and Mohammed Ghanbari. Scope of validity of psnr in image/video quality assessment. Electronics letters, 2008.
Catalin Ionescu, Dragos Papava, Vlad Olaru, and Cristian Sminchisescu. Human3. 6m: Large scale datasets and predictive methods for 3d human sensing in natural environments. IEEE transactions on pattern analysis and machine intelligence, 36(7), 2014.
Matthew Johnson, David K Duvenaud, Alex Wiltschko, Ryan P Adams, and Sandeep R Datta. Composing graphical models with neural networks for structured representations and fast inference. In Advances in neural information processing systems, pp. 2946–2954, 2016.
Nal Kalchbrenner, Aaron van den Oord, Karen Simonyan, Ivo Danihelka, Oriol Vinyals, Alex ¨ Graves, and Koray Kavukcuoglu. Video pixel networks. International Conference on Machine Learning (ICML), 2017.
Diederik P Kingma and Max Welling. Auto-encoding variational bayes. International Conference on Learning Representations (ICLR), 2014.
Rahul G Krishnan, Uri Shalit, and David Sontag. Structured inference networks for nonlinear state space models. In AAAI, pp. 2101–2109, 2017.
Yitong Li, Martin Renqiang Min, Dinghan Shen, David Carlson, and Lawrence Carin. Video generation from text. arXiv preprint arXiv:1710.00421, 2017.
Ziwei Liu, Raymond Yeh, Xiaoou Tang, Yiming Liu, and Aseem Agarwala. Video frame synthesis using deep voxel flow. International Conference on Computer Vision (ICCV), 2017.
William Lotter, Gabriel Kreiman, and David Cox. Deep predictive coding networks for video prediction and unsupervised learning. International Conference on Learning Representations (ICLR), 2017.
Michael Mathieu, Camille Couprie, and Yann LeCun. Deep multi-scale video prediction beyond mean square error. International Conference on Learning Representations (ICLR), 2016.
Junhyuk Oh, Xiaoxiao Guo, Honglak Lee, Richard L Lewis, and Satinder Singh. Action-conditional video prediction using deep networks in atari games. In Advances in Neural Information Processing Systems, 2015.
MarcAurelio Ranzato, Arthur Szlam, Joan Bruna, Michael Mathieu, Ronan Collobert, and Sumit Chopra. Video (language) modeling: a baseline for generative models of natural videos. arXiv preprint arXiv:1412.6604, 2014.
Scott E. Reed, Aaron van den Oord, Nal Kalchbrenner, Sergio Gomez Colmenarejo, Ziyu Wang, ¨ Yutian Chen, Dan Belov, and Nando de Freitas. Parallel multiscale autoregressive density estimation. International Conference on Machine Learning (ICML), 2017.
Rui Shu, James Brofos, Frank Zhang, Hung Hai Bui, Mohammad Ghavamzadeh, and Mykel Kochenderfer. Stochastic video prediction with conditional density estimation. In ECCV Workshop on Action and Anticipation for Visual Learning, 2016.
Nitish Srivastava, Elman Mansimov, and Ruslan Salakhudinov. Unsupervised learning of video representations using lstms. In International Conference on Machine Learning, 2015.
Sergey Tulyakov, Ming-Yu Liu, Xiaodong Yang, and Jan Kautz. Mocogan: Decomposing motion and content for video generation. arXiv preprint arXiv:1707.04993, 2017.
Carl Vondrick and Antonio Torralba. Generating the future with adversarial transformers. In Computer Vision and Pattern Recognition (CVPR), 2017.
Carl Vondrick, Hamed Pirsiavash, and Antonio Torralba. Anticipating the future by watching unlabeled video. arXiv preprint arXiv:1504.08023, 2015.
Carl Vondrick, Hamed Pirsiavash, and Antonio Torralba. Generating videos with scene dynamics. In Advances In Neural Information Processing Systems, 2016.
Jacob Walker, Carl Doersch, Abhinav Gupta, and Martial Hebert. An uncertain future: Forecasting from static images using variational autoencoders. In European Conference on Computer Vision, pp. 835–851. Springer, 2016.
Zhou Wang, Alan C Bovik, Hamid R Sheikh, and Eero P Simoncelli. Image quality assessment: from error visibility to structural similarity. IEEE transactions on image processing, 2004.
SHI Xingjian, Zhourong Chen, Hao Wang, Dit-Yan Yeung, Wai-Kin Wong, and Wang-chun Woo. Convolutional lstm network: A machine learning approach for precipitation nowcasting. In Advances in Neural Information Processing Systems, 2015.
Tianfan Xue, Jiajun Wu, Katherine Bouman, and Bill Freeman. Visual dynamics: Probabilistic future frame synthesis via cross convolutional networks. In Advances in Neural Information Processing Systems, 2016.
Jun-Yan Zhu, Taesung Park, Phillip Isola, and Alexei A. Efros. Unpaired image-to-image translation using cycle-consistent adversarial networks. International Conference on Computer Vision (ICCV), 2017.
# A TRAINING DETAILS
Figure 3 contains details of the network architectures used as generative and inference models. In all of the experiments we used the same set of hyper-parameters which can be found in Table 1.
Table 1: Hyper-parameters used for experiments.
<table><tr><td colspan="2">Generative Network</td></tr><tr><td>model type batch size learning rate scheduled sampling (k) #of masks</td><td>CDNA 16 0.001 900.0 10</td></tr><tr><td># of iterations InferenceNetwork</td><td>200000</td></tr><tr><td>latent minimumo starting β final β # of latent channels # step 1 iterations</td><td>-5.0 0.0 0.001 1 50000</td></tr><tr><td># step 2 iterations # step 3 iterations</td><td>50000 100000</td></tr><tr><td>Optimization</td><td>ADAM</td></tr><tr><td>Method β1</td><td>0.9</td></tr><tr><td>β2 E</td><td>0.999 1e-8</td></tr></table>
In the first step of training, we disable the inference network and instead sample latent values from $\mathcal { N } ( \mathbf { 0 } , \mathbf { I } )$ . In step 2, the latent values will be sampled from the approximated posterior $q _ { \phi } ( { \bf z } | { \bf x } _ { 0 : T } ) =$ $\mathcal { N } \big ( \mu ( \mathbf { x } _ { 0 : T } ) , \sigma ( \mathbf { x } _ { 0 : T } ) \big )$ . Please note that the inference network approximates $\log ( \sigma )$ instead of $\sigma$ for numerical stability. To gradually switch from Step 2 of training procedure to Step 3, we increase $\beta$ linearly from its starting value to its end value over the length of training.123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281# GRAPH PARTITION NEURAL NETWORKS FOR SEMI-SUPERVISED CLASSIFICATION
Anonymous authors Paper under double-blind review
# ABSTRACT
We present graph partition neural networks (GPNN), an extension of graph neural networks (GNNs) able to handle extremely large graphs. GPNNs alternate between locally propagating information between nodes in small subgraphs and globally propagating information between the subgraphs. To efficiently partition graphs, we experiment with spectral partitioning and also propose a modified multi-seed flood fill for fast processing of large scale graphs. We extensively test our model on a variety of semi-supervised node classification tasks. Experimental results indicate that GPNNs are either superior or comparable to state-of-the-art methods on a wide variety of datasets for graph-based semi-supervised classification. We also show that GPNNs can achieve similar performance as standard GNNs with fewer propagation steps.
# 1 INTRODUCTION
Graphs are a flexible way of encoding data, and many tasks can be cast as learning from graphstructured inputs. Examples include prediction of properties of chemical molecules (Duvenaud et al., 2015), answering questions about knowledge graphs (Marino et al., 2016), natural language processing with parse-structured inputs (trees or richer structures like Abstract Meaning Representations) (Banarescu et al.), predicting properties of data structures or source code in programming languages (Li et al., 2016), and making predictions from scene graphs (Teney et al., 2016). Sequence data can be seen as a special case of a simple chain-structured graph. Thus, we are interested in training high-capacity neural network-like models on these types of graph-structured inputs. Graph Neural Networks (GNNs) (Gori et al., 2005; Scarselli et al., 2009; Li et al., 2016; Qi et al., 2017; Li et al., 2017) are one of the best contenders, although there has been much recent interest in applying other neural network-like models to graph data, including generalizations of convolutional architectures (Duvenaud et al., 2015; Kipf & Welling, 2017). Gilmer et al. (2017) recently reviewed and unified many of these models.
An important issue that has not received much attention in GNN models is how information gets propagated across the graph. There are often scenarios in which information has to be propagated over long distances across a graph, e.g., when we have long sequences augmented with additional relationships between elements of the sequence, like in text, programming language source code, or temporal streams. The simplest approach, and the one adopted by almost all graph-based neural networks is to follow synchronous message-passing systems (Attiya & Welch, 2004) from distributed computing theory. Specifically, inference is executed as a sequence of rounds: in each round, every node sends messages to all of its neighbors, the messages are delivered and every node does some computation based on the received messages. While this approach has the benefit of being simple and easy to implement, it is especially inefficient when the task requires to spread information across long distances in the graph. For example, in processing sequence data, if we were to employ the above schedule for a sequence of length $N$ , it would take $\mathcal { O } ( \hat { N } ^ { 2 } )$ messages to propagate information from the beginning of the sequence to the end, and during training all $O ( N ^ { 2 } )$ messages must be stored in memory. In contrast, the common practice with sequence data is to use a forward pass followed by a backward pass at a cost of $O ( N )$ to propagate information from end to end, as in bidirectional recurrent neural networks (RNNs), for example.
One possible approach for tackling this problem is to propagate information over the graph following some pre-specified sequential order, as in Bidirectional LSTMs. However, this sequential solution has several issues. First, if a graph used for training has large diameter, the unrolled GNN computational graph will be large (cf. Bidirectional LSTMs on long sequences). This leads to fundamental issues with learning (e.g., vanishing/exploding gradients) and implementation difficulties (i.e., resource constraints). Second, sequential schedules are typically less amenable to efficient acceleration on parallel hardware. More recently, Gilmer et al. (2017) attempted to tackle the first problem by introducing a “dummy node” with connections to all nodes in the input graph, meaning that all nodes are at most two steps away from each other. However, we note that the graph structure itself often contains important information, which is modified by adding additional nodes and edges.
In this work, we propose graph partition neural networks (GPNN) that exploit a propagation schedule combining features of synchronous and sequential propagation schedules. Concretely, we first partition the graph into disjunct subgraphs and a cut set, and then alternate steps of synchronous propagation within subgraphs with synchronous propagation within the cut set. In Sect. 2, we discuss different propagation schedules on an example, showing that GPNNs can be substantially more efficient than standard GNNs, and then present our model formally. Finally, we evaluate our model in Sect. 4 on a variety of semi-supervised classification benchmarks. The empirical results suggest that our models are either superior to or comparable with state-of-the-art learning systems on graphs.
# 2 MODEL
In this section, we briefly recapitulate graph neural networks (GNNs) and then describe our graph partition neural networks (GPNN). A graph $\mathcal { G } = ( \nu , \mathcal { E } )$ has nodes $\nu$ and edges $\mathcal { E } \subseteq \mathcal { V } \times \mathcal { V }$ . We focus on directed graphs, as our approach readily applies to undirected graphs by splitting any undirected edge into two directed edges. We denote the out-going neighborhood as $\mathcal { N } _ { o u t } ( v ) = \{ u \in \mathcal { V } \mid$ $( v , u ) \in \mathcal { E } \}$ , and similarly, the incoming neighborhood as $\bar { \mathcal { N } _ { i n } } ( v ) = \{ u \in \mathcal { V } \mid ( u , v ) \in \mathcal { E } \}$ . We associate an edge type $c _ { ( v , u ) } \in \{ 1 , \ldots , C \}$ with every edge $( v , u )$ , where $C$ is some pre-specified total number of edge types. Such edge types are used to encode different relationships between nodes. Note that one can also associate multiple edge types with the same edge which results in a multi-graph. W.l.o.g. we assume one edge type per directed edge to simplify the notation.
# 2.1 GRAPH NEURAL NETWORKS
Graph neural networks (Scarselli et al., 2009; Li et al., 2016) can be viewed as an extension of recurrent neural networks (RNNs) to arbitrary graphs. Each node $v$ in the graph is associated with an initial state vector ${ h } _ { v } ^ { ( 0 ) }$ at time step 0. Initial state vectors can be observed features or annotations as in Li et al. (2016). At time step $t$ , an outgoing message is computed for each edge by transforming the source state according to the edge type, i.e.,
$$\pmb { m } _ { ( v , u ) } ^ { ( t ) } = M _ { c _ { ( v , u ) } } ( \pmb { h } _ { v } ^ { ( t ) } ) ,$$
where Mc(u,v) is a message function, which could be the identity or a fully connected neural network. Note the subscript $c _ { ( v , u ) }$ indicating that different edges of the same type share the same instance of the message function. We then aggregate all messages at the receiving nodes, i.e.,
$$\bar { \pmb { m } } _ { u } ^ { ( t ) } = A ( \{ \pmb { m } _ { ( v , u ) } ^ { ( t ) } \ | \ v \in \mathcal { N } _ { i n } ( u ) \} ) ,$$
where $A$ is the aggregation function, which may be a summation, average or max-pooling function. Finally, every node will update its state vector based on its current state vector and the aggregated message, i.e.,
$$\pmb { h } _ { v } ^ { ( t + 1 ) } = U ( \pmb { h } _ { v } ^ { ( t ) } , \pmb { \bar { m } } _ { v } ^ { ( t ) } ) ,$$
where $U$ is the update function, which may be a gated recurrent unit (GRU), a long short term memory (LSTM) unit, or a fully connected network. Note that all nodes share the same instance of update function. The described propagation step is repeatedly applied for a fixed number of time steps $T$ , to obtain final state vectors $\{ h _ { v } ^ { ( T ) } \mid v \in \mathcal { V } \}$ . A node classification task can then be implemented by feeding these state vectors to a fully connected neural network which is shared by all nodes. Back-propagation through time (BPTT) is typically adopted for learning the model.
 Figure 1: Propagation schedules on an example graph. (a) The input graph where the line type, i.e., solid & dash, indicates different edge types; (b) Graph partitions where blue bounding boxes indicate different subgraphs and red edges belong to the cut; (c) Computational graphs of two possible sequential propagation schedules of the input graph; (d) Computational graph for synchronous propagation schedule; (e) Computational graph for GPNNs where both inter-subgraph and intrasubgraph propagation steps are 1.
# Algorithm 1 Graph Partition Propagation Schedule.
1: Input: $K$ subgraphs $\{ S _ { k } | k = 1 , \ldots , K \}$ , cut $ { \boldsymbol { S } } _ { 0 }$ , outer propagation step limit $T$ , intra-subgraph and inter-subgraph propagation step limits $T _ { S }$ and $T _ { C }$ . 2: for $t = 1 , \dots , T$ do 3: for all $k \in \{ 1 , \ldots , K \}$ do in parallel 4: Call SYNCPROP within subgraph $\boldsymbol { S _ { k } }$ for $T _ { S }$ steps. 5: Call SYNCPROP within cut $S _ { 0 }$ for $T _ { C }$ steps. 6: function SYNCPROP 7: Compute & send messages as in Eq. (1) 8: Aggregate messages as in Eq. (2) 9: Update states as in Eq. (3)
# 2.2 GRAPH PARTITION NEURAL NETWORKS
The above inference process is described from the perspective of an individual node. If we look at the same process from the graph view, we observe a synchronous schedule in which all nodes receive and send messages at the same time, cf. the illustration in Fig. 1(d). A natural question is to consider different propagation schedules in which not all nodes in the graph send messages at the same time, e.g., sequential schedules, in which nodes are ordered in some linear sequence and messages are set only from one node at a time. A mix of the two ideas leads to our Graph Partition Neural Networks (GPNN), which we will discuss before elaborating on how to partition graphs appropriately. Finally, we discuss how to handle initial node labels and node classification tasks.
Propagation Model We first consider the example graph in Fig. 1 (a). A corresponding computational graph that shows how information is propagated from time step $t$ to time step $t + 1$ using the standard (synchronous) propagation schedule is shown in Fig. 1 (d). The example graph’s diameter is 5, and it hence requires at least 5 steps to propagate information over the graph. Fig. 1(c) instead shows two possible sequences that show how information can be propagated between nodes 2 to 6 and 5 to 1. These visualizations show that (i) a full synchronous propagation schedule requires significant computation at each step, and (ii) a sequential propagation schedule, in which we only propagate along sequences of nodes, results in very sparse and deep computational graphs. Moreover, experimentally, we found sequential schedules to require multiple propagation rounds across the whole graph, resulting in an even deeper computational graph.
In order to achieve both efficient propagation and tractable learning, we propose a new propagation schedule that follows a divide and conquer strategy. In particular, we first partition the graph into disjunct subgraphs. We will explain the details of how to compute graph partitions below. For now, we assume that we already have $K$ subgraphs such that each subgraph contains a subset of nodes and the edges induced by this subset. We will also have a cut set, i.e., the set of edges that connect different subgraphs. One possible partition is visualized in Fig. 1 (b).
In GPNNs, we alternate between propagating information in parallel local to each subgraph (making use of highly parallel computing units such as GPUs) and propagating messages between subgraphs. Our propagation schedule is shown in Alg. 1. To understand the benefit of this schedule, consider a broadcasting problem over the example graph in Fig. 1. When information from any one node has reached all other nodes in the graph for the first time, this problem is considered as solved. We will compare the number of messages required to solve this problem for different propagation schedules.
Synchronous propagation: Fig. 1(d) shows that a synchronous step requires 10 messages. Broadcasting requires sufficient propagation steps to cover the graph diameter (in this case, 5), giving a total of $5 \times 1 0 = 5 0$ messages.
Partitioned propagation: For simplicity, we analyze the case $T _ { S } = D _ { S }$ , $T _ { C } = 1$ , where $D _ { S }$ is the maximum diameter of the subgraphs. Using the partitioning in 1(e), we have $D _ { S } = 2$ and each step of intra-subgraph propagation requires 8 messages. After $T _ { S }$ steps ( $8 D _ { S }$ messages) the broadcast problem is solved within each subgraph. Inter-subgraph propagation requires 2 messages in this example, giving $8 D _ { S } + 2$ messages per outer loop iteration in Alg. 1. The example requires 2 outer iterations to broadcast between all subgraphs, giving a total of $2 ( \bar { 8 } D _ { S } + 2 ) = 3 \bar { 6 }$ messages.
In general, our propagation schedule requires no more messages than the synchronous schedule to solve broadcast (if the number of subgraphs $K$ is set to 1 or $N$ then our schedule reduces to the synchronous one). We analyze the number of messages required to solve the broadcast problem on chain graphs in detail in Sect. A.1. Overall, our method avoids the large number of messages required by synchronous schedules, while avoiding the very deep computational graphs required by sequential schedules. Our experiments in Sect. 4 show that this makes learning tractable even on extremely large graphs.
Graph Partition We now investigate how to construct graph partitions. First, since partition problems in graph theory typically are NP-hard, we are only looking for approximations in practice. A simple approach is to re-use the classical spectral partition method. Specifically, we follow the normalized cut method in Shi & Malik (2000) and use the random walk normalized graph Laplacian matrix $L = I - D ^ { - 1 } W$ , where $I$ is the identity matrix, $D$ is the degree matrix and $W$ is the weight matrix of graph (i.e., the adjacency matrix if no weights are presented).
However, the spectral partition method is slow and hard to scale with large graphs (Von Luxburg, 2007). For performance reasons, we developed the following heuristic method based on a multiseed flood fill partition algorithm as listed in Alg. 2. We first randomly sample the initial seed nodes biased towards nodes which are labeled and have a large out-degree. We maintain a global dictionary assigning nodes to subgraphs, and initially assign each selected seed node to its own subgraph. We then grow the dictionary using flood fill, attaching unassigned nodes that are direct neighbors of a subgraph to that graph. To avoid bias towards the first subgraph, we randomly permute the order in the beginning of each round. This procedure is repeatedly applied until no subgraph grows anymore. There may still be disconnected components left in the graph, which we assign to the smallest subgraph found so far to balance subgraph sizes.
Node Features & Classification In practice, problems using graph-structured data sometimes (1) do not have observed features associated with every node (Grover & Leskovec, 2016); (2) have very high dimensional sparse features per node (Bing et al., 2015). We develop two types of models for the initial node labels: embedding-input and feature-input. For embedding-input, we introduce learnable node embeddings into the model to solve challenge (1), inspired by other graph embedding methods. For nodes with observed features we initialize the embeddings to these observations, and all other nodes are initialized randomly. All embeddings are fed to the propagation model and are treated as learnable parameters. For feature-input, we apply a sparse fully-connected network to input features to tackle challenge (2). The dimension-reduced feature is then fed to the propagation model, and the sparse network is jointly learned with the rest of model.
We also empirically found that concatenating the input features with the final embedding produced by the propagation model is helpful in boosting the performance.
1: Input: Graph $G$ , number of subgraphs $K$ , indices $I$ of nodes which are labeled. 2: Create two dictionaries $D$ and $L$ and $K$ FIFO queues $Q = \{ Q _ { 1 } , \ldots , Q _ { K } \}$ . $D$ maps node index to FALSE and $L$ maps node index to subgraph index 0. 3: $\forall u \in I$ , compute the out-going degree $d _ { u }$ of node $u$ . 4: $\forall u \in I$ , compute the probability $p _ { u } = d _ { u } / \sum _ { v \in I } d _ { v }$ . 5: Sample $K$ nodes $S = \{ s _ { 1 } , \ldots , s _ { K } \}$ from $I$ based on the above probability distribution $p$ . 6: $\forall s _ { k } \in S$ , enqueue $s _ { k }$ to $Q _ { k }$ $, D ( s _ { k } ) =$ TRUE, $L ( s _ { k } ) = k$ . 7: while Any queue in $Q$ is not empty do 8: for $k \in$ RANDPERM(K) do 9: if $Q _ { k }$ is not empty then 10: $u \mathsf { p o p } Q _ { k }$ 11: for $v \in { \mathrm { C H I L D R E N } } ( u )$ do 12: if $D ( v ) = = $ FALSE then 13: Enqueue $v$ to $Q _ { k }$ 14: $\begin{array} { l } { { L ( v ) = k } } \\ { { D ( v ) = \mathrm { T R U E } } } \end{array}$ 15: 16: Put any unvisited nodes into the smallest subgraph and set $L$ accordingly. 17: Return L
# 3 RELATED WORK
There are many neural network models for handling graph-structured inputs. They can be roughly categorized into generalizations of recurrent neural networks (RNNs) (Goller & Kuchler, 1996; Gori et al., 2005; Scarselli et al., 2009; Socher et al., 2011b; Tai et al., 2015; Li et al., 2016; Marino et al., 2016; Qi et al., 2017; Li et al., 2017) and generalizations of convolutional neural networks (CNNs) (Bruna et al., 2014; Duvenaud et al., 2015; Kipf & Welling, 2017; Schlichtkrull et al., 2017). Gilmer et al. (2017) provide a good review and unification of many of these models, and they present some additional model variations that lead to strong empirical results in making predictions from chemical-structured inputs.
In RNN-like models, the standard approach is to propagate information using a synchronous schedule. In convolution-like models, the node updates mimic standard convolutions where all nodes in a layer are updated as functions of neighboring node states in the previous layer. This leads to information propagating across the graph in the same pattern as synchronous schedules. While our focus has been mainly on the RNN-like model of Li et al. (2016), it would be interesting to apply our schedules to the other models as well.
Some of the RNN based neural network models operate on restricted classes of graphs and employ sequential or sequential-like schedules. For example, recursive neural networks (Goller & Kuchler, 1996; Socher et al., 2011a) and tree-LSTMs Tai et al. (2015) have bidirectional variants that use fully sequential schedules.
It is possible to view Sukhbaatar et al. (2016) as a GNN model with a sequential schedule, where messages are passed inwards towards a master node that aggregates messages from different agents, and then outwards from the master node to all the agents. The difference in our work is the focus on graphs with arbitrary structure (not necessarily a sequence or tree). Recently, Marino et al. (2016) developed an attention-like mechanism to dynamically select a subset of graph nodes to propagate information from, but the propagation is synchronous amongst selected nodes.
An area where scheduling has been studied extensively is in the belief propagation (BP) literature. It is common to decompose a graph into spanning trees and sequentially update the tree structures Wainwright et al. (2002). See also Elidan et al. (2006); Tarlow et al. (2011); Sutton & McCallum (2012) for more discussion of sequential updates in the context of belief propagation. Finally, the question of sequential versus synchronous updates arises in numerical linear algebra. Jacobi iteration uses a synchronous update while Gauss-Seidel applies the same algorithm but according to a sequential schedule.
Table 1: Dataset statistics. ∗ indicates the average label rate over 10 fixed splits.
<table><tr><td>Dataset</td><td>Type</td><td>#Nodes</td><td>#Edges</td><td>#Classes</td><td>#Features</td><td>Label Rate</td></tr><tr><td>Citeseer</td><td>Citation network</td><td>3,327</td><td>4,732</td><td>6</td><td>3,703</td><td>0.036</td></tr><tr><td>Cora</td><td>Citation network</td><td>2,708</td><td>5,429</td><td>7</td><td>1,433</td><td>0.052</td></tr><tr><td>Pubmed</td><td>Citation network</td><td>19,717</td><td>44,338</td><td>3</td><td>500</td><td>0.003</td></tr><tr><td>NELL</td><td>Knowledge graph</td><td>65,755</td><td>266,144</td><td>210</td><td>5,414</td><td>0.1, 0.01, 0.001</td></tr><tr><td>DIEL</td><td>Entity & list graph</td><td>4,373,008</td><td>4,464,261</td><td>4</td><td>1,233,598</td><td>0.0095*</td></tr></table>
<table><tr><td rowspan="2">Method</td><td rowspan="2">(Source)</td><td rowspan="2">Citeseer</td><td rowspan="2">Cora</td><td rowspan="2">Pubmed</td><td colspan="3">NELL</td></tr><tr><td>10%</td><td>1%</td><td>0.1%</td></tr><tr><td>Feat</td><td>(Yang et al., 2016)</td><td>57.2</td><td>57.4</td><td>69.8</td><td>62.1</td><td>40.4</td><td>21.7</td></tr><tr><td>ManiReg</td><td>(Belkin et al., 2006)</td><td>60.1</td><td>59.5</td><td>70.7</td><td>63.4</td><td>41.3</td><td>21.8</td></tr><tr><td>SemiEmb</td><td>(Weston et al.,2012)</td><td>59.6</td><td>59.0</td><td>71.1</td><td>65.4</td><td>43.8</td><td>26.7</td></tr><tr><td>LP</td><td>(Zhu et al., 2003)</td><td>45.3</td><td>68.0</td><td>63.0</td><td>71.4</td><td>44.8</td><td>26.5</td></tr><tr><td>DeepWalk</td><td>(Perozzi et al., 2014)</td><td>43.2</td><td>67.2</td><td>65.3</td><td>79.5</td><td>72.5</td><td>58.1</td></tr><tr><td>ICA</td><td>(Lu & Getoor,2003)</td><td>69.1</td><td>75.1</td><td>73.9</td><td></td><td></td><td></td></tr><tr><td>Planetoid (Transductive)</td><td>(Yang et al., 2016)</td><td>64.9</td><td>75.7</td><td>75.7</td><td>84.5</td><td>75.7</td><td>61.9</td></tr><tr><td>Planetoid (Inductive)</td><td>(Yang et al., 2016)</td><td>64.7</td><td>61.2</td><td>77.2</td><td>70.2</td><td>59.8</td><td>45.4</td></tr><tr><td>GCN</td><td>(Kipf & Welling, 2017)</td><td>70.3</td><td>81.5</td><td>79.0</td><td>t83.0</td><td>t67.0</td><td>t54.2</td></tr><tr><td>GGNN*</td><td>(Li et al., 2016)</td><td>68.1</td><td>77.9</td><td>77.2</td><td>84.6</td><td>66.2</td><td>59.1</td></tr><tr><td>GPNN</td><td>(ours)</td><td>69.7</td><td>81.9</td><td>79.2</td><td>83.7</td><td>74.6</td><td>63.1</td></tr></table>
Table 2: Classification accuracies on citation networks and knowledge graphs. ∗ and † indicate we run our own (resp. the released) implementation..
# 4 EXPERIMENTS
We test our model on a variety of semi-supervised tasks: document classification on citation networks; entity classification in a bipartite graph extracted from a knowledge graph; and distantlysupervised entity extraction. We then compare different partition methods exploited by our model. We also compare the effectiveness of different propagation schedules. We follow the datasets and experimental setups in Yang et al. (2016). The statistics are summarized in Tab. 1, revealing that the datasets vary a lot in terms of scale, label rate and feature dimension. We report the details of hyper-parameters for all experiments in the appendix.
# 4.1 CITATION NETWORKS
We first discuss experimental results on three citation networks: Citeseer, Cora and Pubmed (Sen et al., 2008). The datasets contain sparse bag-of-words feature vectors for each document and a list of citation links between documents. Documents and citation links are regarded as nodes and edges while constructing the graph. 20 instances are sampled for each class as labeled data, 1000 instances as test data, and the rest are used as unlabeled data. The goal is to classify each document into one of the predefined classes. We use the same data split as in Yang et al. (2016) and Kipf & Welling (2017). We use an additional validation set of 500 labeled nodes for tuning hyperparameters as in Kipf & Welling (2017).
The results are listed in Thm. 2. We report the results of baselines directly from Yang et al. (2016) and Kipf & Welling (2017). We see that GPNN is on par with other state-of-the-art methods on these small graphs. We also conducted experiments with 10 random splits and results are reported in the appendix. We found these datasets easy to overfit due to their small size, and use feat-input rather than embedding-input, as the latter case increases the model capacity as well as the risk of overfitting. We also show a t-SNE (Maaten & Hinton, 2008) visualization of node representations produced by the propagation model of GGNN and GPNN on the Cora dataset in Fig. 2 (a) and (b) respectively. The visualizations show that the node representations of GPNN are better separated.
Table 3: Average recall on the DIEL dataset. Note that GCN is not included as it runs out of memory.
<table><tr><td>Method</td><td>Recall@k</td></tr><tr><td>LP (Zhu et al.,2003) DeepWalk (Perozzi et al., 2014)</td><td>16.20 25.80</td></tr><tr><td>Feat (Yang et al., 2016)</td><td>34.90</td></tr><tr><td>DIEL (Bing et al., 2015)</td><td>40.50</td></tr><tr><td>ManiReg (Belkin et al.,2006)</td><td>47.70</td></tr><tr><td>SemiEmb )(Weston et al.,2012)</td><td>48.60</td></tr><tr><td>Planetoid (Transductive) (Yang et al., 2016)</td><td>50.00</td></tr><tr><td>Planetoid (Inductive) (Yang et al., 2016)</td><td>50.10</td></tr><tr><td>GGNN* (Li et al., 2016)</td><td>51.15</td></tr><tr><td>GPNN</td><td>52.11</td></tr></table>
# 4.2 ENTITY CLASSIFICATION
Next, we consider experimental results of entity classification task on the NELL dataset extracted from the knowledge graph first presented in Carlson et al. (2010). A knowledge graph consists of a set of entities and a set of directed edges which have labels (i.e., different types of relation). Following Yang et al. (2016), each triplet $( e _ { 1 } , r , e _ { 2 } )$ of entities $e _ { 1 } , e _ { 2 }$ and relation $r$ in the knowledge graph is split into two tuples. Specifically, we assign separate relation nodes $r _ { 1 }$ and $r _ { 2 }$ to each entity and thus obtain $( e _ { 1 } , r _ { 1 } )$ and $( e _ { 2 } , r _ { 2 } )$ . Entity nodes are associated with sparse feature vectors. We follow Kipf $\&$ Welling (2017) to extend the number of features by assigning a unique one-hot representation for every relation node. This results in a 61278-dim sparse feature vector per node. An additional validation set of 500 labeled nodes under the label rate $0 . 1 \%$ as in Kipf & Welling (2017) is used for tuning hyperparameters. The chosen hyperparameters are then used for other label rates. The semi-supervised task here considers three different label rates $1 0 \%$ , $1 \%$ , $0 . 1 \%$ per class in the training set. We run the released code of GCN with the reported hyperparameters in Kipf & Welling (2017). Since we did not observe overfitting on this dataset, we choose the embedding-input variant as the input model. The results are shown in Tab. 2, where we see that our model outperforms competitors under the most challenging label rate 0.001 and obtain comparable results with the state of the art on other label rates.
# 4.3 DISTANTLY-SUPERVISED ENTITY EXTRACTION
Finally, we consider the DIEL (Distant Information Extraction using coordinate-term Lists) dataset (Bing et al., 2015). This dataset constructs a bipartite graph where nodes are medical entities and texts (referred as mentions and coordinate lists in the original paper). Texts contain some facts about the medical entities. Edges of the graph are links between entities and texts. Each entity is associated with a pre-extracted sparse feature vector. The goal is to extract medical entities from text given sparse feature vectors and the graph. As shown in Tab. 1, this dataset is very challenging due to its extremely large scale and very high-dimensional sparse features. Note that we attempted to run the released code GCN model on this dataset, but ran out of memory. We follow the exact experimental setup as in Bing et al. (2015); Yang et al. (2016), including 10 different data splits, preprocessing of entity mentions and coordinate lists, and evaluation. We randomly sample $1 / 5$ of the training nodes as the validation set. We regard the top- $k$ entities returned by a model as positive instances and compute recall $@ k$ as the evaluation metric where $k = 2 4 0 0 0 0$ as in Bing et al. (2015); Yang et al. (2016). Average recall over 10 runs is reported in Tab. 3, and we see that GPNN outperforms all other models. Note that since Freebase is used as ground truth and some entities are not present in texts, the upper bound of recall given by Bing et al. (2015) is 0.617.
# 4.4 COMPARISON OF DIFFERENT PARTITION METHODS
We now compare the two partition methods we considered for our model: spectral partition and our modified multi-seed flood fill. We use the NELL data set to benchmark and report the average validation accuracy over 10 runs in Tab. 4, in which we also report the average runtime of the partition process. The accuracies of the trained models do not allow for a clear conclusion as to
<table><tr><td>Method</td><td>5</td><td>10</td><td>20</td><td>30</td></tr><tr><td>Spectral Partition</td><td>54.8 (2.49s)</td><td>55.6 (4.16s)</td><td>58.0 (12.2s)</td><td>60.1 (3115s)</td></tr><tr><td>Modified Multi-seed Flood Fill</td><td>62.0 (0.36s)</td><td>63.1 (0.36s)</td><td>57.5 (0.43s)</td><td>59.9 (0.23s)</td></tr></table>
Table 4: Accuracy and run time of different partition methods with different numbers of subgraphs.
 Figure 2: (a), (b) The t-SNE visualization of node representations produced by propagation model of GGNN and GPNN on Cora dataset in which nodes actually belong to 7 classes. (c) Comparison of different propagation schedules with varying propagation steps.
which method to use, and in our further experiments they seem to highly depend on the number of subgraphs, the connectivity of input graphs, optimization and other factors. However, our multi-seed flood fill partition method is substantially faster and is efficiently applicable to very large graphs.
# 4.5 COMPARISON OF DIFFERENT PROPAGATION SCHEDULES
Besides the synchronous and our partition based propagation schedules, we also investigated two further schedules based on a sequential order and a series of minimum spanning trees (MST).
To generate a sequential schedule, we first perform graph traversal via breadth first search (BFS) which gives us a visiting order. We then split the edges into those that follow the visiting order and those that violate it. The edges in each class construct a directed acyclic graph (DAG), and we construct a propagation schedule from each DAG following the principle that every node will send messages once it receives all messages from its parents and updates its own state. An example of the schedule is given in the appendix. Note that this sequential schedule reduces to a standard bidirectional recurrent neural network on a chain graph.
For the MST schedule, we find a sequence of minimum spanning trees as follows. We first assign random positive weights between 0 and 1 to every edge and then apply Kruskal’s algorithm to find an MST. Next we increase the weights by 1 for edges which are present in the MST we found so far. This process is iterated until we find $K$ MSTs where $K$ is the total number of propagation steps.
We compare all four schedules by varying the number of propagation steps on the Cora dataset. The validation accuracies are shown in Fig. 2 (c). In these results, the meaning of one propagation step varies, so the takeaways are based just on the trends and overall performance across number of propagation steps. For the synchronous schedule, it means that every node sent and received messages once and updated its state. For the sequential schedule, it means that messages from all roots of the two DAGs were sent to all the leaves. For the MST-based schedule, it means sending messages from the root to all leaves on one minimum spanning tree. For our partition schedules, it means one outer loop of the algorithm. In this sense, messages are propagated furthest through the graph for the sequential schedule within one propagate step. This is also validated by the best performance of sequential schedule in the beginning. However, when increasing the number of propagation steps, it performs worse as the deep computational graph makes the learning problem very hard. Our partition schedule is better than other schedules when the number of propagation steps is small and tends to perform similarly with synchronous schedule with more steps.
# 5 CONCLUSION
We presented graph partition neural networks, which extend graph neural networks. Relying on graph partitions, our model alternates between locally propagating information between nodes in small subgraphs and globally propagating information between the subgraphs. Moreover, we propose a modified multi-seed flood fill for fast partitioning of large scale graphs. Empirical results show that our model performs better or is comparable to state-of-the-art methods on a wide variety of semi-supervised node classification tasks.
There are quite a few exciting directions to explore in the future. One is to learn the graph partitioning as well as the GNN weights, using a soft partition assignment. Other types of propagation schedules which have proven useful in probabilistic graphical models are also worthwhile to explore in the context of GNNs. To further improve the efficiency of propagating information, different nodes within the graph could share some memory, which mimics the shared memory model in the theory of distributed computing. Perhaps most importantly, this work makes it possible to run GNN models on very large graphs, which potentially opens the door to many new applications.
# REFERENCES
Mart´ın Abadi, Ashish Agarwal, Paul Barham, Eugene Brevdo, Zhifeng Chen, Craig Citro, Greg S. Corrado, Andy Davis, Jeffrey Dean, Matthieu Devin, Sanjay Ghemawat, Ian Goodfellow, Andrew Harp, Geoffrey Irving, Michael Isard, Yangqing Jia, Rafal Jozefowicz, Lukasz Kaiser, Manjunath Kudlur, Josh Levenberg, Dan Mane, Rajat Monga, Sherry Moore, Derek Murray, Chris Olah, ´ Mike Schuster, Jonathon Shlens, Benoit Steiner, Ilya Sutskever, Kunal Talwar, Paul Tucker, Vincent Vanhoucke, Vijay Vasudevan, Fernanda Viegas, Oriol Vinyals, Pete Warden, Martin Watten- ´ berg, Martin Wicke, Yuan Yu, and Xiaoqiang Zheng. TensorFlow: Large-scale machine learning on heterogeneous systems, 2015. URL https://www.tensorflow.org/. Software available from tensorflow.org.
Hagit Attiya and Jennifer Welch. Distributed computing: fundamentals, simulations, and advanced topics, volume 19. John Wiley & Sons, 2004.
Laura Banarescu, Claire Bonial, Shu Cai, Madalina Georgescu, Kira Griffitt, Ulf Hermjakob, Kevin Knight, Philipp Koehn, Martha Palmer, and Nathan Schneider. Abstract meaning representation (amr) 1.0 specification.
Mikhail Belkin, Partha Niyogi, and Vikas Sindhwani. Manifold regularization: A geometric framework for learning from labeled and unlabeled examples. Journal of machine learning research, 7 (Nov):2399–2434, 2006.
Lidong Bing, Sneha Chaudhari, Richard Wang, and William Cohen. Improving distant supervision for information extraction using label propagation through lists. In Proceedings of the 2015 Conference on Empirical Methods in Natural Language Processing, pp. 524–529, 2015.
Joan Bruna, Wojciech Zaremba, Arthur Szlam, and Yann LeCun. Spectral networks and locally connected networks on graphs. ICLR, 2014.
Andrew Carlson, Justin Betteridge, Bryan Kisiel, Burr Settles, Estevam R Hruschka Jr, and Tom M Mitchell. Toward an architecture for never-ending language learning. In AAAI, volume 5, pp. 3, 2010.
David K Duvenaud, Dougal Maclaurin, Jorge Iparraguirre, Rafael Bombarell, Timothy Hirzel, Alan´ Aspuru-Guzik, and Ryan P Adams. Convolutional networks on graphs for learning molecular fingerprints. In NIPS, 2015.
Gal Elidan, Ian McGraw, and Daphne Koller. Residual belief propagation: informed scheduling for asynchronous message passing. In Proceedings of the Twenty-Second Conference on Uncertainty in Artificial Intelligence, pp. 165–173. AUAI Press, 2006.
Justin Gilmer, Samuel S. Schoenholz, Patrick F. Riley, Oriol Vinyals, and George E. Dahl. Neural message passing for quantum chemistry. arXiv preprint arXiv:1704.01212, 2017.
Christoph Goller and Andreas Kuchler. Learning task-dependent distributed representations by backpropagation through structure. In Neural Networks, 1996., IEEE International Conference on, volume 1, pp. 347–352. IEEE, 1996.
Marco Gori, Gabriele Monfardini, and Franco Scarselli. A new model for learning in graph domains. In IJCNN, 2005.
Aditya Grover and Jure Leskovec. node2vec: Scalable feature learning for networks. In Proceedings of the 22nd ACM SIGKDD international conference on Knowledge discovery and data mining, pp. 855–864. ACM, 2016.
Diederik Kingma and Jimmy Ba. Adam: A method for stochastic optimization. arXiv preprint arXiv:1412.6980, 2014.
Thomas N Kipf and Max Welling. Semi-supervised classification with graph convolutional networks. ICLR, 2017.
Ruiyu Li, Makarand Tapaswi, Renjie Liao, Jiaya Jia, Raquel Urtasun, and Sanja Fidler. Situation recognition with graph neural networks. 2017.
Yujia Li, Daniel Tarlow, Marc Brockschmidt, and Richard Zemel. Gated graph sequence neural networks. ICLR, 2016.
Qing Lu and Lise Getoor. Link-based classification. In ICML, volume 3, pp. 496–503, 2003.
Laurens van der Maaten and Geoffrey Hinton. Visualizing data using t-sne. Journal of Machine Learning Research, 9(Nov):2579–2605, 2008.
Kenneth Marino, Ruslan Salakhutdinov, and Abhinav Gupta. The more you know: Using knowledge graphs for image classification. arXiv preprint arXiv:1612.04844, 2016.
Bryan Perozzi, Rami Al-Rfou, and Steven Skiena. Deepwalk: Online learning of social representations. In Proceedings of the 20th ACM SIGKDD international conference on Knowledge discovery and data mining, pp. 701–710. ACM, 2014.
Xiaojuan Qi, Renjie Liao, Jiaya Jia, Sanja Fidler, and Raquel Urtasun. 3D graph neural networks for rgbd semantic segmentation. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pp. 5199–5208, 2017.
Franco Scarselli, Marco Gori, Ah Chung Tsoi, Markus Hagenbuchner, and Gabriele Monfardini. The graph neural network model. IEEE TNN, 2009.
M. Schlichtkrull, T. N. Kipf, P. Bloem, R. vd Berg, I. Titov, and M. Welling. Modeling relational data with graph convolutional networks. arXiv preprint arXiv:1703.06103, 2017.
Prithviraj Sen, Galileo Namata, Mustafa Bilgic, Lise Getoor, Brian Galligher, and Tina Eliassi-Rad. Collective classification in network data. AI magazine, 29(3):93, 2008.
Jianbo Shi and Jitendra Malik. Normalized cuts and image segmentation. IEEE Transactions on pattern analysis and machine intelligence, 22(8):888–905, 2000.
Richard Socher, Eric H Huang, Jeffrey Pennin, Christopher D Manning, and Andrew Y Ng. Dynamic pooling and unfolding recursive autoencoders for paraphrase detection. In Advances in neural information processing systems, pp. 801–809, 2011a.
Richard Socher, Cliff C Lin, Chris Manning, and Andrew Y Ng. Parsing natural scenes and natural language with recursive neural networks. In Proceedings of the 28th international conference on machine learning (ICML-11), pp. 129–136, 2011b.
Sainbayar Sukhbaatar, Rob Fergus, et al. Learning multiagent communication with backpropagation. In Advances in Neural Information Processing Systems, pp. 2244–2252, 2016.
Charles Sutton and Andrew McCallum. Improved dynamic schedules for belief propagation. arXiv preprint arXiv:1206.5291, 2012.
Kai Sheng Tai, Richard Socher, and Christopher D Manning. Improved semantic representations from tree-structured long short-term memory networks. ACL, 2015. Daniel Tarlow, Inmar Givoni, Richard Zemel, and Brendan Frey. Graph cuts is a max-product algorithm. In Uncertainty in Artificial Intelligence (UAI), 2011. Damien Teney, Lingqiao Liu, and Anton van den Hengel. Graph-structured representations for visual question answering. arXiv preprint arXiv:1609.05600, 2016. Ulrike Von Luxburg. A tutorial on spectral clustering. Statistics and computing, 17(4):395–416, 2007. Martin J Wainwright, Tommi Jaakkola, and Alan S Willsky. Tree-based reparameterization for approximate inference on loopy graphs. In Advances in neural information processing systems, pp. 1001–1008, 2002. Jason Weston, Fred´ eric Ratle, Hossein Mobahi, and Ronan Collobert. Deep learning via semi- ´ supervised embedding. In Neural Networks: Tricks of the Trade, pp. 639–655. Springer, 2012. Zhilin Yang, William W Cohen, and Ruslan Salakhutdinov. Revisiting semi-supervised learning with graph embeddings. arXiv preprint arXiv:1603.08861, 2016. Xiaojin Zhu, Zoubin Ghahramani, John Lafferty, et al. Semi-supervised learning using gaussian fields and harmonic functions. In ICML, volume 3, pp. 912–919, 2003.
<table><tr><td>Method</td><td>Citeseer</td><td>Cora</td><td>Pubmed</td></tr><tr><td>GCNt (Kipf & Welling, 2017)</td><td>68.7 ± 2.0</td><td>80.4 ± 2.8</td><td>77.5 ± 2.1</td></tr><tr><td>GGNN* (Li et al., 2016)</td><td>66.3 ± 2.0</td><td>78.9 ± 2.6</td><td>74.7 ± 2.8</td></tr><tr><td>GPNN</td><td>68.6 ± 1.7</td><td>79.9 ± 2.4</td><td>76.1 ± 2.0</td></tr></table>
Table 5: Classification accuracies on citation networks with 10 random splits. ∗ and $\dagger$ indicates we run our own implementation and the released code respectively.
# A APPENDIX
# A.1 BI-DIRECTIONAL CHAIN
In this section, we revisit the broadcast problem on bi-direction chain graphs. We show that our propagation schedule has advantages over the synchronous one via the following proposition.
Proposition 1. Let $\mathcal { G }$ be a bi-direction chain of size $N$ . We have: $( l )$ Synchronous propagation schedule requires $2 ( N - 1 ) ^ { 2 }$ messages to solve the problem; (2) If we partition the chain evenly into $K$ sub-chains for $1 \le K \le N$ , GPNN propagation schedule can solve the problem with $2 ( ( N - K ) ^ { 2 } + ( K ^ { \setminus } - 1 ) ^ { 2 } )$ ) messages.
Proof. We first analyze the case for synchronous propagation schedule. At each round, it needs $2 ( N - 1 )$ messages to propagate messages one step away. Since it requires at least $( N - 1 )$ steps for message from one endpoint of the chain to reach the other, the number of messages to solve broadcast is thus $2 ( N - 1 ) ^ { \frac { \cdot } { 2 } }$ .
We now turn to our schedule. Since the chain is evenly partitioned, each sub-chain is of $n = N / K$ nodes. We need to perform $( n - 1 )$ propagation steps to traverse a sub-chain, so we set $T _ { S } = n - 1$ . The number of messages required by a single sub-chain during the intra-subgraph propagation phase is $2 ( n - 1 ) ^ { 2 }$ , and so all $K$ sub-chains collectively require $2 \bar { K } ( n - 1 ) ^ { 2 }$ messages. Between intrasubgraph propagation, we perform $T _ { C } = 1$ step of inter-subgraph propagation to transfer messages over the cut edges between sub-chains. Each inter-subgraph step requires 2 messages per cut edge - i.e. 2(K-1) messages in total. We need $K$ outer loops to ensure that message from any node can reach any other nodes, and strictly speaking, the the last inter-subgraph propagation step is unnecessary. So in total, we require $K \times \bar { 2 } \bar { K ( { n - 1 } ) } + ( K - 1 ) \times 2 ( K - 1 ) = \bar { 2 } ( ( \bar { N } { - } \bar { K } ) ^ { 2 } + ( \bar { K - 1 } ) ^ { 2 } )$ messages, which proves the proposition. □
One can see from the above proposition that if we take $K = 1$ and $K = N$ , the number of messages of our schedule matches the synchronous one. We can also derive the optimal value of $K$ as $( \bar { N } +$ $1 ) / 2$ resulting in a factor of 2 reduction in the total messages sent compared to the synchronous schedule.
# A.2 HYPERPARAMETERS
We train all models using Adam Kingma & Ba (2014) with a learning rate of 0.01. We also use early stopping with a window size of 10. We clip the norm gradient to ensure that it is no larger than 5.0. The maximum epochs for citation networks, NELL and DIEL are set to 200, 300 and 100 respectively. The weight decays for citation networks, NELL and DIEL are set to $5 . 0 e ^ { - 4 }$ , $1 . 0 e ^ { - 5 }$ and $1 . 0 e ^ { - \bar { 3 } }$ respectively. The dimensions of state vectors of GPNNfor Cora, Citeseer, Pubmed, NELL and DIEL are set to 128, 128, 64, 512 and 64. The output model for Cora, Citeseer, NELL is just softmax layer. For Pubmed and DIEL, we add one hidden layer with tanh activation function before the softmax which have dimension 512 and 2048 respectively.
# A.3 RANDOM SPLITS OF CITATION NETWORKS
We include the results on citation networks with 10 random splits in Table 5. From the table, we can see that our results are comparable with the state-of-the-art on these small scale datasets.
 Figure 3: Sequential scheduling. (a) The original graph. (b) and (c) are the two DAGs obtained by the sequential schedule we described in section 4.5 where BFS traversal is started from node 1.
# A.4 SEQUENTIAL PROPAGATION SCHEDULE
In Fig. 3 we show an example visualization of the DAGs decomposition of the sequential propagation schedule we implemented in the section 4.5.
# A.5 IMPLEMENTATION
The released code of GGNN (Li et al., 2016) is implemented in Torch. We implement both our own version of GGNN and our model in Tensorflow (Abadi et al., 2015). To ensure correctness, we first reproduced the experimental results of the paper on bAbI artificial intelligence (AI) tasks with our implementations of GGNN. Our code will be released soon. One challenging part is the implementation of synchronous propagation within subgraphs. We implicitly implement the parallel part by building one separate branch of the computational graph for each subgraphs (i.e., use a Python for loop rather than tf.while loop). This relies on the claim that tensorflow optimizes the execution of the computational graph in a way that independent branches of the graph will be executed in parallel as decribed in Abadi et al. (2015). However, since we have no control of the optimization of the computational graph, this part could be improved by explicitly putting each branch on one separate computation device, just like the multi-tower solution for training convolutional neural networks (CNNs) on multiple GPUs.123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340# AD V-BNN: IMPROVED ADVERSARIAL DEFENSE THROUGH ROBUST BAYESIAN NEURAL NETWORK
Xuanqing Liu1, Yao $\mathbf { L i } ^ { 2 , }$ ∗, Chongruo $\mathbf { W } \mathbf { u } ^ { 3 , \ast } \&$ Cho-Jui Hsieh1
1: Department of Computer Science, UCLA Los Angeles, CA 90095, UCLA {xqliu,choheish}@cs.ucla.edu 2: Department of Statistics, UC Davis 3: Department of Computer Science, UC Davis Davis, CA 95616, USA {crwu,yaoli}@ucdavis.edu
# ABSTRACT
We present a new algorithm to train a robust neural network against adversarial attacks. Our algorithm is motivated by the following two ideas. First, although recent work has demonstrated that fusing randomness can improve the robustness of neural networks (Liu et al., 2017), we noticed that adding noise blindly to all the layers is not the optimal way to incorporate randomness. Instead, we model randomness under the framework of Bayesian Neural Network (BNN) to formally learn the posterior distribution of models in a scalable way. Second, we formulate the mini-max problem in BNN to learn the best model distribution under adversarial attacks, leading to an adversarial-trained Bayesian neural network. Experiment results demonstrate that the proposed algorithm achieves state-of-the-art performance under strong attacks. On CIFAR-10 with VGG network, our model leads to $14 \%$ accuracy improvement compared with adversarial training (Madry et al., 2017) and random self-ensemble (Liu et al., 2017) under PGD attack with 0.035 distortion, and the gap becomes even larger on a subset of ImageNet1.
# 1 INTRODUCTION
Deep neural networks have demonstrated state-of-the-art performances on many difficult machine learning tasks. Despite the fundamental breakthroughs in various tasks, deep neural networks have been shown to be utterly vulnerable to adversarial attacks (Szegedy et al., 2013; Goodfellow et al., 2015). Carefully crafted perturbations can be added to the inputs of the targeted model to drive the performances of deep neural networks to chance-level. In the context of image classification, these perturbations are imperceptible to human eyes but can change the prediction of the classification model to the wrong class. Algorithms seek to find such perturbations are denoted as adversarial attacks (Chen et al., 2018; Carlini & Wagner, 2017b; Papernot et al., 2017), and some attacks are still effective in the physical world (Kurakin et al., 2017; Evtimov et al., 2017). The inherent weakness of lacking robustness to adversarial examples for deep neural networks brings out security concerns, especially for security-sensitive applications which require strong reliability.
To defend from adversarial examples and improve the robustness of neural networks, many algorithms have been recently proposed (Papernot et al., 2016; Zantedeschi et al., 2017; Kurakin et al., 2017; Huang et al., 2015; Xu et al., 2015). Among them, there are two lines of work showing effective results on medium-sized data (e.g., CIFAR-10). The first line of work uses adversarial training to improve robustness, and the recent algorithm proposed in Madry et al. (2017) has been recognized as one of the most successful defenses, as shown in Athalye et al. (2018). The second line of work adds stochastic components in the neural network to hide gradient information from attackers. In the black-box setting, stochastic outputs can significantly increase query counts for attacks using finite-difference techniques (Chen et al., 2018; Ilyas et al., 2018), and even in the white-box setting the recent Random Self-Ensemble (RSE) approach proposed by Liu et al. (2017) achieves similar performance to Madry’s adversarial training algorithm.
In this paper, we propose a new defense algorithm called Adv-BNN. The idea is to combine adversarial training and Bayesian network, although trying BNNs in adversarial attacks is not new (e.g. (Li & Gal, 2017; Feinman et al., 2017; Smith & Gal, 2018)), and very recently Ye & Zhu (2018) also tried to combine Bayesian learning with adversarial training, this is the first time we scale the problem to complex data and our approach achieves better robustness than previous defense methods. The contributions of this paper can be summarized below:
• Instead of adding randomness to the input of each layer (as what has been done in RSE), we directly assume all the weights in the network are stochastic and conduct training with techniques commonly used in Bayesian Neural Network (BNN). • We propose a new mini-max formulation to combine adversarial training with BNN, and show the problem can be solved by alternating between projected gradient descent and SGD. • We test the proposed Adv-BNN approach on CIFAR10, STL10 and ImageNet143 datasets, and show significant improvement over previous approaches including RSE and adversarial training.
Notations A neural network parameterized by weights $\pmb { w } \in \mathbb { R } ^ { d }$ is denoted by $f ( { \pmb x } ; { \pmb w } )$ , where $\ b { x } \in \mathbb { R } ^ { p }$ is an input example and $y$ is the corresponding label, the training/testing dataset is ${ \mathcal { D } } _ { \mathrm { t r / t e } }$ with size $N _ { \mathrm { t r / t e } }$ respectively. When necessary, we abuse ${ \mathcal { D } } _ { \mathrm { t r / t e } }$ to define the empirical distributions, i.e. Dtr/te = 1Ntr/t $\begin{array} { r } { \mathcal { D } _ { \mathrm { t r / t e } } = \frac { 1 } { N _ { \mathrm { t r / t e } } } \sum _ { i = 1 } ^ { N _ { \mathrm { t r / t e } } } \delta ( x _ { i } ) \delta ( y _ { i } ) } \end{array}$ e PNtr/tei=1 δ(xi)δ(yi), where δ(·) is the Dirac delta function. xo represents the original input and $\pmb { x } ^ { \mathrm { a d v } }$ denotes the adversarial example. The loss function is represented as $\ell \big ( f ( \pmb { x } _ { i } ; \pmb { w } ) , y _ { i } \big )$ , where $i$ is the index of the data point. Our approach works for any loss but we consider the cross-entropy loss in all the experiments. The adversarial perturbation is denoted as $\pmb { \xi } \in \mathbb { R } ^ { p }$ , and adversarial example is generated by ${ \pmb x } ^ { \mathrm { a d v } } = { \pmb x } _ { o } + { \pmb \xi }$ . In this paper, we focus on the attack under norm constraint Madry et al. (2017), so that $\| \pmb { \xi } \| \le \gamma$ . In order to align with the previous works, in the experiments we set the norm to $\| \cdot \| _ { \infty }$ . The Hadamard product is denoted as $\odot$ .
# 2 BACKGROUNDS
# 2.1 ADVERSARIAL ATTACK AND DEFENSE
In this section, we summarize related works on adversarial attack and defense.
Attack: Most algorithms generate adversarial examples based on the gradient of loss function with respect to the inputs. For example, FGSM (Goodfellow et al., 2015) perturbs an example by the sign of gradient, and use a step size to control the $\ell _ { \infty }$ norm of perturbation. Kurakin et al. (2017) proposes to run multiple iterations of FGSM. More recently, C&W attack Carlini & Wagner (2017a) formally poses attack as an optimization problem, and applies a gradient-based iterative solver to get an adversarial example. Both C&W attack and PGD attack (Madry et al., 2017) have been frequently used to benchmark the defense algorithms due to their effectiveness (Athalye et al., 2018). Throughout, we take the PGD attack as an example, largely following Madry et al. (2017).
The goal of PGD attack is to find adversarial examples in a $\gamma$ -ball, which can be naturally formulated as the following objective function:
$$\operatorname* { m a x } _ { \| \pmb { \xi } \| _ { \infty } \leq \gamma } \ell ( f ( \pmb { x } _ { o } + \pmb { \xi } ; \pmb { w } ) , y _ { o } ) .$$
Starting from $\pmb { x } ^ { 0 } = \pmb { x } _ { o }$ , PGD attack conducts projected gradient descent iteratively to update the adversarial example:
$$\begin{array} { r } { \pmb { x } ^ { t + 1 } = \Pi _ { \gamma } \left\{ \pmb { x } ^ { t } + \alpha \cdot \mathrm { s i g n } \Big ( \nabla _ { \pmb { x } } \ell \big ( f ( \pmb { x } ^ { t } ; \pmb { w } ) , y _ { o } \big ) \Big ) \right\} , } \end{array}$$
where $\Pi _ { \gamma }$ is the projection to the set $\{ { \pmb x } | \| { \pmb x } - { \pmb x } _ { o } \| _ { \infty } \le { \gamma } \}$ . Although multi-step PGD iterations may not necessarily return the optimal adversarial examples, we decided to apply it in our experiments, following the previous work of (Madry et al., 2017). An advantage of PGD attack over C&W attack is that it gives us a direct control of distortion by changing $\gamma$ , while in C&W attack we can only do this indirectly via tuning the regularizer.
Since we are dealing with networks with random weights, we elaborate more on which strategy should attackers take to increase their success rate, and the details can be found in Athalye et al. (2018). In random neural networks, an attacker seeks a universal distortion $\boldsymbol { \xi }$ that cheats a majority of realizations of the random weights. This can be achieved by maximizing the loss expectation
$$\pmb { \xi } \triangleq \underset { \| \pmb { \xi } \| _ { \infty } \leq \gamma } { \arg \operatorname* { m a x } } \underset { \pmb { w } } { \mathbb { E } } \big [ \ell \big ( f \big ( \pmb { x } _ { o } + \pmb { \xi } ; \pmb { w } \big ) , y _ { o } \big ) \big ] .$$
Here the model weights $\pmb { w }$ are considered as random vector following certain distributions. In fact, solving (3) to a saddle point can be done easily by performing multi-step (projected) SGD updates. This is done inherently in some iterative attacks such as C&W or PGD discussed above, where the only difference is that we sample new weights $\pmb { w }$ at each iteration.
Defense: There are a large variety of defense methods proposed in recent years, e.g. denoiser based HGD (Liao et al., 2017) and randomized image preprocessing (Xie et al., 2017). Readers can find more from Kurakin et al. (2018). Below we select two representative ones that turn out to be effective to white box attacks. They are the major baselines in our experiments.
The first example is the adversarial training (Szegedy et al., 2013; Goodfellow et al., 2015). It is essentially a data augmentation method, which trains the deep neural networks on adversarial examples until the loss converges. Instead of searching for adversarial examples and adding them into the training data, Madry et al. (2017) proposed to incorporate the adversarial search inside the training process, by solving the following robust optimization problem:
$$\pmb { w } ^ { * } = \underset { \pmb { w } } { \arg \operatorname* { m i n } } \ \underset { ( \pmb { x } , \pmb { y } ) \sim \mathcal { D } _ { \mathrm { t r } } } { \mathbb { E } } \left\{ \underset { \| \pmb { \xi } \| _ { \infty } \leq \gamma } { \operatorname* { m a x } } \ell \big ( f ( \pmb { x } + \pmb { \xi } ; \pmb { w } ) , \ b { y } \big ) \right\} ,$$
where ${ \mathcal { D } } _ { \mathrm { t r } }$ is the training data distribution. The above problem is approximately solved by generating adversarial examples using PGD attack and then minimizing the classification loss of the adversarial example. In this paper, we propose to incorporate adversarial training in Bayesian neural network to achieve better robustness.
The other example is RSE (Liu et al., 2017), in this algorithm the authors proposed a “noise layer”, which fuses input features with Gaussian noise. They show empirically that an ensemble of models can increase the robustness of deep neural networks. Besides, their method can generate an infinite number of models on-the-fly without any additional memory cost. The noise layer is applied in both training and testing phases, so the prediction accuracy will not be largely affected. Our algorithm is different from RSE in two folds: 1) We add noise to each weight instead of input or hidden feature, and formally model it as a BNN. 2) We incorporate adversarial training to further improve the performance.
# 2.2 BAYESIAN NEURAL NETWORKS (BNN)
The idea of BNN is illustrated in Fig. 1. Given the observable random variables $( { \pmb x } , y )$ , we aim to estimate the distributions of hidden variables $\textbf { \em w }$ . In our case, the observable random variables correspond to the features $_ { \textbf { \em x } }$ and labels $y$ , and we are interested in the posterior over the weights $p ( \pmb { w } | \pmb { x } , y )$ given the prior $p ( \pmb { w } )$ . However, the exact solution of posterior is often intractable: notice that $\begin{array} { r } { p ( \pmb { w } | \pmb { x } , y ) = \frac { p ( \pmb { x } , y | \pmb { w } ) p ( \pmb { w } ) } { p ( \pmb { x } , y ) } } \end{array}$ but the denominator involves a high dimensional integral (Blei et al., 2017), hence the conditional probabilities are hard to compute. To speedup inference, we generally have two approaches—we can either sample ${ \pmb w } \sim \bar { p ( { \pmb w } | { \pmb x } , \bar { y ) } }$ efficiently without knowing the closed-form formula through, for example, Stochastic Gradient Langevin Dynamics (SGLD) (Welling & Teh, 2011), or we can approximate the true posterior $p ( \pmb { w } | \pmb { x } , y )$ by a parametric distribution $q _ { \pmb { \theta } } ( \pmb { w } )$ , where the unknown parameter $\pmb \theta$ is estimated by minimizing ${ \sf K L } \big ( q _ { \theta } ( { \pmb w } ) \parallel p ( { \pmb w } | { \pmb x } , y ) \big )$ over $\pmb \theta$ . For
 Figure 1: Illustration of Bayesian neural networks.
neural network, the exact form of KL-divergence can be unobtainable, but we can easily find an unbiased gradient estimator of it using backward propagation, namely Bayes by Backprop (Blundell et al., 2015).
Despite that both methods are widely used and analyzed in-depth, they have some obvious shortcomings, making high dimensional Bayesian inference remain to be an open problem. For SGLD and its extension (e.g. (Li et al., 2016)), since the algorithms are essentially SGD updates with extra Gaussian noise, they are very easy to implement. However, they can only get one sample ${ \pmb w } \sim p ( { \pmb w } | { \pmb x } , y )$ in each minibatch iteration at the cost of one forward-backward propagation, thus not efficient enough for fast inference. In addition, as the step size $\eta _ { t }$ in SGLD decreases, the samples become more and more correlated so that one needs to generate many samples in order to control the variance. Conversely, the variational inference method is efficient to generate samples since we know the approximated posterior $q _ { \pmb { \theta } } ( \pmb { w } )$ once we minimized the KL-divergence. The problem is that for simplicity we often assume the approximation $q _ { \theta }$ to be a fully factorized Gaussian distribution:
$$q _ { \pmb \theta } ( \pmb w ) = \prod _ { i = 1 } ^ { d } q _ { \pmb \theta _ { i } } ( \pmb w _ { i } ) , \mathrm { ~ a n d ~ } q _ { \pmb \theta _ { i } } ( \pmb w _ { i } ) = \mathcal N ( \pmb w _ { i } ; \pmb \mu _ { i } , \pmb \sigma _ { i } ^ { 2 } ) .$$
Although our assumption (5) has a simple form, it inherits the main drawback from mean-field approximation. When the ground truth posterior has significant correlation between variables, the approximation in (5) will have a large deviation from true posterior $p ( \pmb { w } | \pmb { x } , y )$ . This is especially true for convolutional neural networks, where the values in the same convolutional kernel seem to be highly correlated. However, we still choose this family of distribution in our design as the simplicity and efficiency are mostly concerned.
In fact, there are many techniques in deep learning area borrowing the idea of Bayesian inference without mentioning explicitly. For example, Dropout (Srivastava et al., 2014) is regarded as a powerful regularization tool for deep neural networks, which applies an element-wise product of the feature maps and i.i.d. Bernoulli or Gaussian r.v. $B ( 1 , \alpha )$ (or $\bar { \mathcal { N } } ( 1 , \alpha ) \}$ . If we allow each dimension to have an independent dropout rate and take them as model parameters to be learned, then we can extend it to the variational dropout method (Kingma et al., 2015). Notably, learning the optimal dropout rates for data relieves us from manually tuning hyper-parameter on hold-out data. Similar idea is also used in RSE (Liu et al., 2017), except that it was used to improve the robustness under adversarial attacks. As we discussed in the previous section, RSE incorporates Gaussian noise $\epsilon \sim \mathcal { N } ( 0 , \sigma ^ { 2 } )$ in an additive manner, where the variance $\sigma ^ { 2 }$ is user predefined in order to maximize the performance. Different from RSE, our Adv-BNN has two degrees of freedom (mean and variance) and the network is trained on adversarial examples.
# 3 METHOD
In our method, we combine the idea of adversarial training (Madry et al., 2017) with Bayesian neural network, hoping that the randomness in the weights $\textbf { \em w }$ provides stronger protection for our model.
To build our Bayesian neural network, we assume the joint distribution $q _ { \mu , s } ( \pmb { w } )$ is fully factorizable (see (5)), and each posterior $q _ { \pmb { \mu } _ { i } , \pmb { s } _ { i } } ( \pmb { w } _ { i } )$ follows normal distribution with mean $\pmb { \mu _ { i } }$ and standard deviation $\exp ( { \pmb { s } } _ { i } ) > 0$ . The prior distribution is simply isometric Gaussian $\mathcal { N } ( \mathbf { 0 } _ { d } , s _ { 0 } ^ { 2 } I _ { d \times d } )$ . We choose the Gaussian prior and posterior for its simplicity and closed-form KL-divergence, that is, for any two Gaussian distributions $s$ and $t$ ,
$$\mathsf { K L } ( s \parallel t ) = \log \frac { \sigma _ { t } } { \sigma _ { s } } + \frac { \sigma _ { s } ^ { 2 } + ( \mu _ { s } - \mu _ { t } ) ^ { 2 } } { 2 \sigma _ { t } ^ { 2 } } - 0 . 5 , \qquad s \mathrm { o r } t \sim \mathcal { N } ( \mu _ { s \mathrm { o r } t } , \sigma _ { s \mathrm { o r } t } ^ { 2 } ) .$$
Note that it is also possible to choose more complex priors such as “spike-and-slab” (Ishwaran et al., 2005) or Gaussian mixture, although in these cases the KL-divergence of prior and posterior is hard to compute and practically we replace it with the Monte-Carlo estimator, which has higher variance, resulting in slower convergence rate (Kingma, 2017).
Following the recipe of variational inference, we adapt the robust optimization to the evidence lower bound (ELBO) w.r.t. the variational parameters during training. First of all, recall the ELBO on the original dataset (the unperturbed data) can be written as
$$- \mathsf { K L } \big ( q _ { \mu , s } ( w ) \parallel p ( w ) \big ) + \sum _ { ( \mathbf { x } _ { i } , y _ { i } ) \in \mathcal { D } _ { \mathrm { t r } } } \mathbb { E } _ { w \sim q _ { \mu , s } } \log p ( y _ { i } | x _ { i } , w ) ,$$
rather than directly maximizing the ELBO in (7), we consider the following alternative objective,
$$\mathcal { L } ( \mu , s ) \triangleq - \mathsf { K L } \big ( q _ { \mu , s } ( w ) \parallel p ( w ) \big ) + \sum _ { ( x _ { i } , y _ { i } ) \in \mathcal { D } _ { \mathrm { t r } } } \operatorname* { m i n } _ { \| x _ { i } ^ { \mathrm { a d v } } - x _ { i } \| \leq \gamma } \mathbb { E } _ { w \sim q _ { \mu , s } } \log p ( y _ { i } | x _ { i } ^ { \mathrm { a d v } } , w ) .$$
This is essentially finding the minima for each data point $( \boldsymbol { x } _ { i } , \boldsymbol { y } _ { i } ) \in \mathcal { D } _ { \mathrm { t r } }$ inside the $\gamma$ -norm ball, we can also interpret (8) as an even looser lower bound of evidence. So the robust optimization procedure is to maximize (8), i.e.
$$\mu ^ { * } , s ^ { * } = \underset { \mu , s } { \arg \operatorname* { m a x } } \mathcal { L } ( \mu , s ) .$$
To make the objective more specific, we combine (8) with (9) and get
$$\underset { \mu , s } { \arg \operatorname* { m a x } } \left\{ \big [ \sum _ { \left( \mathbf { x } _ { i } , y _ { i } \right) \in \mathcal { D } _ { \mathrm { t r } } } \operatorname* { m i n } _ { \left\| \mathbf { x } _ { i } ^ { \mathrm { a d v } } - \mathbf { x } _ { i } \right\| \leq \gamma } \mathbb { E } _ { w \sim q _ { \mu , s } } \log p ( y _ { i } | x _ { i } ^ { \mathrm { a d v } } , w ) \big ] - \mathsf { K L } \big ( q _ { \mu , s } ( w ) \big \| p ( w ) \big ) \right\}$$
In our case, $p ( \boldsymbol { y } | \mathbf { x } ^ { \mathrm { a d v } } , \boldsymbol { w } ) = \mathrm { S o f t m a x } \big ( f ( \mathbf { x } _ { i } ^ { \mathrm { a d v } } ; \boldsymbol { w } ) \big ) [ \boldsymbol { y } _ { i } ]$ is the network output on the adversarial sample $( x _ { i } ^ { \mathrm { a d v } } , y _ { i } )$ . More generally, we can reformulate our model as $y = f ( { \pmb x } ; { \pmb w } ) { + } \zeta$ and assume the residual $\zeta$ follows either Logistic $( 0 , 1 )$ or Gaussian distribution depending on the specific problem, so that our framework includes both classification and regression tasks. We can see that the only difference between our Adv-BNN and the standard BNN training is that the expectation is now taken over the adversarial examples $( \boldsymbol { x } ^ { \mathrm { a d v } } , \boldsymbol { y } )$ , rather than natural examples $( { \pmb x } , y )$ . Therefore, at each iteration we first apply a randomized PGD attack (as introduced in eq (3)) for $T$ iterations to find $\pmb { x } ^ { \mathrm { a d v } }$ , and then fix the $\pmb { x } ^ { \mathrm { a d v } }$ to update $\mu , s$ .
When updating $\pmb { \mu }$ and $\pmb { s }$ , the KL term in (8) can be calculated exactly by (6), whereas the second term is very complex (for neural networks) and can only be approximated by sampling. Besides, in order to fit into the back-propagation framework, we adopt the Bayes by Backprop algorithm (Blundell et al., 2015). Notice that we can reparameterize $\pmb { w } = \pmb { \mu } + \exp ( \pmb { s } ) \odot \pmb { \epsilon } .$ , where $\epsilon \sim \mathcal { N } ( \mathbf { 0 } _ { d } , I _ { d \times d } )$ is a parameter free random vector, then for any differentiable function $h ( w , \mu , s )$ , we can show that
$$\begin{array} { l } { \displaystyle \frac { \partial } { \partial \mu } \mathop { \mathbb { E } } _ { w } [ h ( w , \mu , s ) ] = \mathop { \mathbb { E } } _ { \epsilon } \left[ \frac { \partial } { \partial w } h ( w , \mu , s ) + \frac { \partial } { \partial \mu } h ( w , \mu , s ) \right] } \\ { \displaystyle \frac { \partial } { \partial s } \mathop { \mathbb { E } } _ { w } [ h ( w , \mu , s ) ] = \mathop { \mathbb { E } } _ { \epsilon } \left[ \exp ( s ) \odot \epsilon \odot \frac { \partial } { \partial w } h ( w , \mu , s ) + \frac { \partial } { \partial s } h ( w , \mu , s ) \right] . } \end{array}$$
Now the randomness is decoupled from model parameters, and thus we can generate multiple $\epsilon$ to form a unbiased gradient estimator. To integrate into deep learning framework more easily, we also designed a new layer called RandLayer, which is summarized in appendix.
It is worth noting that once we assume the simple form of variational distribution (5), we can also adopt the local reparameterization trick (Kingma et al., 2015). That is, rather than sampling the weights $\pmb { w }$ , we directly sample the activations and enjoy the lower variance during the sampling process. Although in our experiments we find the simple Bayes by Backprop method efficient enough.
For ease of doing SGD iterations, we rewrite (9) into a finite sum problem by dividing both sides by the number of training samples $N _ { \mathrm { t r } }$
$$\mu ^ { * } , s ^ { * } = \underset { \mu , s } { \arg \operatorname* { m i n } } - \frac { 1 } { N _ { \mathrm { t r } } } \sum _ { i = 1 } ^ { N _ { \mathrm { t r } } } \log p ( y _ { i } | x _ { i } ^ { \mathrm { a d v } } , w ) + \frac { 1 } { N _ { \mathrm { t r } } } g ( \mu , s ) ,$$
here we define $g ( \pmb { \mu } , \pmb { s } ) \triangleq { \sf K L } ( q _ { \pmb { \mu } , \pmb { s } } ( \pmb { w } ) \parallel p ( \pmb { w } ) )$ by the closed form solution (6), so there is no randomness in it. We sample new weights by $\pmb { w } = \mu + \exp ( \pmb { s } ) \odot \pmb { \epsilon }$ in each forward propagation, so that the stochastic gradient is unbiased. In practice, however, we need a weaker regularization for
small dataset or large model, since the original regularization in (12) can be too large. We fix this problem by adding a factor $0 < \alpha \leq 1$ to the regularization term, so the new loss becomes
$$- \frac { 1 } { N _ { \mathrm { t r } } } \sum _ { i = 1 } ^ { N _ { \mathrm { t r } } } \log p ( y _ { i } | x _ { i } ^ { \mathrm { a d v } } , w ) + \frac { \alpha } { N _ { \mathrm { t r } } } g ( \pmb { \mu } , \pmb { s } ) , \quad 0 < \alpha \leq 1 .$$
In our experiments, we found little to no performance degradation compared with the same network without randomness, if we choose a suitable hyper-parameter $\alpha$ , as well as the prior distribution $\mathcal { N } ( \mathbf { 0 } , s _ { 0 } ^ { 2 } I )$ .
The overall training algorithm is shown in Alg. 1. To sum up, our Adv-BNN method trains an arbitrary Bayesian neural network with the min-max robust optimization, which is similar to Madry et al. (2017). As we mentioned earlier, even though our model contains noise and eventually the gradient information is also noisy, by doing multiple forward-backward iterations, the noise will be cancelled out due to the law of large numbers. This is also the suggested way to bypass some stochastic defenses in Athalye et al. (2018).
# Algorithm 1 Code snippet for training Adv-BNN
<table><tr><td colspan="2">1: procedure pgd_attack(x,y,w)</td><td></td></tr><tr><td>2:</td><td colspan="2">Perform the PGD-attack (2), omitted for brevity</td></tr><tr><td>3:</td><td>procedure train(data,w)</td><td></td></tr><tr><td>4:</td><td>DInput: dataset and network weights w</td><td></td></tr><tr><td>5:</td><td>for(x,y) in data do</td><td></td></tr><tr><td>6:</td><td>xadv ← pgd.attack(x,y, w)</td><td>Generate adversarial images</td></tr><tr><td>7:</td><td>w ←μ+exp(s)①∈,∈~N(0d,Idxd)</td><td>Samplenewmodel parameters</td></tr><tr><td>8:</td><td>y ← forward(w,xadv)</td><td>Forward propagation</td></tr><tr><td>9:</td><td>loss_ce ← cross_entropy(y,y)</td><td>Cross-entropy loss</td></tr><tr><td>10:</td><td>loss_kl ←kl_divergence(w)</td><td>KL-divergence following (6)</td></tr><tr><td>11:</td><td>L(μ,s)←loss_ce+ α ·loss_kl Ntr</td><td>Total loss following (13)</td></tr><tr><td>12:</td><td>,←backward(L(μ,s)) p's</td><td>Backward propagation to get gradients</td></tr><tr><td>13:</td><td>μ,s←μ-nt, aL 8- nts </td><td>>SGD update,omitting momentum and weight decay</td></tr><tr><td colspan="2">14: return net</td><td></td></tr></table>
Will it be beneficial to have randomness in adversarial training? After all, both randomized network and adversarial training can be viewed as different ways for controlling local Lipschitz constants of the loss surface around the image manifold, and thus it is non-trivial to see whether combining those two techniques can lead to better robustness. The connection between randomized network (in particular, RSE) and local Lipschitz regularization has been derived in Liu et al. (2017). Adversarial training can also be connected to local Lipschitz regularization with the following arguments. Recall that the loss function given data $( x _ { i } , y _ { i } )$ is denoted as $\ell \big ( f ( \pmb { x } _ { i } ; \pmb { w } ) , y _ { i } \big )$ , and similarly the loss on perturbed data $( { \pmb x } _ { i } + { \pmb \xi } , y _ { i } )$ is $\ell \big ( f ( \pmb { x } _ { i } + \pmb { \xi } ; \pmb { w } ) , y _ { i } \big )$ . Then if we expand the loss to the first order
$$\begin{array} { r } { \Delta \ell \triangleq \ell \big ( f ( { \boldsymbol x } _ { i } + { \boldsymbol \xi } ; { \boldsymbol w } ) , { \boldsymbol y } _ { i } \big ) - \ell \big ( f ( { \boldsymbol x } _ { i } ; { \boldsymbol w } ) , { \boldsymbol y } _ { i } \big ) = { \boldsymbol \xi } ^ { \mathsf { T } } \nabla _ { { \boldsymbol x } _ { i } } \ell \big ( f ( { \boldsymbol x } _ { i } ; { \boldsymbol w } ) , { \boldsymbol y } _ { i } \big ) + { \boldsymbol O } ( \| { \boldsymbol \xi } \| ^ { 2 } ) , } \end{array}$$
we can see that the robustness of a deep model is closely related to the gradient of the loss over the input, i.e. $\nabla _ { \pmb { x } _ { i } } \ell \big ( f ( \pmb { x } _ { i } ) , y _ { i } \big )$ . If $\| \nabla _ { \pmb { x } _ { i } } \ell \big ( f ( \pmb { x } _ { i } ) , y _ { i } \big ) \|$ is large, then we can find a suitable $\boldsymbol { \xi }$ such that $\Delta \ell$ is large. Under such condition, the perturbed image ${ \pmb x } _ { i } + { \pmb \xi }$ is very likely to be an adversarial example. It turns out that adversarial training (4) directly controls the local Lipschitz value on the training set, this can be seen if we combine (14) with (4)
$$\begin{array} { l } \displaystyle { \operatorname* { m i n } _ { w } \ell \big ( f \big ( { \boldsymbol x } _ { i } ^ { \mathrm { a d v } } ; { \boldsymbol w } \big ) , y _ { i } \big ) = \operatorname* { m i n } _ { { \boldsymbol w } } \operatorname* { m a x } _ { \boldsymbol \parallel \xi \boldsymbol \parallel \leq \gamma } \ell \big ( f \big ( { \boldsymbol x } _ { i } + { \boldsymbol \xi } ; { \boldsymbol w } \big ) } \\ { = \displaystyle { \operatorname* { m i n } _ { { \boldsymbol w } } \operatorname* { m a x } _ { \boldsymbol \parallel \xi \boldsymbol \parallel \leq \gamma } \ell \big ( f \big ( { \boldsymbol x } _ { i } ; { \boldsymbol w } \big ) , y _ { i } \big ) + \xi ^ { \top } \nabla _ { { \boldsymbol x } _ { i } } \ell \big ( f \big ( { \boldsymbol x } _ { i } ; { \boldsymbol w } \big ) , y _ { i } \big ) + \mathcal O ( \| \boldsymbol \xi \| ^ { 2 } ) . } } \end{array}$$
Moreover, if we ignore the higher order term $\mathcal { O } ( \| \pmb { \xi } \| ^ { 2 } )$ then (15) becomes
$$\operatorname* { m i n } _ { \pmb { w } } \ell ( f ( \pmb { x } _ { i } ; \pmb { w } ) , y _ { i } ) + \gamma \cdot \| \nabla _ { \pmb { x } _ { i } } \ell ( f ( \pmb { x } _ { i } ; \pmb { w } ) , y _ { i } ) \| .$$
In other words, the adversarial training can be simplified to Lipschitz regularization, and if the model generalizes, the local Lipschitz value will also be small on the test set. Yet, as (Liu & Hsieh,
2018) indicates, for complex dataset like CIFAR-10, the local Lipschitz is still very large on test set, even though it is controlled on training set. The drawback of adversarial training motivates us to combine the randomness model with adversarial training, and we observe a significant improvement over adversarial training or RSE alone (see the experiment section below).
# 4 EXPERIMENTAL RESULTS
In this section, we test the performance of our robust Bayesian neural networks (Adv-BNN) with strong baselines on a wide variety of datasets. In essence, our method is inspired by adversarial training (Madry et al., 2017) and BNN (Blundell et al., 2015), so these two methods are natural baselines. If we see a significant improvement in adversarial robustness, then it means that randomness and robust optimization have independent contributions to defense. Additionally, we would like to compare our method with RSE (Liu et al., 2017), another strong defense algorithm relying on randomization. Lastly, we include the models without any defense as references. For ease of reproduction, we list the hyper-parameters in the appendix. Readers can also refer to the source code on github.
It is known that adversarial training becomes increasingly hard for high dimensional data (Schmidt et al., 2018). In addition to standard low dimensional dataset such as CIFAR-10, we also did experiments on two more challenging datasets: 1) STL-10 (Coates et al., 2011), which has 5,000 training images and 8,000 testing images. Both of them are $9 6 \times 9 6$ pixels; 2) ImageNet-143, which is a subset of ImageNet (Deng et al., 2009), and widely used in conditional GAN training (Miyato & Koyama, 2018). The dataset has 18,073 training and 7,105 testing images, and all images are $6 4 \times 6 4$ pixels. It is a good benchmark because it has much more classes than CIFAR-10, but is still manageable for adversarial training.
# 4.1 EVALUATING MODELS UNDER WHITE BOX $\ell _ { \infty }$ -PGD ATTACK
In the first experiment, we compare the accuracy under the white box $\ell _ { \infty }$ -PGD attack. We set the maximum $\ell _ { \infty }$ distortion to $\gamma \in \mathrm { ~ [ ~ 0 : 0 ~ . 0 7 : 0 ~ . 0 0 5 ] ~ }$ and report the accuracy on test set. The results are shown in Fig. 2. Note that when attacking models with stochastic components, we adjust PGD accordingly as mentioned in Section 2.1. To demonstrate the relative performance more clearly, we show some numerical results in Tab. 1.
 Figure 2: Accuracy under $\ell _ { \infty }$ -PGD attack on three different datasets: CIFAR-10, STL-10 and ImageNet-143. In particular, we adopt a smaller network for STL-10 namely “Model $\mathbf { A } ^ { \mathsf { { s } } , 1 }$ , while the other two datasets are trained on VGG.
From Fig. 2 and Tab. 1 we can observe that although BNN itself does not increase the robustness of the model, when combined with the adversarial training method, it dramatically increase the testing accuracy for ${ \sim } 1 0 \%$ on a variety of datasets. Moreover, the overhead of Adv-BNN over adversarial training is small: it will only double the parameter space (for storing mean and variance), and the total training time does not increase much. Finally, similar to RSE, modifying existing network architectures into BNN is fairly simple, we only need to replace Conv/BatchNorm/Linear layers by their variational version. Hence we can easily build robust models based on existing ones.
Table 1: Comparing the testing accuracy under different levels of PGD attacks. We include our method, Adv-BNN, and the state of the art defense method, the multi-step adversarial training proposed in Madry et al. (2017). The better accuracy is marked in bold. Notice that although our Adv-BNN incurs larger accuracy drop in the original test set (where $\| \pmb { \xi } \| _ { \infty } = 0 )$ , we can choose a smaller $\alpha$ in (13) so that the regularization effect is weakened, in order to match the accuracy.
<table><tr><td>Data</td><td>Defense</td><td>0</td><td>0.015</td><td>0.035</td><td>0.055</td><td>0.07</td></tr><tr><td>CIFAR10</td><td>Adv. Training Adv-BNN</td><td>80.3 79.7</td><td>58.3 68.7</td><td>31.1 45.4</td><td>15.5 26.9</td><td>10.3 18.6</td></tr><tr><td>STL10</td><td>Adv. Training Adv-BNN</td><td>63.2 59.9</td><td>46.7 51.8</td><td>27.4 37.6</td><td>12.8 27.2</td><td>7.0 21.1</td></tr><tr><td>Data</td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td></td><td>Defense Adv. Training</td><td>0 48.7</td><td>0.004 37.6</td><td>0.01</td><td>0.016</td><td>0.02</td></tr><tr><td>ImageNet-143</td><td>Adv-BNN</td><td>47.3</td><td>43.8</td><td>23.0 39.3</td><td>12.4 30.2</td><td>7.5 24.6</td></tr></table>
# 4.2 BLACK BOX TRANSFER ATTACK
Is our Adv-BNN model susceptible to transfer attack? we answer this question by studying the affinity between models, because if two models are similar (e.g. in loss landscape) then we can easily attack one model using the adversarial examples crafted through the other. In this section, we measure the adversarial sample transferability between different models namely None (no defense), BNN, Adv.Train, RSE and Adv-BNN. This is done by the method called “transfer attack” (Liu et al., 2016). Initially it was proposed as a black box attack algorithm: when the attacker has no access to the target model, one can instead train a similar model from scratch (called source model), and then generate adversarial samples with source model. As we can imagine, the success rate of transfer attack is directly linked with how similar the source/target models are. In this experiment, we are interested in the following question: how easily can we transfer the adversarial examples between these five models? We study the affinity between those models, where the affinity is defined by
$$\rho _ { A \mapsto B } = { \frac { \operatorname { A c c } [ B ] - \operatorname { A c c } [ B \vert A ] } { \operatorname { A c c } [ B ] - \operatorname { A c c } [ B \vert B ] } } ,$$
where $\rho _ { A \mapsto B }$ measures the success rate using source model $A$ and target model $B$ , $\operatorname { A c c } [ B ]$ denotes the accuracy of model $B$ without attack, $\bar { \mathrm { A c c } } [ B | A ( \mathrm { o r } B ) ]$ means the accuracy under adversarial samples generated by model $A ( \ o { \mathrm { o r } } \ : B )$ . Most of the time, it is easier to find adversarial examples through the target model itself, so we have $\operatorname { A c c } [ B | A ] \ \geq \ \operatorname { A c c } [ B | B ]$ and thus $0 \leq \rho _ { A \mapsto B } \leq 1$ . However, $\rho _ { A \mapsto B } = \rho _ { B \mapsto A }$ is not necessarily true, so the affinity matrix is not likely to be symmetric. We illustrate the result in Fig. 3.
We can observe that $\left\{ \mathrm { N o n e , B N N } \right\}$ are similar models, their affinity is strong $( \rho \approx 0 . 8 5 )$ for both direction: $\rho _ { \mathtt { B N N } \mapsto \mathtt { N o n e } }$ and $\rho _ { \mathrm { N o n e r } \mathrm { B N N } }$ . Likewise, $\left\{ \mathrm { R S E , A d v - B N N , A d v \cdot T r a i n } \right\}$ constitute the other group, yet the affinity is not very strong $( \rho \approx 0 . 5 { \sim } 0 . 6 )$ , meaning these three methods are all robust to the black box attack to some extent.
# 4.3 MISCELLANEOUS EXPERIMENTS
Following experiments are not crucial in showing the success of our method, however, we still include them to help clarifying some doubts of careful readers.
 Figure 3: Black box, transfer attack experiment results. We select all combinations of source and target models trained from 5 defense methods and calculate the affinity according to (17).
The first question is about sample efficiency, recall in prediction stage we sample weights from the approximated posterior and generate the label by
$$\hat { y } = \mathop { \arg \operatorname* { m a x } } _ { y } \frac { 1 } { m } \sum _ { k = 1 } ^ { m } p ( y | x , w _ { k } ) , \quad w _ { k } \sim q _ { \mu , s } .$$
In practice, we do not want to average over lots of forward propagation to control the variance, which will be much slower than other models during the prediction stage. Here we take ImageNet-143 dat $\iota + \mathrm { V G G }$ network as an example, to show that only $1 0 { \sim } 2 0$ forward operations are sufficient for robust and accurate prediction. Furthermore, the number seems to be independent on the adversarial distortion, as we can see in Fig. 4(left). So our algorithm is especially suitable to large scale scenario.
One might also be concerned about whether 20 steps of PGD iterations are sufficient to find adversarial examples. It has been known that for certain adversarial defense method, the effectiveness appears to be worse than claimed (Engstrom et al., 2018), if we increase the PGD-steps from 20 to 100. In Fig. $4 ( r i g h t )$ , we show that even if we increase the number of iteration to 1000, the accuracy does not change very much. This means that even the adversary invests more resources to attack our model, its marginal benefit is negligible.
 Figure 4: Left: we tried different number of forward propagation and averaged the results to make prediction (18). We see that for different scales of perturbation $\gamma \in \{ 0 , 0 . 0 1 , 0 . 0 2 \}$ , choosing number of ensemble $n = 1 0 { \sim } 2 0$ is good enough. Right: testing accuracy stabilizes quickly as #PGDsteps goes greater than 20, so there is no necessity to further increase the number of PGD steps.
# 5 CONCLUSION & DISCUSSION
To conclude, we find that although the Bayesian neural network has no defense functionality, when combined with adversarial training, its robustness against adversarial attack increases significantly. So this method can be regarded as a non-trivial combination of BNN and the adversarial training: robust classification relies on the controlled local Lipschitz value, while adversarial training does not generalize this property well enough to the test set; if we train the BNN with adversarial examples, the robustness increases by a large margin. Admittedly, our method is still far from the ideal case, and it is still an open problem on what the optimal defense solution will be.
# REFERENCES
Anish Athalye, Nicholas Carlini, and David Wagner. Obfuscated gradients give a false sense of security: Circumventing defenses to adversarial examples. arXiv preprint arXiv:1802.00420, 2018. David M Blei, Alp Kucukelbir, and Jon D McAuliffe. Variational inference: A review for statisticians. Journal of the American Statistical Association, 112(518):859–877, 2017. Charles Blundell, Julien Cornebise, Koray Kavukcuoglu, and Daan Wierstra. Weight uncertainty in neural network. In International Conference on Machine Learning, pp. 1613–1622, 2015. Nicholas Carlini and David Wagner. Adversarial examples are not easily detected: Bypassing ten detection methods. In Proceedings of the 10th ACM Workshop on Artificial Intelligence and Security, AISec ’17, pp. 3–14, New York, NY, USA, 2017a. ACM. ISBN 978-1-4503-5202- 4. doi: 10.1145/3128572.3140444. URL http://doi.acm.org/10.1145/3128572. 3140444. Nicholas Carlini and David Wagner. Towards evaluating the robustness of neural networks. In Security and Privacy (SP), 2017 IEEE Symposium on, pp. 39–57. IEEE, 2017b. Pin-Yu Chen, Huan Zhang, Yash Sharma, Jinfeng Yi, and Cho-Jui Hsieh. Zoo: Zeroth order optimization based black-box attacks to deep neural networks without training substitute models. In Proceedings of the Thirty-Second AAAI Conference on Artificial Intelligence, 2018. Adam Coates, Andrew $\mathrm { N g }$ , and Honglak Lee. An analysis of single-layer networks in unsupervised feature learning. In Proceedings of the fourteenth international conference on artificial intelligence and statistics, pp. 215–223, 2011. Jia Deng, Wei Dong, Richard Socher, Li-Jia Li, Kai Li, and Li Fei-Fei. Imagenet: A large-scale hierarchical image database. In Computer Vision and Pattern Recognition, 2009. CVPR 2009. IEEE Conference on, pp. 248–255. Ieee, 2009. Logan Engstrom, Andrew Ilyas, and Anish Athalye. Evaluating and understanding the robustness of adversarial logit pairing. arXiv preprint arXiv:1807.10272, 2018. Ivan Evtimov, Kevin Eykholt, Earlence Fernandes, Tadayoshi Kohno, Bo Li, Atul Prakash, Amir Rahmati, and Dawn Song. Robust physical-world attacks on machine learning models. arXiv preprint arXiv:1707.08945, 2017. Reuben Feinman, Ryan R Curtin, Saurabh Shintre, and Andrew B Gardner. Detecting adversarial samples from artifacts. arXiv preprint arXiv:1703.00410, 2017. Ian Goodfellow, Jonathon Shlens, and Christian Szegedy. Explaining and harnessing adversarial examples. In International Conference on Learning Representations, 2015. URL http:// arxiv.org/abs/1412.6572. Ruitong Huang, Bing Xu, Dale Schuurmans, and Csaba Szepesvari. Learning with a strong adver- ´ sary. arXiv preprint arXiv:1511.03034, 2015. Andrew Ilyas, Logan Engstrom, Anish Athalye, and Jessy Lin. Black-box adversarial attacks with limited queries and information. arXiv preprint arXiv:1804.08598, 2018.
Hemant Ishwaran, J Sunil Rao, et al. Spike and slab variable selection: frequentist and bayesian strategies. The Annals of Statistics, 33(2):730–773, 2005.
Diederik P Kingma. Variational inference & deep learning: A new synthesis. 2017.
Diederik P Kingma, Tim Salimans, and Max Welling. Variational dropout and the local reparameterization trick. In Advances in Neural Information Processing Systems, pp. 2575–2583, 2015.
Alexey Kurakin, Ian Goodfellow, and Samy Bengio. Adversarial machine learning at scale. In International Conference of Learning Representation, 2017.
Alexey Kurakin, Ian Goodfellow, Samy Bengio, Yinpeng Dong, Fangzhou Liao, Ming Liang, Tianyu Pang, Jun Zhu, Xiaolin Hu, Cihang Xie, et al. Adversarial attacks and defences competition. arXiv preprint arXiv:1804.00097, 2018.
Chunyuan Li, Changyou Chen, David E Carlson, and Lawrence Carin. Preconditioned stochastic gradient langevin dynamics for deep neural networks. In AAAI, volume 2, pp. 4, 2016.
Yingzhen Li and Yarin Gal. Dropout inference in bayesian neural networks with alpha-divergences. arXiv preprint arXiv:1703.02914, 2017.
Fangzhou Liao, Ming Liang, Yinpeng Dong, Tianyu Pang, Jun Zhu, and Xiaolin Hu. Defense against adversarial attacks using high-level representation guided denoiser. arXiv preprint arXiv:1712.02976, 2017.
Xuanqing Liu and Cho-Jui Hsieh. From adversarial training to generative adversarial networks. arXiv preprint arXiv:1807.10454, 2018.
Xuanqing Liu, Minhao Cheng, Huan Zhang, and Cho-Jui Hsieh. Towards robust neural networks via random self-ensemble. arXiv preprint arXiv:1712.00673, 2017.
Yanpei Liu, Xinyun Chen, Chang Liu, and Dawn Song. Delving into transferable adversarial examples and black-box attacks. arXiv preprint arXiv:1611.02770, 2016.
Aleksander Madry, Aleksandar Makelov, Ludwig Schmidt, Dimitris Tsipras, and Adrian Vladu. Towards deep learning models resistant to adversarial attacks. arXiv preprint arXiv:1706.06083, 2017.
Takeru Miyato and Masanori Koyama. cgans with projection discriminator. 2018.
Nicolas Papernot, Patrick McDaniel, Xi Wu, Somesh Jha, and Ananthram Swami. Distillation as a defense to adversarial perturbations against deep neural networks. In Security and Privacy (SP), 2016 IEEE Symposium on, pp. 582–597. IEEE, 2016.
Nicolas Papernot, Patrick McDaniel, Ian Goodfellow, Somesh Jha, Z Berkay Celik, and Ananthram Swami. Practical black-box attacks against machine learning. In Proceedings of the 2017 ACM on Asia Conference on Computer and Communications Security, pp. 506–519. ACM, 2017.
Ludwig Schmidt, Shibani Santurkar, Dimitris Tsipras, Kunal Talwar, and Aleksander Madry. Adversarially robust generalization requires more data. arXiv preprint arXiv:1804.11285, 2018.
Lewis Smith and Yarin Gal. Understanding measures of uncertainty for adversarial example detection. arXiv preprint arXiv:1803.08533, 2018.
Nitish Srivastava, Geoffrey Hinton, Alex Krizhevsky, Ilya Sutskever, and Ruslan Salakhutdinov. Dropout: a simple way to prevent neural networks from overfitting. The Journal of Machine Learning Research, 15(1):1929–1958, 2014.
Christian Szegedy, Wojciech Zaremba, Ilya Sutskever, Joan Bruna, Dumitru Erhan, Ian Goodfellow, and Rob Fergus. Intriguing properties of neural networks. arXiv preprint arXiv:1312.6199, 2013.
Max Welling and Yee W Teh. Bayesian learning via stochastic gradient langevin dynamics. In Proceedings of the 28th International Conference on Machine Learning (ICML-11), pp. 681–688, 2011.
Cihang Xie, Jianyu Wang, Zhishuai Zhang, Zhou Ren, and Alan Yuille. Mitigating adversarial effects through randomization. arXiv preprint arXiv:1711.01991, 2017.
Kelvin Xu, Jimmy Ba, Ryan Kiros, Kyunghyun Cho, Aaron Courville, Ruslan Salakhudinov, Rich Zemel, and Yoshua Bengio. Show, attend and tell: Neural image caption generation with visual attention. In International Conference on Machine Learning, pp. 2048–2057, 2015.
Nanyang Ye and Zhanxing Zhu. Bayesian adversarial learning. In S. Bengio, H. Wallach, H. Larochelle, K. Grauman, N. Cesa-Bianchi, and R. Garnett (eds.), Advances in Neural Information Processing Systems 31, pp. 6892–6901. Curran Associates, Inc., 2018. URL http: //papers.nips.cc/paper/7921-bayesian-adversarial-learning.pdf.
Valentina Zantedeschi, Maria-Irina Nicolae, and Ambrish Rawat. Efficient defenses against adversarial attacks. In Proceedings of the 10th ACM Workshop on Artificial Intelligence and Security, pp. 39–49. ACM, 2017.
# A HOW TO ATTACK THE RANDOMIZED NETWORK
We largely follow the guidelines of attacking networks with “obfuscated gradients” in Athalye et al. (2018). Specifically, we derive the algorithm for white box attack to random networks denoted as $f ( w ; \epsilon )$ , where $\pmb { w }$ is the (fixed) network parameters and $\epsilon$ is the random vector. Many random neural networks can be reparameterized to this form, where each forward propagation returns different results. In particular, this framework includes our Adv-BNN model by setting ${ \pmb w } = ( { \pmb \mu } , { \pmb s } )$ . Recall the prediction is made through “majority voting”:
$$\begin{array} { r } { \hat { y } = \underset { y } { \arg \operatorname* { m i n } } \ \underset { \epsilon } { \mathbb { E } } \left( f ( \boldsymbol { x } ; \boldsymbol { w } , \epsilon ) , y \right) . } \end{array}$$
So the optimal white-box attack should maximize the loss (19) on the ground truth label $y ^ { * }$ . That is,
$$\pmb { \xi } ^ { \ast } = \underset { \pmb { \xi } } { \arg \operatorname* { m a x } } \underset { \pmb { \epsilon } } { \mathbb { E } } \left( f ( \pmb { x } + \pmb { \xi } ; \pmb { w } , \boldsymbol { \epsilon } ) , y ^ { * } \right) ,$$
and then ${ \pmb x } ^ { \mathrm { a d v } } \triangleq { \pmb x } + { \pmb \xi } ^ { * }$ . To do that we apply SGD optimizer and sampling $\epsilon$ at each iteration,
$$\pmb { \xi } _ { t + 1 } \gets \pmb { \xi } _ { t } + \eta _ { t } \frac { \partial } { \partial \pmb { \xi } } \ell \big ( f ( \pmb { x } + \pmb { \xi } ; \pmb { w } , \pmb { \epsilon } ) , y ^ { * } \big ) \Big | _ { \pmb { \xi } = \pmb { \xi } _ { t } } ,$$
one can see the iteration (21) approximately solves (20).
# B FORWARD & BACKWARD IN RANDLAYER
It is very easy to implement the forward & backward propagation in BNN. Here we introduce the RandLayer that can seamlessly integrate into major deep learning frameworks. We take PyTorch as an example, the code snippet is shown in Alg. 1.
Algorithm 1: Code snippet for implementing RandLayer
<table><tr><td>15 if :ctx.needs_input_grad[0]:</td></tr><tr><td>grad_mu = grad_output + mu/(sigma_O*sigma_0*N)</td></tr><tr><td>16 if ctx.needs_input_grad[1]:</td></tr><tr><td>17 grad_sigma = grad_output*tmp*eps - 1 / N + tmp*tmp/(sigma_0*sigma_0*N)</td></tr><tr><td>18</td></tr><tr><td>19 return grad_mu,grad_sigma,grad_eps,grad_sigma_0,grad_N 20 rand_layer = RandLayerFunc.apply</td></tr></table>
Based on RandLayer, we can further implement variational Linear layer below in Alg. 2. The other layers such as Conv/BatchNorm are very similar.
Algorithm 2: Code snippet for implementing variational Linear layer
<table><tr><td colspan="2">class Linear(Module): __init_(self,d_in,d_out):</td></tr><tr><td colspan="2">def self.d_in = d_in</td></tr><tr><td colspan="2"></td></tr><tr><td colspan="2"></td></tr><tr><td colspan="2">self.d_in = d_in</td></tr><tr><td colspan="2">self.d_out = d_out</td></tr><tr><td colspan="2">self.init_s = init_s</td></tr><tr><td colspan="2">self.mu_weight = Parameter(torch.Tensor(d_out,d_in))</td></tr><tr><td colspan="2">self.sigma_weight = Parameter(torch.Tensor(d_out,d_in))</td></tr><tr><td colspan="2">self.register_buffer('eps_weight',torch.Tensor(d_out,d_in))</td></tr><tr><td colspan="2">def forward(self,x):</td></tr><tr><td colspan="2">weight = rand_layer(self.mu_weight, self.sigma_weight, self.eps_weight)</td></tr><tr><td colspan="2">bias = None</td></tr></table>
# C HYPER-PARAMETERS
We list the key hyper-parameters in Tab. 2, note that we did not tune the hyper-parameters very hard, therefore it is entirely possible to find better ones.
Table 2: Hyper-parameters setting in our experiments.
<table><tr><td>Name</td><td>Value</td><td>Notes</td></tr><tr><td>k</td><td>20</td><td>#PGD iterations in attack</td></tr><tr><td>k'</td><td>10</td><td>#PGD iterations in adversarial training</td></tr><tr><td>2</td><td>CIFAR10/STL10: 8/256, ImageNet: 0.01</td><td>loo-norm in adversarial training</td></tr><tr><td>00</td><td>CIFAR10: 0.05,others: 0.15</td><td>Std. of the prior distribution (not sensitive)</td></tr><tr><td>α</td><td>CIFAR10: 1.0,others: 1.0/50</td><td>See (13)</td></tr><tr><td>n</td><td>10~20</td><td>#Forward passes when doing ensemble inference</td></tr></table>123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160# Regularized siamese neural network for unsupervised outlier detection on brain multiparametric magnetic resonance imaging: application to epilepsy lesion screening
Zara Alaverdyan Univ Lyon, INSA-Lyon, Université Claude Bernard Lyon 1, UJM-Saint Etienne, CNRS, Inserm, CREATIS UMR 5220, U1206, F-69621, Lyon, France zaruhi.alaverdyan@creatis.insa-lyon.fr
Julien Jung, Romain Bouet Lyon Neuroscience Research Center, CRNL, INSERM U1028, CNRS UMR5292, University Lyon 1, Lyon, France {julien.jung, romain.bouet}@inserm.fr
Carole Lartizien Univ Lyon, INSA-Lyon, Université Claude Bernard Lyon 1, UJM-Saint Etienne, CNRS, Inserm, CREATIS UMR 5220, U1206, F-69621, Lyon, France carole.lartizien@creatis.insa-lyon.fr
# Abstract
Computer aided diagnosis (CAD) systems are designed to assist clinicians in various tasks, including highlighting abnormal regions in medical images. Common methods exploit supervised learning using annotated data sets and perform classification at voxel-level. However, many pathologies are characterized by subtle lesions that may be located anywhere in the organ of interest, have various shapes, sizes and textures. Acquiring a data set adequately representing the heterogeneity of such pathologies is therefore a major issue. Moreover, when a lesion is not visually detected on a scan, outlining it accurately is not feasible. Performing supervised learning on such labeled data would not be reliable. In this study, we consider the problem of detecting subtle epilepsy lesions in multiparametric (T1w, FLAIR) MRI exams considered as normal (MRI-negative). We cast this problem as an outlier detection problem and build on a previously proposed approach that consists in learning a oc-SVM model for each voxel in the brain volume using a small number of clinically-guided features [1]. Our goal in this study is to make a step forward by replacing the handcrafted features with automatically learnt representations using neural networks. We propose a novel version of siamese networks trained on patches extracted from healthy patients’ scans only. This network, composed of stacked convolutional autoencoders as subnetworks, is regularized by the reconstruction error of the patches. It is designed to map patches centered at the same spatial localization to ’close’ representations with respect to the chosen metric (i.e. cosine) in a latent space. Finally, the middle layer representations of the subnetworks are fed into oc-SVM models at voxel-level. The model is trained on 75 healthy subjects and validated on 21 patients with confirmed epilepsy lesions (with 18 MR negative patients) and shows a promising performance.
# 1 Introduction
Computer aided diagnosis (CAD) systems have been introduced as to assist clinicians in various tasks such as organ or lesion segmentation, detection of abnormal regions in a medical image, etc. Recent CAD systems for brain pathologies exploit various modalities of neuroimaging data, such as magnetic resonance imaging (MRI) and positron emission tomography (PET). The vast majority of the existing CAD systems are built upon methods developed in supervised settings, using either manually designed features or currently ubiquitous deep learning architectures as in [2, 3, 4, 5]. Such systems benefit from the available data sets (usually) annotated at voxel-level, and output maps where each voxel is characterized either by a class label, a probability or, less commonly, a score discriminating healthy versus pathological voxels. Supervised learning, however, cannot be applied when the number of pathological cases in the training set is not sufficient to account for the complexity of the task. This is often the case when it comes to detecting some brain pathologies such as small vessel diseases (SVD), multiple sclerosis (MS) or epilepsy, when the lesions are subtle and vary largely in terms of shapes and textures. It is not trivial to obtain a well-annotated data set to represent such a variability. To bypass the problem of insufficient labeled data, some authors recently proposed to formulate such lesion detection tasks in semi-supervised settings, by accounting for both labeled and unlabeled data in a deep architecture for MS lesion segmentation [6] or by exploiting weak labels (the number of lesions in a scan) to detect enlarged perivascular spaces in the basal ganglia [7].
In this study we propose to tackle the problem of epilepsy lesion detection in patients with MRI negative exams, meaning that the lesions were not visually identified by clinicians on the MR scans. Similarly to the above mentioned lesion detection tasks, most of the current epilepsy detection methods perform supervised learning by leveraging annotated lesions delineated on MRI positive patients (the lesions are visually detected on the scans) [8] or by careful a posteriori re-reading of postsurgical scans of MRI negative patients who had undergone surgery and were seizure-free afterwards [1, 9, 10, 11]. While obtaining accurately labeled data for MRI positive patients is feasible, the real challenge is to extract accurate delineations in MRI negative patients. [11] showed that exploiting ’too generously’ annotated lesions on MRI negative scans as labels for supervised learning methods leads to poor detection rate due to the presence of normal tissue in the areas labeled as pathological. Therefore, some recent methods cast epilepsy lesion detection task as an outlier detection problem [1, 11, 12]. Such an approach solely needs a training set of non-pathological images, hence no labeled data is required. [1] used a small number of features modeling the gray-white matter junction (similarly to [13, 14]) while [12] and [11] derived features from surface based morphometry (SBM). All the latter methods targeted a specific type of epilepsy caused by focal cortical dysplasia (FCD); hence the features were chosen as to provide the most common FCD-characteristics to the models.
In this work we build on the method proposed in [1] that learns a one-class SVM (oc-SVM) model for each voxel individually. Our goal is to make a step forward by replacing the handcrafted features with automatically learnt representations using neural networks. Deep learning architectures allow to learn representations that are not limited to the clinically-guided features which have to be designed for each pathology individually; the representations are learnt based on the available data. Moreover, certain architectures provide a convenient framework to learn joint representations of multiparametric/multimodality imaging. Our methodological contribution consists in proposing a variant of siamese neural network designed to learn representations for outlier detection on brain images. The network is composed of stacked convolutional autoencoders and is trained on the patches of healthy brain volumes only, by utilizing a novel loss function adapted to the given context. Such a network allows learning meaningful representations which, coupled with voxel-level oc-SVM classifiers, discriminate various brain abnormalities and can be applied to detect subtle pathologies in general. From the medical application perspective, we attempt to make a step forward in automatically learning representations for epilepsy lesion detection, unlike in the previous studies ([1, 11]). Our approach is not targeted at one specific epilepsy type and thus is more generic and also detects lesions with rather unknown signatures. Moreover, to our knowledge, this is the first study to propose a neural network architecture trained on multiparametric MRI data that can be applied to detect epilepsy lesions.
 Figure 1: Siamese neural network composed of stacked convolutional autoencoders as sub-networks. The input consists of a pair of patches of 2 different subjects centered at the same spatial localization in the brain. The middle-layer representation is denoted by $g ( x )$ .
# 2 Method
In this study we propose to use a siamese network to learn patch-level representations in the context of outlier detection. Such an approach is applicable in cases where pathological samples are not available or their number is insufficient to adequately represent the nature of the pathology and hence, supervised learning is not possible.
The motivation behind the architecture choice is the following. Our objective is to map the original patches to a space where the patches belonging to different subjects but centered at the same spatial localization are "close" with respect to a chosen metric. We could consider the patches centered at the same voxel as representatives of the same class (hence, "similar" patches). In this case the number of classes would be equal to the number of voxels in a brain volume (around 4 millions) but the number of samples per class would be equal to the number of subjects. The siamese networks have proved to be efficient in similar scenarios [15, 16] where the number of classes is largely greater than the number of samples per class.
# 2.1 Regularized siamese neural network for representation learning
# 2.1.1 Architecture
The proposed architecture is illustrated on figure 1. Our regularized siamese neural network (rSNN) consists of two identical (same architecture, shared parameters) subnetworks - stacked convolutional autoencoders (sCAE) with $K$ hidden layers and a cost module. The input $\mathbf { x }$ of a SCAE is first encoded to a middle-layer representation by a series of convolutional and max-pooling operations and later decoded with a series of deconvolutions and up-poolings to produce a reconstruction $\hat { \bf x }$ of the input. A convolutional layer $l$ is composed of $N _ { l }$ kernels and biases and can be expressed as
$$\mathbf { H } _ { l } ^ { m } = f ( \mathbf { W } _ { l - 1 } ^ { m } * \mathbf { H } _ { l - 1 } + b _ { l - 1 } ^ { m } )$$
where $\mathbf { H } _ { l } ^ { m }$ is the $m$ -th feature map of the convolutional layer $l$ , $\mathbf { W } _ { l } ^ { m }$ is the kernel matrix associated with $\mathbf { H } _ { l } ^ { m }$ and $b _ { l } ^ { m }$ is its bias, $f$ is an activation function (usually non-linear). $^ *$ denotes the convolution operation. The parameters are iteratively updated to optimize a loss function that measures the deviation between the output $\hat { \bf x }$ and the input $\mathbf { x }$ .
The siamese network receives a pair of patches $\left( \mathbf { x _ { 1 } } , \mathbf { x _ { 2 } } \right)$ at input, then each patch is propagated through the corresponding subnetwork yielding representations $g ( \mathbf { x _ { t } } ) , t \ = \ ( 1 , 2 )$ in the middle layer which are then passed to the loss function $L$ below. It is important to mention that, unlike in the classical siamese frameworks where the network also receives a binary label that stands for the similarity/dissimilarity of the pair, in our application all the considered pairs are ’similar’ and therefore the label is not present in the loss function. The loss function, however, can be easily modified to meet the general setting.
# 2.1.2 Loss function
Our loss function is designed to maximize the cosine similarity between $g ( \mathbf { x _ { 1 } } )$ and $g ( \mathbf { x _ { 2 } } )$ . In the absence of dissimilar pairs (the notion of dissimilar patches is not defined in our context), it is necessary to add a regularizing term. To this end, we propose to use the mean squared error between the input patches and their reconstructions output by the subnetworks. Without a proper regularization term, the loss function could be driven to 0 by mapping all the patches to a constant value. The proposed loss function for a single pair hence is:
$$L ( \mathbf { x _ { 1 } } , \mathbf { x _ { 2 } } ; \Theta ) = \sum _ { t = 1 } ^ { 2 } | | \mathbf { x _ { t } } - { \hat { \mathbf { x _ { t } } } } | | _ { 2 } ^ { 2 } - \alpha c o s ( g ( \mathbf { x _ { 1 } } ) , g ( \mathbf { x _ { 2 } } ) )$$
where $\hat { \mathbf { x } } _ { \mathbf { t } }$ is the reconstructed output of subnetwork $t$ of the patch $\mathbf { x _ { t } }$ while $g ( \mathbf { x _ { t } } )$ is its (vectorized) representation in the middle layer and $\alpha$ is a coefficient that controls the tradeoff between the two terms. $\Theta$ represents the parameter set.
# 2.2 Voxel-level outlier detection with oc-SVM classifiers
A oc-SVM classifier [17] is an outlier detection method that seeks to find the optimal hyperplane that separates the given points from the origin in a dot product space defined by some kernel function $\phi$ . The corresponding optimization problem is the following:
$$\begin{array} { l } { \displaystyle \underset { \mathbf { w } , \rho , \xi _ { i } } { \operatorname* { m i n } } \quad \displaystyle \frac { 1 } { 2 } | | \mathbf { w } | | ^ { 2 } - \rho + \frac { 1 } { \nu \mathrm { n } } \sum _ { \mathrm { i } = 1 } ^ { \mathrm { n } } \xi _ { \mathrm { i } } } \\ { \displaystyle \mathrm { s u b j e c t ~ t o } \quad \mathbf { w } \cdot \phi ( \mathbf { x _ { i } } ) \geq \rho - \xi _ { \mathrm { i } } , \xi _ { \mathrm { i } } \geq 0 , \mathrm { i } \in [ 1 , \mathrm { n } ] } \end{array}$$
where $n$ is the number of training examples, $\mathbf { x _ { i } }$ is the $i$ -th example in the training dataset $X$ , $\xi _ { i }$ -s are slack variables relaxing the inequality constraints as to account for the non-separable classes, w and $\rho$ define the separating hyperplane, $\nu$ is a parameter that sets a boundary to the fraction of outliers allowed. The decision function, then, for an example $\mathbf { x }$ is ${ \bf w } \cdot \phi ( { \bf x } ) - \dot { \rho }$ . This decision function contributes to the signed score output by a oc-SVM model (in a typical scenario examples with negatives scores would be considered outliers).
To validate the usefulness of the features learnt by the proposed method, we use the representations in the middle layer of the subnetworks $( g ( \mathbf { x } ) )$ to train oc-SVM classifiers at voxel level. Each voxel is associated with a classifier, hence the number of classifiers is equal to the number of voxels in a volume (around 4 million voxels). For a given voxel $v _ { i }$ , the associated oc-SVM classifier $C _ { i }$ is trained on the matrix $M _ { i } = [ \bf { x _ { i 1 } } , . . . , \bf { x _ { i n } } ]$ where $\mathbf { x _ { i j } }$ is the feature vector corresponding to the patch centered at $v _ { i }$ of subject $j$ and $n$ is the number of subjects.
For a new patient, each voxel $v _ { i }$ is matched against the corresponding classifier $C _ { i }$ and is assigned the signed score output by the classifier. This yields a distance map $D _ { p }$ for the given patient.
# 2.3 Post-processing
For a given patient, the output of the previous step - the distance map $D _ { p }$ - is then post-processed to obtain the final detections. A 3-step post-processing is proposed as follows.
The first step consists in normalizing the distance maps with respect to the intra-subject spatial variability. For that purpose, the distance maps of the control subjects are computed by performing a $k$ -fold evaluation of the controls in the training set (i.e. for each fold of normal subjects, the distance maps are obtained with oc-SVMs trained on the remaining subjects). These maps are used to estimate the standard deviation of the normal subjects’ distance distribution at voxel-level. For a given patient $p$ , a new map $\acute { D } _ { p }$ is computed by a voxel-wise division of the output distance map $D _ { p }$ over the estimated standard deviations. The final distance map $F _ { p }$ is then derived by averaging $D _ { p }$ and $\acute { D } _ { p }$ i.e. $\begin{array} { r } { F _ { p } = \frac { 1 } { 2 } ( \frac { D _ { p } } { m a x ( a b s ( D _ { p } ) ) } + \frac { \dot { D } _ { p } } { m a x ( a b s ( \dot { D } _ { p } ) } ) ) } \end{array}$ . The reason behind the additional term is that some zones in the brain have more intra-subject variability than others and therefore are more likely to be considered as anomalies. By weighing them by the standard deviation, the score maps account for this effect. The second step consists in thresholding the $F _ { p }$ map to produce a cluster map. We keep the most negative scores up to the score corresponding to a pre-chosen $p$ -value in the patient’s distance score distribution and apply a 26-connectivity rule to identify connected components which we refer to as clusters. The voxel clusters smaller than a fixed size (here, 82 voxels corresponding to the expected cluster size calculated with the SPM analysis of the T1 MRI data) are discarded. This allows quick elimination of small and very negative clusters which usually represent isolated intensity peaks (the size of the majority of the detected clusters varies between 500 and 1500, this threshold therefore does not affect the performance in any significant way). The clusters are what we refer to as detections by the proposed method. By varying the $p$ -value the number of clusters can be controlled according to a clinician’s needs.
The third step consists in ranking the detected clusters to help the analysis of the detections. For each patient individually, a $p$ -value is found that produces at most 15 clusters. Among those, we use the following ranking criterion to assign a rank to a cluster $c _ { i }$
$$r a n k ( \mathbf { c _ { i } } ) \sim \lambda * \frac { s c o r e ( \mathbf { c _ { i } } ) } { m i n _ { j } s c o r e ( \mathbf { c _ { j } } ) } + ( 1 - \lambda ) * \frac { s i z e ( \mathbf { c _ { i } } ) } { m a x _ { j } s i z e ( \mathbf { c _ { j } } ) }$$
where $s c o r e ( c _ { i } )$ is the average of the voxel scores in the cluster and $s i z e ( c _ { i } )$ is the number of voxels in the cluster. Such a ranking favors large clusters with the most negative average score. Using this ranking, we keep the top $n$ detections and discard the rest. When there is a significant overlap between a detected cluster and the ground truth for a given patient, we consider the cluster a true positive and false positive otherwise.
# 3 Experiments and results
# 3.1 Dataset description and pre-processing
The study was approved by our institutional review board with approval numbers 2012-A00516-37 and 2014-019 B and a written consent was obtained for all participants.
Our database consists of multiparametric (T1-weighted and FLAIR) MR images of 75 healthy subjects and 21 patients. They all had a 3D anatomical T1-weighted brain MRI (TR/TE 2400/3.55; 160 sagittal slices of $1 9 2 \mathrm { ~ x ~ } 1 9 2 \ 1 . 2 \mathrm { m m }$ cubic voxels) and FLAIR (176 sagittal slices of $1 9 6 \times 2 5 6 ~ 1 . 2 \mathrm { m m }$ cubic voxels) on a $1 . 5 \mathrm { T }$ Sonata scanner (Siemens Healthcare, Erlangen, Germany). All the volumes were normalized to the standard brain template of the Montreal Neurological Institute (MNI) [18] using a voxel size of $1 \mathrm { ~ x ~ } 1 \mathrm { ~ x ~ } 1 \mathrm { ~ m m }$ . This processing was performed using the unified segmentation algorithm [19] implemented in SPM12 also correcting for magnetic field inhomogeneities. This spatial normalisation assures a voxel-level correspondence between the subjects. We removed top $1 \%$ intensities and scaled the images between 0 and 1 at image level before feeding the patches to the rSNN.
The method has been validated on 21 patients admitted to our clinical center with confirmed medically intractable epileptogenic lesions: 2 of them were visually detected on the patient FLAIR images (but not on T1w images) and only 1 lesion was identified on both T1w and FLAIR scans. The remaining 18 patients are confirmed MR negative patients. The MR negative patients had undertaken surgeries and have been seizure-free since. The ground truth annotations used in the performance evaluation were obtained by outlining the visible zones of the MR positive patients and by combining the information of post-surgical MR images and the resected zones for MR negative patients.
# 3.2 Feature extraction with SNN
The proposed rSNN consists of two identical subnetworks - stacked convolutional autoencoders with the architecture as in fig. 2. In the mono-modal scenario, they both receive at input $1 5 \mathrm { x } 1 5$ patches extracted from all the available healthy subjects’ volumes of the corresponding modality (T1w or FLAIR) with a stride of 8. In the multi-modal scenario, the input consists of the patches of each modality joint as channels. For each of the patches, a random ’similar pair’ is found among the other subjects yielding in total around 3.5 million pairs. The $\alpha$ parameter in the loss 1 is set to 0 during the first 10 epochs, then grows linearly for 15 epochs until it reaches 0.5 and then plateaus for 5 more epochs. We used ReLU activation function in all the layers except the last one where the sigmoid is used (the input patches are scaled between 0 and 1). The Adam optimizer was used with the learning rate set to 0.001 (the rest of the parameters remained at their default value as implemented in Theano). The architecture itself is not arbitrary. The size of the patches at input was chosen after a number of tested configurations and is justified by the subtle nature of epilepsy lesions. Indeed, larger patch sizes were not successful at detecting subtle lesions. Since the middle-layer representations are used to build oc-SVM models per voxel where the number of samples per model is equal to the number of subjects, having large representation vectors would not be beneficial. As shown on figure 2 the middle layer has 16 feature maps of $2 \mathbf { x } 2$ which, when flattened, yields a 64-dimensional vector.
 Figure 2: rSNN subnetwork architecture for epilepsy lesion detection. $C$ and $D C$ denote convolutional and deconvolutional layers respectively, $M P$ and $U P$ denote Maxpooling and Uppooling. The C and DC layers are denoted with the number of features maps (e.g. 16 for the first C layer) and the kernel size in parenthesis (e.g. 3x3 for the first C layer). With this configuration, the middle-layer is composed of 16 feature maps of size $2 \mathbf { x } 2$ which yields a 64-dimensional representation vector $g ( \mathbf { x } )$ when flattened.
# 3.3 oc-SVM classifier design
We used oc-SVM classifiers with RBF kernel which gives us two parameters to tune - $\nu$ (upper bound on the fraction of permitted outliers) and $\gamma$ (the kernel parameter). Varying the parameter $\nu$ did not significantly impact the results; the fraction of the outliers is controlled in the post-processing step by the threshold value applied on the distance map. It was set to 0.03 for all the voxels. The $\gamma$ parameter was derived for each voxel $v _ { i }$ individually by estimating the median of the standardized euclidean pairwise distances of the corresponding matrix $M _ { i }$ (see section 2.2) as in [20].
# 3.4 Results
Below we evaluate the performance of the system on 21 patients with confirmed epilepsy lesions. We first demonstrate the advantage of the multi-modal approach versus mono-modal approaches. Fig. 3 shows the true detection rates among the top $n$ clusters for 3 scenarios - voxel-level outlier detection with T1w-only, FLAIR-only and T1w/FLAIR-trained features, for 3 values of $\lambda$ of expression 3, the trade-off coefficient between the cluster size and average score. It clearly demonstrates that features learnt on the combination of multimodality data outperform the individual modalities. Moreover, the figure shows that ranking the clusters by both their average score and size has an advantage over the individual criteria. With this ranking approach, the multimodal model achieves $62 \%$ of true detections among the top 10 clusters. [11] reports a detection rate of $70 \%$ when individual SBM-based features are used; the results vary between 60 and $70 \%$ when considering combinations of some of these SBM features. 2 of the 3 MR positive lesions were detected among the top 2 clusters. This result is expected considering that visually detected lesions have visible markers that allow to distinguish them easily unlike the MR negative patients whose lesions may be detected along with other outliers of similar ’suspiciousness’.
We have also compared the global results of our CAD system to the results obtained with a general linear model (GLM) learned on feature maps derived from T1w images using three settings - 1. junction contrast, 2.extension contrast and 3. the conjunction of both contrasts - for a $p$ -value of 0.001 as done in [1]. These features model the junction between gray and white matters as described in [13, 14]. For a fair comparison, the same clustering and ranking procedures (as described in section 2.3) were applied and only the top 10 clusters were considered. The results are summarized in table 1. While extension contrast detects one additional lesion compared with our mono-modal T1-based approach, the combination of junction and extension contrasts does not achieve our best performance with T1w/FLAIR model. We should also note that without applying the ranking method the original SPM implementation produces much more false positive detections without any significant change in the true positive rate.
 Figure 3: The performance of the CAD system. $\mathbf { X }$ -axis: Top $n$ clusters, y-axis: Detection rate among the top $n$ clusters. From left to right: $\lambda = 1$ (score-only), $\lambda = 0 . 5$ (score and size average) and $\lambda = 0$ (size-only) ranking criteria.
Table 1: Our system versus GLM model on T1w MRI as implemented in SPM software. First column: the true positive rate; the number of detected patients / total number of patients in parenthesis. Second column: the true positive rate calculated on MRI negative patients only. Third column: the average number of false positive detections per patient.
<table><tr><td></td><td>True positive rate</td><td>True positive rate on MR negative patients</td><td>Average # of false positives</td></tr><tr><td>rSNN +oc-SVMon T1 (ranked, top 10)</td><td>0.38 (8/21)</td><td>0.38 (7/18)</td><td>9</td></tr><tr><td>rSNN + oc-SVM on FLAIR (ranked,top 10)</td><td>0.52 (11/21)</td><td>0.5 (9/18)</td><td>9</td></tr><tr><td>rSNN + oc-SVMon T1/FLAIR (ranked,top 10)</td><td>0.62 (13/21)</td><td>0.61 (11/18)</td><td>9</td></tr><tr><td>SPMJunction on T1 (ranked,top 10)</td><td>0.28 (6/21)</td><td>0.27 (5/18)</td><td>9</td></tr><tr><td>SPM Extension on T1 (ranked,top 10)</td><td>0.43 (9/21)</td><td>0.44 (8/18)</td><td>9</td></tr><tr><td>SPM Junction-Extension on T1 (ranked, top 10)</td><td>0.24 (5/21)</td><td>0.22 (4/18)</td><td>9</td></tr></table>
 Figure 4: CAD system output for patients $A ^ { + }$ , $B ^ { - }$ and $C ^ { - }$ respectively ( $^ +$ stands for MR positive patients, − for MR negative patients). Top row: Transverse slices centered at the lesion locations (highlighted in red circles). Bottom row: Maximum intensity projections (MIP) of the cluster maps overlaid on the MRI transverse slices. The maps show the top 1, top 6 and top 3 clusters, respectively.
# 4 Discussion
This study presents a novel method to learn representations that can be used in the task of anomaly detection on brain images. We have formulated a regularized siamese network architecture that learns normal brain representations using a set of non-pathological MR volumes. The features learnt with the network do not target specific pathology but rather allow to capture normal variability from a cohort of healthy subjects. The framework allows integrating multiple modalities and we have shown the performance gain obtained by coupling T1w and FLAIR imaging for the task of detecting subtle epilepsy lesions in MRI negative patients. To our knowledge, this is the first attempt to use deep learning for epilepsy lesion detection.
Most current studies target a specific type of the pathology, referred to as focal cortical dysplasia (FCD), mainly resulting from a malformation of cortical development and leading to drug-resistant epilepsy lesions. Some of these studies use manually designed features characterizing cortical malformations based on surface based morphometry (SBM) [9, 11, 12]. Others associate these morphometric features to the intensity anomalies in T1w MRI mainly caused by heterotopy lesions [1, 8]. Our method seeks to find more complex features in an unsupervised manner in order to identify lesions with unknown signatures. Naturally, such an approach, when applied to a specific pathology, is likely to produce more false positive detections. Although a fair comparison with published results is difficult because of the differences in the patient groups, results reported in table 1 ( $6 2 \%$ sensitivity for 9 false positives per scan) are of the same order as those reported in recent studies for the difficult task of automated detection in MRI-negative patients. Indeed, the system proposed in [11] based on SBM features coupled with semi-supervised hierarchical conditional random fields achieves $70 \%$ sensitivity on a sample of $2 0 \mathrm { T } 1$ weighted MRI negative patients among the top 10 detections per scan. In [1], a CAD system based on morphometric and intensity features coupled with a oc-SVM classifier allows achieving the same $70 \%$ sensitivity with an average of 4 false positives per scan when evaluated on a small cohort of 8 T1w MRI negative patients.
There are different options to improve the diagnostic performance of the proposed system. First, some pathology-specific information could be introduced in the post-processing step, by discarding some of the detected clusters based on shape and/or localization criteria. In the majority of the cases, as shown in figure 4, most of the detected false positive clusters are indeed irregularities that can be easily removed by a trained radiologist. An alternative option is to move towards a semi-supervised setting by enhancing the neural network with a few ’pathological’ patches that could be extracted from MRI positive cases or after a careful analysis of retrospective MRI negative patients, following, for instance, some ideas recently proposed in [21]. More improvement could be achieved by accounting for the complementary information provided by different imaging modalities. T1 and FLAIR modalities, introduced as channels to our network, allowed a significant diagnostic performance gain as shown on figure 3. We expect a further performance gain by exploiting PET imaging as recently demonstrated in [22].
Finally, the proposed method is quite straightforward to implement and to apply in daily practice as the output of the system can be obtained under a couple of minutes.
# 5 Acknowledgements
This work was performed within the framework of the LABEX PRIMES (ANR-11-LABX-0063) of Université de Lyon, within the program "Investissements d’Avenir" (ANR-11-IDEX-0007) operated by the French National Research Agency (ANR). The authors sincerely thank Valentin Hoang for his valuable contribution to the SPM analysis.
# References
[1] M. El Azami, A. Hammers, J. Jung, N. Costes, R. Bouet, and C. Lartizien, “Detection of lesions underlying intractable epilepsy on t1-weighted mri as an outlier detection problem,” PloS one, vol. 11, no. 9, p. e0161498, 2016. [2] P. Moeskops, M. A. Viergever, A. M. Mendrik, L. S. de Vries, M. J. Benders, and I. Išgum, “Automatic segmentation of mr brain images with a convolutional neural network,” IEEE transactions on medical imaging, vol. 35, no. 5, pp. 1252–1261, 2016. [3] K. Kamnitsas, C. Ledig, V. F. Newcombe, J. P. Simpson, A. D. Kane, D. K. Menon, D. Rueckert, and B. Glocker, “Efficient multi-scale 3d cnn with fully connected crf for accurate brain lesion segmentation,” Medical Image Analysis, vol. 36, pp. 61 – 78, 2017. [4] M. Ghafoorian, N. Karssemeijer, T. Heskes, M. Bergkamp, J. Wissink, J. Obels, K. Keizer, F.-E. de Leeuw, B. van Ginneken, E. Marchiori, and B. Platel, “Deep multi-scale location-aware 3d convolutional neural networks for automated detection of lacunes of presumed vascular origin,” Neuroimage, vol. 14, pp. 391– 399, 2017. [5] Q. Dou, H. Chen, L. Yu, L. Zhao, J. Qin, D. Wang, V. Mok, L. Shi, and P.-A. Heng, “Automatic detection of cerebral microbleeds from mr images via 3d convolutional neural networks.,” IEEE transactions on medical imaging, vol. 35, no. 5, pp. 1182–1195, 2016. [6] C. Baur, S. Albarqouni, and N. Navab, “Semi-supervised deep learning for fully convolutional networks,” in Medical Image Computing and Computer-Assisted Intervention (MICCAI 2017) (M. Descoteaux, L. Maier-Hein, A. Franz, P. Jannin, D. L. Collins, and S. Duchesne, eds.), (Cham), pp. 311–319, Springer International Publishing, 2017. [7] F. Dubost, G. Bortsova, H. Adams, A. Ikram, W. J. Niessen, M. Vernooij, and M. De Bruijne, “Gp-unet: Lesion detection from weak labels with a 3d regression network,” in Medical Image Computing and Computer Assisted Intervention (MICCAI 2017) (M. Descoteaux, L. Maier-Hein, A. Franz, P. Jannin, D. L. Collins, and S. Duchesne, eds.), (Cham), pp. 214–221, Springer International Publishing, 2017. [8] R. S. Gill, S.-J. Hong, F. Fadaie, B. Caldairou, B. Bernhardt, N. Bernasconi, and A. Bernasconi, “Automated detection of epileptogenic cortical malformations using multimodal mri,” in Deep Learning in Medical Image Analysis and Multimodal Learning for Clinical Decision Support, pp. 349–356, Springer, 2017. [9] S.-J. Hong, H. Kim, D. Schrader, N. Bernasconi, B. C. Bernhardt, and A. Bernasconi, “Automated detection of cortical dysplasia type ii in mri-negative epilepsy,” Neurology, vol. 83, no. 1, pp. 48–55, 2014. [10] B. Ahmed, C. E. Brodley, K. E. Blackmon, R. Kuzniecky, G. Barash, C. Carlson, B. T. Quinn, W. K. Doyle, J. French, O. Devinsky, and T. Thesen, “Cortical feature analysis and machine learning improves detection of "mri-negative" focal cortical dysplasia.,” Epilepsy and behavior, vol. 48, pp. 21–8, 2015. [11] B. Ahmed, T. Thesen, K. E. Blackmon, R. Kuzniekcy, O. Devinsky, and C. E. Brodley, “Decrypting "cryptogenic" epilepsy: Semi-supervised hierarchical conditional random fields for detecting cortical lesions in mri-negative patients,” Journal of Machine Learning Research, vol. 17, no. 112, pp. 1–30, 2016. [12] T. Thesen, B. T. Quinn, C. Carlson, O. Devinsky, J. DuBois, C. R. McDonald, J. French, R. Leventer, O. Felsovalyi, X. Wang, et al., “Detection of epileptogenic cortical malformations with surface-based mri morphometry,” PloS one, vol. 6, no. 2, p. e16430, 2011. [13] H.-J. Huppertz, C. Grimm, S. Fauser, J. Kassubek, I. Mader, A. Hochmuth, J. Spreer, and A. SchulzeBonhage, “Enhanced visualization of blurred gray–white matter junctions in focal cortical dysplasia by voxel-based 3d mri analysis,” Epilepsy research, vol. 67, no. 1-2, pp. 35–50, 2005. [14] J. Wagner, B. Weber, H. Urbach, C. E. Elger, and H.-J. Huppertz, “Morphometric mri analysis improves detection of focal cortical dysplasia type ii,” Brain, vol. 134, no. 10, pp. 2844–2854, 2011. [15] J. Bromley, J. W. Bentz, L. Bottou, I. Guyon, Y. LeCun, C. Moore, E. Säckinger, and R. Shah, “Signature verification using a "siamese" time delay neural network,” IJPRAI, vol. 7, no. 4, pp. 669–688, 1993. [16] S. Chopra, R. Hadsell, and Y. LeCun, “Learning a similarity metric discriminatively, with application to face verification,” in Computer Vision and Pattern Recognition, 2005. CVPR 2005. IEEE Computer Society Conference on, vol. 1, pp. 539–546, IEEE, 2005. [17] B. Schölkopf, J. C. Platt, J. Shawe-Taylor, A. J. Smola, and R. C. Williamson, “Estimating the support of a high-dimensional distribution,” Neural computation, vol. 13, no. 7, pp. 1443–1471, 2001. [18] J. Mazziotta, A. Toga, A. Evans, P. Fox, J. Lancaster, K. Zilles, R. Woods, T. Paus, G. Simpson, B. Pike, et al., “A probabilistic atlas and reference system for the human brain: International consortium for brain mapping (icbm),” Philosophical Transactions of the Royal Society of London B: Biological Sciences, vol. 356, no. 1412, pp. 1293–1322, 2001. [19] J. Ashburner and K. Friston, “Unified segmentation,” Neuroimage, vol. 26, pp. 839–851, 2005. [20] B. Caputo, K. Sim, F. Furesjo, and A. Smola, “Appearance-based object recognition using svms: which kernel should i use?,” in Proc of NIPS workshop on Statistical methods for computational experiments in visual processing and computer vision, Whistler, vol. 2002, 2002. [21] M. P. Shah, S. N. Merchant, and S. P. Awate, “Abnormality detection using deep neural networks with robust quasi-norm autoencoding and semi-supervised learning,” in IEEE International Symposium on Biomedical Imaging (ISBI 2018), pp. 568–572. [22] Y. L. Tan, H. Kim, S. Lee, T. Tihan, L. Ver Hoef, S. G. Mueller, A. J. Barkovich, D. Xu, and R. Knowlton, “Quantitative surface analysis of combined mri and pet enhances detection of focal cortical dysplasias.,” Neuroimage, vol. 166, pp. 10–18, 2018.123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327# NORMALIZING THE NORMALIZERS: COMPARING AND EXTENDING NETWORK NORMALIZATION SCHEMES
Mengye $\mathbf { R e n } ^ { * \dagger }$ , Renjie Liao∗†, Raquel Urtasun†, Fabian H. $\mathbf { S i n z ^ { \ddagger } }$ , Richard S. Zemel†> †University of Toronto, Toronto ON, CANADA ‡Baylor College of Medicine, Houston TX, USA >Canadian Institute for Advanced Research (CIFAR) {mren, rjliao, urtasun}@cs.toronto.edu fabian.sinz@epagoge.de, zemel@cs.toronto.edu
# ABSTRACT
Normalization techniques have only recently begun to be exploited in supervised learning tasks. Batch normalization exploits mini-batch statistics to normalize the activations. This was shown to speed up training and result in better models. However its success has been very limited when dealing with recurrent neural networks. On the other hand, layer normalization normalizes the activations across all activities within a layer. This was shown to work well in the recurrent setting. In this paper we propose a unified view of normalization techniques, as forms of divisive normalization, which includes layer and batch normalization as special cases. Our second contribution is the finding that a small modification to these normalization schemes, in conjunction with a sparse regularizer on the activations, leads to significant benefits over standard normalization techniques. We demonstrate the effectiveness of our unified divisive normalization framework in the context of convolutional neural nets and recurrent neural networks, showing improvements over baselines in image classification, language modeling as well as super-resolution.
# 1 INTRODUCTION
Standard deep neural networks are difficult to train. Even with non-saturating activation functions such as ReLUs (Krizhevsky et al., 2012), gradient vanishing or explosion can still occur, since the Jacobian gets multiplied by the input activation of every layer. In AlexNet (Krizhevsky et al., 2012), for instance, the intermediate activations can differ by several orders of magnitude. Tuning hyperparameters governing weight initialization, learning rates, and various forms of regularization thus become crucial in optimizing performance.
In current neural networks, normalization abounds. One technique that has rapidly become a standard is batch normalization (BN) in which the activations are normalized by the mean and standard deviation of the training mini-batch (Ioffe & Szegedy, 2015). At inference time, the activations are normalized by the mean and standard deviation of the full dataset. A more recent variant, layer normalization (LN), utilizes the combined activities of all units within a layer as the normalizer (Ba et al., 2016). Both of these methods have been shown to ameliorate training difficulties caused by poor initialization, and help gradient flow in deeper models.
A less-explored form of normalization is divisive normalization (DN) (Heeger, 1992), in which a neuron’s activity is normalized by its neighbors within a layer. This type of normalization is a well established canonical computation of the brain (Carandini & Heeger, 2012) and has been extensively studied in computational neuroscience and natural image modelling (see Section 2). However, with few exceptions (Jarrett et al., 2009; Krizhevsky et al., 2012) it has received little attention in conventional supervised deep learning.
Here, we provide a unifying view of the different normalization approaches by characterizing them as the same transformation but along different dimensions of a tensor, including normalization across examples, layers in the network, filters in a layer, or instances of a filter response. We explore the effect of these varieties of normalizations in conjunction with regularization, on the prediction performance compared to baseline models. The paper thus provides the first study of divisive normalization in a range of neural network architectures, including convolutional neural networks (CNNs) and recurrent neural networks (RNNs), and tasks such as image classification, language modeling and image super-resolution. We find that DN can achieve results on par with BN in CNN networks and out-performs it in RNNs and super-resolution, without having to store batch statistics. We show that casting LN as a form of DN by incorporating a smoothing parameter leads to significant gains, in both CNNs and RNNs. We also find advantages in performance and stability by being able to drive learning with higher learning rate in RNNs using DN. Finally, we demonstrate that adding an L1 regularizer on the activations before normalization is beneficial for all forms of normalization.
# 2 RELATED WORK
In this section we first review related work on normalization, followed by a brief description of regularization in neural networks.
# 2.1 NORMALIZATION
Normalization of data prior to training has a long history in machine learning. For instance, local contrast normalization used to be a standard effective tool in vision problems (Pinto et al., 2008; Jarrett et al., 2009; Sermanet et al., 2012; Le, 2013). However, until recently, normalization was usually not part of the machine learning algorithm itself. Two notable exceptions are the original AlexNet by Krizhevsky et al. (2012) which includes a divisive normalization step over a subset of features after ReLU at each pixel location, and the work by Jarrett et al. (2009) who demonstrated that a combination of nonlinearities, normalization and pooling improves object recognition in two-stage networks.
Recently Ioffe & Szegedy (2015) demonstrated that standardizing the activations of the summed inputs of neurons over training batches can substantially decrease training time in deep neural networks. To avoid covariate shift, where the weight gradients in one layer are highly dependent on previous layer outputs, Batch Normalization (BN) rescales the summed inputs according to their variances under the distribution of the mini-batch data. Specifically, if $z _ { j , n }$ denotes the activation of a neuron $j$ on example $n$ , and $B ( n )$ denotes the mini-batch of examples that contains $n$ , then BN computes an affine function of the activations standardized over each mini-batch:
$$\tilde { z } _ { n , j } = \gamma \frac { z _ { n , j } - \mathbb { E } [ z _ { j } ] } { \sqrt { \frac { 1 } { | B ( n ) | } ( z _ { n , j } - \mathbb { E } [ z _ { j } ] ) ^ { 2 } } } + \beta \quad \mathbb { E } [ z _ { j } ] = \frac { 1 } { | B ( n ) | } \sum _ { m \in B ( n ) } z _ { m , j }$$
However, training performance in Batch Normalization strongly depends on the quality of the aquired statistics and, therefore, the size of the mini-batch. Hence, Batch Normalization is harder to apply in cases for which the batch sizes are small, such as online learning or data parallelism. While classification networks can usually employ relatively larger mini-batches, other applications such as image segmentation with convolutional nets use smaller batches and suffer from degraded performance. Moreover, application to recurrent neural networks (RNNs) is not straightforward and leads to poor performance (Laurent et al., 2015).
Several approaches have been proposed to make Batch Normalization applicable to RNNs. Cooijmans et al. (2016) and Liao & Poggio (2016) collect separate batch statistics for each time step. However, neither of this techniques address the problem of small batch sizes and it is unclear how to generalize them to unseen time steps.
More recently, Ba et al. (2016) proposed Layer Normalization (LN), where the activations are normalized across all summed inputs within a layer instead of within a batch:
$$\tilde { z } _ { n , j } = \gamma \frac { z _ { n , j } - \mathbb { E } [ z _ { n } ] } { \sqrt { \frac { 1 } { | L ( j ) | } ( z _ { n , j } - \mathbb { E } [ z _ { n } ] ) ^ { 2 } } } + \beta \quad \mathbb { E } [ z _ { n } ] = \frac { 1 } { | L ( j ) | } \sum _ { k \in L ( j ) } z _ { n , k }$$
where $L ( j )$ contains all of the units in the same layer as $j$ . While promising results have been shown on RNN benchmarks, direct application of layer normalization to convolutional layers often leads to a degradation of performance. The authors hypothesize that since the statistics in convolutional layers can vary quite a bit spatially, normalization with statistics from an entire layer might be suboptimal.
Ulyanov et al. (2016) proposed to normalize each example on spatial dimensions but not on channel dimension, and was shown to be effective on image style transfer applications (Gatys et al., 2016).
Liao et al. (2016a) proposed to accumulate the normalization statistics over the entire training phase, and showed that this can speed up training in recurrent and online learning without a deteriorating effect on the performance. Since gradients cannot be backpropagated through this normalization operation, the authors use running statistics of the gradients instead.
Exploring the normalization of weights instead of activations, Salimans & Kingma (2016) proposed a reparametrization of the weights into a scale independent representation and demonstrated that this can speed up training time.
Divisive Normalization (DN) on the other hand modulates the neural activity by the activity of a pool of neighboring neurons (Heeger, 1992; Bonds, 1989). DN is one of the most well studied and widely found transformations in real neural systems, and thus has been called a canonical computation of the brain (Carandini & Heeger, 2012). While the exact form of the transformation can differ, all formulations model the response of a neuron $\tilde { z } _ { j }$ as a ratio between the acitivity in a summation field $A _ { j }$ , and a norm-like function of the suppression field $B _ { j }$
$$\tilde { z } _ { j } = \gamma \frac { \sum _ { z _ { i } \in A _ { j } } u _ { i } z _ { i } } { \left( \sigma ^ { 2 } + \sum _ { z _ { k } \in B _ { j } } w _ { k } z _ { k } ^ { p } \right) ^ { \frac { 1 } { p } } } ,$$
where $\{ u _ { i } \}$ are the summation weights and $\{ w _ { k } \}$ the suppression weights.
Previous theoretical studies have outlined several potential computational roles for divisive normalization such as sensitivity maximization (Carandini & Heeger, 2012), invariant coding (Olsen et al., 2010), density modelling (Balle et al., 2016), image compression (Malo et al., 2006), distributed ´ neural representations (Simoncelli & Heeger, 1998), stimulus decoding (Ringach, 2009; Froudarakis et al., 2014), winner-take-all mechanisms (Busse et al., 2009), attention (Reynolds & Heeger, 2009), redundancy reduction (Schwartz & Simoncelli, 2001; Sinz & Bethge, 2008; Lyu & Simoncelli, 2008; Sinz & Bethge, 2013), marginalization in neural probabilistic population codes (Beck et al., 2011), and contextual modulations in neural populations and perception (Coen-Cagli et al., 2015; Schwartz et al., 2009).
# 2.2 REGULARIZATION
Various regularization techniques have been applied to neural networks for the purpose of improving generalization and reduce overfitting. They can be roughly divided into two categories, depending on whether they regularize the weights or the activations.
Regularization on Weights: The most common regularizer on weights is weight decay which just amounts to using the L2 norm squared of the weight vector. An L1 regularizer (Goodfellow et al., 2016) on the weights can also be adopted to push the learned weights to become sparse. Scardapane et al. (2016) investigated mixed norms in order to promote group sparsity.
Regularization on Activations: Sparsity or group sparsity regularizers on the activations have shown to be effective in the past (Roz, 2008; Kavukcuoglu et al., 2009) and several regularizers have been proposed that act directly on the neural activations. Glorot et al. (2011) add a sparse regularizer on the activations after ReLU to encourage sparse representations. Dropout developed by Srivastava et al. (2014) applies random masks to the activations in order to discourage them to co-adapt. DeCov proposed by Cogswell et al. (2015) tries to minimize the off-diagonal terms of the sample covariance matrix of activations, thus encouraging the activations to be as decorrelated as possible. Liao et al. (2016b) utilize a clustering-based regularizer to encourage the representations to be compact.
 Figure 1: Illustration of different normalization schemes, in a CNN. Each $H \times W$ -sized feature map is depicted as a rectangle; overlays depict instances in the set of $C$ filters; and two examples from a mini-batch of size $N$ are shown, one above the other. The colors show the summation/suppression fields of each scheme.
# 3 A UNIFIED FRAMEWORK FOR NORMALIZING NEURAL NETS
We first compare the three existing forms of normalization, and show that we can modify batch normalization (BN) and layer normalization (LN) in small ways to make them have a form that matches divisive normalization (DN). We present a general formulation of normalization, where existing normalizations involve alternative schemes of accumulating information. Finally, we propose a regularization term that can be optimized jointly with these normalization schemes to encourage decorrelation and/or improve generalization performance.
# 3.1 GENERAL FORM OF NORMALIZATION
Without loss of generality, we denote the hidden input activation of one arbitrary layer in a deep neural network as $\mathbf { z } \in \mathbb { R } ^ { \tilde { N } \times L }$ . Here $N$ is the mini-batch size. In the case of a CNN, $L = H \times W \times C$ , where $H , W$ are the height and width of the convolutional feature map and $C$ is the number of filters. For an RNN or fully-connected layers of a neural net, $L$ is the number of hidden units.
Different normalization methods gather statistics from different ranges of the tensor and then perform normalization. Consider the following general form:
$$\begin{array} { l } { \displaystyle z _ { n , j } = \sum _ { i } w _ { i , j } x _ { n , i } + b _ { j } } \\ { \displaystyle v _ { n , j } = z _ { n , j } - \mathbb { E } _ { A _ { n , j } } [ z ] } \\ { \displaystyle \tilde { z } _ { n , j } = \frac { v _ { n , j } } { \sqrt { \sigma ^ { 2 } + \mathbb { E } _ { \mathcal { B } _ { n , j } } [ v ^ { 2 } ] } } } \end{array}$$
where $A _ { j }$ and $B _ { j }$ are subsets of $z$ and $v$ respectively. $\mathcal { A }$ and $\boldsymbol { B }$ in standard divisive normalization are referred to as summation and suppression fields (Carandini & Heeger, 2012). One can cast each normalization scheme into this general formulation, where the schemes vary based on how they define these two fields. These definitions are specified in Table 1. Optional parameters $\gamma$ and $\beta$ can be added in the form of $\gamma _ { j } \tilde { z } _ { n , j } + \beta _ { j }$ to increase the degree of freedom.
Fig. 1 shows a visualization of the normalization field in a 4-D ConvNet tensor setting. Divisive normalization happens within a local spatial window of neurons across filter channels. Here we set $d ( \cdot , \cdot )$ to be the spatial $L _ { \infty }$ distance.
# 3.2 NEW MODEL COMPONENTS
Smoothing the Normalizers: One obvious way in which the normalization schemes differ is in terms of the information that they combine for normalizing the activations. A second more subtle but important difference between standard BN and LN as opposed to DN is the smoothing term $\sigma$ in the denominator of Eq. (1). This term allows some control of the bias of the variance estimation, effectively smoothing the estimate. This is beneficial because divisive normalization does not utilize information from the mini-batch as in BN, and combines information from a smaller field than LN. A similar but different denominator bias term $\operatorname* { m a x } ( \sigma , c )$ appears in (Jarrett et al., 2009), which is active when the activation variance is small. However, the clipping function makes the transformation not invertible, losing scale information.
<table><tr><td>Model</td><td>Range</td><td>Normalizer Bias</td></tr><tr><td>BN</td><td>An,j ={2m,j : m ∈[1,N],j ∈[1,H] × [1,W]} Bn,j = {Um,j : m ∈ [1,N],j ∈[1,H] ×[1,W]}</td><td>g=0</td></tr><tr><td>LN</td><td>An,j ={zn,i :i ∈[1,L]} Bn,j={Un,i : i∈[1,L]}</td><td>σ=0</td></tr><tr><td>DN</td><td>An,j ={2n,i : d(i,j)≤RA} Bn,j = {Un,i : d(i,j)≤RB}</td><td>q≥0</td></tr></table>
 Table 1: Different choices of the summation and suppression fields $\mathcal { A }$ and $\boldsymbol { B }$ , as well as the constant $\sigma$ in the normalizer lead to known normalization schemes in neural networks. $d ( i , j )$ denotes an arbitrary distance between two hidden units $_ { i }$ and $j$ , and $R$ denotes the neighbourhood radius. Figure 2: Divisive normalization followed by ReLU can be viewed as a new activation function. Left: Effect of varying $\sigma$ in this activation function. Right: Two units affect each other’s activation in the $\mathrm { D N + }$ ReLU formulation.
Moreover, if we take the nonlinear activation function after normalization into consideration, we find that $\sigma$ will change the overall properties of the non-linearity. To illustrate this effect, we use a simple 1-layer network which consists of: two input units, one divisive normalization operator, followed by a ReLU activation function. If we fix one input unit to be 0.5, varying the other one with different values of $\sigma$ produces different output curves (Fig. 2, left). These curves exhibit different non-linear properties compared to the standard ReLU. Allowing the other input unit to vary as well results in different activation functions of the first unit depending on the activity of the second (Fig. 2, right). This illustrates potential benefits of including this smoothing term $\sigma$ , as it effectively modulates the rectified response to vary from a linear to a highly saturated response.
In this paper we propose modifications of the standard BN and LN which borrow this additive term $\sigma$ in the denominator from DN. We study the effect of incorporating this smoother in the respective normalization schemes below.
L1 regularizer: Filter responses on lower layers in deep neural networks can be quite correlated which might impair the estimate of the variance in the normalizer. More independent representations help disentangle latent factors and boost the networks performance (Higgins et al., 2016). Empirically, we found that putting a sparse (L1) regularizer
$$\mathcal { L } _ { L 1 } = \alpha \frac { 1 } { N L } \sum _ { n , j } | v _ { n , j } |$$
on the centered activations $v _ { n , j }$ helps decorrelate the filter responses (Fig. 5). Here, $N$ is the batch size and $L$ is the number of hidden units, and $\mathcal { L } _ { L 1 }$ is the regularization loss which is added to the training loss.
A possible explanation for this effect is that the L1 regularizer might have a similar effect as maximum likelihood estimation of an independent Laplace distribution. To see that, let $p _ { v } \left( \mathbf { v } \right) \propto \exp \left( - \left\| \mathbf { v } \right\| _ { 1 } \right)$ and $\mathbf { x } = W ^ { - 1 } \mathbf { v }$ , with $W$ a full rank invertible matrix. Under this model $p _ { x } \left( \mathbf { x } \right) = p _ { v } \left( W \mathbf { x } \right) \left| \operatorname* { d e t } W \right|$ .
Then, minimization of the L1 norm of the activations under the volume-conserving constraint det $A =$ const. corresponds to maximum likelihood on that model, which would encourage decorrelated responses. We do not enforce such a constraint, and the filter matrix might even not be invertible. However, the supervised loss function of the network benefits from having diverse non-zero filters. This encourages the network to not collapse filters along the same direction or put them to zero, and might act as a relaxation of the volume-conserving constraint.
# 3.3 SUMMARY OF NEW MODELS
DN and $\mathbf { D } \mathbf { N } ^ { * }$ : We propose DN as a new local normalization scheme in neural networks. In convolutional layers, it operates on a local spatial window across filter channels, and in fully connected layers it operates on a slice of a hidden state vector. Additionally, $\mathrm { D N ^ { * } }$ has a L1 regularizer on the pre-normalization centered activation $( v _ { n , j } )$ .
BN-s and $\mathbf { B N } ^ { * }$ : To compare with DN and $\mathrm { D N ^ { * } }$ , we also propose modifications to original BN: we denote BN-s with $\sigma ^ { 2 }$ in the denominator’s square root, and $\mathbf { B N } ^ { * }$ with the L1 regularizer on top of BN-s.
LN-s and $\mathbf { L N ^ { * } }$ : We apply the same changes as from BN to BN-s and $\mathbf { B N } ^ { * }$ . In order to narrow the differences in the normalization schemes down to a few parameter choices, we additionally remove the affine transformation parameters $\gamma$ and $\beta$ from LN such that the difference between $\mathrm { L N ^ { * } }$ and $\mathrm { D N ^ { * } }$ is only the size of the normalization field. $\gamma$ and $\beta$ can really be seen as a separate layer and in practice we find that they do not improve the performance in the presence of $\sigma ^ { 2 }$ .
# 4 EXPERIMENTS
We evaluate the normalization schemes on three different tasks:
CNN image classification: We apply different normalizations on CNNs trained on the CIFAR-10/100 datasets for image recognition, each of which contains 50,000 training images and 10,000 test images. Each image is of size $3 2 \times 3 2 \times 3$ and has been labeled an object class out of 10 or 100 total number of classes. RNN language modeling: We apply different normalizations on RNNs trained on the Penn Treebank dataset for language modeling, containing 42,068 training sentences, 3,370 validation sentences, and 3,761 test sentences. CNN image super-resolution: We train a CNN on low resolution images and learn cascades of non-linear filters to smooth the upsampled images. We report performance of trained CNN on the standard Set 14 and Berkeley 200 dataset.
For each model, we perform a grid search of three or four choices of each hyperparameter including the smoothing constant $\sigma$ , and L1 regularization constant $\alpha$ , and learning rate $\epsilon$ on the validation set.
# 4.1 CIFAR EXPERIMENTS
We used the standard CNN model provided in the Caffe library. The architecture is summarized in Table 2. We apply normalization before each ReLU function. We implement DN as a convolutional operator, fixing the local window size to $5 \times 5 , 3 \times 3 , 3 \times 3$ for the three convolutional layers in all the CIFAR experiments.
We set the learning rate to 1e-3 and momentum 0.9 for all experiments. The learning rate schedule is set to $\{ 5 \mathrm { K } , 3 0 \mathrm { K } , 5 0 \mathrm { K } \}$ for the baseline model and to $\{ 3 0 \mathrm { K } , 5 0 \mathrm { K } , 8 0 \mathrm { K } \}$ for all other models. At every stage we multiply the learning rate by 0.1. Weights are randomly initialized from a zero-mean normal distribution with standard deviation $\{ 1 \mathrm { e } { - } 4 , 1 \mathrm { e } { - } 2 , 1 \mathrm { e } { - } 2 \}$ for the convolutional layers, and $\{ 1 \mathrm { e } \mathrm { - } 1 , 1 \mathrm { e } \mathrm { - } 1 \}$ for fully connected layers. Input images are centered on the dataset image mean.
Table 3 summarizes the test performances of $\mathbf { B N } ^ { * }$ , $\mathrm { L N ^ { * } }$ and $\mathrm { D N ^ { * } }$ , compared to the performance of a few baseline models and the standard batch and layer normalizations. We also add standard regularizers to the baseline model: L2 weight decay (WD) and dropout. Adding the smoothing constant and L1 regularization consistently improves the classification performance, especially for the original LN. The modification of LN makes it now better than the original BN, and only slightly worse than $\mathbf { B N } ^ { * }$ . $\mathrm { D N ^ { * } }$ achieves comparable performance to $\mathbf { B N ^ { * } }$ on both datasets, but only relying on a local neighborhood of hidden units.
Table 2: CIFAR CNN specification
<table><tr><td>Type</td><td>Size</td><td>Kernel</td><td>Stride</td></tr><tr><td>input</td><td>32 × 32×3</td><td>1</td><td>-</td></tr><tr><td>conv +relu</td><td>32 × 32 × 32</td><td>5×5×3×32</td><td>1</td></tr><tr><td>max pool</td><td>16 ×16×32</td><td>3×3</td><td>2</td></tr><tr><td>conv +relu</td><td>16 ×16 × 32</td><td>5×5×32×32</td><td>1</td></tr><tr><td>avg pool</td><td>8×8×32</td><td>3×3</td><td>2</td></tr><tr><td>conv +relu</td><td>8×8×64</td><td>5×5×32×64</td><td>1</td></tr><tr><td>avg pool</td><td>4×4×64</td><td>3×3</td><td>2</td></tr><tr><td>fully conn. linear</td><td>64</td><td></td><td></td></tr><tr><td>fully conn. linear</td><td>10 or 100</td><td></td><td></td></tr></table>
Table 3: CIFAR-10/100 experiments
<table><tr><td>Model</td><td>CIFAR-10 Acc.</td><td>CIFAR-100 Acc.</td></tr><tr><td>Baseline</td><td>0.7565</td><td>0.4409</td></tr><tr><td>Baseline +WD +Dropout</td><td>0.7795</td><td>0.4179</td></tr><tr><td>BN</td><td>0.7807</td><td>0.4814</td></tr><tr><td>LN</td><td>0.7211</td><td>0.4249</td></tr><tr><td>BN*</td><td>0.8179</td><td>0.5156</td></tr><tr><td>LN*</td><td>0.8091</td><td>0.4957</td></tr><tr><td>DN*</td><td>0.8122</td><td>0.5066</td></tr></table>
ResNet Experiments. Residual networks (ResNet) (He et al., 2016), a type of CNN with residual connections between layers, achieve impressive performance on many image classification benchmarks. The original architecture uses BN by default. If we remove BN, the architecture is very difficult to train or converges to a poor solution. We first reproduced the original BN ResNet-32, obtaining $9 2 . 6 \%$ accuracy on CIFAR10, and $6 9 . 8 \%$ on CIFAR-100. Our best DN model achieves $9 1 . 3 \%$ and $6 6 . 6 \%$ , respectively. While this performance is lower than the original BN-ResNet, there is certainly room to improve as we have not performed any hyperparameter optimization. Importantly, the beneficial effects of sigma $( 2 . 5 \%$ gain on CIFAR-100) and the L1 regularizer $( 0 . 5 \% )$ are still found, even in the presence of other regularization techniques such as data augmentation and weight decay in the training.
Since the number of sigma hyperparameters scales with the number of layers, we found that setting sigma as a learnable parameter for each layer helps the performance ( $1 . 3 \%$ gain on CIFAR-100). Note that training this parameter is not possible in the formulation by Jarrett et al. (2009). The learned sigma shows a clear trend: it tends to decrease with depth, and in the last convolution layer it approaches 0 (see Fig. 3).
 Figure 3: Input scale $( | x | )$ vs. learned $\sigma$ at each layer, color coded by the layer number in ResNet-32, trained on CIFAR-10 (left), and CIFAR-100 (right).
# 4.2 RNN EXPERIMENTS
To apply divisive normalization in fully connected layers of RNNs, we consider a local neighborhood in the hidden state vector $\mathbf { h } _ { j - R : j + R }$ , where $R$ is the radius
Table 4: PTB Word-level language modeling experiments
<table><tr><td>Model</td><td>LSTM</td><td>TanH RNN</td><td>ReLU RNN</td></tr><tr><td>Baseline</td><td>115.720</td><td>149.357</td><td>147.630</td></tr><tr><td>BN</td><td>123.245</td><td>148.052</td><td>164.977</td></tr><tr><td>LN</td><td>119.247</td><td>154.324</td><td>149.128</td></tr><tr><td>BN*</td><td>116.920</td><td>129.155</td><td>138.947</td></tr><tr><td>LN*</td><td>101.725</td><td>129.823</td><td>116.609</td></tr><tr><td>DN*</td><td>102.238</td><td>123.652</td><td>117.868</td></tr></table>
of the neighborhood. Although the hidden states are randomly initialized, this structure will impose local competition among the neighbors.
$$\begin{array} { l } { \displaystyle v _ { j } = z _ { j } - \frac { 1 } { 2 R + 1 } \sum _ { r = - R } ^ { R } z _ { j + r } } \\ { \displaystyle \tilde { z } _ { j } = \frac { v _ { j } } { \sqrt { \sigma ^ { 2 } + \frac { 1 } { 2 R + 1 } \sum _ { r = - R } ^ { R } v _ { j + r } ^ { 2 } } } } \end{array}$$
We follow Cooijmans et al. (2016)’s batch normalization implementation for RNNs: normalizers are separate for input transformation and hidden transformation. Let $B N ( \cdot ) , L N ( \cdot ) , D N ( \cdot )$ be BatchNorm, LayerNorm and DivNorm, and $g$ be either tanh or ReLU.
$$\begin{array} { r l } & { \mathbf { h } _ { t + 1 } = g ( W _ { x } \mathbf { x } _ { t } + W _ { h } \mathbf { h } _ { t - 1 } + b ) } \\ & { \mathbf { h } _ { t + 1 } ^ { ( B N ) } = g ( B N ( W _ { x } \mathbf { x } _ { t } + b _ { x } ) + B N ( W _ { h } \mathbf { h } _ { t - 1 } ^ { ( B N ) } + b _ { h } ) ) } \\ & { \mathbf { h } _ { t + 1 } ^ { ( L N ) } = g ( L N ( W _ { x } \mathbf { x } _ { t } + W _ { h } \mathbf { h } _ { t - 1 } ^ { ( L N ) } + b ) ) } \\ & { \mathbf { h } _ { t + 1 } ^ { ( D N ) } = g ( D N ( W _ { x } \mathbf { x } _ { t } + W _ { h } \mathbf { h } _ { t - 1 } ^ { ( D N ) } + b ) ) } \end{array}$$
Note that in recurrent BN, the additional parameters $\gamma$ and $\beta$ are shared across timesteps whereas the moving averages of batch statistics are not shared. For the LSTM version, we followed the released implementation from the authors of layer normalization 1, and apply LN at the same places as BN and $\mathbf { B N ^ { * } }$ , which is after the linear transformation of $W _ { x } { \bf x }$ and $W _ { h } \mathbf { h }$ individually. For $\mathrm { L N ^ { * } }$ and DN, we modified the places of normalization to be at each non-linearity, instead of jointly with a concatenated vector for different non-linearity. We found that this modification improves the performance and makes the formulation clearer since normalization is always a combined operation with the activation function. We include details of the LSTM implementation in the Appendix.
The RNN model is provided by the Tensorflow library (Abadi et al., 2016) and the LSTM version was originally proposed in Zaremba et al. (2014). We used a two-layer stack-RNN of size 400 (vanilla RNN) or 200 (LSTM). $R$ is set to 60 (vanilla RNN) and 30 (LSTM). We tried both tanh and ReLU as the activation function for the vanilla RNN. For unnormalized baselines and BN+ReLU, the initial learning rate is set to 0.1 and decays by half every epoch, starting at the 5th epoch for a maximum of 13 epochs. For the other normalized models, the initial learning rate is set to 1.0 while the schedule is kept the same. Standard stochastic gradient descent is used in all RNN experiments, with gradient clipping at 5.0.
Table 4 shows the test set perplexity for LSTM models and vanilla models. Perplexity is defined as $\begin{array} { r } { \mathrm { p p l } = \exp ( - \sum _ { x } \log p ( x ) ) } \end{array}$ . We find that BN and LN alone do not improve the final performance relative to the baseline, but similar to what we see in the CNN experiments, our modified versions $\mathbf { B N } ^ { * }$ and $\mathrm { L N ^ { * } }$ show significant improvements. $\mathbf { B N } ^ { * }$ on RNN is outperformed by both $\mathrm { L N ^ { * } }$ and DN. By applying our normalization, we can improve the vanilla RNN perplexity by $20 \%$ , comparable to an LSTM baseline with the same hidden dimension.
Table 5: Average test results of PSNR and SSIM on Set14 Dataset.
<table><tr><td>Model</td><td>PSNR (x3)</td><td>SSIM (x3)</td><td>PSNR (x4)</td><td>SSIM (x4)</td></tr><tr><td>Bicubic</td><td>27.54</td><td>0.7733</td><td>26.01</td><td>0.7018</td></tr><tr><td>A+</td><td>29.13</td><td>0.8188</td><td>27.32</td><td>0.7491</td></tr><tr><td>SRCNN</td><td>29.35</td><td>0.8212</td><td>27.53</td><td>0.7512</td></tr><tr><td>BN</td><td>22.31</td><td>0.7530</td><td>21.40</td><td>0.6851</td></tr><tr><td>DN*</td><td>29.38</td><td>0.8229</td><td>27.64</td><td>0.7562</td></tr></table>
Table 6: Average test results of PSNR and SSIM on BSD200 Dataset.
<table><tr><td>Model</td><td>PSNR (x3)</td><td>SSIM (x3)</td><td>PSNR (x4)</td><td>SSIM (x4)</td></tr><tr><td>Bicubic</td><td>27.19</td><td>0.7636</td><td>25.92</td><td>0.6952</td></tr><tr><td>A+</td><td>27.05</td><td>0.7945</td><td>25.51</td><td>0.7171</td></tr><tr><td>SRCNN</td><td>28.42</td><td>0.8100</td><td>26.87</td><td>0.7378</td></tr><tr><td>BN</td><td>21.89</td><td>0.7553</td><td>21.53</td><td>0.6741</td></tr><tr><td>DN*</td><td>28.44</td><td>0.8110</td><td>26.96</td><td>0.7428</td></tr></table>
# 4.3 SUPER RESOLUTION EXPERIMENTS
We also evaluate DN on the low-level computer vision problem of single image super-resolution. We adopt the SRCNN model of Dong et al. (2016) as the baseline which consists of 3 convolutional layers and 2 ReLUs. From bottom to top layers, the sizes of the filters are 9, 5, and $5 ^ { 2 }$ . The number of filters are 64, 32, and 1, respectively. All the filters are initialized with zero-mean Gaussian and standard deviation 1e-3. Then we respectively apply batch normalization (BN) and our divisive normalization with L1 regularization $\mathrm { ( D N ^ { * } ) }$ to the convolutional feature maps before ReLUs. We construct the training set in a similar manner as Dong et al. (2016) by randomly cropping 5 million patches (size $3 3 \times 3 3$ ) from a subset of the ImageNet dataset of Deng et al. (2009). We only train our model for 4 million iterations which is less than the one adopted by SRCNN, i.e., 15 million, as the gain of PSNR and SSIM by spending that long time is marginal.
We report the average test results, utilizing the standard metrics PSNR and SSIM (Wang et al., 2004), on two standard test datasets Set14 (Zeyde et al., 2010) and BSD200 (Martin et al., 2001). We compare with two state-of-the-art single image super-resolution methods, $\mathbf { A } +$ (Timofte et al., 2013) and SRCNN (Dong et al., 2016). All measures are computed on the Y channel of YCbCr color space. We also provide a visual comparison in Fig. 4.
As show in Tables 5 and $6 \mathrm { D N ^ { * } }$ outperforms the strong competitor SRCNN, while BN does not perform well on this task. The reason may be that BN applies the same statistics to all patches of one image which causes some overall intensity shift (see Figs. 4). From the visual comparisons, we can see that our method not only enhances the resolution but also removes artifacts, e.g., the ringing effect in Fig. 4.
# 4.4 ABLATION STUDIES AND DISCUSSION
Finally, we investigated the differential effects of the $\sigma ^ { 2 }$ term and the L1 regularizer on the performance. We ran ablation studies on CIFAR-10/100 as well as PTB experiments. The results are listed in Table 7.
We find that adding the smoothing term $\sigma ^ { 2 }$ and the L1 regularization consistently increases the performance of the models. In the convolutional networks, we find that L1 and $\sigma$ both have similar effects on the performance. L1 seems to be slightly more important. In recurrent networks, $\sigma ^ { 2 }$ has a much more dramatic effect on the performance than the L1 regularizer.
Fig. 5 plots randomly sampled pairwise pre-normalization responses (after the linear transform) in the first layer at the same spatial location of the feature map, along with the average pair-wise correlation coefficient (Corr) and mutual information (MI). It is evident that both $\sigma$ and L1 encourages independence of the learned linear filters.
 Figure 4: Comparisons at a magnification factor of 4.
There are several factors that could explain the improvement in performance. As mentioned above, adding the L1 regularizer on the activations encourages the filter responses to be less correlated. This can increase the robustness of the variance estimate in the normalizer and lead to an improved scaling of the responses to a good regime. Furthermore, adding the smoother to the denominator in the normalizer can be seen as implicitly injecting zero mean noise on the activations. While noise injection would not change the mean, it does add a term to the variance of the data, which is represented by $\sigma ^ { 2 }$ . This term also makes the normalization equation invertible. While dividing by the standard deviation decreases the degrees of freedom in the data, the smoothed normalization equation is fully information preserving. Finally, DN type operations have been shown to decrease the redundancy of filter responses to natural images and sound (Schwartz & Simoncelli, 2001; Sinz & Bethge, 2008; Lyu & Simoncelli, 2008). In combination with the L1 regularizer this could lead to a more independent representation of the data and thereby increase the performance of the network.
# 5 CONCLUSIONS
We have proposed a unified view of normalization techniques which contains batch and layer normalization as special cases. We have shown that when combined with a sparse regularizer on the activations, our framework has significant benefits over standard normalization techniques. We have demonstrated this in the context of both convolutional neural nets as well as recurrent neural networks. In the future we plan to explore other regularization techniques such as group sparsity. We also plan to conduct a more in-depth analysis of the effects of normalization on the correlations of the learned representations.
Table 7: Comparison of standard batch and layer normalation (BN and LN) models, to those with only L1 regularizer $( + \mathrm { L } 1 )$ , only the $\sigma$ smoothing term (-s), and with both $( ^ { \ast } )$ . We also compare divisive normalization with both $\mathrm { ( D N ^ { * } ) }$ , versus with only the smoothing term (DN).
<table><tr><td>Model</td><td>CIFAR-10</td><td>CIFAR-100</td><td>LSTM</td><td>Tanh RNN</td><td>ReLU RNN</td></tr><tr><td>Baseline Baseline +L1</td><td>0.7565 0.7839</td><td>0.4409 0.4517</td><td>115.720 111.885</td><td>149.357 143.965</td><td>147.630 148.572</td></tr><tr><td>BN BN+L1 BN-s</td><td>0.7807 0.8067 0.8017 0.8179</td><td>0.4814 0.5100 0.5005 0.5156</td><td>123.245 123.736 123.243 116.920</td><td>148.052 152.777 131.719 129.155</td><td>164.977 166.658 139.159 138.947</td></tr><tr><td>BN* LN LN +L1</td><td>0.7211 0.7994</td><td>0.4249 0.4990</td><td>119.247 116.964</td><td>154.324</td><td>149.128</td></tr><tr><td>LN-s</td><td></td><td></td><td></td><td>152.100</td><td>147.937</td></tr><tr><td></td><td>0.8083</td><td>0.4863</td><td>102.492</td><td>133.812</td><td>118.786</td></tr><tr><td>LN*</td><td>0.8091</td><td>0.4957</td><td>101.725</td><td></td><td></td></tr><tr><td>DN</td><td>0.8058</td><td></td><td></td><td>129.823</td><td>116.609</td></tr><tr><td></td><td></td><td>0.4892</td><td>103.714</td><td>132.143</td><td>118.789</td></tr><tr><td>DN*</td><td>0.8122</td><td>0.5066</td><td>102.238</td><td>123.652</td><td>117.868</td></tr><tr><td></td><td></td><td></td><td></td><td></td><td></td></tr></table>
 Figure 5: First layer CNN pre-normalized activation joint histogram
Acknowledgements RL is supported by Connaught International Scholarships. FS would like to thank Edgar Y. Walker, Shuang Li, Andreas Tolias and Alex Ecker for helpful discussions. Supported by the Intelligence Advanced Research Projects Activity (IARPA) via Department of Interior/Interior Business Center (DoI/IBC) contract number D16PC00003. The U.S. Government is authorized to reproduce and distribute reprints for Governmental purposes notwithstanding any copyright annotation thereon. Disclaimer: The views and conclusions contained herein are those of the authors and should not be interpreted as necessarily representing the official policies or endorsements, either expressed or implied, of IARPA, DoI/IBC, or the U.S. Government.
# REFERENCES
Sparse coding via thresholding and local competition in neural circuits. Neural Computation, 20(10): 2526–63, 2008. ISSN 08997667. doi: 10.1162/neco.2008.03-07-486.
Abadi, Mart´ın, Barham, Paul, Chen, Jianmin, Chen, Zhifeng, Davis, Andy, Dean, Jeffrey, Devin, Matthieu, Ghemawat, Sanjay, Irving, Geoffrey, Isard, Michael, Kudlur, Manjunath, Levenberg, Josh, Monga, Rajat, Moore, Sherry, Murray, Derek Gordon, Steiner, Benoit, Tucker, Paul A., Vasudevan, Vijay, Warden, Pete, Wicke, Martin, Yu, Yuan, and Zhang, Xiaoqiang. Tensorflow: A system for large-scale machine learning. CoRR, abs/1605.08695, 2016.
Ba, Jimmy Lei, Kiros, Jamie Ryan, and Hinton, Geoffrey E. Layer normalization. CoRR, abs/1607.06450, 2016.
Balle, Johannes, Laparra, Valero, and Simoncelli, Eero P. Density modeling of images using a ´ generalized normalization transformation. ICLR, 2016.
Beck, J. M., Latham, P. E., and Pouget, A. Marginalization in Neural Circuits with Divisive Normalization. The Journal of neuroscience : the official journal of the Society for Neuroscience, 31(43):15310–9, oct 2011. ISSN 1529-2401. doi: 10.1523/JNEUROSCI.1706-11.2011.
Bevilacqua, Marco, Roumy, Aline, Guillemot, Christine, and Morel, Marie-Line Alberi. Lowcomplexity single-image super-resolution based on nonnegative neighbor embedding. In BMVC, 2012.
Bonds, A. B. Role of Inhibition in the Specification of Orientation Selectivity of Cells in the Cat Striate Cortex. Visual Neuroscience, 2(01):41–55, 1989.
Busse, L., Wade, A. R., and Carandini, M. Representation of Concurrent Stimuli by Population Activity in Visual Cortex. Neuron, 64(6):931–942, dec 2009. ISSN 0896-6273. doi: 10.1016/j. neuron.2009.11.004.
Carandini, M. and Heeger, D. J. Normalization as a canonical neural computation. Nature reviews. Neuroscience, 13(1):51–62, nov 2012. ISSN 1471-0048. doi: 10.1038/nrn3136.
Coen-Cagli, R., Kohn, A., and Schwartz, O. Flexible gating of contextual influences in natural vision. Nature Neuroscience, 18(11):1648–1655, 2015. ISSN 1097-6256. doi: 10.1038/nn.4128.
Cogswell, Michael, Ahmed, Faruk, Girshick, Ross, Zitnick, Larry, and Batra, Dhruv. Reducing overfitting in deep networks by decorrelating representations. ICLR, 2015.
Cooijmans, Tim, Ballas, Nicolas, Laurent, Cesar, and Courville, Aaron. Recurrent batch normaliza- ´ tion. CoRR, abs/1603.09025, 2016.
Deng, Jia, Dong, Wei, Socher, Richard, Li, Li-Jia, Li, Kai, and Fei-Fei, Li. Imagenet: A large-scale hierarchical image database. In CVPR, 2009.
Dong, Chao, Loy, Chen Change, He, Kaiming, and Tang, Xiaoou. Image super-resolution using deep convolutional networks. TPAMI, 38(2):295–307, 2016.
Froudarakis, Emmanouil, Berens, Philipp, Ecker, Alexander S, Cotton, R James, Sinz, Fabian H, Yatsenko, Dimitri, Saggau, Peter, Bethge, Matthias, and Tolias, Andreas S. Population code in mouse V1 facilitates readout of natural scenes through increased sparseness. Nature neuroscience, 17(6):851–7, apr 2014. ISSN 1546-1726. doi: 10.1038/nn.3707.
Gatys, Leon A., Ecker, Alexander S., and Bethge, Matthias. Image style transfer using convolutional neural networks. In CVPR, 2016.
Glorot, Xavier, Bordes, Antoine, and Bengio, Yoshua. Deep sparse rectifier neural networks. In AISTATS, 2011.
Goodfellow, Ian, Bengio, Yoshua, and Courville, Aaron. Deep learning. Book in preparation for MIT Press, 2016.
He, Kaiming, Zhang, Xiangyu, Ren, Shaoqing, and Sun, Jian. Deep residual learning for image recognition. In CVPR, 2016. Heeger, D. J. Normalization of cell responses in cat striate cortex. Vis Neurosci, 9(2):181–197, 1992. ISSN 09525238. Higgins, I., Matthey, L., Glorot, X., Pal, A., Uria, B., Blundell, C., Mohamed, S., and Lerchner, A. Early Visual Concept Learning with Unsupervised Deep Learning. CoRR, abs/1606.05579, 2016. Ioffe, Sergey and Szegedy, Christian. Batch normalization: Accelerating deep network training by reducing internal covariate shift. In ICML, 2015. Jarrett, K., Kavukcuoglu, K., Ranzato, M. A., and LeCun, Y. What is the best multi-stage architecture for object recognition? ICCV, 2009. Kavukcuoglu, K., Ranzato, M.’A., Fergus, R., and LeCun, Y. Learning invariant features through topographic filter maps. In CVPR Workshops, 2009. Krizhevsky, A., Sutskever, I., and Hinton, G. E. ImageNet Classification with Deep Convolutional Neural Networks. NIPS, 2012. Laurent, Cesar, Pereyra, Gabriel, Brakel, Phil ´ emon, Zhang, Ying, and Bengio, Yoshua. Batch ´ normalized recurrent neural networks. arXiv preprint arXiv:1510.01378, 2015. Le, Quoc V. Building high-level features using large scale unsupervised learning. In 2013 IEEE international conference on acoustics, speech and signal processing, pp. 8595–8598. IEEE, 2013. Liao, Q. and Poggio, T. Bridging the Gaps Between Residual Learning, Recurrent Neural Networks and Visual Cortex. CoRR, abs/1604.03640, 2016. Liao, Qianli, Kawaguchi, Kenji, and Poggio, Tomaso. Streaming Normalization: Towards Simpler and More Biologically-plausible Normalizations for Online and Recurrent Learning. CoRR, abs/1610.06160, 2016a. Liao, Renjie, Schwing, Alexander, Zemel, Richard, and Urtasun, Raquel. Learning deep parsimonious representations. NIPS, 2016b. Lyu, Siwei and Simoncelli, Eero P. Reducing statistical dependencies in natural signals using radial Gaussianization. NIPS, 2008. Malo, J., Epifanio, I., Navarro, R., and Simoncelli, E. P. Nonlinear image representation for efficient perceptual coding. TIP, 15(1):68–80, 2006. Martin, David, Fowlkes, Charless, Tal, Doron, and Malik, Jitendra. A database of human segmented natural images and its application to evaluating segmentation algorithms and measuring ecological statistics. In ICCV, 2001. Olsen, S. R, Bhandawat, V., and Wilson, R. I. Divisive Normalization in Olfactory Population Codes. Neuron, 66(2):287–299, 2010. ISSN 10974199. doi: 10.1016/j.neuron.2010.04.009. Pinto, N., Cox, D. D., and DiCarlo, J. J. Why is Real-World Visual Object Recognition Hard? PLoS Comput Biol, 4(1):e27, jan 2008. doi: 10.1371/journal.pcbi.0040027. Reynolds, J. H. and Heeger, D. J. The normalization model of attention. Neuron, 61(2):168–85, jan 2009. ISSN 1097-4199. doi: 10.1016/j.neuron.2009.01.002. Ringach, D. L. Population coding under normalization. Vision Research, 50(22):2223–2232, 2009. ISSN 18785646. doi: 10.1016/j.visres.2009.12.007. Salimans, Tim and Kingma, Diederik P. Weight normalization: A simple reparameterization to accelerate training of deep neural networks. In NIPS, 2016. Scardapane, S., Comminiello, D., Hussain, A., and Uncin, A. Group sparse regularization for deep neural networks. CoRR, abs/1607.00485, 2016. Schwartz, O. and Simoncelli, E. P. Natural signal statistics and sensory gain control. Nat Neurosci, 4 (8):819–825, 2001. ISSN 1097-6256. doi: 10.1038/90526. Schwartz, O., J., Sejnowski T., and P., Dayan. Perceptual organization in the tilt illusion. Journal of Vision, 9(4):1–20, apr 2009. ISSN 1534-7362. Sermanet, P., Chintala, S., and LeCun, Y. Convolutional neural networks applied to house numbers digit classification. Proceedings of International Conference on Pattern Recognition ICPR12, (Icpr):10–13, 2012. ISSN 1051-4651. doi: 10.0/Linux-x86 64. Simoncelli, E. P. and Heeger, D. J. A model of neuronal responses in visual area MT. Vision Research, 38(5):743–761, 1998. Sinz, Fabian and Bethge, Matthias. Temporal Adaptation Enhances Efficient Contrast Gain Control on Natural Images. PLoS Computational Biology, 9(1):e1002889, jan 2013. ISSN 1553734X. Sinz, Fabian H and Bethge, Matthias. The Conjoint Effect of Divisive Normalization and Orientation Selectivity on Redundancy Reduction. In NIPS, 2008. Srivastava, Nitish, Hinton, Geoffrey E, Krizhevsky, Alex, Sutskever, Ilya, and Salakhutdinov, Ruslan. Dropout: a simple way to prevent neural networks from overfitting. JMLR, 15(1):1929–1958, 2014. Timofte, Radu, De Smet, Vincent, and Van Gool, Luc. Anchored neighborhood regression for fast example-based super-resolution. In ICCV, 2013. Ulyanov, Dmitry, Vedaldi, Andrea, and Lempitsky, Victor S. Instance normalization: The missing ingredient for fast stylization. CoRR, abs/1607.08022, 2016. Wang, Zhou, Bovik, Alan C, Sheikh, Hamid R, and Simoncelli, Eero P. Image quality assessment: from error visibility to structural similarity. TIP, 13(4):600–612, 2004. Zaremba, Wojciech, Sutskever, Ilya, and Vinyals, Oriol. Recurrent neural network regularization. CoRR, abs/1409.2329, 2014. Zeyde, Roman, Elad, Michael, and Protter, Matan. On single image scale-up using sparserepresentations. In International conference on curves and surfaces, pp. 711–730. Springer, 2010.
# A EFFECT OF SIGMA AND L1 ON CIFAR-10/100 VALIDATION SET
We plot the effect of $\sigma$ and L1 regularization on the validation performance in Figure 6. While sigma makes the most contributions to the improvement, L1 also provides much gain for the original version of LN and BN.
 Figure 6: Validation accuracy on CIFAR-10/100 showing effect of sigma constant (a, b) and L1 regularization (c, d) on BN, LN, and DN
# B LSTM IMPLEMENTATION DETAILS
In LSTM experiments, we found that have an individual normalizer for each non-linearity (sigmoid and tanh) helps the performance for both LN and DN. Eq. 12-14 are the standard LSTM equations, and let $N$ be the normalizer function, our new normalizer is replacing the nonlinearity with Eq. 15-16. This modification can also be thought as combining normalization and activation as a single activation function.
This is different from the released implementation of LN and BN in LSTM, which separately normalized the concatenated vector $W _ { h } \mathbf { h } _ { t - 1 }$ and $W _ { x } { \bf x } _ { t }$ . For all $\mathrm { L N ^ { * } }$ and DN experiments we choose this new formulation, whereas LN experiments are consistent with the released version.
$$\begin{array} { r c l } { \left( \begin{array} { l } { \mathbf { f } _ { t } } \\ { \mathbf { i } _ { t } } \\ { \mathbf { o } _ { t } } \\ { \mathbf { g } _ { t } } \end{array} \right) } & { = } & { W _ { h } \mathbf { h } _ { t - 1 } + W _ { x } \mathbf { x } _ { t } + \mathbf { b } } \\ { \mathbf { c } _ { t } } & { = } & { \sigma ( \mathbf { f } _ { t } ) \odot \mathbf { c } _ { t - 1 } + \sigma ( \mathbf { i } _ { t } ) \odot \mathrm { t a n h } ( \mathbf { g } _ { t } ) } \\ { \mathbf { h } _ { t } } & { = } & { \sigma ( \mathbf { o } _ { t } ) \odot \mathrm { t a n h } ( \mathbf { c } _ { t } ) } \end{array}$$
$$\begin{array} { r c l } { { \bar { \sigma } ( x ) } } & { { = } } & { { \sigma ( N ( x ) ) } } \\ { { \overline { { { \operatorname { t a n h } } } } ( x ) } } & { { = } } & { { \operatorname { t a n h } ( N ( x ) ) } } \end{array}$$
# C MORE RESULTS ON IMAGE SUPER-RESOLUTION
We include results on another standard dataset Set5 Bevilacqua et al. (2012) in Table 8 and show more visual results in Fig. 7.
Table 8: Average test results of PSNR and SSIM on Set5 Dataset.
<table><tr><td>Model</td><td>PSNR (x3)</td><td>SSIM (x3)</td><td>PSNR (x4)</td><td>SSIM (x4)</td></tr><tr><td>Bicubic</td><td>30.41</td><td>0.8678</td><td>28.44</td><td>0.8097</td></tr><tr><td>A+</td><td>32.59</td><td>0.9088</td><td>30.28</td><td>0.8603</td></tr><tr><td>SRCNN</td><td>32.83</td><td>0.9087</td><td>30.52</td><td>0.8621</td></tr><tr><td>BN</td><td>22.85</td><td>0.8027</td><td>20.71</td><td>0.7623</td></tr><tr><td>DN*</td><td>32.83</td><td>0.9106</td><td>30.62</td><td>0.8665</td></tr></table>
 Figure 7: Comparisons at a magnification factor of 4.123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334# INTRIGUING PROPERTIES OF ADVERSARIAL EXAM-PLES
Anonymous authors Paper under double-blind review
# ABSTRACT
It is becoming increasingly clear that many machine learning classifiers are vulnerable to adversarial examples. In attempting to explain the origin of adversarial examples, previous studies have typically focused on the fact that neural networks operate on high dimensional data, they overfit, or they are too linear. Here we show that distributions of logit differences have a universal functional form. This functional form is independent of architecture, dataset, and training protocol; nor does it change during training. This leads to adversarial error having a universal scaling, as a power-law, with respect to the size of the adversarial perturbation. We show that this universality holds for a broad range of datasets (MNIST, CIFAR10, ImageNet, and random data), models (including state-of-the-art deep networks, linear models, adversarially trained networks, and networks trained on randomly shuffled labels), and attacks (FGSM, step l.l., PGD). Motivated by these results, we study the effects of reducing prediction entropy on adversarial robustness. Finally, we study the effect of network architectures on adversarial sensitivity. To do this, we use neural architecture search with reinforcement learning to find adversarially robust architectures on CIFAR10. Our resulting architecture is more robust to white and black box attacks compared to previous attempts.
# 1 INTRODUCTION
An intriguing aspect of deep learning models in computer vision is that while they can classify images with high accuracy, they fail catastrophically when those same images are perturbed slightly in an adversarial fashion (Szegedy et al., 2013; Goodfellow et al., 2014). The prevalence of adversarial examples presents challenges to our understanding of how deep networks generalize and pose security risks in real world applications (Papernot et al., 2016a; Kurakin et al., 2016a). Several techniques have been proposed to defend against adversarial examples. Adversarial training (Goodfellow et al., 2014) augments the training data with adversarial examples. It has been shown that using stronger adversarial attacks in adversarial training can increase the robustness to stronger attacks, but at the cost of a decrease in clean accuracy (i.e. accuracy on samples that have not been adversarially perturbed) (Madry et al., 2017). Defensive distillation (Papernot et al., 2016b), feature squeezing (Xu et al., 2017), and Parseval training (Cisse et al., 2017) have also been shown to make models more robust against adversarial attacks.
The goal of this work is to study the common properties of adversarial examples. We calculate the adversarial error, defined as the difference between clean accuracy and adversarial accuracy at a given size of adversarial perturbation (). Surprisingly, adversarial error has a similar dependence on small values of $\epsilon$ for all network models and datasets we studied, including linear, fully-connected, simple convolutional networks, Inception v3 (Szegedy et al., 2016), Inception-ResNet v2, Inception v4 (Szegedy et al., 2017), ResNet v1, ResNet v2 (He et al., 2016), NasNet-A (Zoph & Le, 2016; Zoph et al., 2017), adversarially trained Inception v3 (Kurakin et al., 2016b) and Inception-ResNet v2 (Tramer et al., 2017), and networks trained on randomly shuffled labels of MNIST. Adversarial \` error due to the Fast Gradient Sign Method (FGSM), its L2-norm variant, and Projected Gradient Descent (PGD) attack grows as a power-law like $A \epsilon ^ { B }$ with $B$ between 0.9 and 1.3. By contrast, we find that adversarial error caused by one-step least likely class method (step l.l.) also scales as a power-law where $B$ is between 1.8 and 2.5 for small $\epsilon$ . This observed universality points to a mysterious commonality between these models and datasets, despite the different number of channels, pixels, and classes present. Adversarial error caused by FGSM on the training set of randomly shuffled labels of MNIST (LeCun & Cortes) also has the power-law form where $B = 1 . 2$ , which implies that the universality is not a result of the specific content of these datasets nor the ability of the model to generalize.
To discover the mechanism behind this universality we show how, at small $\epsilon$ , the success of an adversarial attack depends on the input-logit Jacobian of the model and on the logits of the network. We demonstrate that the susceptibility of a model to FGSM and PGD attacks is in large part dictated by the cumulative distribution of the difference between the most likely logit and the second most likely logit. We observe that this cumulative distribution has a universal form among all datasets and models studied, including randomly produced data. Together, we believe these results provide a compelling story regarding the susceptibility of machine learning models to adversarial examples at small $\epsilon$ .
We show that training with single-step adversarial examples offers protection against large $\epsilon$ attacks (between 0.2 and 32), but does not help appreciably at defending against small $\epsilon$ attacks (below 0.2). At $\epsilon = 0 . 2$ , all ImageNet models we studied incur 10 to $2 5 \%$ adversarial error, and surprisingly, vanilla NASNet-A (best clean accuracy in our study) has a lower adversarial error than adversarially trained Inception-ResNet v2 or Inception v3 (Kurakin et al., 2016b) (Fig. 1(a)). In light of these results, we explore a different avenue to adversarial robustness through architecture selection. We perform neural architecture search (NAS) using reinforcement learning (Zoph & Le, 2016; Zoph et al., 2017). These techniques allow us to find several architectures that are especially robust to adversarial perturbations. In addition, by analyzing the adversarial robustness of the tens-of-thousands of architectures constructed by NAS, we gain insights into the relationship between size of a model, its clean accuracy, and its adversarial robustness. In summary, the key contributions of our work are:
• We study the functional form of adversarial error and logit differences across several models and datasets, which turn out to be universal. We analytically derive the commonality in the power-law tails of the logit differences, and show how it leads to the commonality in the form of adversarial error. • We observe that although the qualitative form of logit differences and adversarial error is universal, it can be quantitatively improved with entropy regularization and better network architectures. • We study the dependence of adversarial robustness on the network architecture via NAS. We show that while adversarial accuracy is strongly correlated with clean accuracy, it is only weakly correlated with model size. Our work leads to architectures that are more robust to white-box and black-box attacks on CIFAR10 (Krizhevsky & Hinton, 2009) than previous studies.
# 2 SURPRISING UNIVERSALITY OF ADVERSARIAL ERROR AT SMALL
FGSM computes adversarial examples as:
$$\boldsymbol { x } ^ { \mathrm { a d v } } = \boldsymbol { x } + \epsilon \mathrm { s i g n } \left( \nabla _ { \boldsymbol { x } } L ( \boldsymbol { x } , \boldsymbol { y } ) \right) ,$$
where $x$ is the clean image, $y$ is the correct label for that image, $x ^ { \mathrm { a d v } }$ is the adversarial image, $\epsilon$ is the size of the adversarial perturbation, and $L ( x , y )$ is the loss function. $\epsilon$ values are specified in range [0,255]. We only study white-box attacks in this section.
We begin with a preliminary examination of the architectural dependence of adversarial robustness. To that end, in Fig. 1 (a) we plot the test set adversarial error due to an FGSM attack as a function of $\epsilon$ for several models on ImageNet (Russakovsky et al., 2015). We note that for $\epsilon < 0 . 2$ , the adversarial error follows a power law form with an exponent between 0.9 and 1.1 for all models studied. Even adversarially trained models Kurakin et al. (2016b), while adversarially much more robust for larger values of $\epsilon$ , follow a similar form and reach as large as $20 \%$ adversarial error at smaller $\epsilon$ .
In light of the surprising commonality in adversarial error at small- $\epsilon$ , we investigate whether there is any way to get a different form for the adversarial error. To do this, we evaluate the adversarial error due to step l.l. attack, which is computed as:
$$x ^ { \mathrm { a d v } } = x - \epsilon \mathrm { s i g n } \left( \nabla _ { x } L ( x , y _ { l . l . } ) \right) ,$$
where $y _ { l . l . }$ is least likely class predicted by the network on clean image $x$ (Kurakin et al., 2016b). The adversarial error also follows a power law, however with a larger exponent. The exponents range from 1.8 to 2.2 for ImageNet models (Fig. 1(b)), and 1.8 to 2.5 for models trained on MNIST (Fig. 2(c)) and CIFAR10. Thus, we see that attack protocol can change the exponent of the observed power-law.
 Figure 1: Test set adversarial error as a function of $\epsilon$ for models trained on ImageNet due to FGSM and step l.l. attack in (a) and (b), respectively. adv. tr. denotes models that are adversarially trained (Kurakin et al., 2016b). In (b), we also show two of the power law fits with straight lines.
To test the limits of the universality observed in Fig. 1, we perform a number of more extensive tests. First, we investigate the effect of architecture by stochastically sampling thousands of different neural networks and train them on MNIST. We then measure their adversarial error due to FGSM on the test set. The architectures we sample are either fully-connected networks with 1-4 hidden layers and 30-2000 hidden nodes in each layer, or simple convolutional networks with dropout rates between 0-0.5. The adversarial error of representative linear, fully-connected, and convolutional networks are shown in Fig. 2 (a). As above, these models all have the same form of adversarial error with a powerlaw dependence on $\epsilon$ with exponents between 0.9 and 1.2.
See Fig. 9 in the Appendix for a plot with all of the generated networks. We perform the same analysis on a 32-layer ResNet trained on CIFAR10 (He et al., 2016), which achieves a $9 2 . 6 \%$ clean accuracy on the test set. The result is shown in Appendix Fig. 10, where the adversarial error follows a power law with an exponent of 0.99 up to an $\epsilon$ of 1.
Next, we probe the relationship between generalization and adversarial robustness following a similar approach to Zhang et al. (2016). In particular, we train a fully connected network on MNIST with shuffled labels until it reaches perfect accuracy on the training set. The adversarial error on the training set is shown in Fig. 2(b). Once again we see that the adversarial error follows an almost identical power-law form at small $\epsilon$ with an exponent of 1.2.
Finally, we further investigate the dependence of adversarial robustness on attack protocol. We plot in Fig. 2 (c) the adversarial error on MNIST with an $L _ { \infty }$ -normalized FGSM attack, an $L _ { 2 }$ - normalized FGSM attack, and a 20-step projected gradient descent (PGD) attack (Madry et al., 2017). We see that despite the anomalous exponent observed for step-l.l. attacks, the other attack methods display the same universality with exponents of 1.1, 1.2, and 1.3 for L2-norm, FGSM, and PGD attacks, respectively. step-l.l. attack on MNIST has an exponent of 2.3.
# 3 A MEAN-FIELD THEORY OF ADVERSARIAL PERTURBATIONS
# 3.1 LINEAR RESPONSE
We now offer a theoretical explanation for the observed universal behavior of adversarial error. The breadth of these observations shows that adversarial error for small adversarial perturbations does not depend on the specifics of the neural network, which implies that we can understand the small $\epsilon$ regime by making simplifying approximations. We begin by considering the linear response of a neural network to adversarial perturbations. Another approach to adversarial examples that considers the linear response of the network can be found in Nayebi & Ganguli (2017). The effect of margins on adversarial robustness has been brought up in ?.
 Figure 2: Points represent adversarial error as a function of $\epsilon$ for models trained on MNIST. Straight lines are power-law fits. (a) FGSM attack on fully-connected 3-layer network (FC), a linear model, and a convolutional network (b) FGSM attack on FC trained on randomly shuffled labels (evaluated on the training set). (c) Different attacks on FC.
We will study an $L _ { 2 }$ -variant of the FGSM attack. Here, the adversarial perturbation is given by,
$$x ^ { \mathrm { a d v } } = x + \epsilon \frac { \nabla _ { x } L } { | | \nabla _ { x } L | | _ { 2 } }$$
instead of the more commonly used $\ell _ { \infty }$ variant. As shown above, the form and exponent of adversarial error is qualitatively insensitive to this choice (see Fig. 2(c)). We will now attempt to compute the minimum $\epsilon$ , that we call $\hat { \epsilon } ( x )$ , required before the class assigned to an input, $x$ , changes. Assuming the network was able to perfectly classify clean images, the adversarial error rate will then be $P ( \bar { \hat { \epsilon } } < \epsilon )$ . While perfect classification will not be achieved in practice, the insensitivity of the form of adversarial error to clean accuracy demonstrated above for many systems suggests that this approximation is sound.
Notationally, we will refer to the output of the network as ${ \hat { y } } _ { i } ( x )$ and the corresponding logits as $h _ { i } ( x )$ . The class prediction of the network will then be arg $\operatorname* { m a x } ( \hat { y } ( x ) ) = \operatorname { a r g m a x } ( h ( x ) )$ . For simplicity we will choose an ordering of the logits such that $h _ { 1 } ( x ) \geq h _ { 2 } ( x ) \geq \cdot \cdot \cdot \geq h _ { N } ( x )$ . We can then enumerate a set of logit-differences, $\Delta _ { i j } ( x ) = h _ { i } ( x ) - \dot { h _ { j } } ( x )$ . If an adversarial perturbation is to successfully cause the network to make an erroneous prediction, then it must be true that $h _ { 1 } ( x ^ { \mathrm { a d v } } ) < h _ { j } ( \dot { x } ^ { \mathrm { a d v } } )$ for at least one $j$ .
We calculate the response of the logits to adversarial perturbation. We consider the linearized response of the network and find that in the limit of small $\epsilon$ (see Appendix 6.2.1),
$$h ( x ^ { \mathrm { a d v } } ) = h ( x ) + \epsilon \frac { J ^ { T } J \delta } { | | J \delta | | _ { 2 } } + \mathcal { O } ( \epsilon ^ { 2 } )$$
where $J _ { i j } = \partial h _ { j } / \partial x _ { i }$ is the input-logit Jacobian of the network and $\delta _ { i } = \partial L / \partial h _ { i }$ is the error of the outputs of the network. For notational convenience we will define $\Gamma ( x ) = J ^ { T } J \delta / | J \delta | | _ { 2 }$ . In this linear model we therefore predict that the logit-differences will scale as follows,
$$\Delta _ { i j } ( x ^ { \mathrm { a d v } } ) \approx \Delta _ { i j } ( x ) + \epsilon ( \Gamma _ { i } ( x ) - \Gamma _ { j } ( x ) ) + \mathcal { O } ( \epsilon ^ { 2 } ) .$$
Recall that the adversarial perturbation will successfully cause the network to just barely misclassify an input precisely when $\Delta _ { 1 j } ( x ^ { \mathrm { a d v } } ) = 0$ for at least one $j$ . We can predict per-class $\epsilon$ -thresholds beyond which the network will misclassify a given point,
$$\hat { \epsilon } _ { j } ( x ) = \frac { \Delta _ { 1 j } ( x ) } { \Gamma _ { j } ( x ) - \Gamma _ { 1 } ( x ) } .$$
Together this allows us to compute a linear approximation to $\hat { \epsilon }$ given by $\hat { \epsilon } _ { \mathrm { l i n e a r } } ( x ) = \operatorname* { m i n } _ { j } ( \epsilon _ { j } ( x ) )$
We can confirm that the change in the logits for small changes in the inputs is well-described by this linear model. This is shown in fig. 3 (a) where we see the logits for a single example upon perturbation over a range of $\epsilon$ . In particular, for small $\epsilon$ we see an excellent agreement between the linear approximation and the true logit dynamics. We also see that the $\epsilon$ where the first and second logit cross is well-approximated by the linear prediction. In Fig. 3 (b) we plot $\hat { \epsilon } _ { \mathrm { l i n e a r } } ( x )$ against $\hat { \epsilon } ( x )$ evaluated on every MNIST example in the test set. The white dashed line is the line $\hat { \epsilon } ( x ) = \hat { \epsilon } _ { \mathrm { l i n e a r } } ( x )$ . We see that when $\hat { \epsilon } ( x )$ is small the $\hat { \epsilon } _ { \mathrm { l i n e a r } } ( x )$ concentrate increasingly around the $\hat { \epsilon } ( x )$ . Together these results show that the linear response predictions are valid for small adversarial perturbations.
 Figure 3: Linear approximation for the response of the logits to adversarial perturbation. (a) The dynamics of logits to an adversarial perturbation as a function of size $\epsilon$ for a single training example. Dashed lines show the linear approximation. Colors indicate the ranking of the logit from largest (red) to smallest (blue). (b) The smallest $\epsilon$ needed to fool the network (ˆ) for individual test examples compared with the prediction from the linear theory. (c) Mean field prediction of $\hat { \epsilon }$ .
While the linear model outlined above gives excellent agreement in the $\epsilon 0$ limit, the $\Gamma _ { i } ( x )$ are themselves complicated objects (being functions of the Jacobian). This makes the analytic evaluation of Eq. (6) challenging. We therefore introduce a “mean-field” approximation to Eq. (6) by replacing $\Gamma _ { i } ( x )$ by its average over the dataset, $\langle \Gamma _ { i } ( x ) \rangle$ . Similar independence approximations have previously been successful in analyzing the expressivity and trainability of neural networks (Schoenholz et al., 2016; Poole et al., 2016). Finally, we observe that the vast majority of the time (for example, more than $9 5 \%$ of successful FGSM attacks for $\epsilon < 5 0$ ), it is $\Delta _ { 1 2 } ( x ^ { \mathrm { a d v } } )$ that goes to zero before any of the other $\Delta _ { 1 j }$ . We therefore assume that this will be the dominant failure mode for neural networks and write down a mean-field estimate for $\hat { \epsilon }$ ,
$$\hat { \epsilon } _ { \mathrm { M . F . } } = \frac { \Delta _ { 1 2 } ( x ) } { \langle \Gamma _ { 2 } \rangle - \langle \Gamma _ { 1 } \rangle } .$$
We show in Fig. 3 (c) that this approximation continues to be strongly correlated with ˆ. Together these results suggest that the adversarial error rate for perturbations of size $\epsilon$ will be
$$P ( \hat { \epsilon } \le \epsilon ) \approx P \left[ \Delta _ { 1 2 } \le \epsilon ( \langle \Gamma _ { 2 } \rangle - \langle \Gamma _ { 1 } \rangle ) \right] = P ( \Delta _ { 1 2 } \le \tilde { \epsilon } )$$
where we have defined $\tilde { \epsilon } = \epsilon ( \left. \Gamma _ { 2 } \right. - \left. \Gamma _ { 1 } \right. )$ to be a network-specific rescaling of $\epsilon$ . We therefore expect the adversarial error rate at small $\epsilon$ to be dictated by the cumulative distribution of $\Delta _ { 1 2 }$ for attacks that effectively target the second most likely class (e.g. FGSM, PGD ...etc.).
# 3.2 UNIVERSAL PROPERTIES OF THE LOGIT DIFFERENCE DISTRIBUTION
With the results from the preceding section in hand, we now investigate the distribution of logit differences, $P ( \Delta _ { 1 j } )$ . Since we are particularly interested in the small $\epsilon$ regime, we seek to compute $P ( \Delta _ { 1 j } )$ for small $\Delta _ { 1 j }$ . To make progress we will again make a mean field approximation and assume that each of the logits are i.i.d. with arbitrary distribution. With this approximation we find that for small $\Delta _ { 1 j }$ (see Appendix 6.2.2),
$$P ( \Delta _ { 1 j } ) = C \Delta _ { 1 j } ^ { j - 2 } + \mathcal { O } ( \Delta _ { 1 j } ^ { j - 1 } )$$
where $C$ is a network specific constant. An interesting consequence of this result is that the difference that we are particularly interested in, $P ( \Delta _ { 1 2 } )$ , scales as $\mathcal { O } ( 1 )$ as $\Delta _ { 1 2 } 0$ . This implies that, generically, we expect the most likely logit and second most likely logit to have a finite probability of being arbitrarily close together. We interpret this as an inherent uncertainty in the predictions of neural networks.
While it is not obvious that the assumption of a factorial logit distribution is valid here, we will see that Eq. (9) captures the universal features of the distribution at small values of the logit difference. Indeed, from the previous section we see that the form of Eq. (9) implies that the adversarial error rate should scale as follows
$$P ( \hat { \epsilon } < \epsilon ) \approx P ( \Delta _ { 1 2 } < \tilde { \epsilon } ) \approx C \tilde { \epsilon } + \mathcal { O } ( \tilde { \epsilon } ^ { 2 } )$$
as was broadly observed in the previous section.
To further test whether or not the mean field approximation is valid, we evaluate $\Delta _ { 1 j }$ for a number of different neural network architectures and datasets. We find that on all datasets and models studied, the $\Delta _ { 1 j }$ distributions have power-law tails. As predicted, $\Delta _ { 1 2 }$ has a power-law tail with an exponent of about 0, and $\Delta _ { 1 j }$ for $j > 2$ have power-law tails with positive exponents increasing with $j$ . We note, however, that the powers are typically not integral for large $j$ . It seems likely that this breakdown is the result of correlations between the logits. In Fig. 4, we compare distribution of $\Delta _ { 1 j }$ with $j = 2 , 3 , 4$ for ImageNet and logits that are independently sampled from a uniform distribution for 5 million samples with 10 classes. In Fig. 6 we see similar results for MNIST. Together these results verify our predictions over a vast set of networks and datasets.
The empirical results above show that adversarial error has a power-law form for well-studied and random datasets, simple full connected networks as well as complicated state-of-the-art models. It follows that the prevalence and commonality of adversarial examples is not due to the depth of the model (for example, see the linear model in Fig. 2 (a)), or the high-dimensionality of the datasets. Rather, they are due to the fact that lots of examples have small $\Delta _ { 1 2 }$ values. This makes it easy to find examples to fool the model at test-time.
It is interesting that the distribution of $\Delta _ { 1 j }$ , at small $\Delta _ { 1 j }$ , for trained models is essentially identical to that of i.i.d. random logits (especially for $j = 2$ ). This suggests that while our training procedures are good at modifying the largest logit in a way that leads to good clean accuracies, these procedures do not induce strong enough correlations between the logits to disrupt the essential scaling uncovered above. This problem is reminiscent of the problem distillation (Hinton et al., 2015) attempts to solve, by incorporating information about ratios of incorrect classes. This might be one of the reasons defensive distillation improves adversarial robustness. It would be interesting to study the distributions of logit differences during training of distillation networks.
 Figure 4: (a) Distribution of $\Delta _ { 1 j }$ of NASNet-A trained on ImageNet. (b) Distribution of $\Delta _ { 1 j }$ for logits that are sampled independently from a uniform random distribution for 5 million samples with 10 classes. $\Delta _ { 1 j }$ of other models are in Appendix Fig. 14
Given the large density of small more robust. Our proposed los $\Delta _ { 1 2 }$ values, we study an entronction can be written as: $\begin{array} { r } { \mathrm { \bar { l o s s } } = \mathrm { o l d } \mathrm { \bar { l o s s } } - \lambda \sum _ { i = 1 } ^ { n } p _ { i } \log p _ { i } } \end{array}$ where is a hyperparameter, $n$ is the number of classes, and $p _ { i }$ are the outputs of the neural network. This regularization term has been used by Miyato et al. (2017) for semi-supervised learning tasks. It aims to increase the confidence of the network on each sample, which is the opposite of previous regularization attempts that penalized confidence to increase generalization accuracy (Pereyra et al.,
2017; Szegedy et al., 2015). By penalizing the entropy of the softmax outputs, we aim to increase the logit differences.
In Fig. 5, we show that entropy regularization with a $\lambda = 4 . 5$ increases the adversarial robustness both for regularly trained networks and step l.l. adversarially trained networks, and both for permutation invariant and regular MNIST. We note that the same qualitative results hold for other values of $\lambda$ we tried. Despite the increase in adversarial accuracy, the permutation invariant MNIST model has $0 . 8 \%$ lower clean accuracy when trained with the entropy penalty. In Appendix Fig. 11, we show that a wide ResNet trained with the entropy regularizer has improved robustness with no loss in clean accuracy.
 Figure 5: Step l.l. attack adversarial accuracy as a function of $\epsilon$ for CNN and permutation invariant MNIST in (a) and (b), respectively. Regular training (purple), entropy regularization (red), adversarial training (green), and adversarial training with entropy regularization (blue) have been implemented. Adversarial training was done using the step l.l. method. In (c), we show the PGD attack adversarial accuracy on permutation invariant MNIST trained with and without step l.l. adversarial training.
We investigate whether the increased adversarial robustness is due to increased logit differences. In Fig. 6, we plot the distribution of $\Delta _ { 1 j }$ for $j$ up to 4, for two networks trained on permutation invariant MNIST, with and without entropy regularization. As expected, margins are shifted to larger values and density of samples with small $\Delta _ { 1 j }$ are reduced. The tails still follow a power-law form with the same exponents, however there are fewer samples with small margins compared to a regularly trained network. Although entropy regularization made our networks white-box attacks, it did not lead to a significant improvement against black-box attacks. For this reason, we focus on the influence of network architectures on adversarial sensitivity below.
 Figure 6: Distribution of $\Delta _ { 1 j }$ up to $j = 5$ for permutation invariant MNIST trained with and without entropy regularization in red and purple, respectively.
# 4 ROLE OF NETWORK ARCHITECTURES IN ADVERSARIAL ROBUSTNESS
Several recent papers observe that larger networks are more robust against adversarial examples, regardless if they are adversarially trained or not (Kurakin et al., 2016b; Madry et al., 2017). However, it is not clear if network architectures play an important role in adversarial robustness. Are larger models more robust because they have more trainable parameters, or simply because they have higher clean accuracy? Is it possible to find more robust network architectures that do not necessarily have more parameters? We run several experiments to answer these questions, as well as to find an adversarially more robust model on CIFAR10. We perform neural architecture search (NAS) with reinforcement learning. Our search space and procedure are almost exactly the same as in Zoph et al. (2017). One difference is that we restrict the search space so that the normal cell must be the same as the reduction cell. This reduces the complexity of the search space as now we have only half as many predictions. Finally, we increase the number of prediction steps from 5 to 7 to slightly gain back the complexity that was lost when we restricted the normal cell to be equal to the reduction cell.
We carry out two experiments:
• Experiment 1: NAS where child models are trained with clean and step l.l. adversarial examples and the reward is computed on the validation set with FGSM adversarial accuracy at $\epsilon = 8$ . • Experiment 2: NAS where child models are trained with clean and PGD adversarial examples and the reward is computed on the validation set with FGSM adversarial accuracy at $\epsilon = 8$ .
In both experiments, child models are trained for 10 epochs on a training set of 25 thousand samples. Child models are trained on mini-batches where half of the samples are adversarially perturbed, following the procedure in (Kurakin et al., 2016b). At the end of each experiment, we pick the child model with the highest FGSM adversarial accuracy at $\epsilon = 8$ on the validation set of 5000 samples, and scale up the number of filters. We train the enlarged models for 100 epochs on the full training set of 45000 samples for 12 different hyperparameter sets, and pick the one with the highest adversarial accuracy on the validation set. Finally, we report below the performance of these models on a held-out test set of 10 thousand samples. To provide a comparison with the results of our two experiments, we also run a vanilla NAS where the reward is clean validation accuracy. We will refer to the best architecture from vanilla NAS as NAS Baseline. When trained using the setup above only on clean examples, NAS Baseline reaches a test set accuracy of $9 5 . 3 \%$ .
 Figure 7: (a) step l.l. adversarial accuracy of NAS Baseline trained with and without step l.l. adversarial examples in green and red, respectively. Best model from Experiment 1 is shown in blue. (b) PGD adversarial accuracy of NAS Baseline trained with and without PGD adversarial examples in green and red, respectively. Best model from Experiment 2 is shown in blue.
We present the results of Experiment 1 in Fig 7(a). Here the green curve is the adversarial accuracy NAS Baseline. The blue curve is the adversarial accuracy of a network architecture that was found by Experiment 1. Both of these architectures are trained with the same adversarial training procedure. We try the same sets of hyperparameters and report here the models with best adversarial accuracy at $\epsilon = 8$ on the validation set. Adversarial training reduced the clean accuracy by $0 . 2 \%$ . Adversarially trained models both have clean accuracy of $9 5 . 1 \%$ on the test set, whereas the model that was trained without adversarial training reached $9 5 . 3 \%$ accuracy.
We next use PGD adversarial examples in the training of child models, to find architectures that are more robust to any adversarial attack within an $\epsilon$ ball (Madry et al., 2017). Following the training procedure by Madry et al. (2017), we use 7 steps of size 2, for a total $\epsilon = 8$ . We present the results of Experiment 2 in Fig. 7(b). As was the case in Experiment 1, the architecture found by adversarial NAS leads to a more robust model. At $\epsilon = 8$ , the architecture from Experiment 2 reaches a $17 \%$ higher adversarial accuracy on PGD examples. We compare our results to the results by Madry et al. (2017). Madry et al. (2017) trained only on PGD examples, whereas half of our minibatches are clean examples. Despite this, we match their accuracy on white-box PGD attacks. Against other white- and black-box attacks our model is more robust, and our clean accuracy is $5 . 9 \%$ higher. We also note that NAS Baseline model has 4.9 million trainable parameters, whereas the model from Experiments 1 and 2 have 2.3 million and 3.5 million parameters, respectively. NAS found an adversarially more robust architecture with many fewer parameters. Best architecture from Experiment 2 and NAS Baseline are presented in Appendix Fig. 16. Finally, we study the performance statistics of child models during NAS. In Fig. 8, we report the results for 9360 child models that were trained during Experiment 1. As explained above, these models are only trained for 10 epochs. In Fig. 8(a), we see that the correlation between adversarialy accuracy and the number of trainable parameters of the model is not very strong. On the other hand, adversarial accuracy is strongly correlated with clean accuracy (Fig. 8(b)). We hypothesize that this is the reason both Madry et al. (2017) and Kurakin et al. (2016b) found that making networks larger increased adversarial robustness, because it also increased the clean accuracy. This implies that commonly used architectures, like Inception v3 and ResNet, benefit from having more parameters. This however was not the case for most child models during NAS. On the other hand, having a high clean accuracy is not sufficient for adversarial robustness. As seen in Fig. 8(c), there is a large variance in the adversarial accuracy of models with good clean accuracy. The range of adversarial accuracies in the histogram of models with larger than $85 \%$ clean accuracy is $22 \%$ and the standard deviation is $2 . 6 \%$ . For this reason, our experiments led to more robust architectures than NAS Baseline.
Table 1: Performance of our best architecture from Experiment 2 at $\epsilon = 8$ . Black-box attacks are sourced from a copy of the network independently initialized and trained.
<table><tr><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1></td><td rowspan=1 colspan=3>White-box</td><td rowspan=1 colspan=3>Black-box</td></tr><tr><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1>Clean</td><td rowspan=1 colspan=1>FGSM</td><td rowspan=1 colspan=1>step 1.1.</td><td rowspan=1 colspan=1>PGD</td><td rowspan=1 colspan=1>FGSM</td><td rowspan=1 colspan=1>step 1.1.</td><td rowspan=1 colspan=1>PGD</td></tr><tr><td rowspan=1 colspan=1>Madry et al. (2017)</td><td rowspan=1 colspan=1>87.3%</td><td rowspan=1 colspan=1>56.1%</td><td rowspan=1 colspan=1>1</td><td rowspan=1 colspan=1>50.0%</td><td rowspan=1 colspan=1>67.0 %</td><td rowspan=1 colspan=1>1</td><td rowspan=1 colspan=1>64.2%</td></tr><tr><td rowspan=1 colspan=1>This work</td><td rowspan=1 colspan=1>93.2%</td><td rowspan=1 colspan=1>63.6%</td><td rowspan=1 colspan=1>77.9%</td><td rowspan=1 colspan=1>50.1%</td><td rowspan=1 colspan=1>78.1 %</td><td rowspan=1 colspan=1>84.9%</td><td rowspan=1 colspan=1>75.0%</td></tr></table>
 Figure 8: Performance of child models on the validation set. FGSM adversarial accuracy at $\epsilon = 8$ vs. number of trainable parameters and clean accuracy in (a) and (b), respectively. Black dots represent each child model, purple line is a running average. Figure (c) is the histogram of the adversarial accuracy for models with clean accuracy larger than $85 \%$ .
# 5 CONCLUSION
In this paper we studied common properties of adversarial examples across different models and datasets. We theoretically derived a universality in logit differences and adversarial error of machine learning models. We showed that architecture plays an important role in adversarial robustness, which correlates strongly with clean accuracy.
# REFERENCES
Moustapha Cisse, Piotr Bojanowski, Edouard Grave, Yann Dauphin, and Nicolas Usunier. Parseval networks: Improving robustness to adversarial examples. In International Conference on Machine Learning, pp. 854–863, 2017.
Ian J Goodfellow, Jonathon Shlens, and Christian Szegedy. Explaining and harnessing adversarial examples. arXiv preprint arXiv:1412.6572, 2014.
Kaiming He, Xiangyu Zhang, Shaoqing Ren, and Jian Sun. Deep residual learning for image recognition. In Proceedings of the IEEE conference on computer vision and pattern recognition, pp. 770–778, 2016.
Geoffrey Hinton, Oriol Vinyals, and Jeff Dean. Distilling the knowledge in a neural network. arXiv preprint arXiv:1503.02531, 2015.
Alex Krizhevsky and Geoffrey Hinton. Learning multiple layers of features from tiny images. 2009.
Alexey Kurakin, Ian Goodfellow, and Samy Bengio. Adversarial examples in the physical world. arXiv preprint arXiv:1607.02533, 2016a.
Alexey Kurakin, Ian Goodfellow, and Samy Bengio. Adversarial machine learning at scale. arXiv preprint arXiv:1611.01236, 2016b.
Yann LeCun and Corinna Cortes. The mnist database of handwritten digits. http://yann. lecun. com/exdb/mnist/.
Aleksander Madry, Aleksandar Makelov, Ludwig Schmidt, Dimitris Tsipras, and Adrian Vladu. Towards deep learning models resistant to adversarial attacks. arXiv preprint arXiv:1706.06083, 2017.
Takeru Miyato, Shin-ichi Maeda, Masanori Koyama, and Shin Ishii. Virtual adversarial training: a regularization method for supervised and semi-supervised learning. arXiv preprint arXiv:1704.03976, 2017.
Aran Nayebi and Surya Ganguli. Biologically inspired protection of deep networks from adversarial attacks. arXiv preprint arXiv:1703.09202, 2017.
Nicolas Papernot, Patrick McDaniel, Ian Goodfellow, Somesh Jha, Z Berkay Celik, and Ananthram Swami. Practical black-box attacks against deep learning systems using adversarial examples. arXiv preprint arXiv:1602.02697, 2016a.
Nicolas Papernot, Patrick McDaniel, Xi Wu, Somesh Jha, and Ananthram Swami. Distillation as a defense to adversarial perturbations against deep neural networks. In Security and Privacy (SP), 2016 IEEE Symposium on, pp. 582–597. IEEE, 2016b.
Gabriel Pereyra, George Tucker, Jan Chorowski, Łukasz Kaiser, and Geoffrey Hinton. Regularizing neural networks by penalizing confident output distributions. arXiv preprint arXiv:1701.06548, 2017.
Ben Poole, Subhaneil Lahiri, Maithreyi Raghu, Jascha Sohl-Dickstein, and Surya Ganguli. Exponential expressivity in deep neural networks through transient chaos. In Advances In Neural Information Processing Systems, pp. 3360–3368, 2016.
Olga Russakovsky, Jia Deng, Hao Su, Jonathan Krause, Sanjeev Satheesh, Sean Ma, Zhiheng Huang, Andrej Karpathy, Aditya Khosla, Michael Bernstein, et al. Imagenet large scale visual recognition challenge. International Journal of Computer Vision, 115(3):211–252, 2015.
Samuel S Schoenholz, Justin Gilmer, Surya Ganguli, and Jascha Sohl-Dickstein. Deep information propagation. arXiv preprint arXiv:1611.01232, 2016.
Christian Szegedy, Wojciech Zaremba, Ilya Sutskever, Joan Bruna, Dumitru Erhan, Ian Goodfellow, and Rob Fergus. Intriguing properties of neural networks. arXiv preprint arXiv:1312.6199, 2013.
Christian Szegedy, Wei Liu, Yangqing Jia, Pierre Sermanet, Scott Reed, Dragomir Anguelov, Dumitru Erhan, Vincent Vanhoucke, and Andrew Rabinovich. Going deeper with convolutions. In Proceedings of the IEEE conference on computer vision and pattern recognition, pp. 1–9, 2015.
Christian Szegedy, Vincent Vanhoucke, Sergey Ioffe, Jon Shlens, and Zbigniew Wojna. Rethinking the inception architecture for computer vision. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pp. 2818–2826, 2016.
Christian Szegedy, Sergey Ioffe, Vincent Vanhoucke, and Alexander A Alemi. Inception-v4, inception-resnet and the impact of residual connections on learning. In AAAI, pp. 4278–4284, 2017.
Florian Tramer, Alexey Kurakin, Nicolas Papernot, Dan Boneh, and Patrick McDaniel. Ensemble \` adversarial training: Attacks and defenses. arXiv preprint arXiv:1705.07204, 2017.
Weilin Xu, David Evans, and Yanjun Qi. Feature squeezing: Detecting adversarial examples in deep neural networks. arXiv preprint arXiv:1704.01155, 2017.
Chiyuan Zhang, Samy Bengio, Moritz Hardt, Benjamin Recht, and Oriol Vinyals. Understanding deep learning requires rethinking generalization. arXiv preprint arXiv:1611.03530, 2016.
Barret Zoph and Quoc V Le. Neural architecture search with reinforcement learning. arXiv preprint arXiv:1611.01578, 2016.
Barret Zoph, Vijay Vasudevan, Jonathon Shlens, and Quoc V Le. Learning transferable architectures for scalable image recognition. arXiv preprint arXiv:1707.07012, 2017.
# 6 APPENDIX
# 6.1 FURTHER EXPERIMENTS
 Figure 9: Adversarial error for hundreds of models trained on MNIST, including fully-connected and convolutional models. We only show models with clean accuracy larger than $80 \%$ .
 Figure 10: Points represent the adversarial error due to FGSM as a function of $\epsilon$ for a 32-layer ResNet trained on CIFAR10. Straight line is a power law fit with an exponent of 0.99.
 Figure 11: Effect of adding an entropy regularization $( \lambda = 3 . 0 )$ ): step l.l. adversarial accuracy of wide ResNet on CIFAR10, with and without entropy regularization. Both models have a clean accuracy of $9 4 \%$ . They were both trained for 100 epochs with the same hyperparameters.
# 6.2 DERIVATIONS
Here we derive several of the results found in the main text.
# 6.2.1 LINEAR RESPONSE
First, we compute the linear response of the network to the $L _ { 2 }$ FGSM attack. Let, $f : \mathbb { R } ^ { N } \to \mathbb { R } ^ { M }$ be a neural network (or other model) structured such that $f = \operatorname { s o f t m a x } \circ h$ where $h : \mathbb { R } ^ { N } \to \mathbb { R } ^ { M }$ maps inputs to logits. Additionally define a loss $L : \mathbb { R } ^ { M } \to \mathbb { R }$ which can be cross-entropy, $L ^ { 2 }$ , etc.. To generate adversarial examples we start with an input $\boldsymbol { x } \in \mathbb { R } ^ { N }$ and a corresponding target $t \in \mathbb { R } ^ { M }$ such that $t _ { \beta } = 1$ if $\beta = \gamma$ for some $\gamma$ and $t _ { \beta } = 0$ otherwise. We assume our network gets the answer correct so that $h _ { \gamma } > h _ { \beta }$ for all $\beta \neq \gamma$ . Then we apply the adversarial perturbation,
$$x _ { \alpha } ^ { \prime } = x _ { \alpha } + \epsilon \frac { \nabla _ { x } L } { | | \nabla _ { x } L | | _ { 2 } } .$$
Note that we can write
$$\nabla _ { x } L = { \frac { \partial L } { \partial x _ { \alpha } } } = \sum _ { \beta } { \frac { \partial h _ { \beta } } { \partial x _ { \alpha } } } { \frac { \partial L } { \partial h _ { \beta } } } = \sum _ { \beta } J _ { \alpha \beta } { \frac { \partial L } { \partial h _ { \beta } } } = J \delta .$$
Where we associate $J _ { \alpha \beta } = \partial h _ { \beta } / \partial x _ { \alpha }$ with the input-to-logit Jacobian linking the inputs to the logits and $\delta = \partial L / \partial h _ { \beta }$ the error of the outputs of the network.
 Figure 12: Fully connected network trained on MNIST with hinge loss. (a) Distributions of logit differences. (b) Red dots represent the adversarial error when FGSM attack uses the same hinge loss from training. Blue dots represent the adversarial error when FGSM attack uses a cross-entropy loss to create the adversarial examples.The line is a power-law fit with an exponent of 0.98
 Figure 13: Fully connected network trained on MNIST with L2-norm loss. (a) Distributions of logit differences. (b) Black dots represent the adversarial error due to FGSM. The line is a power-law fit with an exponent of 1.02
We can compute the change to the logits of the network due to this perturbation. We find,
$$\begin{array} { l } { \displaystyle h ( \boldsymbol { x } ^ { \prime } ) = h ( \boldsymbol { x } + \epsilon \nabla _ { \boldsymbol { x } } L / | | \nabla _ { \boldsymbol { x } } L | | _ { 2 } ) } \\ { \displaystyle h _ { \beta } ^ { \prime } \approx h _ { \beta } + \frac { \epsilon } { | | \nabla _ { \boldsymbol { x } } L | | _ { 2 } } \sum _ { \alpha } \frac { \partial h _ { \beta } } { \partial x _ { \alpha } } \frac { \partial L } { \partial x _ { \alpha } } + \mathcal { O } ( \epsilon ^ { 2 } ) } \\ { \displaystyle ~ = h _ { \beta } + \frac { \epsilon } { | | \nabla _ { \boldsymbol { x } } L | | _ { 2 } } \sum _ { \alpha \delta } \frac { \partial h _ { \beta } } { \partial x _ { \alpha } } \frac { \partial h _ { \delta } } { \partial x _ { \alpha } } \frac { \partial L } { \partial h _ { \delta } } } \end{array}$$
where we have plugged in for eq. (11). Expressing the above equation in terms of the Jacobian, it follows that we can write the effect of the adversarial perturbation on the logits by,
$$h ^ { \prime } = h + \epsilon \frac { J ^ { T } J \delta } { | | J \delta | | _ { 2 } }$$
as postulated.
 Figure 14: (a) Distribution of $\Delta _ { 1 N }$ for other ImageNet models.
 Figure 15: (a) FGSM adversarial accuracy of NAS Baseline trained with and without step l.l. adversarial examples in green and red, respectively. Best model from Experiment 1 is shown in blue. (b) FGSM adversarial accuracy of NAS Baseline trained with and without PGD adversarial examples in green and red, respectively. Best model from Experiment 2 is shown in blue.
6.2.2 UNIVERSAL PROPERTIES OF THE LOGIT DIFFERENCE DISTRIBUTION
We now show that
$$P ( \Delta _ { 1 j } ) = C \Delta _ { 1 j } ^ { j - 2 } + \mathcal { O } ( \Delta _ { 1 j } ^ { j - 1 } ) .$$
To make progress we will again make a mean field approximation and assume that each of the logits are i.i.d. with arbitrary distribution $P ( h )$ . We denote the cumulative distribution $F ( h )$ . While it is not obvious that the factorial approximation is valid here, we will see that the resulting distribution of $P ( \Delta _ { 1 j } )$ shares many qualitative similarities with the distribution observed in real networks.
We first change variables from the logits to a sorted version of the logits, $r _ { i }$ . The ranked logits are defined such that $r _ { 1 } = \operatorname* { m a x } ( \{ h _ { i } \} )$ , $r _ { 2 } = \mathrm { m a x } ( \{ h _ { i } \} \backslash \{ r _ { 1 } \} ) , \cdot \cdot \cdot$ . Our first result is to compute the resulting joint distribution between $r _ { 1 }$ and $r _ { j }$ ,
$$P _ { j } ( r _ { 1 } , r _ { j } ) = A ( N , j ) F ^ { N - j } ( r _ { j } ) \left[ F ( r _ { 1 } ) - F ( r _ { j } ) \right] ^ { j - 2 } P ( r _ { j } ) P ( r _ { 1 } )$$
where $A ( N , j ) = N ( N - 1 ) { \binom { N - 2 } { j - 2 } }$ is a combinatorial factor. Eq. (18) has a simple interpretation. $F ^ { N - j } ( r _ { j } )$ is the probability that there are $N - j$ variables less than $r _ { j }$ ; $[ F ( r _ { 1 } ) - F ( r _ { j } ) ] ^ { j - 2 }$ is the probability that $j - 2$ variables are between $r _ { j }$ and $r _ { 1 }$ ; $P ( r _ { j } ) P ( r _ { 1 } )$ is the probability that there is one variable equal to each of $r _ { 1 }$ and $r _ { j }$ . The combinatorial factor can be understood since there are $N$ ways of selecting $r _ { 1 }$ , $N - 1$ ways of selecting $r _ { j }$ , and $\binom { N - 2 } { j - 2 }$ ways of choosing $j - 2$ variables out of the remaining $N - 2$ to be between $r _ { j }$ and $r _ { 1 }$ .
In terms of eq. (18) we can compute the distribution over $\Delta _ { 1 j }$ to be given by,
$$\begin{array} { l } { { P ( \Delta _ { 1 j } ) = \displaystyle \int d r P _ { j } ( r + \Delta _ { 1 j } , r ) } } \\ { { \displaystyle \qquad = A ( N , j ) \int d r F ^ { N - j } ( r ) \left[ F ( r + \Delta _ { 1 j } ) - F ( r ) \right] ^ { j - 2 } P ( r ) P ( r + \Delta _ { 1 j } ) . } } \end{array}$$
We can analyze this equation for small $\Delta _ { 1 j }$ . Expanding to lowest order in $\Delta _ { 1 j }$ ,
$$\begin{array} { l } { P ( \Delta _ { 1 j } ) \approx A ( N , j ) \displaystyle \int d r { \cal F } ^ { N - j } ( r ) \left[ { \cal F } ( r ) + \Delta _ { 1 j } P ( r ) - { \cal F } ( r ) \right] ^ { j - 2 } P ( r ) \left[ P ( r ) + \Delta _ { 1 j } \frac { d P ( r ) } { d r } \right] } \\ { \displaystyle ~ ( \Delta ( N , j ) \Delta _ { 1 j } ^ { j - 2 } \int d r { \cal F } ^ { N - j } ( r ) P ^ { j } ( r ) + \mathcal { O } ( \Delta _ { 1 j } ^ { j - 1 } ) . ~ } \end{array}$$
Since the term in the integral does not depend on $\Delta _ { 1 j }$ the result follows with,
$${ \cal C } = { \cal N } ( N - 1 ) { \binom { N - 2 } { j - 2 } } \int d r F ^ { N - j } ( r ) P ^ { j } ( r ) .$$
# 6.2.3 ARCHITECTURES
 Figure 16: Left: Best architecture from Experiment 1. Right: Architecture of NAS Baseline. We note that the architecture from Experiment 1 is “longer” and “narrower” than previous architectures found by NAS for higher clean accuracy (Zoph & Le, 2016; Zoph et al., 2017).123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239# LEARNING INTRINSIC SPARSE STRUCTURES WITHIN LONG SHORT-TERM MEMORY
Wei Wen∗, Yiran Chen & Hai Li Electrical and Computer Engineering, Duke University {wei.wen,yiran.chen,hai.li}@duke.edu
Yuxiong $\mathbf { H e } ^ { \dagger }$ , Samyam Rajbhandari†, Minjia Zhang†, Wenhan Wang†, Fang Liu§ & Bin $\mathbf { H } \mathbf { u } ^ { \mathrm { \ S } }$ Business AI† and Bing§, Microsoft {yuxhe,samyamr,minjiaz,wenhanw,fangliu,binhu}@microsoft.com
# ABSTRACT
Model compression is significant for the wide adoption of Recurrent Neural Networks (RNNs) in both user devices possessing limited resources and business clusters requiring quick responses to large-scale service requests. This work aims to learn structurally-sparse Long Short-Term Memory (LSTM) by reducing the sizes of basic structures within LSTM units, including input updates, gates, hidden states, cell states and outputs. Independently reducing the sizes of basic structures can result in inconsistent dimensions among them, and consequently, end up with invalid LSTM units. To overcome the problem, we propose Intrinsic Sparse Structures (ISS) in LSTMs. Removing a component of ISS will simultaneously decrease the sizes of all basic structures by one and thereby always maintain the dimension consistency. By learning ISS within LSTM units, the obtained LSTMs remain regular while having much smaller basic structures. Based on group Lasso regularization, our method achieves $1 0 . 5 9 \times$ speedup without losing any perplexity of a language modeling of Penn TreeBank dataset. It is also successfully evaluated through a compact model with only 2.69M weights for machine Question Answering of SQuAD dataset. Our approach is successfully extended to nonLSTM RNNs, like Recurrent Highway Networks (RHNs). Our source code is available1.
# 1 INTRODUCTION
Model Compression (Jaderberg et al. (2014), Han et al. (2015a), Wen et al. (2017), Louizos et al. (2017)) is a class of approaches of reducing the size of Deep Neural Networks (DNNs) to accelerate inference. Structure Learning (Zoph & Le (2017), Philipp & Carbonell (2017), Cortes et al. (2017)) emerges as an active research area for DNN structure exploration, potentially replacing human labor with machine automation for design space exploration. In the intersection of both techniques, an important area is to learn compact structures in DNNs for efficient inference computation using minimal memory and execution time without losing accuracy. Learning compact structures in Convolutional Neural Networks (CNNs) have been widely explored in the past few years. Han et al. (2015b) proposed connection pruning for sparse CNNs. Pruning method also works successfully in coarse-grain levels, such as pruning filters in CNNs (Li et al. (2017)) and reducing neuron numbers (Alvarez & Salzmann (2016)). Wen et al. (2016) presented a general framework to learn versatile compact structures (neurons, filters, filter shapes, channels and even layers) in DNNs.
Learning the compact structures in Recurrent Neural Networks (RNNs) is more challenging. As a recurrent unit is shared across all the time steps in sequence, compressing the unit will aggressively affect all the steps. A recent work by Narang et al. (2017) proposes a pruning approach that deletes up to $9 0 \%$ connections in RNNs. Connection pruning methods sparsify weights of recurrent units but cannot explicitly change basic structures, e.g., the number of input updates, gates, hidden states, cell states and outputs. Moreover, the obtained sparse matrices have an irregular/nonstructured pattern of non-zero weights, which is unfriendly for efficient computation in modern hardware systems (Lebedev & Lempitsky (2016)). Previous study (Wen et al. (2016)) on sparse matrix multiplication in GPUs showed that the speedup2 was either counterproductive or ignorable. More specific, with sparsity3 of $6 7 . 6 \%$ , $9 2 . 4 \%$ , $9 7 . 2 \%$ , $9 6 . 6 \%$ and $9 4 . 3 \%$ in weight matrices of AlexNet, the speedup was $0 . 2 5 \times$ , $0 . 5 2 \times$ , $1 . 3 8 \times$ , $1 . 0 4 \times$ , and $1 . 3 6 \times$ , respectively. This problem also exists in CPUs. Fig. 1 shows that non-structured pattern in sparsity limits the speedup. We only starts to observe speed gain when the sparsity is beyond $8 0 \%$ , and the speedup is about $3 \times$ to $4 \times$ even when the sparsity is $9 5 \%$ which is far below the theoretical $2 0 \times$ . In this work, we focus on learning structurally sparse LSTMs for computation efficiency. More specific, we aim to reduce the number of basic structures simultaneously during learning, such that the obtained LSTMs have the original schematic with dense connections but with smaller sizes of these basic structures. Such compact models have structured sparsity, with columns and rows in weight matrices removed, whose computation efficiency is shown in Fig. 1. Moreover, off-the-shelf libraries in deep learning frameworks can be directly utilized to deploy the reduced LSTMs. Details should be explained.
 Figure 1: Speedups of matrix multiplication using non-structured and structured sparsity. Speeds are measured in Intel MKL implementations in Intel Xeon CPU E5-2673 v3 $@$ $2 . 4 0 \mathrm { G H z }$ . General matrix-matrix multiplication (GEMM) of $\mathbf { W } \cdot \mathbf { X }$ is implemented by cblas sgemm. The matrix sizes are selected to reflect commonly used GEMMs in LSTMs. For example, (a) represents GEMM in LSTMs with hidden size 1500, input size 1500 and batch size 10. To accelerate GEMM by sparsity, W is sparsified. In non-structured sparsity approach, W is randomly sparsified and encoded as Compressed Sparse Row format for sparse computation (using mkl scsrmm); in structured sparsity approach, $2 k$ columns and $4 k$ rows in W are removed to match the same level of sparsity (i.e., the percentage of removed parameters) for faster GEMM under smaller sizes.
There is a vital challenge originated from recurrent units: as the basic structures interweave with each other, independently removing these structures can result in mismatch of their dimensions and then inducing invalid recurrent units. The problem does not exist in CNNs, where neurons (or filters) can be independently removed without violating the usability of the final network structure. One of our key contributions is to identify the structure inside RNNs that shall be considered as a group to most effectively explore sparsity in basic structures. More specific, we propose Intrinsic Sparse Structures (ISS) as groups to achieve the goal. By removing weights associated with one component of ISS, the sizes/dimensions (of basic structures) are simultaneously reduced by one.
We evaluated our method by LSTMs and RHNs in language modeling of Penn Treebank dataset (Marcus et al. (1993)) and machine Question Answering of SQuAD dataset (Rajpurkar et al. (2016)). Our approach works both in fine-tuning and in training from scratch. In a RNN with two stacked LSTM layers with hidden sizes of 1500 (i.e., 1500 components of ISS) for language modeling (Zaremba et al. (2014)), our method learns that the sizes of 373 and 315 in the first and second LSTMs, respectively, are sufficient for the same perplexity. It achieves $1 0 . 5 9 \times$ speedup of inference time. The result is obtained by training from scratch with the same number of epochs. Directly training LSTMs with sizes of 373 and 315 cannot achieve the same perplexity, which proves the advantage of learning ISS for model compression. Encouraging results are also obtained in more compact and state-of-the-art models – the RHN models (Zilly et al. (2017)) and BiDAF model (Seo et al. (2017)).
# 2 RELATED WORK
A major approach in DNN compression is to reduce the complexity of structures within DNNs. The studies can be categorized to three classes: removing redundant structures in original DNNs, approximating the original function of DNNs (Denil et al. (2013), Jaderberg et al. (2014), Hinton et al. (2015), Lu et al. (2016), Prabhavalkar et al. (2016), Molchanov et al. (2017)), and designing DNNs with inherently compact structures (Szegedy et al. (2015), He et al. (2016), Wu et al. (2017), Bradbury et al. (2016)). Our method belongs to the first category.
Research on removing redundant structures in Feed-forward Neural Networks (FNNs), typically in CNNs, has been extensively studied. Based on $\ell _ { 1 }$ regularization (Liu et al. (2015), Park et al. (2017)) or connection pruning (Han et al. (2015b), Guo et al. (2016)), the number of connections/parameters can be dramatically reduced. Group Lasso based methods were proved to be effective in reducing coarse-grain structures (e.g., neurons, filters, channels, filter shapes, and even layers) in CNNs (Wen et al. (2016), Alvarez & Salzmann (2016), Lebedev & Lempitsky (2016), Yoon & Hwang (2017)). For instance, Wen et al. (2016) reduced the number of layers from 32 to 18 in ResNet without any accuracy loss for CIFAR-10 dataset. A recent work by Narang et al. (2017) advances connection pruning techniques for RNNs. It compresses the size of Deep Speech 2 (Amodei et al. (2016)) from $2 6 8 \mathrm { M B }$ to around $3 2 \mathrm { { M B } }$ . However, to the best of our knowledge, little work has been carried out to reduce coarse-grain structures beyond fine-grain connections in RNNs. To fill this gap, our work targets to develop a method that can learn to reduce the number of basic structures within LSTM units. After learning those structures, final LSTMs are still regular LSTMs with the same connectivity, but have the sizes reduced.
Another line of related research is Structure Learning of FNNs or CNNs. Zoph & Le (2017) uses reinforcement learning to search good neural architectures. Philipp & Carbonell (2017) dynamically adds and eliminates neurons in FNNs by using group Lasso regularization. Cortes et al. (2017) gradually adds sub-networks to current networks to incrementally reduce the objective function. All these works focused on finding optimal structures in FNNs or CNNs for classification accuracy. In contrast, this work aims at learning compact structures in LSTMs for model compression.
# 3 LEARNING INTRINSIC SPARSE STRUCTURES
# 3.1 INTRINSIC SPARSE STRUCTURES
The computation within LSTMs is (Hochreiter & Schmidhuber (1997))
$$\begin{array} { r l } & { \mathbf i _ { t } = \sigma \left( \mathbf x _ { t } \cdot \mathbf W _ { x i } + \mathbf h _ { t - 1 } \cdot \mathbf W _ { h i } + \mathbf b _ { i } \right) } \\ & { \mathbf f _ { t } = \sigma \left( \mathbf x _ { t } \cdot \mathbf W _ { x f } + \mathbf h _ { t - 1 } \cdot \mathbf W _ { h f } + \mathbf b _ { f } \right) } \\ & { \mathbf o _ { t } = \sigma \left( \mathbf x _ { t } \cdot \mathbf W _ { x o } + \mathbf h _ { t - 1 } \cdot \mathbf W _ { h o } + \mathbf b _ { o } \right) } \\ & { \mathbf u _ { t } = t a n h \left( \mathbf x _ { t } \cdot \mathbf W _ { x u } + \mathbf h _ { t - 1 } \cdot \mathbf W _ { h u } + \mathbf b _ { u } \right) } \\ & { \mathbf c _ { t } = \mathbf f _ { t } \odot \mathbf c _ { t - 1 } + \mathbf i _ { t } \odot \mathbf u _ { t } } \\ & { \mathbf h _ { t } = \mathbf o _ { t } \odot t a n h \left( \mathbf c _ { t } \right) } \end{array}$$
where $\odot$ is element-wise multiplication, $\sigma ( \cdot )$ is sigmoid function, and $t a n h ( \cdot )$ is hyperbolic tangent function. Vectors are row vectors. Ws are weight matrices, which transform the concatenation (of hidden states $\mathbf { h } _ { t - 1 }$ and inputs $\mathbf { x } _ { t }$ ) to input updates $\mathbf { u } _ { t }$ and gates $( \mathbf { i } _ { t } , \mathbf { f } _ { t }$ and $\mathbf { o } _ { t }$ ). Fig. 2 is the schematic of LSTMs in the layout of Olah (2015). The transformations by Ws and the corresponding nonlinear functions are illustrated in rectangle blocks. Our goal is to reduce the size of this sophisticated structure within LSTMs, meanwhile maintaining the original schematic. Because of element-wise operators $ \mathrm { ( } ^ { 6 6 } \mathrm { ( } \oplus ^ { 3 } $ and “ $\circled { \times } \cdot$ ”), all vectors along the blue band in Fig. 2 must have the same dimension. We call this constraint as “dimension consistency”. The vectors required to obey the dimension consistency include input updates, all gates, hidden states, cell states, and outputs. Note that hidden states are usually outputs connected to classifier layer or stacked LSTM layers. As can be seen in Fig. 2, vectors (along the blue band) interweave with each other so removing an individual component from one or a few vectors independently can result in the violation of dimension consistency.
 Figure 2: Intrinsic Sparse Structures (ISS) in LSTM units.
 Figure 3: Applying Intrinsic Sparse Structures in weight matrices.
To overcome this, we propose Intrinsic Sparse Structures (ISS) within LSTMs as shown by the blue band in Fig. 2. One component of ISS is highlighted as the white strip. By decreasing the size of ISS (i.e., the width of the blue band), we are able to simultaneously reduce the dimensions of basic structures.
To learn sparse ISS, we turn to weight sparsifying. There are totally eight weight matrices in Eq. (1). We organize them in the form of Fig. 3 as basic LSTM cells in TensorFlow. We can remove one component of ISS by zeroing out all associated weights in the white rows and white columns in Fig. 3. Why? Suppose the $k$ -th hidden state of $\mathbf { h }$ is removable, then the $k$ -th row in the lower four weight matrices can be all zeros (as shown by the left white horizontal line in Fig. 3), because those weights are on connections receiving the $k$ -th useless hidden state. Likewise, all connections receiving the $k$ -th hidden state in next layer(s) can be removed as shown by the right white horizontal line. Note that next layer(s) can be an output layer, LSTM layers, fully-connected layers, or a mix of them. ISS overlay two or more layers, without explicit explanation, we refer to the first LSTM layer as the ownership of ISS. When the $k$ -th hidden state turns useless, the $k$ -th output gate and $k$ -th cell state generating this hidden state are removable. As the $k$ -th output gate is generated by the $k$ -th column in $\mathbf { W } _ { x o }$ and $\mathbf { W } _ { h o }$ , these weights can be zeroed out (as shown by the fourth vertical white line in Fig. 3). Tracing back against the computation flow in Fig. 2, we can reach similar conclusions for forget gates, input gates and input updates, as respectively shown by the first, second and third vertical line in Fig. 3. For convenience, we call the weights in white rows and columns as an “ISS weight group”. Although we propose ISS in LSTMs, variants of ISS for vanilla RNNs, Gated Recurrent Unit (GRU) (Cho et al. (2014)), and Recurrent Highway Networks (RHNs) (Zilly et al. (2017)) can also be realized based on the same philosophy.
For even a medium-scale LSTM, the number of weights in one ISS weight group can be very large. It seems to be very aggressive to simultaneously slaughter so many weights to maintain the original recognition performance. However, the proposed ISS intrinsically exists within LSTMs and can even be unveiled by independently sparsifying each weight using $\ell _ { 1 }$ -norm regularization. The experimental result is covered in Appendix A. It unveils that sparse ISS intrinsically exist in LSTMs and the learning process can easily converge to the status with a high ratio of ISS removed. In Section 3.2, we propose a learning method to explicitly remove much more ISS than the implicit $\ell _ { 1 }$ -norm regularization.
# 3.2 LEARNING METHOD
Suppose $\mathbf { w } _ { k } ^ { ( n ) }$ is a vector of all weights in the $k$ -th component of ISS in the $n$ -th LSTM layer $1 \leq n \leq N$ and $1 \leq k \leq K ^ { ( n ) } )$ , where $N$ is the number of LSTM layers and $K ^ { ( n ) }$ is the number of ISS components (i.e., hidden size) of the $n$ -th LSTM layer. The optimization goal is to remove as many “ISS weight groups” $\mathbf { w } _ { k } ^ { ( n ) }$ as possible without losing accuracy. Methods to remove weight groups (such as filters, channels and layers) have been successfully studied in CNNs as summarized in Section 2. However, how these methods perform in RNNs is unknown. Here, we extend the group Lasso based methods (Yuan & Lin (2006)) to RNNs for ISS sparsity learning. More specific, the group Lasso regularization is added to the minimization function in order to encourage sparsity in ISS. Formally, the ISS regularization is
$$R ( \mathbf { w } ) = \sum _ { n = 1 } ^ { N } \sum _ { k = 1 } ^ { K ^ { ( n ) } } \left| \left| \mathbf { w } _ { k } ^ { ( n ) } \right| \right| _ { 2 } ,$$
where w is the vector of all weights and $| | \cdot | | _ { 2 }$ is $\ell _ { 2 }$ -norm (i.e., Euclidean length). In Stochastic Gradient Descent (SGD) training, the step to update each ISS weight group becomes
$$\mathbf { w } _ { k } ^ { ( n ) } \mathbf { w } _ { k } ^ { ( n ) } - \eta \cdot ( \frac { \partial E ( \mathbf { w } ) } { \partial \mathbf { w } _ { k } ^ { ( n ) } } + \lambda \cdot \frac { \mathbf { w } _ { k } ^ { ( n ) } } { \mathbf { w } _ { k } ^ { ( n ) } _ { 2 } } ) ,$$
where $E ( \mathbf { w } )$ is data loss, $\eta$ is learning rate and $\lambda > 0$ is the coefficient of group Lasso regularization to trade off recognition accuracy and ISS sparsity. The regularization gradient, i.e., the last term in Eq. (3), is a unit vector. It constantly squeezes the Euclidean length of each w(n)k t o zero, such that, a high portion of ISS components can be enforced to fully-zeros after learning. To avoid division by zero in the computation of regularization gradient, we can add a tiny number $\epsilon$ in $| | \cdot | | _ { 2 }$ , that is,
$$\left| \left| \mathbf { w } _ { k } ^ { ( n ) } \right| \right| _ { 2 } \triangleq \sqrt { \epsilon + \sum _ { j } \left( w _ { k j } ^ { ( n ) } \right) ^ { 2 } } ,$$
where wkj is the $j$ -th element of $\mathbf { w } _ { k } ^ { ( n ) }$ . We set $\epsilon = 1 . 0 e - 8$ . The learning method can effectively squeeze many groups near zeros, but it is very hard to exactly stabilize them as zeros because of the always-present fluctuating weight updates. Fortunately, the fluctuation is within a tiny ball centered at zero. To stabilize the sparsity during training, we zero out the weights whose absolute values are smaller than a pre-defined threshold $\tau$ . The process of thresholding is applied per mini-batch.
# 4 EXPERIMENTS
Our experiments use published models as baselines. The application domains include language modeling of Penn TreeBank and machine Question Answering of SQuAD dataset. For more comprehensive evaluation, we sparsify ISS in LSTM models with both a large hidden size of 1500 and a small hidden size of 100. We also extended ISS approach to state-of-the-art Recurrent Highway Networks (RHNs) (Zilly et al. (2017)) to reduce the number of units per layer. We maximize threshold $\tau$ to fully exploit the benefit. For a specific application, we preset $\tau$ by cross validation. The maximum $\tau$ which sparsifies the dense model (baseline) without deteriorating its performance is selected. The validation of $\tau$ is performed only once and no training effort is needed. $\tau$ is $1 . 0 e - 4$ for the stacked LSTMs in Penn TreeBank, and it is $4 . 0 e - 4$ for the RHN and the BiDAF model. We used HyperDrive by Rasley et al. (2017) to explore the hyperparameter of $\lambda$ . More details can be found in our source code.
To measure the inference speed, the experiments were run on a dual socket Intel Xeon CPU E5- $2 6 7 3 ~ \mathrm { v } 3 ~ \textcircled { \div } \ 2 . 4 0 \mathrm { G H z }$ processor with a total of 24 cores (12 per socket) and 128GB of memory. Intel MKL library 2017 update 2 was used for matrix-multiplication operations. OpenMP runtime was utilized for parallelism. We used Intel $\mathrm { C } { + + }$ Compiler 17.0 to generate executables that were run on Windows Server 2016. Each of the experiments was run for 1000 iterations, and the execution time was averaged to find the execution latency.
Table 1: Learning ISS sparsity from scratch in stacked LSTMs.
<table><tr><td>Method</td><td>Dropout keep ratio</td><td>Perplexity (validate, test)</td><td>ISS #in (1st,2nd) LSTM</td><td>Weight #</td><td>Total time*</td><td>Speedup</td><td>Mult-add reduction†</td></tr><tr><td>baseline</td><td>0.35</td><td>(82.57, 78.57)</td><td>(1500,1500)</td><td>66.0M</td><td>157.0ms</td><td>1.00×</td><td>1.00×</td></tr><tr><td>ISS</td><td>0.60</td><td>(82.59,78.65) (80.24,76.03)</td><td>(373,315) (381,535)</td><td>21.8M 25.2M</td><td>14.82ms 22.11ms</td><td>10.59× 7.10×</td><td>7.48× 5.01×</td></tr><tr><td>direct design</td><td>0.55</td><td>(90.31, 85.66)</td><td>(373,315)</td><td>21.8M</td><td>14.82ms</td><td>10.59×</td><td>7.48x</td></tr></table>
\* Measured with 10 batch size and 30 unrolled steps. † The reduction of multiplication-add operations in matrix multiplication. Defined as (original Mult-add)/(left Mult-add)
 Figure 4: Intrinsic Sparse Structures learned by group Lasso regularization (zoom in for better view). Original weight matrices are plotted, where blue dots are nonzero weights and white ones refer zeros. For better visualization, original matrices are evenly down-sampled by $1 0 \times 1 0$ .
# 4.1 LANGUAGE MODELING
# 4.1.1 STACKED LSTMS
A RNN with two stacked LSTM layers for language modeling (Zaremba et al. (2014)) is selected as the baseline. It has hidden sizes of 1500 (i.e., 1500 components of ISS) in both LSTM units. The output layer has a vocabulary of 10000 words. The dimension of word embedding in the input layer is 1500. Word embedding layer is not sparsified because the computation of selecting a vector from a matrix is very efficient. The same training scheme as the baseline is adopted to learn ISS sparsity, except a larger dropout keep ratio of 0.6 versus 0.35 of the baseline because group Lasso regularization can also avoid over-fitting. All models are trained from scratch for 55 epochs. The results are shown in Table 1. Note that, when trained using dropout keep ratio of 0.6 without adopting group Lasso regularization, the baseline over-fits and the lowest validation perplexity is 97.73. The trade-off of perplexity and sparsity is controlled by $\lambda$ . In the second row, with tiny perplexity difference from baseline, our approach can reduce the number of ISS in the first and second LSTM unit from 1500, down to 373 and 315, respectively. It reduces the model size from 66.0M to 21.8M and achieves $1 0 . 5 9 \times$ speedup. Remarkably, the practical speedup $( 1 0 . 5 9 \times )$ even goes beyond theoretical mult-add reduction $( 7 . 4 8 \times )$ as shown in Table 1 —which comes from the increased computational efficiency. When applying structured sparsity, the underlying weight matrices become smaller so as to fit into the L3 cache with good locality, which improves the FLOPS (floating point operations per second). This is a key advantage of our approach over non-structurally sparse RNNs generated by connection pruning (Narang et al. (2017)), which suffers from irregular memory access pattern and inferior-theoretical speedup. At last, when learning a compact structure, our method can perform as structure regularization to avoid overfitting. As shown in the third row in Table 1, lower perplexity is achieved by even a smaller (25.2M) and faster $( 7 . 1 0 \times )$ model. Its learned weight matrices are visualized in Fig. 4, where 1119 and 965 ISS components shown by white strips are removed in the first and second LSTM, respectively.
A straightforward way to reduce model complexity is to directly design a RNN with a smaller hidden size and train from scratch. Compare with direct design approach, our ISS method can automatically learn optimal structures within LSTMs. More importantly, compact models learned by ISS method have lower perplexity, comparing with direct design method. To evaluate it, we directly design a RNN with exactly the same structure of the second RNN in Table 1 and train it from scratch instead of learning ISS from a larger RNN. The result is included in the last row of Table 1. We tuned dropout keep ratio to get best perplexity for the directly-designed RNN. The final test perplexity is 85.66, which is 7.01 higher that our ISS method.
Table 2: Learning ISS sparsity from scratch in RHNs.
<table><tr><td>Method</td><td>入</td><td>Perplexity (validate, test)</td><td>RHN width</td><td>Parameter #</td></tr><tr><td>baseline</td><td>0.0</td><td>(67.9, 65.4)</td><td>830</td><td>23.5M</td></tr><tr><td>ISs</td><td>0.004</td><td>(67.5, 65.0)</td><td>726</td><td>18.9M</td></tr><tr><td>ISS*</td><td>0.005</td><td>(68.1, 65.4)</td><td>517</td><td>11.1M</td></tr><tr><td>ISS*</td><td>0.006</td><td>(70.3, 67.7)</td><td>403</td><td>7.6M</td></tr><tr><td>ISS*</td><td>0.007</td><td>(74.5, 71.2)</td><td>328</td><td>5.7M</td></tr></table>
\* All dropout ratios are multiplied by $0 . 6 \times$
# 4.1.2 EXTENSION TO RECURRENT HIGHWAY NETWORKS
Recurrent Highway Networks (RHN) (Zilly et al. (2017)) is a class of state-of-the-art recurrent models, which enable “step-to-step transition depths larger than one”. In a RHN, we define the number of units per layer as RHN width. Specifically, we select the “Variational $\mathrm { R H N } + \mathrm { W T } ^ { \dag }$ model in Table 1 of Zilly et al. (2017) as the baseline. It has depth 10 and width 830, with totally 23.5M parameters. In a nutshell, our approach can reduce the RHN width from 830 to 517 without losing perplexity.
Following the same idea of identifying the “ISS weight groups” to reduce the size of basic structures in LSTMs, we can identify the groups in RHNs to reduce the RHN width. In brief, one group include corresponding columns/rows in weight matrices of the $H$ nonlinear transform, of the $T$ and $C$ gates, and of the embedding and output layers. The group size is 46520. The groups are indicated by JSON files in our source code4. By learning ISS in RHNs, we can simultaneously reduce the dimension of word embedding and the number of units per layer.
Table 2 summarizes results. All experiments are trained from scratch with the same hyperparameters in the baseline, except that smaller dropout ratios are used in ISS learning. Larger $\lambda$ , smaller RHN width but higher perplexity. More importantly, without losing perplexity, our approach can learn a smaller model with RHN width 517 from an initial model with RHN width 830. This reduces the model size to 11.1M, which is $5 2 . 8 \%$ reduction. Moreover, ISS learning can find a smaller RHN model with width 726, meanwhile improve the state-of-the-art perplexity as shown by the second entry in Table 2.
# 4.2 MACHINE READING COMPREHENSION
We evaluate ISS method by state-of-the-art dataset (SQuAD) and model (BiDAF). SQuAD (Rajpurkar et al. (2016)) is a recently released reading comprehension dataset, crowdsourced from 100, $0 0 0 +$ question-answer pairs on $5 0 0 +$ Wikipedia articles. ExactMatch (EM) and F1 scores are two major metrics for the task5. The higher those scores are, the better the model is. We adopt BiDAF (Seo et al. (2017)) to evaluate how ISS method works in small LSTM units. BiDAF is a compact machine Question Answering model with totally 2.69M weights. The ISS sizes are only 100 in all LSTM units. The implementation of BiDAF is made available by its authors 6.
BiDAF has character, word and contextual embedding layers to extract representations from input sentences, following which are bi-directional attention layer, modeling layer, and final output layer. LSTM units are used in contextual embedding layer, modeling layer, and output layer. All LSTMs are bidirectional (Schuster & Paliwal (1997)). In a bidirectional LSTM, there are one forward plus one backward LSTM branch. The two branches share inputs and their outputs are concatenated for next stacked layers. We found that it is hard to remove ISS components in contextual embedding layer, because the representations are relatively dense as it is close to inputs and the original hidden size (100) is relatively small. In our experiments, we exclude LSTMs in contextual embedding layer and sparsify all other LSTM layers. Those LSTM layers are the computation bottleneck of BiDAF.
Table 3: Remaining ISS components in BiDAF by fine-tuning.
<table><tr><td>EM</td><td>F1</td><td>ModFwd1</td><td>ModBwd1</td><td>ModFwd2</td><td>ModBwd2</td><td>OutFwd</td><td>OutBwd</td><td>weight #</td><td>Total time*</td></tr><tr><td>67.98</td><td>77.85</td><td>100</td><td>100</td><td>100</td><td>100</td><td>100</td><td>100</td><td>2.69M</td><td>6.20ms</td></tr><tr><td>67.21</td><td>76.71</td><td>100</td><td>95</td><td>78</td><td>82</td><td>71</td><td>52</td><td>2.08M</td><td>5.79ms</td></tr><tr><td>66.59</td><td>76.40</td><td>84</td><td>90</td><td>38</td><td>46</td><td>34</td><td>21</td><td>1.48M</td><td>4.52ms</td></tr><tr><td>65.29</td><td>75.47</td><td>54</td><td>47</td><td>22</td><td>30</td><td>18</td><td>12</td><td>1.03M</td><td>3.54ms</td></tr><tr><td>64.81</td><td>75.22</td><td>52</td><td>50</td><td>19</td><td>26</td><td>15</td><td>12</td><td>1.01M</td><td>3.51ms</td></tr></table>
Measured with batch size 1.
Table 4: Remaining ISS components in BiDAF by training from scratch.
<table><tr><td>EM</td><td>F1</td><td>ModFwd1</td><td>ModBwd1</td><td>ModFwd2</td><td>ModBwd2</td><td>OutFwd</td><td>OutBwd</td><td>weight #</td><td>Total time*</td></tr><tr><td>67.98</td><td>77.85</td><td>100</td><td>100</td><td>100</td><td>100</td><td>100</td><td>100</td><td>2.69M</td><td>6.20ms</td></tr><tr><td>67.36</td><td>77.16</td><td>87</td><td>81</td><td>87</td><td>92</td><td>74</td><td>96</td><td>2.29M</td><td>5.83ms</td></tr><tr><td>66.32</td><td>76.22</td><td>51</td><td>33</td><td>42</td><td>58</td><td>37</td><td>26</td><td>1.17M</td><td>4.46ms</td></tr><tr><td>65.36</td><td>75.78</td><td>20</td><td>33</td><td>40</td><td>38</td><td>31</td><td>16</td><td>0.95M</td><td>3.59ms</td></tr><tr><td>64.60</td><td>74.99</td><td>23</td><td>22</td><td>35</td><td>35</td><td>25</td><td>14</td><td>0.88M</td><td>2.74ms</td></tr></table>
Measured with batch size 1.
We profiled the computation time on CPUs, and find those LSTM layers (excluding contextual embedding layer) consume $7 6 . 4 7 \%$ of total inference time. There are three bi-directional LSTM layers we will sparsify, two of which belong to the modeling layer, and one belongs to the output layer. More details of BiDAF are covered by Seo et al. (2017). For brevity, we mark the forward (backward) path of the 1st bi-directional LSTM in the modeling layer as ModFwd1 (ModBwd1). Similarly, ModFwd2 and ModBwd2 are for the 2nd bi-directional LSTM. Forward (backward) LSTM path in the output layer are marked as OutFwd and OutBwd.
As discussed in Section 3.1, multiple parallel layers can receive the hidden states from the same LSTM layer and all connections (weights) receive those hidden states belong to the same ISS. For instance, ModFwd2 and ModBwd2 both receive hidden states of ModFwd1 as inputs, therefore the $k$ -th “ISS weight group” includes the $k$ -th rows of weights in both ModFwd2 and ModBwd2, plus the weights in the $k$ -th ISS component within ModFwd1. For simplicity, we use “ISS of ModFwd1” to refer to the whole group of weights. Structures of six ISS are included in Table 5 in Appendix B. We learn ISS sparsity in BiDAF by both fine-tuning the baseline and training from scratch. All the training schemes keep as the same as the baseline except applying a higher dropout keep ratio. After training, we zero out weights whose absolute values are smaller than 0.02. This does not impact EM and F1 scores, but increase sparsity.
Table 3 shows the EM, F1, the number of remaining ISS components, model size, and inference speed. The first row is the baseline BiDAF. Other rows are obtained by fine-tuning baseline using ISS regularization. In the second row by learning ISS, with small EM and F1 loss, we can reduce ISS in all LSTMs except ModFwd1. For example, almost half of the ISS components are removed in OutBwd. By increasing the strength of group Lasso regularization $( \lambda )$ , we can increase the ISS sparsity by losing some EM/F1 scores. The trade-off is listed in Table 3. With 2.63 F1 score loss, the sizes of OutFwd and OutBwd can be reduced from original 100 to 15 and 12, respectively. At last, we find it hard to reduce ISS sizes without losing any EM/F1 score. This implies that BiDAF is compact enough and its scale is suitable for both computation and accuracy. However, our method can still significantly compress this compact model under acceptable performance loss.
At last, instead of fine-tuning baseline, we train BiDAF from scratch with ISS learning. The results are summarized in Table 4. Our approach also works well when training from scratch. Overall, training from scratch balances the sparsity across all layers better than fine-tuning, which results in even better compression of model size and speedup of inference time. The histogram of vector lengths of “ISS weight groups” is plotted in Appendix C.
# 5 CONCLUSION
We proposed Intrinsic Sparse Structures (ISS) within LSTMs and its learning method to simultaneously reduce the sizes of input updates, gates, hidden states, cell states and outputs within the sophisticated LSTM structure. By learning ISS, a structurally sparse LSTM can be obtained, which essentially is a regular LSTM with reduced hidden dimension. Thus, no software or hardware specific customization is required to get storage saving and computation acceleration. Though ISS is proposed with LSTMs, it can be easily extended to vanilla RNNs, Gated Recurrent Unit (GRU) (Cho et al. (2014)), and Recurrent Highway Networks (RHNs) (Zilly et al. (2017)).
# ACKNOWLEDGMENTS
Thank researchers and engineers in Microsoft for giving valuable feedback on this work, with acknowledgments to Wei He, Freddie Zhang, Yi Liu, Jacob Devlin and Chen Zhou. Also thank Jeff Rasley (intern in Microsoft Research, Brown University) for helping me to use HyperDrive (Rasley et al. (2017)) for hyper-parameter exploration. This work was supported in part by NSF CCF1744082, NSF CCF-1725456 and DOE SC0017030. Any opinions, findings, conclusions or recommendations expressed in this material are those of the authors and do not necessarily reflect the views of NSF, DOE, or their contractors.
# REFERENCES
Jose M Alvarez and Mathieu Salzmann. Learning the number of neurons in deep networks. In Advances in Neural Information Processing Systems, 2016.
Dario Amodei, Sundaram Ananthanarayanan, Rishita Anubhai, Jingliang Bai, Eric Battenberg, Carl Case, Jared Casper, Bryan Catanzaro, Qiang Cheng, Guoliang Chen, et al. Deep speech 2: Endto-end speech recognition in english and mandarin. In International Conference on Machine Learning, pp. 173–182, 2016.
James Bradbury, Stephen Merity, Caiming Xiong, and Richard Socher. Quasi-recurrent neural networks. arXiv:1611.01576, 2016.
Kyunghyun Cho, Bart Van Merrienboer, Caglar Gulcehre, Dzmitry Bahdanau, Fethi Bougares, Hol- ¨ ger Schwenk, and Yoshua Bengio. Learning phrase representations using rnn encoder-decoder for statistical machine translation. arXiv:1406.1078, 2014.
Corinna Cortes, Xavi Gonzalvo, Vitaly Kuznetsov, Mehryar Mohri, and Scott Yang. Adanet: Adaptive structural learning of artificial neural networks. In Proceedings of the 34th International Conference on Machine Learning, pp. 874–883, 2017.
Misha Denil, Babak Shakibi, Laurent Dinh, Nando de Freitas, et al. Predicting parameters in deep learning. In Advances in Neural Information Processing Systems, 2013.
Yiwen Guo, Anbang Yao, and Yurong Chen. Dynamic network surgery for efficient dnns. In Advances In Neural Information Processing Systems, 2016.
Song Han, Huizi Mao, and William J Dally. Deep compression: Compressing deep neural networks with pruning, trained quantization and huffman coding. arXiv:1510.00149, 2015a.
Song Han, Jeff Pool, John Tran, and William Dally. Learning both weights and connections for efficient neural network. In Advances in Neural Information Processing Systems, 2015b.
Kaiming He, Xiangyu Zhang, Shaoqing Ren, and Jian Sun. Deep residual learning for image recognition. In Proceedings of the IEEE conference on computer vision and pattern recognition, pp. 770–778, 2016.
Geoffrey Hinton, Oriol Vinyals, and Jeff Dean. Distilling the knowledge in a neural network. arXiv preprint arXiv:1503.02531, 2015.
Sepp Hochreiter and Jurgen Schmidhuber. Long short-term memory. ¨ Neural computation, 9(8): 1735–1780, 1997.
Max Jaderberg, Andrea Vedaldi, and Andrew Zisserman. Speeding up convolutional neural networks with low rank expansions. arXiv:1405.3866, 2014.
Vadim Lebedev and Victor Lempitsky. Fast convnets using group-wise brain damage. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pp. 2554–2564, 2016.
Hao Li, Asim Kadav, Igor Durdanovic, Hanan Samet, and Hans Peter Graf. Pruning filters for efficient convnets. In International Conference on Learning Representations (ICLR), 2017.
Baoyuan Liu, Min Wang, Hassan Foroosh, Marshall Tappen, and Marianna Pensky. Sparse convolutional neural networks. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pp. 806–814, 2015.
Christos Louizos, Karen Ullrich, and Max Welling. Bayesian compression for deep learning. arXiv:1705.08665, 2017.
Zhiyun Lu, Vikas Sindhwani, and Tara N Sainath. Learning compact recurrent neural networks. In Acoustics, Speech and Signal Processing (ICASSP), 2016 IEEE International Conference on, pp. 5960–5964. IEEE, 2016.
Mitchell P Marcus, Mary Ann Marcinkiewicz, and Beatrice Santorini. Building a large annotated corpus of english: The penn treebank. Computational linguistics, 19(2):313–330, 1993.
Pavlo Molchanov, Stephen Tyree, Tero Karras, Timo Aila, and Jan Kautz. Pruning convolutional neural networks for resource efficient inference. In International Conference on Learning Representations (ICLR), 2017.
Sharan Narang, Gregory Diamos, Shubho Sengupta, and Erich Elsen. Exploring sparsity in recurrent neural networks. arXiv:1704.05119, 2017.
Christopher Olah. Understanding lstm networks. GITHUB blog, posted on August, 27:2015, 2015.
Jongsoo Park, Sheng Li, Wei Wen, Ping Tak Peter Tang, Hai Li, Yiran Chen, and Pradeep Dubey. Faster cnns with direct sparse convolutions and guided pruning. In International Conference on Learning Representations (ICLR), 2017.
George Philipp and Jaime G Carbonell. Nonparametric neural networks. In International Conference on Learning Representations (ICLR), 2017.
Rohit Prabhavalkar, Ouais Alsharif, Antoine Bruguier, and Lan McGraw. On the compression of recurrent neural networks with an application to lvcsr acoustic modeling for embedded speech recognition. In Acoustics, Speech and Signal Processing (ICASSP), 2016 IEEE International Conference on, pp. 5970–5974. IEEE, 2016.
Pranav Rajpurkar, Jian Zhang, Konstantin Lopyrev, and Percy Liang. Squad: $1 0 0 { , } 0 0 0 { + }$ questions for machine comprehension of text. arXiv:1606.05250, 2016.
Jeff Rasley, Yuxiong He, Feng Yan, Olatunji Ruwase, and Rodrigo Fonseca. HyperDrive: Exploring Hyperparameters with POP Scheduling. In Proceedings of the 18th International Middleware Conference, Middleware ’17. ACM, 2017.
Mike Schuster and Kuldip K Paliwal. Bidirectional recurrent neural networks. IEEE Transactions on Signal Processing, 45(11):2673–2681, 1997.
Minjoon Seo, Aniruddha Kembhavi, Ali Farhadi, and Hannaneh Hajishirzi. Bidirectional attention flow for machine comprehension. In International Conference on Learning Representations (ICLR), 2017.
Christian Szegedy, Wei Liu, Yangqing Jia, Pierre Sermanet, Scott Reed, Dragomir Anguelov, Dumitru Erhan, Vincent Vanhoucke, and Andrew Rabinovich. Going deeper with convolutions. In Proceedings of the IEEE conference on computer vision and pattern recognition, pp. 1–9, 2015.
Wei Wen, Chunpeng Wu, Yandan Wang, Yiran Chen, and Hai Li. Learning structured sparsity in deep neural networks. In Advances in Neural Information Processing Systems, 2016.
Wei Wen, Cong Xu, Chunpeng Wu, Yandan Wang, Yiran Chen, and Hai Li. Coordinating filters for faster deep neural networks. In The IEEE International Conference on Computer Vision (ICCV), October 2017.
Chunpeng Wu, Wei Wen, Tariq Afzal, Yongmei Zhang, Yiran Chen, and Hai Li. A compact dnn: Approaching googlenet-level accuracy of classification and domain adaptation. In Proceedings of the IEEE conference on computer vision and pattern recognition, 2017.
Jaehong Yoon and Sung Ju Hwang. Combined group and exclusive sparsity for deep neural networks. In International Conference on Machine Learning, pp. 3958–3966, 2017.
Ming Yuan and Yi Lin. Model selection and estimation in regression with grouped variables. Journal of the Royal Statistical Society: Series B (Statistical Methodology), 68(1):49–67, 2006.
Wojciech Zaremba, Ilya Sutskever, and Oriol Vinyals. Recurrent neural network regularization. arXiv:1409.2329, 2014.
Julian Georg Zilly, Rupesh Kumar Srivastava, Jan Koutn´ık, and Jurgen Schmidhuber. Recurrent ¨ highway networks. In Proceedings of the 34th International Conference on Machine Learning, pp. 4189–4198, 2017.
Barret Zoph and Quoc V Le. Neural architecture search with reinforcement learning. In International Conference on Learning Representations (ICLR), 2017.
 Figure 5: Intrinsic Sparse Structures unveiled by $\ell _ { 1 }$ regularization (zoom in for a better view). The top row shows the original weight matrices, where blue dots are nonzero weights and white ones refer zeros; the bottom row are the weight matrices in the format of Fig. 3, where white strips are ISS components whose weights are all zeros. For better visualization, the original matrices are evenly down-sampled by $1 0 \times 1 0$ .
We take the large stacked LSTMs by Zaremba et al. (2014) for language modeling as the example. The network has two stacked LSTM layers whose dimensions of inputs and states are both 1500, and it has an output layer with a vocabulary of 10000 words. The sizes of “ISS weight groups” of two LSTM layers are 24000 and 28000. The perplexities of validation set and test set are respectively 82.57 and 78.57. We fine-tune this baseline LSTMs with $\ell _ { 1 }$ -norm regularization. The same training hyper-parameters as the baseline are adopted, except a bigger dropout keep ratio of 0.6 (original 0.35). A weaker dropout is used because $\ell _ { 1 }$ -norm is also a regularization to avoid overfitting. A too strong dropout plus $\ell _ { 1 }$ -norm regularization can result in underfitting. The weight decay of $\ell _ { 1 }$ - norm regularization is 0.0001. The sparsified network has validation perplexity and test perplexity of 82.40 and 78.60, respectively, which is approximately the same with the baseline. The sparsity of weights in the first LSTM layer, the second LSTM layer and the last output layer is $9 1 . 6 6 \%$ , $9 0 . 3 2 \%$ and $9 0 . 2 2 \%$ , respectively. Fig. 5 plots the learned sparse weight matrices. The sparse matrices in the top row reveal some interesting patterns: there are lots of all-zero columns and rows, and their positions are highly correlated. Those patterns are profiled in the bottom row. Much to our surprise, sparsifying individual weight independently can converge to sparse LSTMs with many ISS removed—504 and 220 ISS components in the first and second LSTM layer are all-zeros.
# APPENDIX B ISS IN BIDAF
Table 5: The ISS in BiDAF.
<table><tr><td>LSTM name</td><td>Dimensions of weight matrix</td><td>Receivers of hidden states</td><td>Size of “ISS weight group”</td></tr><tr><td>ModFwd1</td><td>900 × 400</td><td>ModFwd2 ModBwd2</td><td>4800</td></tr><tr><td>ModBwd1</td><td>900 × 400</td><td>ModFwd2 ModBwd2</td><td>4800</td></tr><tr><td>ModFwd2</td><td>300 × 400</td><td>OutFwd OutBwd logit layer for start index</td><td>3201</td></tr><tr><td>ModBwd2</td><td>300 × 400</td><td>OutFwd OutBwd logit layer for start index</td><td>3201</td></tr><tr><td>OutFwd</td><td>1500 × 400</td><td>logit layer for end index</td><td>6401</td></tr><tr><td>OutBwd</td><td>1500 × 400</td><td>logit layer for end index</td><td>6401</td></tr></table>
 Figure 6: Histogram of vector lengths of “ISS weight groups” in BiDAF. The ISS-learned BiDAF is the one in the third row of Table 4 with $\mathrm { E M 6 6 . 3 2 }$ and F1 76.22. Using our approach, the lengths are regularized closer to zeros with a peak at the zero, resulting in high ISS sparsity.123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252# FIXING WEIGHT DECAY REGULARIZATION IN ADAM
Anonymous authors Paper under double-blind review
# ABSTRACT
We note that common implementations of adaptive gradient algorithms, such as Adam, limit the potential benefit of weight decay regularization, because the weights do not decay multiplicatively (as would be expected for standard weight decay) but by an additive constant factor. We propose a simple way to resolve this issue by decoupling weight decay and the optimization steps taken w.r.t. the loss function. We provide empirical evidence that our proposed modification (i) decouples the optimal choice of weight decay factor from the setting of the learning rate for both standard SGD and Adam, and (ii) substantially improves Adam’s generalization performance, allowing it to compete with SGD with momentum on image classification datasets (on which it was previously typically outperformed by the latter). We also demonstrate that longer optimization runs require smaller weight decay values for optimal results and introduce a normalized variant of weight decay to reduce this dependence. Finally, we propose a version of Adam with warm restarts (AdamWR) that has strong anytime performance while achieving state-ofthe-art results on CIFAR-10 and ImageNet32x32. Our source code will become available after the review process.
# 1 INTRODUCTION
Adaptive gradient methods, such as AdaGrad (Duchi et al., 2011), RMSProp (Tieleman & Hinton, 2012), and Adam (Kingma & Ba, 2014) have become a default method of choice for training feedforward and recurrent neural networks (Xu et al., 2015; Gregor et al., 2015; Radford et al., 2015). Nevertheless, state-of-the-art results for popular image classification datasets, such as CIFAR-10 and CIFAR-100 Krizhevsky (2009), are still obtained by applying SGD with momentum (Huang et al., 2016; 2017; Loshchilov & Hutter, 2016; Gastaldi, 2017). Furthermore, Wilson et al. (2017) suggested that adaptive gradient methods do not generalize as well as SGD with momentum when tested on a diverse set of deep learning tasks such as image classification, character-level language modeling and constituency parsing. Different hypotheses about the origins of this worse generalization have been investigated, such as the presence of sharp local minima (Keskar et al., 2016; Dinh et al., 2017) and inherent problems of adaptive gradient methods (Wilson et al., 2017). In this paper, we show that a major factor in the poor generalization of the most popular adaptive gradient method, Adam, lies in its dysfunctional implementation of weight decay; the issue we identify in Adam also pertains to other adaptive gradient methods.
Specifically, our analysis of Adam given in this paper leads to the following observations:
# The standard way to implement $\mathbf { L } _ { 2 }$ regularization/weight decay in Adam is dysfunctional.
One possible explanation why Adam and other adaptive gradient methods might be outperformed by SGD with momentum is that $\mathrm { L _ { 2 } }$ regularization/weight decay are implemented suboptimally in common deep learning libraries. Therefore, on tasks/datasets where the use of $\mathrm { L _ { 2 } }$ regularization is beneficial (e.g., on many popular image classification datasets), Adam leads to worse results than SGD with momentum (for which $\mathrm { L _ { 2 } }$ regularization behaves as expected).
$\mathbf { L } _ { 2 }$ regularization and weight decay are not the same thing. Contrary to common belief, the two techniques are not equivalent. For SGD, they can be made equivalent by a reparameterization of the weight decay factor based on the learning rate; this is not the case for Adam. In particular, when combined with adaptive gradients, $\mathrm { L _ { 2 } }$ regularization leads to weights with large gradients being regularized less than they would be when using weight decay.
Optimal weight decay is a function (among other things) of the total number of batch passes/weight updates.
Our empirical analysis of Adam suggests that the longer the runtime/number of batch passes to be performed, the smaller the optimal weight decay. This effect tends to be neglected because hyperparameters are often tuned for a fixed or a comparable number of training epochs. As a result, the values of the weight decay found to perform best for short runs do not generalize to much longer runs.
Our contributions are aimed at fixing the issues described above:
Decoupling weight decay from the gradient-based update (Section 2). We suggest to decouple the gradient-based update from weight decay for both SGD and Adam. The resulting SGD version SGDW decouples optimal settings of the learning rate and the weight decay factor, and the resulting Adam version AdamW generalizes substantially better than Adam.
Normalizing the values of weight decay (Section 3). We propose to parameterize the weight decay factor as a function of the total number of batch passes. This leads to a greater invariance of the hyperparameter settings in the sense that the values found to perform best for short runs also perform well for many times longer runs.
Adam with warm restarts and normalized weight decay (Section 4). After we fix the weight decay in Adam and design AdamW, we introduce AdamWR to obtain strong anytime performance by performing warm restarts.
The main motivation of this paper is to fix the weight decay in Adam to make it competitive w.r.t. SGD with momentum even for those problems where it did not use to be competitive. We hope that as a result, practitioners do not need to switch between Adam and SGD anymore, which in turn should help to reduce the common issue of selecting dataset/task-specific training algorithms and their hyperparameters.
# 2 DECOUPLING THE WEIGHT DECAY FROM THE GRADIENT-BASED UPDATE
In the weight decay described by Hanson & Pratt (1988), the weights $\boldsymbol { x }$ decay exponentially as
$$\begin{array} { r } { \pmb { x } _ { t + 1 } = ( 1 - w _ { t } ) \pmb { x } _ { t } - \alpha _ { t } \nabla f _ { t } ( \pmb { x } _ { t } ) , } \end{array}$$
where $w _ { t }$ defines the rate of the weight decay at time-step $t$ and $\nabla f _ { t } ( { \pmb x } _ { t } )$ is the $t { \cdot }$ -th batch gradient multiplied by a learning rate $\alpha _ { t }$ . Following Hanson & Pratt (1988), one can also modify the original batch loss $f _ { t } ( \pmb { x } _ { t } )$ and consider a bias term (also referred to as the regularization term) accounting for “costs” on weights which are, e.g., quadratic in the weight values as for $\mathrm { L _ { 2 } }$ regularization:
$$f _ { t , r e g } ( \pmb { x } _ { t } ) = f _ { t } ( \pmb { x } _ { t } ) + \frac { w _ { t } } { 2 } \left\| \pmb { x } _ { t } \right\| _ { 2 } ^ { 2 } ,$$
where $w _ { t }$ defines the impact of the $\mathrm { L _ { 2 } }$ regularization. In order to consider the weight decay regularization, one can reformulate the objective function as in Eq. (2) or directly adjust $\bar { \nabla } f _ { t } ( \pmb { x } _ { t } )$ as
$$\nabla f _ { t , r e g } ( { \pmb x } _ { t } ) = \nabla f _ { t } ( { \pmb x } _ { t } ) + w _ { t } { \pmb x } _ { t } .$$
Historically, stochastic gradient descent methods inherited this way of implementing the weight decay regularization.
The currently most common way (e.g., in popular libraries such as TensorFlow, Keras, PyTorch, Torch, and Lasagne) to introduce the weight decay regularization is to use the $\mathrm { L _ { 2 } }$ regularization term as in Eq. (2) or, often equivalently, to directly modify the gradient as in Eq. (3). Let’s first consider the simple case of SGD with momentum; Algorithm 1 demonstrates modifying the gradients directly in this method (see line 6). The weight decay term $w _ { t } \mathbf { x } _ { t - 1 }$ will first modify ${ \pmb g } _ { t }$ (see line 6) and then affect the momentum term $\pmb { m } _ { t }$ (see line 8). While the smoothing of the weight decay factor by $\beta _ { 1 }$
1: given learning rate $\alpha _ { t } \in \mathbb { R }$ , momentum factor $\beta _ { 1 } \in \mathbb { R }$ , weight decay factor $w \in \mathbb { R }$ 2: initialize time step $t \gets 0$ , parameter vector $\pmb { x } _ { t = 0 } ~ \in ~ \mathbb { R } ^ { n }$ , first moment vector $\pmb { m } _ { t = 0 } \gets \pmb { \theta }$ , schedule multiplier $\eta _ { t = 0 } \in \mathbb { R }$ 3: repeat 4: $t \gets t + 1$ 5: $\nabla f _ { t } ( { \pmb x } _ { t - 1 } ) \gets S e l e c t B a t c h ( { \pmb x } _ { t - 1 } )$ . select batch and return the corresponding gradient 6: $\pmb { \mathscr { g } } _ { t } \gets \nabla f _ { t } ( \pmb { x } _ { t - 1 } ) \ + w _ { t } \pmb { x } _ { t - 1 }$ 7: ηt ← SetScheduleMultiplier(t) . can be fixed, decay, be used for warm restarts 8: ${ \pmb { m } } _ { t } \gets \beta _ { 1 } { \pmb { m } } _ { t - 1 } + \eta _ { t } \alpha _ { t } \pmb { g } _ { t }$ 9: $\pmb { x } _ { t } \gets \pmb { x } _ { t - 1 } - \pmb { m } _ { t } \gets \eta _ { t } w _ { t } \pmb { x } _ { t - 1 }$
<table><tr><td>Algorithm1 SGD with momentum</td><td>and SGDW with momentum</td><td></td></tr></table>
10: until stopping criterion is met
11: return optimized parameters $\mathbf { \boldsymbol { x } } _ { t }$
# Algorithm 2 Adam and AdamW
1: given $\alpha _ { t } = 0 . 0 0 1 , \beta _ { 1 } = 0 . 9 , \beta _ { 2 } = 0 . 9 9 9 , \epsilon = 1 0 ^ { - 8 } , w \in \mathbb { R }$ 2: initialize time step $t \gets 0$ , parameter vector $\pmb { x } _ { t = 0 } \in \mathbb { R } ^ { n }$ , first moment vector $\pmb { m } _ { t = 0 } \pmb { \theta }$ , second moment vector $\pmb { \nu } _ { t = 0 } \pmb { \theta }$ , schedule multiplier $\eta _ { t = 0 } \in \mathbb { R }$ 3 : repeat 4: $t \gets t + 1$ 5: $\nabla f _ { t } ( { \pmb x } _ { t - 1 } ) \gets S e l e c t B a t c h ( { \pmb x } _ { t - 1 } )$ . select batch and return the corresponding gradient 6: $\pmb { \mathrm { g } } _ { t } \nabla f _ { t } ( \pmb { x } _ { t - 1 } ) \ + w _ { t } \pmb { x } _ { t - 1 }$ 7: $\pmb { m } _ { t } \beta _ { 1 } \pmb { m } _ { t - 1 } + \overline { { ( 1 - \beta _ { 1 } ) \pmb { g } _ { t } } }$ . here and below all operations are element-wise 8: $\pmb { \nu } _ { t } \gets \beta _ { 2 } \pmb { \nu } _ { t - 1 } + ( 1 - \beta _ { 2 } ) \pmb { g } _ { t } ^ { 2 }$ 9: $\hat { \pmb { m } } _ { t } \gets \pmb { m } _ { t } / ( 1 - \beta _ { 1 } ^ { t } )$ $\triangleright$ here, $\beta _ { 1 }$ is taken to the power of $t$ 10: $\hat { \pmb { { \nu } } } _ { t } \gets { \pmb { { \nu } } } _ { t } / ( 1 - \beta _ { 2 } ^ { t } )$ $\triangleright$ here, $\beta _ { 2 }$ is taken to the power of $t$ 11: ηt ← SetScheduleMultiplier(t) . can be fixed, decay, be used for warm restarts 12: $\pmb { x } _ { t } \pmb { x } _ { t - 1 } - \eta _ { t } ( \alpha _ { t } \hat { m } _ { t } / ( \sqrt { \hat { \nu } _ { t } } + \epsilon ) + w _ { t } \pmb { x } _ { t - 1 } )$ 13: until stopping criterion is met 14: return optimized parameters $\mathbf { \boldsymbol { x } } _ { t }$
(see line 8) might be a feature, we note (for simplicity, we omit $\eta _ { t }$ ) that $\mathbf { \boldsymbol { x } } _ { t }$ will decay by $\alpha _ { t } w _ { t } \pmb { x } _ { t - 1 }$ (see line 9) and not $w _ { t } \mathbf { x } _ { t - 1 }$ as one could expect according to the definition of the weight decay given by Eq. (1). Practically, if one wants to keep the actual weight decay $\alpha _ { t } w _ { t }$ fixed while changing $\alpha _ { t }$ to $\alpha _ { t } ^ { \prime }$ , then $w _ { t }$ should be modified to $\begin{array} { r } { w _ { t } ^ { \prime } = \frac { \alpha _ { t } w _ { t } } { \alpha _ { t } ^ { \prime } } } \end{array}$ αtwtα0 . This renders the problem of hyperparameter selection of $\alpha _ { t }$ and $w _ { t }$ non-separable.
We propose to fix this problem by following the original definition of weight decay given by Eq. (1) and decay the weights simultaneously with the update of $\mathbf { \boldsymbol { x } } _ { t }$ based on gradient information in Line 9 of Algorithm 1. This yields our proposed SGD variant SGDW with momentum. Although the proposed simple modification explicitly decouples $w _ { t }$ and $\alpha _ { t }$ , some problem-dependent implicit coupling is likely to remain. In order to account for a possible scheduling of both $\alpha _ { t }$ and $w _ { t }$ , we introduce a scaling factor $\eta _ { t }$ delivered by a user-defined procedure SetScheduleMultiplier $( t )$ . It should be noted that when $\mathrm { L _ { 2 } }$ regularization is used, weight decay contributes to the batch gradient and thus effectively is scheduled in the same way as the learning rate. Now, since we decouple the two we should also remember to schedule both of them with $\eta _ { t }$ .
Having shown that using $\mathrm { L _ { 2 } }$ regularization instead of weight decay already couples regularization and learning rate in the simple case of SGD with momentum, we now consider adaptive gradient optimizers, such as the Adam algorithm proposed by Kingma & Ba (2014), in which the coupling leads to even more unintended behavior. As an adaptive gradient method, Adam maintains a vector $\nu _ { t }$ responsible for storing smoothed amplitudes of parameter-wise gradients ${ \pmb g } _ { t } ^ { 2 }$ (see line 8 in Algorithm 2). These factors are used to control parameter-wise learning rates by normalizing parameter-wise√ gradients by $\sqrt { \hat { \nu _ { t } } } + \epsilon$ in line 12 of Algorithm 2. The common way to introduce the weight decay $w _ { t } \mathbf { x } _ { t - 1 }$ to Adam results in an update which only distantly resembles the original weight decay given by Eq. (1) because the $\nu _ { t }$ vectors are not only responsible for the parameter-wise amplitudes of $\pmb { g } _ { t }$ but also for the parameter-wise amplitudes of weights $\mathbf { \boldsymbol { x } } _ { t }$ . The amplitudes are then used to renormalize $\hat { \pmb { m } } _ { t }$ as given in line 12 of Algorithm 2. To gain a bit of intuition, let us consider the case when $t$ is large, causing $\beta _ { 1 } ^ { t }$ and $\beta _ { 2 } ^ { t }$ to go to zero and
$$\boldsymbol { x } _ { t } \gets \boldsymbol { x } _ { t - 1 } - \eta _ { t } \alpha _ { t } \frac { \beta _ { 1 } m _ { t - 1 } + ( 1 - \beta _ { 1 } ) g _ { t } } { \sqrt { \beta _ { 2 } \nu _ { t - 1 } + ( 1 - \beta _ { 2 } ) g _ { t } ^ { 2 } } + \epsilon } , \ \mathrm { w i t h } \ g _ { t } = \nabla f _ { t } ( \boldsymbol { x } _ { t - 1 } ) + w _ { t } \boldsymbol { x } _ { t - 1 } ,$$
where operations are performed parameter-wise. Not only the batch gradient $\nabla f _ { t } ( { \pmb x } _ { t - 1 } )$ is normalized but also the weight decay $w _ { t } \mathbf { x } _ { t - 1 }$ itself. Since this formula normalizes updates by their typical amplitudes, the decay of weights does not account for amplitudes anymore, leading to the relative decay being weaker for weights with large gradients. This is a correct implementation of $\mathbf { L } _ { 2 }$ regularization, but not of weight decay. Therefore, it might be misleading to use the two terms interchangeably, as is commonly done in the literature. We note that this difference between the two mechanisms for Adam has not been investigated and/or described before. As in the case of SGDW, we propose to follow the original definition of weight decay and perform it simultaneously with the gradient-based update as shown in line 12 of Algorithm 2 for AdamW. As we will demonstrate experimentally (in Section 5.2), AdamW generalizes much better than Adam.
# 3 NORMALIZED WEIGHT DECAY
Since our preliminary experiments showed that different weight decay factors are optimal for different computational budgets (defined in terms of the number of batch passes), we introduce a normalized weight decay to reduce this dependence. At iteration $t$ , $w _ { t }$ is set as follows:
$$w _ { t } = w _ { n o r m } \sqrt { \frac { b _ { t } } { B T _ { i } } } ,$$
where $b _ { t }$ is the batch size, $B$ is the total number of training points to be used in one epoch and $T _ { i }$ is the total number of epochs within the $i$ -th run/restart of the algorithm. Thus, $w _ { n o r m }$ can be interpreted as the weight decay to be used if only one batch pass is allowed. We note a recent relevant observation of Li et al. (2017) who demonstrated that a smaller batch size (for the same total number of epochs) leads to the shrinking effect of weight decay being more pronounced. Here, we propose to address that effect with normalized weight decay.
# 4 ADAM WITH WARM RESTARTS AND NORMALIZED WEIGHT DECAY
We now apply warm restarts to Adam, following the recent work of Loshchilov & Hutter (2016). There, the authors proposed Stochastic Gradient Descent with Warm Restarts (SGDR) to improve anytime performance of SGD by quickly cooling down the learning rate and periodically increasing it. SGDR has been successfully adopted to lead to new state-of-the-art results for popular image classification benchmarks (Huang et al., 2017; Gastaldi, 2017), and we therefore tried extending it to Adam. However, while our initial version of Adam with warm restarts had better anytime performance than Adam, it was not competitive with SGD with warm restarts, precisely because of Adam’s dysfunctional weight decay. Now, having fixed weight decay regularization (Section 2) and also having introduced normalized weight decay (Section 3), the work of Loshchilov & Hutter (2016) on warm restarts directly carries over, and we use it to construct AdamWR to fully benefit from warm restarts.
In the interest of keeping the presentation self-contained, we briefly describe how SGDR schedules the change of the effective learning rate in order to accelerate the training of DNNs. Here, we decouple the initial learning rate and its multiplier $\eta _ { t }$ used to obtain the actual learning rate at iteration $t$ (see, e.g., line 8 in Algorithm 1). In SGDR, we simulate a new warm-started run/restart of SGD once $T _ { i }$ epochs are performed, where $i$ is the index of the run. Importantly, the restarts are not performed from scratch but emulated by increasing $\eta _ { t }$ while the old value of $\mathbf { } _ { \pmb { x } _ { t } }$ is used as an initial solution. The amount by which $\eta _ { t }$ is increases controls to which extent the previously acquired information (e.g., momentum) is used. Within the $i \cdot$ -th run, the value of $\eta _ { t }$ decays according to the cosine annealing (Loshchilov & Hutter, 2016) for each batch as follows:
$$\eta _ { t } = \eta _ { m i n } ^ { ( i ) } + 0 . 5 ( \eta _ { m a x } ^ { ( i ) } - \eta _ { m i n } ^ { ( i ) } ) ( 1 + \cos ( \pi T _ { c u r } / T _ { i } ) ) ,$$
where η min and $\eta _ { m a x } ^ { ( i ) }$ are ranges for the multiplier and $T _ { c u r }$ accounts for how many epochs have been performed since the last restart. $T _ { c u r }$ is updated at each batch iteration $t$ and is thus not constrained to integer values. Adjusting (e.g., decreasing) η(i)min and $\eta _ { m a x } ^ { ( i ) }$ at every $i$ -th restart (see also Smith (2016)) could potentially improve performance, but we do not consider that option in our experiments because it would involve additional hyperparameters. For $\eta _ { m a x } ^ { ( i ) } = 1$ and $\eta _ { m i n } ^ { ( i ) } = 0$ , one can simplify Eq. (6) to
$$\eta _ { t } = 0 . 5 + 0 . 5 \cos ( \pi T _ { c u r } / T _ { i } ) .$$
In order to maintain a good anytime performance, one can start with an initially small $T _ { i }$ (e.g., from $1 \%$ to $10 \%$ of the expected total budget) and multiply it by a factor of $T _ { m u l t }$ (e.g., $T _ { m u l t } = 2$ ) at every restart. The $( i + 1 )$ -th restart is triggered when $T _ { c u r } = T _ { i }$ by setting $T _ { c u r }$ to 0. An example setting of the schedule multiplier is given in Section 1.1 of the supplementary material. Note that the effective learning rate is controlled by $\eta _ { t } \alpha _ { t }$ where $\alpha _ { t }$ is set to the initial learning rate and stays constant in our experimental setup. The reason why we employ $\alpha _ { t }$ and not simply $\alpha$ is to account for possible practical extensions, e.g., to adapt $\alpha _ { t }$ as a function of batch size in (scheduled) large-batch settings.
Our proposed AdamWR algorithm represents AdamW given in Algorithm 2 with $\eta _ { t }$ following Eq. (7) and $w _ { t }$ computed at each iteration using normalized weight decay according to Eq. (5). We note that normalized weight decay allowed us to use a constant parameter setting across short and long runs performed within AdamWR. Equivalently to AdamWR, we define SGDWR as SGDW with warm restarts.
# 5 EXPERIMENTAL VALIDATION
Our experimental setup follows that of Gastaldi (2017), who proposed, in addition to $\mathrm { L _ { 2 } }$ regularization, to apply the new Shake-Shake regularization to a 3-branch residual neural network. Gastaldi (2017) showed that this regularization allowed to achieve new state-of-the-art results of $2 . 8 6 \%$ on the CIFAR-10 dataset (Krizhevsky, 2009) and of $1 5 . 8 5 \%$ on CIFAR-100. The network was trained by SGDR with batch size 128 for 1800 epochs $\begin{array} { r } { T _ { 0 } = 1 8 0 0 \mathrm { \Omega } } \end{array}$ ) without restarts with the learning rate scheduled by Eq. (6). The regular data augmentation procedure used for the CIFAR datasets was applied. We used the same model/source code based on fb.resnet.torch 1. The base networks are a 26 2x64d ResNet (i.e. the network has a depth of 26, 2 residual branches and the first residual block has a width of 64) and $2 6 2 \mathrm { x } 9 6 \mathrm { d }$ ResNet with 11.6M and 25.6M parameters, respectively. For a detailed description of the network and the Shake-Shake method, we refer the interested reader to Gastaldi (2017).
# 5.1 DECOUPLING THE WEIGHT DECAY AND INITIAL LEARNING RATE PARAMETERS
In order to verify our hypothesis about the coupling of the initial learning rate $\alpha _ { t }$ and the weight decay factor $w _ { t }$ , we trained a 2x64d ResNet with cosine annealing for 100 epochs with different settings of $\alpha _ { t }$ and $w _ { t }$ . Throughout this paper, we scheduled the learning rate with cosine annealing because it leads to better results than a fixed learning rate (see SuppFigure 1 in the supplementary material). Figure 1 compares SGD vs. SGDW (top row) and Adam vs. AdamW (bottom row). For the case of SGD (Figure 1, top left), weight decay is not decoupled from the learning rate (the common way as described in Algorithm 1), and the figure clearly shows that the basin of best hyperparameter settings (depicted by color and top-10 hyperparameter settings by black circles) is not aligned with the $\mathbf { X }$ -axis or y-axis but lies on the diagonal. This suggests that the two hyperparameters are interdependent and need to be changed simultaneously, while only changing one of them might substantially worsen results. Consider, e.g., the setting at the top left black circle $( \alpha _ { t } = 1 / 2$ , $w _ { t } = 1 / 8 * 0 . 0 0 1 )$ ; only changing either $\alpha _ { t }$ or $w _ { t }$ by itself would worsen results, while changing both of them could still yield clear improvements. We note that this coupling of initial learning rate and weight decay factor might have contributed to SGD’s reputation of being very sensitive to its hyperparameter settings.
 Figure 1: The Top-1 test error of a 26 2x64d ResNet on CIFAR-10 measured after 100 epochs. The proposed SGDW and AdamW (right column) have a more separable hyperparameter space.
In contrast, the results for our new SGDW in Figure 1 (top right) show that SGDW decouples weight decay and initial learning rate. The proposed approach renders the two hyperparameters more separable: even if the learning rate is not well tuned yet (e.g., consider the value of 1/1024 in Figure 1, top right), leaving it fixed and only optimizing the weight decay factor would yield a good value (of $1 / 4 ^ { * } 0 . 0 0 1$ ). This is not the case for the original SGD shown in Figure 1 (top left).
The results for different hyperparameter settings of the original Adam are given in Figure 1 (bottom left). Adam’s best hyperparameter settings performed clearly worse than SGD’s best ones (compare Figure 1, top left). While both methods use the original way to employ weight decay, the original Adam did not benefit from it at all: its best results obtained for non-zero weight decay values were comparable to the best ones obtained without the weight decay regularization, i.e., when $w _ { t } = 0$ . Similarly to the original SGD, the shape of the hyperparameter landscape suggests that the two hyperparameters are coupled.
In contrast, the results for our new AdamW in Figure 1 (bottom right) show that AdamW largely decouples weight decay and learning rate. The results for the best hyperparameter settings were substantially better than the best ones of the original Adam and rivaled those of SGD and SGDW.
 Figure 2: Learning curves (top row) and generalization results (bottom row) obtained by a $2 6 2 \mathrm { x } 9 6 \mathrm { d }$ ResNet trained with Adam and AdamW on CIFAR-10. See text for details.
In summary, the experimental results in Figure 1 support our hypothesis that the weight decay and learning rate hyperparameters can be decoupled, and that this in turn simplifies the problem of hyperparameter tuning in SGD and improves Adam’s performance to be competitive w.r.t. SGD with momentum.
# 5.2 BETTER GENERALIZATION OF ADAMW
While the previous experiment suggested that the basin of optimal hyperparameters of AdamW is broader and deeper than the one of Adam, we next investigated the results for much longer runs of 1800 epochs to compare the generalization capabilities of AdamW and Adam.
We fixed the initial learning rate to 0.001 which represents both the default learning rate for Adam and the one which showed reasonably good results in our experiments. Figure 2 shows the results for 12 settings of the weight decay of Adam and 7 settings of the normalized weight decay of AdamW. Interestingly, while the dynamics of the learning curves of Adam and AdamW often coincided for the first half of the training run, AdamW often led to lower training loss and test errors (see Figure 2 top left and top right, respectively). Importantly, the use of weight decay in Adam did not yield as good results as in AdamW (see also Figure 2, bottom left). Next, we investigated whether AdamW’s better results were only due to better convergence or due to better generalization. The results in Figure 2 (bottom right) for the best settings of Adam and AdamW suggest that AdamW did not only yield better training loss but also yielded better generalization performance for similar training loss values. The results on ImageNet32x32 (see SuppFigure 4 in the supplementary material) lead to the same conclusion of substantially improved generalization performance.
 Figure 3: Top-1 test error on CIFAR-10 (left) and Top-5 test error on ImageNet32x32 (right).
5.3 EASIER HYPERPARAMETER SELECTION DUE TO NORMALIZED WEIGHT DECAY
Our experimental results with Adam and SGD suggested that the total runtime in terms of the number of epochs affect the basin of optimal hyperparameters (see SuppFigure 3 in the supplementary material). More specifically, the greater the total number of epochs the smaller the values of the weight decay should be. SuppFigure 3 shows that our remedy for this problem, the normalized weight decay defined in Eq. (7), simplifies hyperparameter selection because the optimal values observed for short runs are similar to the ones for much longer runs. While our initial experiments on CIFAR-10 suggested the square root fit we proposed in Eq. (7), to double-check that this is not a coincidence, we also performed experiments on the ImageNet32x32 dataset (Chrabaszcz et al., 2017), a downsampled version of the original ImageNet dataset with 1.2 million $3 2 \times 3 2$ pixels images, where an epoch is 24 times longer than on CIFAR-10. This experiment also supported the square root scaling: the best values of the normalized weight decay observed on CIFAR-10 represented nearly optimal values for ImageNet $3 2 \mathrm { x } 3 2 $ (see SuppFigure 3). In contrast, had we used the same raw weight decay values $w _ { t }$ for ImageNet32x32 as for CIFAR-10 and for the same number of epochs, without the proposed normalization, $w _ { t }$ would have been roughly 5 greater than optimal for ImageNet32x32, leading to much worse performance. The optimal normalized weight decay values were also very similar (e.g., $w _ { n o r m } = 0 . 0 2 5$ and $w _ { n o r m } = 0 . 0 5$ ) across SGDW and AdamW.
We investigated whether the use of much longer runs (1800 epochs) of the original Adam with $\mathrm { L _ { 2 } }$ regularization makes the use of cosine annealing unnecessary. The results of Adam without cosine annealing (i.e., with fixed learning rate) for a 4 by 4 logarithmic grid of hyperparameter settings are given in SuppFigure 5 in the supplementary material. Even after taking into account the low resolution of the grid, the results appear to be at best comparable to the ones obtained with AdamW with 18 times less epochs and a smaller network (see SuppFigure 2). These results are not very surprising given Figure 1 (which demonstrates the effectiveness of AdamW) and SuppFigure 2 (which demonstrates the necessity to use some learning rate schedule such as cosine annealing).
# 5.4 ADAMWR WITH WARM RESTARTS FOR BETTER ANYTIME PERFORMANCE
Finally, we investigated the strong anytime performance AdamWR obtains from warm restarts (using normalized weight decay to avoid the need for a different weight decay factor for restarts with longer annealing schedules). As Figure 3 shows, AdamWR greatly sped up AdamW on CIFAR10 and ImageNet32x32, up to a factor of 10 (see the results at the first restart). For the default learning rate of 0.001, AdamW achieved $15 \%$ relative improvement in test errors compared to Adam both on CIFAR-10 (also see Figure 2) and ImageNet32x32 (also see SuppFigure 4). AdamWR achieved the same improved results but with a much better anytime performance. These improvements closed most of the gap between Adam and SGDWR on CIFAR-10 and yielded comparable performance on ImageNet32x32.
# 6 DISCUSSION AND CONCLUSION
Following suggestions that adaptive gradient methods such as Adam might lead to worse generalization than SGD with momentum (Wilson et al., 2017), we identified at least one possible explanation to this phenomenon: the dysfunctional use of $\mathrm { L _ { 2 } }$ regularization and weight decay. We proposed a simple fix to deal with this issue, yielding substantially better generalization performance in our AdamW variant. We also proposed normalized weight decay and warm restarts for Adam, showing that a more robust hyperparameteer selection and a better anytime performance can be achieved in our new AdamWR variant.
Our preliminary results obtained with AdamW and AdamWR on image classification datasets must be verified on a wider range of tasks, especially the ones where the use of regularization is expected to be important. It would be interesting to integrate our findings on weight decay into other methods which attempt to improve Adam, e.g, normalized direction-preserving Adam (Zhang et al., 2017). While we focussed our experimental analysis on Adam, we believe that similar results also hold for other adaptive gradient methods, such as AdaGrad (Duchi et al., 2011) and RMSProp (Tieleman & Hinton, 2012).
The results shown in Figure 2 suggest that Adam and AdamW follow very similar curves most of the time until the third phase of the run where AdamW starts to branch out to outperform Adam. As pointed out by an anonymous reviewer, it would be interesting to investigate what causes this branching and whether the desired effects are observed at the bottom of the landscape. One could investigate this using the approach of Im et al. (2016) to switch from Adam to AdamW at a given epoch index. Since it is quite possible that the effect of regularization is not that pronounced in the early stages of training, one could think of designing a version of Adam which exploits this by being fast in the early stages and well-regularized in the late stages of training. The latter might be achieved with a custom schedule of the weight decay factor.
In this paper, we argue that the popular interpretation that weight decay $\mathbf { \tau } = \mathbf { L } _ { 2 }$ regularization is not precise. Instead, the difference between the two leads to the following important consequences. Two algorithms as different as SGD and Adam will exhibit different effective rates of weight decay even if the same regularization coefficient is used to include $\mathrm { L _ { 2 } }$ regularization in the objective function. Moreover, when decoupled weight decay is applied, two algorithms as different as SGDW and AdamW will optimize two effectively different objective functions even if the same weight decay factor is used. Our findings suggest that the original Adam algorithm with $\mathrm { L _ { 2 } }$ regularization affects effective rates of weight decay in a way that precludes effective regularization, and that effective regularization is achievable by decoupling the weight decay.
Advani & Saxe (2017) analytically showed that in the limited data regime of deep networks the presence of eigenvalues that are zero forms a frozen subspace in which no learning occurs and thus smaller (e.g., zero) initial weight norms should be used to achieve best generalization results. Our future work shall consider adapting initial weight norms or weight norm constraints (Salimans & Kingma, 2016) at each warm restart. Kawaguchi et al. (2017) proposed a family of regularization techniques which are specific to the current batch and its size. Similarly to $\mathrm { L _ { 2 } }$ regularization and weight decay, the latter techniques might be attempted to be transformed to act directly on weights.
# REFERENCES
Madhu S. Advani and Andrew M. Saxe. High-dimensional dynamics of generalization error in neural networks. arXiv:1710.03667, 2017. Patryk Chrabaszcz, Ilya Loshchilov, and Frank Hutter. A downsampled variant of ImageNet as an alternative to the CIFAR datasets. arXiv:1707.08819, 2017. Laurent Dinh, Razvan Pascanu, Samy Bengio, and Yoshua Bengio. Sharp minima can generalize for deep nets. arXiv:1703.04933, 2017. John Duchi, Elad Hazan, and Yoram Singer. Adaptive subgradient methods for online learning and stochastic optimization. The Journal of Machine Learning Research, 12:2121–2159, 2011. Xavier Gastaldi. Shake-Shake regularization. arXiv preprint arXiv:1705.07485, 2017.
Karol Gregor, Ivo Danihelka, Alex Graves, Danilo Jimenez Rezende, and Daan Wierstra. Draw: A recurrent neural network for image generation. arXiv:1502.04623, 2015.
Stephen Jose Hanson and Lorien Y Pratt. Comparing biases for minimal network construction with ´ back-propagation. In Proceedings of the 1st International Conference on Neural Information Processing Systems, pp. 177–185, 1988.
Gao Huang, Zhuang Liu, and Kilian Q Weinberger. Densely connected convolutional networks. arXiv:1608.06993, 2016.
Gao Huang, Yixuan Li, Geoff Pleiss, Zhuang Liu, John E Hopcroft, and Kilian Q Weinberger. Snapshot ensembles: Train 1, get m for free. arXiv:1704.00109, 2017.
Daniel Jiwoong Im, Michael Tao, and Kristin Branson. An empirical analysis of deep network loss surfaces. arXiv preprint arXiv:1612.04010, 2016.
Kenji Kawaguchi, Leslie Pack Kaelbling, and Yoshua Bengio. Generalization in deep learning. arXiv:1710.05468, 2017.
Nitish Shirish Keskar, Dheevatsa Mudigere, Jorge Nocedal, Mikhail Smelyanskiy, and Ping Tak Peter Tang. On large-batch training for deep learning: Generalization gap and sharp minima. arXiv:1609.04836, 2016.
Diederik Kingma and Jimmy Ba. Adam: A method for stochastic optimization. arXiv:1412.6980, 2014.
Alex Krizhevsky. Learning multiple layers of features from tiny images. 2009.
Hao Li, Zheng Xu, Gavin Taylor, and Tom Goldstein. Visualizing the loss landscape of neural nets. arXiv preprint arXiv:1712.09913, 2017.
Ilya Loshchilov and Frank Hutter. SGDR: stochastic gradient descent with warm restarts. arXiv:1608.03983, 2016.
Alec Radford, Luke Metz, and Soumith Chintala. Unsupervised representation learning with deep convolutional generative adversarial networks. arXiv:1511.06434, 2015.
Tim Salimans and Diederik P Kingma. Weight normalization: A simple reparameterization to accelerate training of deep neural networks. In Advances in Neural Information Processing Systems, pp. 901–909, 2016.
Leslie N Smith. Cyclical learning rates for training neural networks. arXiv:1506.01186v3, 2016.
Tijmen Tieleman and Geoffrey Hinton. Lecture 6.5-rmsprop: Divide the gradient by a running average of its recent magnitude. COURSERA: Neural networks for machine learning, 4(2):26– 31, 2012.
Ashia C Wilson, Rebecca Roelofs, Mitchell Stern, Nathan Srebro, and Benjamin Recht. The marginal value of adaptive gradient methods in machine learning. arXiv:1705.08292, 2017.
Kelvin Xu, Jimmy Ba, Ryan Kiros, Kyunghyun Cho, Aaron Courville, Ruslan Salakhudinov, Rich Zemel, and Yoshua Bengio. Show, attend and tell: Neural image caption generation with visual attention. In International Conference on Machine Learning, pp. 2048–2057, 2015.
Zijun Zhang, Lin Ma, Zongpeng Li, and Chuan Wu. Normalized direction-preserving adam. arXiv:1709.04546, 2017.
# 1 SUPPLEMENTARY MATERIAL
# 1.1 AN EXAMPLE SETTING OF THE SCHEDULE MULTIPLIER
An example schedule of the schedule multiplier $\eta _ { t }$ is given in SuppFigure 1 for $T _ { i = 0 } = 1 0 0$ and $T _ { m u l t } = 2$ . After the initial 100 epochs the learning rate will reach 0 because $\eta _ { t = 1 0 0 } = 0$ . Then, since $T _ { c u r } = T _ { i = 0 }$ , we restart by resetting $T _ { c u r } = 0$ , causing the multiplier $\eta _ { t }$ to be reset to 1 due to Eq. (7). This multiplier will then decrease again from 1 to 0, but now over the course of 200 epochs because $T _ { i = 1 } = T _ { i = 0 } T _ { m u l t } = 2 0 0$ . Solutions obtained right before the restarts, when $\eta _ { t } = 0$ (e.g., at epoch indexes 100, 300, 700 and 1500 as shown in SuppFigure 1) are recommended by the optimizer as the solutions, with more recent solutions prioritized.
 SuppFigure 1: An example schedule of the learning rate multiplier as a function of epoch index. The first run is scheduled to converge at epoch $T _ { i = 0 } = 1 0 0$ , then the budget for the next run is doubled as $T _ { i = 1 } = T _ { i = 0 } T _ { m u l t } = 2 0 0$ , etc.
 SuppFigure 2: Adam with fixed learning rate (left) and with cosine annealing (right). We show the final test error of a $2 6 ~ 2 \mathrm { x } 6 4 \mathrm { d }$ ResNet on CIFAR-10 after 100 epochs of SGD with momentum. The results where the learning rate is fixed (left) are inferior to the ones where the learning rate is scheduled according to cosine annealing (right). Therefore, we schedule the learning rate with cosine annealing for all methods given in the paper.
 SuppFigure 3: Effect of normalized weight decay. We show the final test Top-1 error on CIFAR10 (first two rows for AdamW without and with normalized weight decay) and Top-5 error on ImageNet32x32 (last two rows for AdamW and SGDW, both with normalized weight decay) of a $2 6 2 \mathrm { x } 6 4 \mathrm { d }$ ResNet after different numbers of epochs (see columns). While the optimal settings of the raw weight decay change significantly for different runtime budgets (see the first row), the values of the normalized weight decay remain very similar for different budgets (see the second row) and different datasets (here, CIFAR-10 and ImageNet32x32), and even across AdamW and SGDW.
 SuppFigure 4: Learning curves (top row) and generalization results (Top-5 errors in bottom row) obtained by a $2 6 2 \mathrm { x } 9 6 \mathrm { d }$ ResNet trained with Adam and AdamW on ImageNet32x32.
 SuppFigure 5: Adam without cosine annealing, i.e., with fixed learning rate. We show the final test error of a $2 6 ~ 2 \mathrm { x } 9 6 \mathrm { d }$ ResNet on CIFAR-10 after 1800 epochs of the original Adam for different settings of learning rate and weight decay used for $\mathrm { L _ { 2 } }$ regularization. These results can be compared to the ones of AdamW shown in SuppFigure 3 (top row). The results of AdamW with only 100 epochs and a smaller network seem to be at least as good as the ones of Adam with 18 times as many epochs and a bigger network.md/train/rJxgknCcK7/rJxgknCcK7.mdAdded+317
md/train/rJxpuoCqtQ/rJxpuoCqtQ.mdAdded+479
md/train/rJxt0JHKvS/rJxt0JHKvS.mdAdded+475
md/train/rJzIBfZAb/rJzIBfZAb.mdAdded+398
md/train/rJzLciCqKm/rJzLciCqKm.mdAdded+572
md/train/rYhBGWYm6AU/rYhBGWYm6AU.mdAdded+223
md/train/rbdKZJxDWWx/rbdKZJxDWWx.mdAdded+214
md/train/rcQdycl0zyk/rcQdycl0zyk.mdAdded+344
md/train/rdT5GV-LnZU/rdT5GV-LnZU.mdAdded+529
md/train/rh0vIXw6i33/rh0vIXw6i33.mdAdded+396
md/train/rk49Mg-CW/rk49Mg-CW.mdAdded+267
md/train/rk4Fz2e0b/rk4Fz2e0b.mdAdded+281
md/train/rk4Qso0cKm/rk4Qso0cKm.mdAdded+340
md/train/rk5UYassf/rk5UYassf.mdAdded+160
md/train/rk5upnsxe/rk5upnsxe.mdAdded+327
md/train/rk6H0ZbRb/rk6H0ZbRb.mdAdded+334
md/train/rk6cfpRjZ/rk6cfpRjZ.mdAdded+239
md/train/rk6qdGgCZ/rk6qdGgCZ.mdAdded+252
md/train/rk8wKk-R-/rk8wKk-R-.mdAdded
md/train/rk9eAFcxg/rk9eAFcxg.mdAdded
md/train/rkA1f3NpZ/rkA1f3NpZ.mdAdded
md/train/rkE3y85ee/rkE3y85ee.mdAdded
md/train/rkE8pVcle/rkE8pVcle.mdAdded
md/train/rkEFLFqee/rkEFLFqee.mdAdded
md/train/rkEfPeZRb/rkEfPeZRb.mdAdded
md/train/rkFBJv9gg/rkFBJv9gg.mdAdded
md/train/rkGG6s0qKQ/rkGG6s0qKQ.mdAdded
md/train/rkGZuJb0b/rkGZuJb0b.mdAdded
md/train/rkGabzZgl/rkGabzZgl.mdAdded
md/train/rkHVZWZAZ/rkHVZWZAZ.mdAdded
md/train/rkKCdAdgx/rkKCdAdgx.mdAdded
md/train/rkMW1hRqKX/rkMW1hRqKX.mdAdded
md/train/rkQkBnJAb/rkQkBnJAb.mdAdded
md/train/rkQu4Wb0Z/rkQu4Wb0Z.mdAdded
md/train/rkRwGg-0Z/rkRwGg-0Z.mdAdded
md/train/rkTBjG-AZ/rkTBjG-AZ.mdAdded
md/train/rkTS8lZAb/rkTS8lZAb.mdAdded
md/train/rkWN3g-AZ/rkWN3g-AZ.mdAdded
md/train/rkYTTf-AZ/rkYTTf-AZ.mdAdded
md/train/rkZB1XbRZ/rkZB1XbRZ.mdAdded
md/train/rkZvSe-RZ/rkZvSe-RZ.mdAdded
md/train/rkZzY-lCb/rkZzY-lCb.mdAdded
md/train/rkaSvlnoG/rkaSvlnoG.mdAdded
md/train/rkaT3zWCZ/rkaT3zWCZ.mdAdded
md/train/rkaqxm-0b/rkaqxm-0b.mdAdded
md/train/rkcQFMZRb/rkcQFMZRb.mdAdded
md/train/rkcya1ZAW/rkcya1ZAW.mdAdded
md/train/rkdU7tCaZ/rkdU7tCaZ.mdAdded
md/train/rke3TJrtPS/rke3TJrtPS.mdAdded
md/train/rke41hC5Km/rke41hC5Km.mdAdded