Datasets:
Tasks:
Question Answering
Modalities:
Image
Formats:
imagefolder
Languages:
English
Size:
100K - 1M
ArXiv:
License:
Add files using upload-large-folder tool
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
Files changed (50)
- md/train/-oUhJJILWHb/-oUhJJILWHb.mdAdded+197
- md/train/1-j4VLSHApJ/1-j4VLSHApJ.mdAdded+256
- md/train/9CPc4EIr2t1/9CPc4EIr2t1.mdAdded+294
- md/train/B1eksh4KvH/B1eksh4KvH.mdAdded+258
- md/train/B1g5sA4twr/B1g5sA4twr.mdAdded+442
- md/train/B1l08oAct7/B1l08oAct7.mdAdded
- md/train/B1n8LexRZ/B1n8LexRZ.mdAdded+438
- md/train/BJ5UeU9xx/BJ5UeU9xx.mdAdded+236
- md/train/BJlahxHYDS/BJlahxHYDS.mdAdded+567
- md/train/BJuysoFeg/BJuysoFeg.mdAdded+240
- md/train/BJxH22EKPS/BJxH22EKPS.mdAdded+390
- md/train/BJxpIJHKwB/BJxpIJHKwB.mdAdded+417
- md/train/BklIxyHKDr/BklIxyHKDr.mdAdded+466
- md/train/By4HsfWAZ/By4HsfWAZ.mdAdded+313
- md/train/ByJWeR1AW/ByJWeR1AW.mdAdded+288
- md/train/Byg9A24tvB/Byg9A24tvB.mdAdded+515
- md/train/BygFVAEKDH/BygFVAEKDH.mdAdded+376
- md/train/BygZK2VYvB/BygZK2VYvB.mdAdded+316
- md/train/ByxkijC5FQ/ByxkijC5FQ.mdAdded
- md/train/E4PK0rg2eP/E4PK0rg2eP.mdAdded
- md/train/EsA9Nr9JHvy/EsA9Nr9JHvy.mdAdded
- md/train/GY6-6sTvGaf/GY6-6sTvGaf.mdAdded
- md/train/H1K6Tb-AZ/H1K6Tb-AZ.mdAdded
- md/train/H1edIiA9KQ/H1edIiA9KQ.mdAdded
- md/train/H1ltQ3R9KQ/H1ltQ3R9KQ.mdAdded
- md/train/HJC2SzZCW/HJC2SzZCW.mdAdded
- md/train/HJe4Cp4KwH/HJe4Cp4KwH.mdAdded
- md/train/HJeO7RNKPr/HJeO7RNKPr.mdAdded
- md/train/HJxyZkBKDr/HJxyZkBKDr.mdAdded
- md/train/HWX5j6Bv_ih/HWX5j6Bv_ih.mdAdded
- md/train/HkezXnA9YX/HkezXnA9YX.mdAdded
- md/train/HkgHk3RctX/HkgHk3RctX.mdAdded
- md/train/HkzRQhR9YX/HkzRQhR9YX.mdAdded
- md/train/HkzSQhCcK7/HkzSQhCcK7.mdAdded
- md/train/HyEtjoCqFX/HyEtjoCqFX.mdAdded
- md/train/HygUOoC5KX/HygUOoC5KX.mdAdded
- md/train/LSFCEb3GYU7/LSFCEb3GYU7.mdAdded
- md/train/LU687itn08w/LU687itn08w.mdAdded
- md/train/LVWcGZr-8h/LVWcGZr-8h.mdAdded
- md/train/MNVjrDpu6Yo/MNVjrDpu6Yo.mdAdded
- md/train/N9oPAFcuYWX/N9oPAFcuYWX.mdAdded
- md/train/QYjO70ACDK/QYjO70ACDK.mdAdded
- md/train/QkRbdiiEjM/QkRbdiiEjM.mdAdded
- md/train/QpT9Q_NNfQL/QpT9Q_NNfQL.mdAdded
- md/train/RHY_9ZVcTa_/RHY_9ZVcTa_.mdAdded
- md/train/RYcgfqmAOHh/RYcgfqmAOHh.mdAdded
- md/train/S1lyyANYwr/S1lyyANYwr.mdAdded
- md/train/S1x1IkHtPr/S1x1IkHtPr.mdAdded
- md/train/SJDJNzWAZ/SJDJNzWAZ.mdAdded
- md/train/SJTQLdqlg/SJTQLdqlg.mdAdded
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197# Learning Debiased Representation via Disentangled Feature Augmentation
Jungsoo Lee\*1,2 Eungyeup $\mathbf { K i m } ^ { * 1 , 2 }$ Juyoung Lee2 Jihyeon Lee1 Jaegul Choo1
1KAIST AI, 2Kakao Enterprise, South Korea 1{bebeto, eykim94, gina3833, jchoo}@kaist.ac.kr, 2{bebeto.lee, josh.ey, michael.jy}@kakaoenterprise.com
# Abstract
Image classification models tend to make decisions based on peripheral attributes of data items that have strong correlation with a target variable (i.e., dataset bias). These biased models suffer from the poor generalization capability when evaluated on unbiased datasets. Existing approaches for debiasing often identify and emphasize those samples with no such correlation (i.e., bias-conflicting) without defining the bias type in advance. However, such bias-conflicting samples are significantly scarce in biased datasets, limiting the debiasing capability of these approaches. This paper first presents an empirical analysis revealing that training with “diverse” bias-conflicting samples beyond a given training set is crucial for debiasing as well as the generalization capability. Based on this observation, we propose a novel feature-level data augmentation technique in order to synthesize diverse bias-conflicting samples. To this end, our method learns the disentangled representation of (1) the intrinsic attributes (i.e., those inherently defining a certain class) and (2) bias attributes (i.e., peripheral attributes causing the bias), from a large number of bias-aligned samples, the bias attributes of which have strong correlation with the target variable. Using the disentangled representation, we synthesize bias-conflicting samples that contain the diverse intrinsic attributes of bias-aligned samples by swapping their latent features. By utilizing these diversified bias-conflicting features during the training, our approach achieves superior classification accuracy and debiasing results against the existing baselines on synthetic and real-world datasets.
# 1 Introduction
Despite the recent advancement of deep neural networks, they often rely overly on the correlation between peripheral attributes and labels, referred to as dataset bias [1], especially when such strong bias is found in a given dataset. A majority of samples in the biased dataset exhibit visual attributes that are not innate but frequently co-occur with target labels (i.e., bias attributes). For example, most of the bird images in the training dataset may contain the background as the blue sky, while the birds may still be found in different places. Thus, the model trained with such a biased dataset is likely to learn the bias attributes more than intrinsic attributes, the innate visual attributes that inherently define a certain class, e.g., the wings of birds. This causes the model to learn shortcuts for classification [2], failing to generalize on the images with no such correlations (e.g., birds on grounds or grass) during the test phase. Throughout the paper, bias-aligned samples correspond to data items containing a strong correlation between bias attributes and labels (e.g., birds in the sky), while bias-conflicting samples indicate the other cases that are rarely found (e.g., birds on grounds).
To tackle such a task, previous studies often define a specific bias type (e.g., color and texture) in advance [3, 4, 5, 6, 7, 8, 9, 10], which enables them to design a debiasing network tailored for the predefined bias type. For example, Bahng et al. [6] leverage BagNet [11], which has limited size of receptive fields, to focus on learning color and texture. However, defining a bias type in advance 1) limits the capability of debiasing in other bias types and 2) requires expensive labor to manually identify the bias type. To handle such an issue, a recent approach [12] defines a bias based on an intuitive observation that the bias attributes are often easier to learn than the intrinsic attributes for neural networks. In this regard, they re-weight bias-conflicting samples while de-emphasizing the bias-aligned ones. However, we point out that the reason behind the limited generalization capability of existing debiasing approaches lies in the significant scarcity of bias-conflicting samples compared to the bias-aligned ones in a given training set. In other words, it is challenging to learn the debiased representation from these scarce bias-conflicting samples because the models are prone to memorize (thus being overfitted to) these samples, failing to learn the intrinsic attributes. Therefore, we claim that a neural network can learn properly debiased representation when these data items are diversified during training.
We conduct a brief experiment to demonstrate the importance of diversity in debiasing. Diversity in our work indicates the different valid realization of intrinsic attributes in a certain class (e.g., thick, narrow, tilted, and scribbled digit shapes in MNIST [13]). Our observation is that training a model with diverse bias-conflicting samples beyond a given training set is crucial for learning debiased representation (Section 3.2). In this regard, synthesizing bias-conflicting samples is one of the straightforward approaches to increase the diversity of such samples. In fact, a large amount of bias-aligned samples in a given training set already contain diverse intrinsic attributes, which can work as informative sources for increasing the diversity. However, as bias and intrinsic attributes are highly entangled in their embedding space, it is difficult to extract the intrinsic ones from these bias-aligned samples. Therefore, disentangling these correlations enables to synthesize diversified bias-conflicting samples that originate from bias-aligned samples.
In this paper, we propose a novel feature augmentation approach via disentangled representation for debiasing. We first train two different encoders to embed images into the disentangled representation of their intrinsic and bias attributes. With the disentangled representation, we randomly swap the latent vectors extracted from different images, most of which are bias-aligned samples in our training set. These swapped features thus contain both bias and intrinsic attributes without the correlation between them, which, in turn, can work as augmented bias-conflicting samples in our training. These features include intrinsic features of bias-aligned ones, increasing the diversity of a given training set, especially for bias-conflicting data items. Furthermore, to enhance the quality of diversified features, we propose a scheduling strategy of feature augmentation which enables to utilize the representation disentangled to a certain degree. In summary, the main contributions of our work include:
• Through our preliminary experiment, we reveal that increasing the diversity of biasconflicting samples is crucial for debiasing. • Based on such an observation, we propose a novel feature augmentation method via disentangled representation for diversifying the bias-conflicting samples. • We achieve the state-of-the-art performances in two synthetic datasets (i.e., Colored MNIST and Corrupted CIFAR-10) and one real-world dataset (i.e., Biased FFHQ) against existing baselines.
# 2 Related Work
Debiasing predefined bias Several existing approaches mitigate the bias by pre-defining a certain bias type, either explicitly [3, 4, 5] or implicitly [6, 7, 8, 9, 10, 14]. For example, Bahng et al. [6] and Wang et al. [7] design a color- and texture-oriented network to adversarially learn a debiased model against the biased one. However, as these methods still require a specific bias type such as texture in advance, they lack the general applicability to the datasets where the bias types are demanding to recognize.
Instead of defining certain types of bias, recent approaches [12, 15, 16] rely on the straightforward assumption that networks are prone to exploit the bias when it acts as a shortcut [2], i.e., easy to learn in the early training phase. Nam et al. [12] emphasize the bias-conflicting samples during training by using generalized cross-entropy loss [17]. Darlow et al. [15] and Huang et al. [16] presume that high gradient of latent vectors accounts for the shortcuts that model learns. In the line with the recent studies, we tackle debiasing without pre-defining a certain bias type.
Table 1: The classification accuracy on the unbiased test sets. The diversity ratio indicates the ratio of bias-conflicting samples in the dataset pooled for each experiment. The sampling ratio refers to the ratio of bias-conflicting samples included in each mini-batch. We report the averaged accuracy over three independent trials with the standard deviation. In both datasets, we observe that the bias can be mitigated with diverse bias-conflicting samples even with a small sampling ratio. Bold and underlined values indicate the best and second best accuracy, respectively.
<table><tr><td>Dataset</td><td>Diversity ratio</td><td>Sampling ratio</td><td>Accuracy (%)</td></tr><tr><td rowspan="4">Colored MNIST</td><td>5%</td><td>50%</td><td>83.77±2.03</td></tr><tr><td>1%</td><td>50%</td><td>67.19±1.99</td></tr><tr><td>5%</td><td>1%</td><td>77.97±6.00</td></tr><tr><td>1%</td><td>1%</td><td>49.91±4.22</td></tr><tr><td rowspan="4">Corrupted CIFAR-10</td><td>5%</td><td>50%</td><td>46.99±0.82</td></tr><tr><td>1%</td><td>50%</td><td>33.08±0.80</td></tr><tr><td>5%</td><td>1%</td><td>36.66±0.55</td></tr><tr><td>1%</td><td>1%</td><td>23.98±0.00</td></tr></table>
Data augmentation for debiasing Geirhos et al. [10] mitigate the texture bias by utilizing additional training images with their styles being transferred by adaptive instance normalization (AdaIN) [18]. Minderer et al. [19] train an image-to-image translation network for removing shortcut cues in the self-supervised task. However, such image-level data augmentation is limited to resolving the predefined texture bias which can not be adopted to other general types of bias.
One alternative is to exploit the latent space for data augmentation. For example, Darlow et al. [15] adversarially perturb the latent vectors corresponding to the high gradients to generate the samples against bias. Zhou et al. [20] mix the style of different source domains by AdaIN [18] to increase the domain generalization ability. Despite the effectiveness of the augmentation in the latent space, the strong unwanted correlation between bias attributes and labels prevents from obtaining the desirable intrinsic features. We resolve this issue by leveraging the disentangled representation in debiasing, which is widely used in image-to-image translation task [21, 22, 23]. To the best of our knowledge, no previous work in debiasing leverage this disentangled representation for the purpose of feature augmentation. For the rest of the paper, we elaborate how we perform the feature augmentation based on the disentangled representation.
# 3 Importance of Diversity in Debiasing
This section describes the details of a toy-set experiment in which we observe the importance of diversity in learning debiased representation. In Section 3.1, we first introduce the two synthetic datasets, Colored MNIST and Corrupted CIFAR-10, that we utilize for the observation. Then, we elaborate the results of the experiments in Section 3.2.
# 3.1 Dataset
Colored MNIST is a modified MNIST dataset [13] with the color bias. We select ten distinct colors and inject each color on the foreground of each digit to create color bias. By adjusting the number of bias-conflicting data samples in the training set, we obtain four different datasets with the ratio of bias-conflicting samples of $0 . 5 \%$ , $1 \%$ , $2 \%$ , and $5 \%$ .
Corrupted CIFAR-10 has ten different types of texture bias applied in CIFAR-10 [24] dataset, constructed by following the design protocol of Hendrycks and Dietterich [25]. Each class is highly correlated with a certain texture (e.g., frost and brightness). Corrupted CIFAR-10 also has four different datasets with their correlation ratios as in Colored MNIST.
# 3.2 Increasing diversity outperforms oversampling
To confirm the significance of diversity of bias-conflicting samples in debiasing, we train four different settings: oversampling bias-conflicting samples by $50 \%$ in each mini-batch (i.e., 128 from a batch size of 256), from the pool of i) $5 \%$ dataset and ii) $1 \%$ dataset, sampling bias-conflicting samples by $1 \%$ in each mini-batch (i.e., 2 from a batch size of 256) from the pool of iii) $5 \%$ dataset and iv) $1 \%$ dataset. Oversampling provides the same amount of bias-conflicting samples as the aligned ones to the model in every training step. Bias-conflicting images sampled from the pool of $5 \%$ dataset have more diverse appearances of bias-conflicting samples compared to those from $1 \%$ dataset.
Table 1 shows the image classification accuracy of each setting validated on the unbiased test images. Apparently, oversampling diverse bias-conflicting samples (first row) outperforms the other three methods. Similarly, sampling a small amount of bias-conflicting samples with the least diversity (fourth row) shows the lowest classification accuracy. The interesting finding is that sampling fewer but diverse conflicting samples in each mini-batch (third row) outperforms oversampling bias-conflicting samples with limited diversity (second row). These results lead to the conclusion that the diversity of bias-conflicting samples is a more crucial factor for learning debiased representation than the ratio of sampling in the training. As the diversity is limited (the latter case), the model can be easily overfitted to the given bias-conflicting samples, thus less likely to learn the generalized intrinsic attributes. With the Colored MNIST as an example, the shape of digits may vary. To be more specific, the digit shape may be thick, narrow, tilted, scribbled, and etc. If the bias-conflicting samples do not include certain visual facets (e.g., not including scribbled digit images) due to the limited number of samples, the model may imperfectly learn the intrinsic attributes of digit shapes. On the other hand, in the former case (third row), the model can learn multiple facets of intrinsic attributes when they are sampled from the diverse pool of datasets, resulting in learning intrinsic attributes even without oversampling the bias-conflicting images.
# 4 Debiasing via disentangled feature augmentation
Motivated by such an observation in Section 3.2, we propose a feature-level augmentation strategy for synthesizing additional bias-conflicting samples, as illustrated in Fig. 1. First, we train the two separate encoders which embed an image into disentangled latent vectors corresponding to the intrinsic and bias attributes, respectively (Section 4.1). Swapping these feature vectors among training samples enables to augment the bias-conflicting samples which no more contain a correlation between two attributes (Section 4.2). To further enhance the effectiveness, we schedule the feature augmentation after the representation is disentangled at a certain degree (Section 4.3).
# 4.1 Learning disentangled representation
In contrast to the bias-conflicting samples, a large amount of bias-aligned images have diverse appearances of their intrinsic attributes. By leveraging these attributes for augmentation, we can naturally obtain the diversified bias-conflicting samples containing the diverse intrinsic attributes. However, it remains challenging in that these attributes are strongly correlated with the bias attributes in the bias-aligned samples. Therefore, we propose to design two encoders with their linear classifiers to extract the disentangled latent vectors from the input images.
As shown in Fig. 1, encoders $E _ { i }$ and $E _ { b }$ embed an image $x$ into intrinsic feature vectors $z _ { i } = E _ { i } ( x )$ and bias feature vectors $z _ { b } = E _ { b } ( x )$ , respectively. Afterward, linear classifiers $C _ { i }$ and $C _ { b }$ take the concatenated vector $z = [ z _ { i } ; z _ { b } ]$ as input to predict the target label $y$ . To train $E _ { i }$ and $C _ { i }$ as intrinsic feature extractor and $E _ { b }$ and $C _ { b }$ as bias extractor, we utilize the relative difficulty score of each data sample, proposed in the previous work of Nam et al. [12]. More specifically, we train $E _ { b }$ and $C _ { b }$ to be overfitted to the bias attributes by utilizing the generalized cross entropy (GCE) [17], while $E _ { i }$ and $C _ { i }$ are trained with the cross entropy (CE) loss. Then, the samples with high CE loss from $C _ { b }$ can be regarded as the bias-conflicting samples compared to the samples with low CE loss. In this regard, we obtain the relative difficulty score of each data sample as
$$W ( z ) = \frac { C E ( C _ { b } ( z ) , y ) } { C E ( C _ { i } ( z ) , y ) + C E ( C _ { b } ( z ) , y ) } .$$
As bias-conflicting samples obtain high values of $W$ , we emphasize the loss of these samples for
training $E _ { i }$ and $C _ { i }$ , enforcing them to learn the intrinsic attributes. Therefore, the objective function for disentanglement can be written as
$$L _ { \mathrm { d i s } } = W ( z ) C E ( C _ { i } ( z ) , y ) + \lambda _ { \mathrm { d i s } } G C E ( C _ { b } ( z ) , y ) .$$
To ensure that $C _ { i }$ and $C _ { b }$ predicts target labels mainly based on $z _ { i }$ and $z _ { b }$ , respectively, the loss
$C _ { i }$ is not backpropagated to $E _ { b }$ , and vice versa.
 Figure 1: The overview of our proposed debiasing approach. $( E _ { i } , C _ { i } )$ and $( E _ { b } , C _ { b } )$ are pairs of an encoder and a linear classifier trained to learn the disentangled representation of intrinsic attributes and bias attributes, respectively. With the disentangled features $z _ { i }$ and $z _ { b }$ , the feature augmentation is performed by swapping these latent vectors among different training samples, after certain iterations of training. $R$ refers to the re-weighting algorithm which implicitly differentiates bias-aligned samples and bias-conflicting samples. Each color indicates the different data samples.
# Algorithm 1 Debiasing with disentangled feature augmentation
Input: image $x$ , label $y$ , iteration $t$ , augment iteration $t _ { \mathrm { s w a p } }$ Initialize two networks $( E _ { i } , C _ { i } )$ , $( E _ { b } , C _ { b } )$ while not converged do Extract $z _ { i } , z _ { b }$ from $E _ { i } ( x )$ , $E _ { b } ( x )$ Concatenate $\boldsymbol { z } = [ z _ { i } ; z _ { b } ]$ Update $( E _ { i } , C _ { i } )$ , $( E _ { b } , C _ { b } )$ with $L _ { \mathrm { d i s } } = W ( z ) C E ( C _ { i } ( z ) , y ) + G C E ( C _ { b } ( z ) , y )$ if $t > t _ { \mathrm { s w a p } }$ : Randomly permute $\boldsymbol { z } = [ z _ { i } , z _ { b } ]$ into $z _ { \mathrm { s w a p } } = [ z _ { i } ; \tilde { z _ { b } } ]$ Calculate Ls $\ L _ { \mathrm { v a p } } = W ( z ) C E ( C _ { i } ( z _ { \mathrm { s w a p } } ) , \dot { y } ) + G C E ( C _ { b } ( z _ { \mathrm { s w a p } } ) , \tilde { y }$ ) Update $( E _ { i } , C _ { i } ^ { \dot { \mathbf { \alpha } } } )$ , $( E _ { b } , C _ { b } )$ with $L _ { \mathrm { t o t a l } } = L _ { \mathrm { d i s } } + \lambda _ { \mathrm { s w a p } } L _ { \mathrm { s w a p } }$ end
# 4.2 Feature swapping for augmentation
While such an architecture disentangles the intrinsic features and bias features, $E _ { i }$ and $C _ { i }$ are still mainly trained with an excessively small amount of bias-conflicting samples. Therefore, $E _ { i }$ and $C _ { i }$ fail to fully acquire the intrinsic representation of a target class. To promote further improvement in learning intrinsic feature vectors, we diversify the bias-conflicting samples by swapping the disentangled latent vectors among the training sets. In other words, we randomly permute the intrinsic features and bias features in each mini-batch and obtain $z _ { \mathrm { s w a p } } ~ = ~ [ z _ { i } ; \tilde { z _ { b } } ]$ where $\tilde { z _ { b } }$ denotes the randomly permuted bias attributes of $z _ { b }$ . As the intrinsic and bias attributes in ${ z _ { \mathrm { s w a p } } }$ are obtained from two different images, they certainly have less correlation compared to $\boldsymbol { z } = [ z _ { i } ; \dot { z _ { b } } ]$ where both are from the same image. Since the biased dataset is mostly composed of bias-aligned samples, these vectors are likely from the bias-aligned samples, highly diversified compared to the bias-conflicting ones. Then, $z _ { \mathrm { s w a p } } = [ z _ { i } ; \tilde { z _ { b } } ]$ act as augmented bias-conflicting latent vectors with diversity inherited from the bias-aligned samples. Along with $L _ { \mathrm { d i s } }$ , we add the following loss function to train two neural networks with the augmented features
$$L _ { \mathrm { s w a p } } = W ( z ) C E ( C _ { i } ( z _ { \mathrm { s w a p } } ) , y ) + \lambda _ { \mathrm { s w a p } _ { b } } G C E ( C _ { b } ( z _ { \mathrm { s w a p } } ) , \tilde { y } ) ,$$
where $\tilde { y }$ denotes target labels for permute bias attributes $\tilde { z }$ . Thus, total loss function is described as
$$L _ { \mathrm { t o t a l } } = L _ { \mathrm { d i s } } + \lambda _ { \mathrm { s w a p } } L _ { \mathrm { s w a p } }$$
where $\lambda _ { \mathrm { s w a p } }$ is adjusted for weighting the importance of the feature augmentation.
# 4.3 Scheduling the feature augmentation
While training with additional synthesized features helps to mitigate the unwanted correlation, utilizing them from the beginning of training does not improve the debiasing performance. To be more specific, in the early stage of training, the representations of $z _ { i }$ and $z _ { b }$ are imperfectly disentangled to be used as the sources of feature augmentation. Feature augmentation should be conducted after two features are disentangled at a certain degree. Without the disentangled representation, the augmented features work as noisy samples which may aggravate the debiasing performances. We verify the importance of scheduling the feature augmentation in Table 3. Our approach can be summarized with Algorithm 1.
 Figure 2: Example images of datasets utilized in our work. In each dataset, the images above the dotted line indicate the bias-aligned samples while the ones below the dotted line are the bias-conflicting samples. For Colored MNIST and Corrupted CIFAR-10, each column indicates each class. For BFFHQ, the group of three columns indicates each class.
# 5 Experiment
This section demonstrates the effectiveness of feature augmentation based on disentangled representation in debiasing with both quantitative and qualitative evaluation. We compare our method with the previous approaches in debiasing with three different datasets with varied bias ratios. Then, we conduct the ablation study which demonstrates the importance of 1) learning disentangled representation, 2) feature augmentation, and 3) scheduling feature augmentation. For the qualitative evaluation, we verify how our approach disentangles the intrinsic features and bias features by visualizing them on 2D embedding space via t-SNE [26] and reconstructing images from them.
# 5.1 Experiment details
Baselines Our baselines consist of vanilla network, HEX [7], EnD [27], ReBias [6] and LfF [12]. Vanilla denotes the classification model trained only with the original cross-entropy (CE) loss, without any debiasing strategies. EnD explicitly leverages the bias labels (e.g., the color label in Colored MNIST) during the training phase. HEX and ReBias explicitly presume the texture of an image as a bias type, while LfF requires no prior knowledge on it.
Datasets As shown in Fig. 2, we use two synthetic datasets (Colored MNIST and Corrputed CIFAR10) and one real-world dataset (Biased FFHQ) to evaluate the generalization of debiasing baselines over various domains. Biased FFHQ (BFFHQ) is curated from FFHQ dataset [28] which contains human face images annotated with their facial attributes. Among the facial attributes, we select age and gender as the intrinsic and bias attribute, respectively, and construct the dataset with images of high correlation between them. More specifically, most of the females are ‘young’ (i.e., age ranging from 10 to 29) and males are ‘old’ (i.e., age ranging from 40 to 59). Therefore, bias-aligned samples which compose the majority of the dataset are young women and old men.
For each dataset, we set the degree of correlation by adjusting the number of bias-conflicting samples among the training dataset. The ratio of bias-conflicting samples are $0 . 5 \%$ , $1 \%$ , $2 \%$ and $5 \%$ for both Colored MNIST and Corrupted CIFAR-10, respectively, and $0 . 5 \%$ for BFFHQ. For the evaluation of Colored MNIST and Corrupted CIFAR-10, we construct an unbiased test set which includes images without the high correlation existing in the training set. For the BFFHQ, we construct a bias-conflicting test set which excludes the bias-aligned samples from the unbiased test set. The reason is as following. The bias-aligned images consist a half of the unbiased test set in BFFHQ which may still be correctly classified by the biased classifier. This inflates the accuracy of the unbiased test set which is not our original intention. Therefore, we intentionally use the bias-conflicting test set for the BFFHQ.
Table 2: Image classification accuracy evaluated on unbiased test sets of Colored MNIST and Corrupted CIFAR-10, and the bias-conflicting test set of BFFHQ with varying ratio of bias-conflicting samples. We denote whether the model requires a bias type in advance by cross mark (i.e., not required), and check mark (i.e., required). Best performing results are marked in bold, while secondbest results are denoted with underlines.
<table><tr><td rowspan="2">Dataset</td><td rowspan="2">Ratio (%)</td><td>Vanilla [29]</td><td>HEX [7]</td><td>EnD [27]</td><td>ReBias [6]</td><td>LfF[12]</td><td>Ours</td></tr><tr><td>X</td><td>√</td><td>√</td><td>√</td><td>×</td><td>X</td></tr><tr><td rowspan="4">Colored MNIST</td><td>0.5</td><td>35.19±3.49</td><td>30.33±0.76</td><td>34.28±1.20</td><td>70.47±1.84</td><td>52.50±2.43</td><td>65.22±4.41</td></tr><tr><td>1.0</td><td>52.09±2.88</td><td>43.73±5.50</td><td>49.50±2.51</td><td>87.4±0.78</td><td>61.89±4.97</td><td>81.73±2.34</td></tr><tr><td>2.0</td><td>65.86±3.59</td><td>56.85±2.58</td><td>68.45±2.16</td><td>92.91±0.15</td><td>71.03±2.44</td><td>84.79±0.95</td></tr><tr><td>5.0</td><td>82.17±0.74</td><td>74.62±3.20</td><td>81.15±1.43</td><td>96.96±0.04</td><td>80.57±3.84</td><td>89.66±1.09</td></tr><tr><td rowspan="4">Corrupted CIFAR-10</td><td>0.5</td><td>23.08±1.25</td><td>13.87±0.06</td><td>22.89±0.27</td><td>22.27±0.41</td><td>28.57±1.30</td><td>29.95±0.71</td></tr><tr><td>1.0</td><td>25.82±0.33</td><td>14.81±0.42</td><td>25.46±0.41</td><td>25.72±0.20</td><td>33.07±0.77</td><td>36.49±1.79</td></tr><tr><td>2.0</td><td>30.06±0.71</td><td>15.20±0.54</td><td>31.31±0.35</td><td>31.66±0.43</td><td>39.91±0.30</td><td>41.78±2.29</td></tr><tr><td>5.0</td><td>39.42±0.64</td><td>16.04±0.63</td><td>40.26±0.85</td><td>43.43±0.41</td><td>50.27±1.56</td><td>51.13±1.28</td></tr><tr><td>BFFHQ</td><td>0.5</td><td>56.87±2.69</td><td>52.83±0.90</td><td>56.87±1.42</td><td>59.46±0.64</td><td>62.2±1.0</td><td>63.87±0.31</td></tr></table>
Implementation details We use multi-layer perceptron (MLP) with three hidden layers for Colored MNIST, and ResNet-18 [29] for the remaining datasets. To accommodate the disentangled vectors, we double the number of hidden units in the last fully-connected layer of each network. During the inference phase, we use $C _ { i } ( z )$ for the final prediction, where $z = [ z _ { i } ; z _ { b } ]$ . For the training, we set the batch size of 256 for Colored MNIST and Corrupted CIFAR-10, respectively, and 64 for BFFHQ. Bias-conflicting augmentation is scheduled to be applied after 10K iterations for all datasets. We report the averaged accuracy of the unbiased test sets over three independent trials with the mean and the standard deviation. We include the remaining implementation details in Section D in the supplementary material.
# 5.2 Quantitative evaluation
Comparison on test sets Table 2 shows the comparisons of image classification accuracy evaluated on the test sets. In general, our approach demonstrates the superior performance in both synthetic and real-world datasets against the baselines with large gaps. Especially, compared to the baselines which do not define the bias types in advance (vanilla [29] and LfF [12]), our approach achieves the stateof-the-art performance across all datasets. This indicates that utilizing the diversified bias-conflicting samples through our augmentation plays a pivotal role in learning debiased representation regardless of the bias types.
Regarding the real-world dataset, our approach also outperforms HEX [7] and ReBias [6] which utilize the tailored modules for a specific bias type (e.g., color and texture), and EnD [27] that uses the explicit bias labels. We even show superior performance compared to HEX in Colored MNIST without defining the bias type beforehand. While ReBias achieves the best accuracy in Colored MNIST, they utilize BagNet [11] in order to focus on the color bias. Even without using such an architecture, we achieve the second best performance which is comparable to ReBias.
Ablation studies Table 3 demonstrates the importance of each module in our approach through ablation studies: 1) disentangled representation learning, 2) feature augmentation, and 3) scheduling feature augmentation. We set the ratio of bias-conflicting samples to $1 \%$ for Colored MNIST and Corrupted CIFAR10, and $0 . 5 \%$ for BFFHQ. We also compare each module with the vanilla network (first row). We observe that performing the scheduled feature augmentation shows the best classification accuracy on the test sets across all datasets. We also show that performing feature augmentation at the early stage of training does not guarantee the effectiveness of debiasing. Performing feature augmentation at the beginning of training rather aggravates the performance. That is, when the representation of intrinsic attributes and bias attributes are not disentangled at a certain degree, augmented features may act as noisy samples. Training with these additional noisy features prevents models from achieving further improvement.
Table 3: Ablation studies on 1) disentangled representation learning, 2) feature augmentation, and 3) scheduling feature augmentation. Each row indicates the different training settings with check mark denoting the setting applied. We average the accuracy of each training over three independent trials.
<table><tr><td>Disentangle</td><td>Augment</td><td>Scheduled Augment</td><td>Colored MNIST</td><td>Corrupted CIFAR10</td><td>BFFHQ</td></tr><tr><td></td><td></td><td></td><td>52.09±2.88</td><td>25.82±0.33</td><td>56.87±2.69</td></tr><tr><td><>></td><td></td><td></td><td>74.03±2.40</td><td>27.73±1.02</td><td>59.4±2.46</td></tr><tr><td></td><td></td><td></td><td>72.29±3.82</td><td>32.81±2.47</td><td>61.27±3.26</td></tr><tr><td></td><td>?</td><td>√</td><td>81.73±2.34</td><td>52.31±1.00</td><td>63.87±0.31</td></tr></table>
# 5.3 Analysis
2D Projection of Disentangled Representation Fig. 3 shows the projection of latent vectors $z _ { i }$ and $z _ { b }$ extracted from the intrinsic encoder $E _ { i }$ and bias encoder $E _ { b }$ , respectively, on a 2D space using Colored MNIST. We show projection of $z _ { i }$ and $z _ { b }$ in Fig. 3(a) and Fig. 3(b), respectively. The colors of projected dots in the first row (i) and the second row (ii) indicate the target labels and bias labels, respectively. We observe that $z _ { i }$ are clustered according to the target labels while $z _ { b }$ are clustered with the bias labels. The results represent that our method successfully learns the disentangled intrinsic and bias attributes.
Prediction with Disentangled Representation In Table 4, we report the 1) original and 2) swapping accuracy of $C _ { i }$ and $C _ { b }$ , the linear classifiers of the intrinsic and the bias encoder, respectively. To be specific, for the original accuracy, we extract the two disentangled vectors, $z _ { i }$ and $z _ { b }$ , from the same image, concatenate them to make $z = [ z _ { i } ; z _ { b } ]$ , and forward them into each linear classifier. For the swapping accuracy, however, we first permute $z _ { b }$ and concatenate $z _ { i }$ with the permuted $z _ { b }$ (i.e., denoted as $\tilde { z _ { b } }$ in Section 4.2) to make $z _ { \mathrm { s w a p } } = [ z _ { i } ; \tilde { z _ { b } } ]$ . Then, we pass these concatenated latent vectors to each linear classifier. Afterward, we evaluate the accuracy of predicted labels of 1) $C _ { i } ( z )$ and $C _ { i } ( z _ { \mathrm { { s w a p } } } )$ with intrinsic labels and 2) $C _ { b } ( z )$ and $C _ { b } ( z _ { \mathrm { s w a p } } )$ with bias labels. The Intrinsic and Bias columns in Table 4 denote the accuracy with respect to the target labels and bias labels, respectively. Even the feature vectors of bias attributes are randomly swapped, our method maintains a reasonable classification accuracy. This indicates that our model well disentangles between $z _ { i }$ and $z _ { b }$ , and $C _ { i }$ robustly utilizes $z _ { i }$ to predict target labels even when $z _ { b }$ is taken from the different image, and vice versa. Note that we utilized the parameters of the model trained on each dataset after converging at a certain degree.
 Figure 3: Each row (i and ii) include 2D projection of $z _ { i }$ and $z _ { b }$ with the colors encoded by their labels (i.e., groundtruth labels in row i and bias labels in row ii) in Colored MNIST. We observe that $z _ { i }$ and $z _ { b }$ are well clustered according to the target and bias labels, respectively.
<table><tr><td rowspan="3">Accuracy(%)</td><td colspan="2">Colored MNIST</td><td colspan="2">Corrupted CIFAR10</td><td colspan="2">BFFHQ</td></tr><tr><td>Intrinsic</td><td>Bias</td><td>Intrinsic</td><td>Bias</td><td>Intrinsic</td><td>Bias</td></tr><tr><td>Original</td><td>76.08</td><td>98.07</td><td>35.63</td><td>74.16</td><td>57.40</td><td>49.00</td></tr><tr><td>Swapping</td><td>71.40</td><td>94.29</td><td>35.14</td><td>76.46</td><td>58.40</td><td>51.60</td></tr></table>
Table 4: Accuracy from disentangled representation. The ratio of bias-conflicting samples in Colored MNIST, Corrupted CIFAR-10, and BFFHQ are $1 \%$ , $1 \%$ , and $0 . 5 \%$ , respectively.
 Figure 4: Reconstructed images from disentangled representation in Colored MNIST. Each column and row indicate the samples where the bias attribute (color) and the intrinsic attribute (digit) are extracted, respectively. By swapping the bias features with a given intrinsic feature, we observe that the color changes while maintaining the digit.
Reconstruction of Disentangled Representation Fig. 4 shows the reconstructed images of Colored MNIST by using the disentangled representation of intrinsic features and bias features. Images in the first row and column indicate the images used for extracting the bias attribute (i.e., color) and intrinsic attribute (i.e., digit), respectively. We train an auxiliary decoder by providing the latent vector $z$ from our pre-trained models as input in order to visualize the disentangled representations at the pixel level. By changing the bias attributes (as the column changes), the color of digit changes while maintaining the digit shape. This demonstrates that the bias features and intrinsic features independently contain color and digit information, respectively. Note that the reconstruction loss for updating the decoder is not backpropagated to our pre-trained classification models. Due to this fact, the reconstructed images may lack qualities such as showing blurry images. Further implementation details are included in Section D in the supplementary material.
# 6 Conclusions
In this work, we propose a feature augmentation method based on the disentangled representation of intrinsic and bias attributes. The main intuition behind our work is that increasing the diversity of bias-conflicting samples beyond a given training set is crucial for debiasing. Since the biased dataset strongly correlates the bias attributes and labels, we intentionally train two different encoders and extract bias features and intrinsic features. After the representations are disentangled to a certain degree, we proliferate the bias-conflicting samples by randomly swapping the vectors. We demonstrate the effectiveness of feature augmentation via extensive experiments, ablation studies, and qualitative evaluation of the disentangled representation. We believe our work inspires the future work of learning debiased representation with the improved generalization capability.
Acknowledgements This work was supported by the Institute of Information & communications Technology Planning & Evaluation (IITP) grant funded by the Korean government(MSIT) (No. 2019-0-00075, Artificial Intelligence Graduate School Program(KAIST), No. 2021-0-01778, Development of human image synthesis and discrimination technology below the perceptual threshold), the Air Force Research Laboratory, under agreement number FA9550-18-S-0003, and Kakao Enterprise. This material is based on research sponsored by The U.S. Government is authorized to reproduce and distribute reprints for Governmental purposes notwithstanding any copyright notation thereon.
References [1] A. Torralba and A. A. Efros. Unbiased look at dataset bias. CVPR ’11, 2011. [2] Robert Geirhos, Jörn-Henrik Jacobsen, Claudio Michaelis, Richard Zemel, Wieland Brendel, Matthias Bethge, and Felix A Wichmann. Shortcut learning in deep neural networks. Nature Machine Intelligence, 2(11):665–673, 2020. [3] Byungju Kim, Hyunwoo Kim, Kyungsu Kim, Sungjin Kim, and Junmo Kim. Learning not to learn: Training deep neural networks with biased data. In The IEEE Conference on Computer Vision and Pattern Recognition (CVPR), June 2019. [4] Yi Li and Nuno Vasconcelos. Repair: Removing representation bias by dataset resampling. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pages 9572–9581, 2019. [5] Shiori Sagawa, Pang Wei Koh, Tatsunori B Hashimoto, and Percy Liang. Distributionally robust neural networks for group shifts: On the importance of regularization for worst-case generalization. arXiv preprint arXiv:1911.08731, 2019. [6] Hyojin Bahng, Sanghyuk Chun, Sangdoo Yun, Jaegul Choo, and Seong Joon Oh. Learning de-biased representations with biased representations. In International Conference on Machine Learning (ICML), 2020. [7] Haohan Wang, Zexue He, Zachary L. Lipton, and Eric P. Xing. Learning robust representations by projecting superficial statistics out. In International Conference on Learning Representations, 2019. [8] Remi Cadene, Corentin Dancette, Hedi Ben younes, Matthieu Cord, and Devi Parikh. Rubi: Reducing unimodal biases for visual question answering. In H. Wallach, H. Larochelle, A. Beygelzimer, F. d'Alché- Buc, E. Fox, and R. Garnett, editors, Advances in Neural Information Processing Systems, volume 32. Curran Associates, Inc., 2019. [9] Christopher Clark, Mark Yatskar, and Luke Zettlemoyer. Don’t take the easy way out: Ensemble based methods for avoiding known dataset biases. In Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing and the 9th International Joint Conference on Natural Language Processing (EMNLP-IJCNLP), pages 4069–4082, Hong Kong, China, November 2019. Association for Computational Linguistics. [10] Robert Geirhos, Patricia Rubisch, Claudio Michaelis, Matthias Bethge, Felix A. Wichmann, and Wieland Brendel. Imagenet-trained CNNs are biased towards texture; increasing shape bias improves accuracy and robustness. In International Conference on Learning Representations, 2019. [11] Wieland Brendel and Matthias Bethge. Approximating cnns with bag-of-local-features models works surprisingly well on imagenet. International Conference on Learning Representations, 2019. [12] Junhyun Nam, Hyuntak Cha, Sungsoo Ahn, Jaeho Lee, and Jinwoo Shin. Learning from failure: Training debiased classifier from biased classifier. In Advances in Neural Information Processing Systems, 2020. [13] Yann LeCun and Corinna Cortes. MNIST handwritten digit database. 2010. [14] Aishwarya Agrawal, Dhruv Batra, and Devi Parikh. Analyzing the behavior of visual question answering models. In Proceedings of the 2016 Conference on Empirical Methods in Natural Language Processing, pages 1955–1960, Austin, Texas, November 2016. Association for Computational Linguistics. [15] Luke Darlow, Stanisław Jastrz˛ebski, and Amos Storkey. Latent adversarial debiasing: Mitigating collider bias in deep neural networks. arXiv preprint arXiv:2011.11486, 2020. [16] Zeyi Huang, Haohan Wang, Eric P. Xing, and Dong Huang. Self-challenging improves cross-domain generalization. In ECCV, 2020. [17] Zhilu Zhang and Mert R Sabuncu. Generalized cross entropy loss for training deep neural networks with noisy labels. arXiv preprint arXiv:1805.07836, 2018. [18] Xun Huang and Serge Belongie. Arbitrary style transfer in real-time with adaptive instance normalization. In ICCV, 2017. [19] Matthias Minderer, Olivier Bachem, N. Houlsby, and M. Tschannen. Automatic shortcut removal for self-supervised representation learning. In ICML, 2020. [20] Kaiyang Zhou, Yongxin Yang, Yu Qiao, and Tao Xiang. Domain generalization with mixstyle. In ICLR, 2021. [21] Hsin-Ying Lee, Hung-Yu Tseng, Jia-Bin Huang, Maneesh Kumar Singh, and Ming-Hsuan Yang. Diverse image-to-image translation via disentangled representations. In European Conference on Computer Vision, 2018. [22] Xun Huang, Ming-Yu Liu, Serge Belongie, and Jan Kautz. Multimodal unsupervised image-to-image translation. In ECCV, 2018. [23] Taesung Park, Jun-Yan Zhu, Oliver Wang, Jingwan Lu, Eli Shechtman, Alexei A. Efros, and Richard Zhang. Swapping autoencoder for deep image manipulation. In Advances in Neural Information Processing Systems, 2020. [24] A. Krizhevsky and G. Hinton. Learning multiple layers of features from tiny images. Master’s thesis, Department of Computer Science, University of Toronto, 2009. [25] Dan Hendrycks and Thomas Dietterich. Benchmarking neural network robustness to common corruptions and perturbations. In International Conference on Learning Representations, 2019. [26] Laurens van der Maaten and Geoffrey Hinton. Visualizing data using t-SNE. Journal of Machine Learning Research, 9:2579–2605, 2008. [27] Enzo Tartaglione, Carlo Alberto Barbano, and Marco Grangetto. End: Entangling and disentangling deep representations for bias correction. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), pages 13508–13517, June 2021. [28] Tero Karras, Samuli Laine, and Timo Aila. A style-based generator architecture for generative adversarial networks. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), June 2019. [29] Kaiming He, Xiangyu Zhang, Shaoqing Ren, and Jian Sun. Deep residual learning for image recognition. arXiv preprint arXiv:1512.03385, 2015.123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256# LEARN2WEIGHT: WEIGHTS TRANSFER DEFENSE AGAINST SIMILAR-DOMAIN ADVERSARIAL ATTACKS
Anonymous authors Paper under double-blind review
# ABSTRACT
Recent work in black-box adversarial attacks for NLP systems has attracted attention. Prior black-box attacks assume that attackers can observe output labels from target models based on selected inputs. In this work, inspired by adversarial transferability, we propose a new type of black-box NLP adversarial attack that an attacker can choose a similar domain and transfer the adversarial examples to the target domain and cause poor performance in target model. Based on domain adaptation theory, we then propose a defensive strategy, called Learn2Weight, which trains to predict the weight adjustments for target model in order to defense the attack of similar-domain adversarial examples. Using Amazon multi-domain sentiment classification dataset, we empirically show that Learn2Weight model is effective against the attack compared to standard black-box defense methods such as adversarial training and defense distillation. This work contributes to the growing literature on machine learning safety.
# 1 INTRODUCTION
As machine learning models are applied to more and more real-world tasks, addressing machine learning safety is becoming an increasingly pressing issue. Deep learning algorithms have been shown to be vulnerable to adversarial examples (Szegedy et al., 2013; Goodfellow et al., 2014; Papernot et al., 2016a). In particular, prior black-box adversarial attacks assume that the adversary is not aware of the target model architecture, parameters or training data, but is capable of querying the target model with supplied inputs and obtaining the output predictions. The phenomenon that adversarial examples generated from one model may also be adversarial to another model is known as adversarial transferability (Szegedy et al., 2013).
Motivated by adversarial transferability, we conjecture another black-box attack pipeline where the adversary does not even need to have access to the target model nor query labels from crafted inputs. Instead, as long as the adversary knows the task of the target, he can choose a similar domain, to build a substitute model and then attack the target model with adversarial examples that are generated from the attack domain.
 Figure 1: Diagrammatic representation of the problem
(a) Generalized architecture of similarity-based attacks.

(b) Flow of how an adversary physician can leverage similarity attack to fool opioid risk models.
The similar-domain adversarial attack may be more practical than prior blackbox attacks as label querying from target model is not needed. This attack can be illustrated with the following example (Figure 1b) in medical insurance fraud (Finlayson et al., 2019). Insurance companies may use hypothetical opioid risk models to classify the likelihood (high/low) of a patient to abuse the opioids to be prescribed, based on the patient’s medical history as text input. Physicians can run the original patient history through the attack pipeline to generate an adversarial patient history, where the original is more likely to be rejected (”High” risk) and the adversarial is more likely to be accepted (”Low” risk). Perturbations in patient history could be, for example, a slight perturbation from ”alcohol abuse” to ”alcohol dependence”, and it may successfully fool the insurance company’s model.
Based on domain adaption theory (Ben-David et al., 2010), we conjecture that it is the domain-variant features that cause the success of the similar-domain attack. The adversarial examples with domainvariant features are likely to reside in the low-density regions (far away from decision boundary) of the empirical distribution of the target training data which could fool the target model (Zhang et al., 2019b). Literature indicates that worsened generalizability is a tradeoff faced by existing defenses such as adversarial training (Raghunathan et al., 2019) and domain generalization techniques (Wang et al., 2019). In trying to increase robustness against adversarial inputs, a model faces a tradeoff of weakened accuracy towards clean inputs. Given that an adversarial training loss function is composed of a loss against clean inputs and loss against adversarial inputs, improper optimization where the latter is highly-optimized and the former weakly-optimized does not improve general performance in the real-world. To curb this issue, methods have been proposed (Zhang et al., 2019b; Lamb et al., 2019; Schmidt et al., 2018), such as factoring in under-represented data points in training set.
To defend against this similar-domain adversarial attack, we propose a weight transfer network approach, Learn2Weight, so that the target model’s decision boundary can adapt to the examples from low-density regions. Experiments confirm the effectiveness of our approach against the similardomain attack over other baseline defense methods. Moreover, our approach is able to improve robustness accuracy without losing the target model’s standard generalization accuracy.
Our contribution can be summarized as follows:
• We are among the first to propose the similar-domain adversarial attack. This attack pipeline relaxes the previous black-box attack assumption that the adversary has access to the target model and can query the model with crafted examples. • We propose a defensive strategy for this attack based on domain adaptation theory. Experiment results show the effectiveness of our approach over existing defense methods, against the similar-domain attack.
Recent work in adversarial attack for NLP systems has attracted attention. See (Zhang et al., 2020) survey for an overview of the adversarial attack in NLP. Existing research proposes different attack methods for generating adversarial text examples (Moosavi-Dezfooli et al., 2016; Ebrahimi et al., 2018; Wallace et al., 2019). The crafted adversarial text examples have been shown to fool the state-of-the-art NLP systems such as BERT (Jin et al., 2019). A large body of adversarial attack research focuses on black-box attack where the adversary builds a substitute model by querying the target model with supplied inputs and obtaining the output predictions. The key idea behind such black-box attack is that adversarial examples generated from one model may also be mis-classified by another model, which is known as adversarial transferability (Szegedy et al., 2013; Cheng et al., 2019). While prior work examines the transferability between different models trained over the same dataset, or the transferability between the same or different model trained over disjoint subsets of a dataset, our work examines the adversarial transferability between different domains, which we call similar-domain attack.
Table 1: Comparison of attack domain sentences correctly classified when unperturbed by respective attack domain models and target domain models, then misclassified after perturbation by target models trained on books and baby domain. The perturbations are in blue, and prediction confidence in brackets.
<table><tr><td colspan="3">Attack domain:baby,Target domain:books</td></tr><tr><td>Original sentence (Actual label: Pos)</td><td>I purchased this toy for my sonwhen he was 4 monthsold.At first,he seemed a little intimidated by the toys.</td><td>Pos (0.712)</td></tr><tr><td>Adversarial sentence</td><td>I obtained this toys for my children when he was 4 weeks senior. At first, he hoped a modest harassed by the toy.</td><td>Neg (0.364)</td></tr><tr><td>Original sentence (Actual label: Pos)</td><td>It felt like a big commitment for me to have to run the program 2 times a day, and near the end of my pregnancy I was annoyed with having anything strapped across my belly.</td><td>Pos (0.825)</td></tr><tr><td>Adversarial sentence</td><td>It felt like a big committed for me to have to run the program 2 length a day, and near the end of my pregnancy Iwas annoyed with takes anything strapped acrossmy belly.</td><td>Neg (0.420)</td></tr><tr><td colspan="3">Attack domain: dvd, Target domain: baby</td></tr><tr><td>Original sentence (Actual label: Pos)</td><td>Fast times at ridgemont high is a clever, insightful,and wicked film! It is not just another teen movie.</td><td>Pos (0.614)</td></tr><tr><td>Adversarial sentence</td><td>Sooner days at ridgemont high is a sane, thoughtful, and wicked flick! It is not just another adolescent flick.</td><td>Neg (0.335)</td></tr><tr><td>Original sentence</td><td>This dvd gives a very good 6O minute workout.As others have pointed out the</td><td>Pos (0.647)</td></tr><tr><td>(Actual label: Pos) Adversarial sentence</td><td>cardio is very dancy. The first time I did it,I felt a bit awkward with the steps. This dvd gives a awfully okay 6O minute exercise. As others have pointed out the cardio is very dancy. The first time I did it, I perceived a bit awkward with the steps.</td><td>Neg (0.258)</td></tr></table>
# 3 SIMILAR-DOMAIN ADVERSARIAL ATTACK
# 3.1 ADVERSARIAL ATTACK BACKGROUND
Adversarial attacks modify inputs to cause errors in machine learning inference (Szegedy et al., 2013). We utilize the basic gradient-based attack method Fast Gradient Sign Method (FGSM) (Goodfellow et al., 2014) and its variants, RAND-FGSM (Tramer et al., 2017) and \` Basic Iterative Method (BIM) (Kurakin et al., 2016a;b; Xie et al., 2018). Other NLP adversarial generation algorithms could also be used, such as DeepFool (Moosavi-Dezfooli et al., 2016), HotFlip (Ebrahimi et al., 2018), universal adversarial trigger (Wallace et al., 2019), and TextFooler (Jin et al., 2019). To perform gradient-based perturbations upon discrete space data, we follow (Yang et al., 2018) to generate adversarial text.
Our proposed similar-domain adversarial attack is in-variant to adversarial algorithm, meaning that the adversarial algorithm used would not affect the attack performance. Without losing generality, we denote $A d v ( f , x )$ as an NLP adversarial text generation method, defined as below.
Definition 1. NLP Adversarial Generation. Given a deep neural network model $f$ built on text data $X$ , an NLP adversarial generation method produces one adversarial instances $x ^ { \prime } A d v ( f , x )$ for $x \in X$ , $x ^ { \prime } \approx x$ . The goal of the adversarial attack is to deviate the label to incorrect one $f ( x ^ { \prime } ) \neq f ( x )$
# 3.2 SIMILAR-DOMAIN ADVERSARIAL ATTACK
We present the architecture of similar-domain adversarial attack in Figure 1a. The defender, the target of the attack, constructs a target model trained on domain text data $T$ (0). An attacker, only having a rough idea about the target’s task but lacking direct access to the target data or target model parameters, collects attack data from a similar domain $S$ and trains an attack model (1). He runs the attack model on the test data (2) to obtain correctly-classified instances (3). He chooses an adversarial attack algorithm and generates a set of adversarial samples $A$ (4). He exposes $A$ to the target model, hoping $A$ mislead the target model to produce an output of his choice (5). This type of attack works best as an adversarial attack that compromises systems that base decision-making on one-instance.
Definition 2. Similar-domain Adversarial Attack. A target model $f$ , built on target domain data $T$ , is a deep neural network model with parameter weights $W _ { T }$ that maps a text instance to a label: $y f ( X , W _ { T } )$ . An adversary chooses a source attack domain $S$ , builds a substitute model $f _ { S }$ , and generates a set of adversarial examples $A$ from $S$ using $A d v ( f _ { S } , S )$ , so that during an attack $f ( A , W _ { T } ) = f _ { S } ( A )$ .
Table 2: Similar-domain attack performance. Bold indicates the least successful attack domain (i.e. highest after-attack accuracy) for each target domain, as well as the corresponding transfer loss value.
<table><tr><td>Target Domain</td><td colspan="3">book</td><td colspan="3">magazine</td><td colspan="3">baby</td></tr><tr><td>Original Accuracy Intra-attack Accuracy</td><td colspan="3">0.880</td><td colspan="3">0.960</td><td colspan="3">0.890</td></tr><tr><td></td><td></td><td>0.525</td><td></td><td></td><td>0.570</td><td></td><td></td><td>0.632</td><td></td></tr><tr><td>Attack Domain</td><td>magazine</td><td>baby</td><td>dvd</td><td>baby</td><td>dvd</td><td>book</td><td>dvd</td><td>book</td><td>magazine</td></tr><tr><td>Unperturbed Accuracy</td><td>0.726</td><td>0.646</td><td>0.745</td><td>0.739</td><td>0.663</td><td>0.673</td><td>0.624</td><td>0.652</td><td>0.665</td></tr><tr><td>After-attack Accuracy</td><td>0.398</td><td>0.421</td><td>0.395</td><td>0.381</td><td>0.366</td><td>0.343</td><td>0.365</td><td>0.386</td><td>0.401</td></tr><tr><td>Shared Vocab</td><td>0.381</td><td>0.255</td><td>0.455</td><td>0.260</td><td>0.345</td><td>0.381</td><td>0.270</td><td>0.255</td><td>0.260</td></tr><tr><td>Transfer Loss</td><td>0.017</td><td>0.071</td><td>0.000</td><td>0.079</td><td>0.022</td><td>0.010</td><td>0.066</td><td>0.050</td><td>0.069</td></tr></table>
# 3.3 DOMAIN SIMILARITY
Here, domain similarity refers to the similarity between attacker’s chosen domain and defender’s domain. SharedVocab measures the overlap of unique words, in each of the datasets; a higher degree of overlapping vocabulary implies the two domains are more similar. We also use Transfer Loss, a standard metric for domain adaptation Blitzer et al. (2007); Glorot et al. (2011), to measure domain similarity; lower loss indicates higher similarity. The test error from a target model trained on target domain $T$ and evaluated on attack domain $S$ returns transfer error $e ( S , T )$ . The baseline error $e ( T , T )$ term is the test error obtained from target model trained on target domain (train) data $T$ and tested on target domain (evaluation) data $T$ . This computes the transfer loss, $t f ( S , T ) = e ( S , T ) - e ( T , T )$ .
# 4 IS THE ATTACK EFFECTIVE?
# 4.1 SETUP
Dataset. We simulate the similar-domain adversarial attack using Amazon’s multi-domain sentiment classification dataset (Blitzer et al., 2007), a commonly-used dataset in cross-domain sentiment classification1, with 1,000 positive and 1,000 negative reviews for each of the 25 product categories.
Model. In practice, there could be unlimited choice for the attack model and target model, such as different deep learning architecture, different training parameters. To simplify the discussion, we choose Long Short-Term Memory (LSTM) network as a suitable baseline sentiment classification model (Wang et al., 2018) for our target model and attack model. The architecture consists of 64 LSTM cells, $80 \%$ dropout, using a sigmoid activation function.
Metrics. We first report the accuracy of the target models on the target domain test samples before the attack as the original accuracy. Then we measure the accuracy of the target models against adversarial samples crafted from the attack domain samples, denoted as the after-attack accuracy. Intra-attack accuracy denotes the after-attack accuracy where the attack domain is identical to the target domain. By comparing original and after-attack accuracy, we can evaluate the success of the attack. The greater the gap between the original and after-attack accuracy, the more successful the attack. Unperturbed accuracy measures the accuracy of the target model against the complete, unperturbed test set of the attack domain, to demonstrate that any drop in classification accuracy is not from domain shift alone but from adversarial transferability.
# 4.2 RESULTS
The similar-domain adversarial attack results are presented in Table 2. We see a significant gap between original accuracy and after-attack accuracy indicating that this attack can impose valid threat to a target NLP system. After the similar-domain adversarial attack, the accuracy drops dramatically by a large margin. Take the book target domain for example, when the attack domain is magazine, the after-attack accuracy drops to 0.398, and when the attack domain is baby, the accuracy is 0.421. Moreover, we observe a positive correlation between transfer loss and after-attack accuracy, and a negative correlation between shared vocab and after-attack accuracy.
# 5 DEFENDING AGAINST SIMILAR-DOMAIN ADVERSARIAL ATTACK
In order to defend against a similarity based adversarial attack, it is critical to block adversarial transferability. Adversarial training is the most intuitive yet effective defense strategy for adversarial attack (Goodfellow et al., 2014; Madry et al., 2017). However, this may not be effective for two reasons. First, there is no formal guidance for generating similar-domain adversarial examples because the defender has no idea what the attack data domain is. Second, simple feeding the target model with adversarial examples may even hurt the generalization of the target model (Raghunathan et al., 2019; Zhang et al., 2019a; Su et al., 2018), which is also confirmed in our experiments.
# 5.1 WEIGHT TRANSFER LEARNING
The use of weight transfer networks (Ha et al., 2016; Hu et al., 2018; Kuen et al., 2019) is concerned with adapting weights from one model into another, and generating/predicting the complete set of weights for a model given the input samples. In our context, distinctly different weights are produced for target models trained on inputs of different domains, and feature transferability (Yosinski et al., 2014) in the input space can be expected to translate to weight transferability in the model weights space. Rather than completely regenerating classification weights, our model robustification defense, Learn2Weight L2W predicts the perturbation to existing weights $\left( W ^ { \prime } = W + \Delta W \right)$ ) for each new instance.
# 5.2 LEARN2WEIGHT MODEL
We conjecture that an effective defense strategy is to perturb the target model weights depending on the feature distribution of the input instance. $L 2 W$ (Algorithm 1) recalculates the target model weights depending on the input. $L 2 W$ (Algorithm 2) trains on sentences from different domains and a weight differential for that domain (the weight adjustment required to tune the target model’s weights to adapt to the input’s domain). We obtain the weight differential $\Delta W$ by finding the difference between the weights of $f$ trained on sentence:label pairs from a specific domain $W _ { S _ { j } }$ and weights of $f$ trained on sentence:label pairs from the target domain $W _ { T }$ . Other training models may be possible; here we trained a sequence-to-sequence network (Sutskever et al., 2014) on sentence: $\Delta W$ pairs.
<table><tr><td>Algorithm 1: Learn2Weight: Inference</td><td>Algorithm 2: Learn2Weight:Training</td></tr><tr><td>inference (Xadv, L2W(.), f(Wr,T)) Input:Passed arguments include the adversarial input Xadu, the Learn2Weight model L2W(-),and the target model f(Wr,T) Output :Target model with weighted</td><td>train (T,D) Input :Target domain T={Ti}0; Set of M domains D={S,j)j; withNsentences, N,M i indexing specific sentence tensor and j indexing specific domains Output :Trained Learn2Weight model L2W(·)</td></tr><tr><td>updated byLearn2Weight f(W*,T) is the expected output Pass Xadu as in input into the trained L2W(-) function,and the weight differential required for the target model with weights Wr is△W.</td><td>Initialize empty X and Y to store sentences Xi from each domain j with corresponding weight differential. X←;Y←; Compute weights of f trained on T. Wr ← f(T);</td></tr><tr><td>△W ← L2W(Xadv); The returned function is the target model with updated weights Wr+△W. return f(Wr +△W,T);</td><td>X←T;Y←WT-Wr; Train each domain Sj,compute respective weights, append the differential △W to Y and each sentence in Si,j into X. foreach domain Sj ∈D do Ws,← f(Sj); △W ←Wsj-Wr;</td></tr></table>
# Algorithm 3: tf-optimization
tfOptimization $( T , M , n _ { m a x } )$
Input :Target domain $T = \{ T _ { i } \} _ { i = 0 } ^ { N }$ to be used in synthesizing $M$ similar domains; with $N$ sentences, $i$ indexing specific sentence tensor; $n _ { m a x }$ is the max number of tf-optimization iterations Output :Set $D$ containing $M$ domains Initialize empty $D$ to store synthesized domains $S _ { j }$ of index $j$ . $D \gets \emptyset ; j \gets 0$ ; while $j < M$ do Run each iteration until $n _ { m a x }$ . for iter $ 0$ to $n _ { m a x }$ do Apply adversarial perturbations to $T$ . $T _ { i t e r } ^ { \hat { a } \hat { d } v } \gets A d v ( f , \hat { T } )$ ; Determine change to $A d v ( \cdot )$ or iter depending on computed transfer loss. if $c h e c k ( t f ( T _ { i t e r } ^ { a d v } , T ) ) \gets T r u e$ then If low enough, $T _ { i t e r } ^ { a d v }$ can be added as synthetic domain into $D$ . $D \gets T _ { i t e r } ^ { a d v }$ ; break; else Adjust perturbation parameters. $A d v ( \cdot ) a d j u s t ( A d v ( \cdot ) )$ ; $j \gets j + 1$ ; Return set of Domains to be used for training by $L 2 W$ . return $D$ ;
# 5.3 TRANSFER LOSS OPTIMIZATION
To generate synthetic domains of varying domain similarity so that defenders defend their model using only target domain data $T$ , the following equation introduces transfer loss optimization (Algorithm 3). The defender iteratively generates adversarial examples $X _ { N } ^ { a d v }$ while maximizing the transfer loss function $t f$ ; this produces a substitute attack domain corpora $S _ { j }$ . We iteratively adjust perturbation parameters $A d v ( \cdot )$ and iteration count $N$ to minimize the transfer loss of our generated dataset.
$$\underset { N , A d v ( \cdot ) } { \arg \operatorname* { m i n } } t f _ { N } \Bigl ( X _ { N } ^ { a d v } , T \Bigr ) = e \Bigl ( A d v ( f , T ) , T \Bigr ) - e \Bigl ( T , T \Bigr )$$
# 5.4 EXPLANATION: BLOCKING TRANSFERABILITY
To facilitate our explanation, we adapt from domain adaptation literature (Ben-David et al., 2010; Liu et al., 2019; Zhang et al., $2 0 1 9 \mathrm { c }$ ):
$$e ( A , T ) \leq e ( T , T ) + d _ { \mathcal { H } \Delta \mathcal { H } } ( A , T ) + \lambda$$
where $\mathcal { H }$ is the hypothesis space, $h$ is a hypothesis function that returns labels $\{ 0 , 1 \}$ , and $e ( T , T )$ and $e ( A , T )$ are the generalization errors from passing target domain data $T$ and adversarial data $A$ through a classifier trained on $T$ . $d _ { \mathcal { H } \Delta \mathcal { H } } ( A , T )$ is the $\mathcal { H } \Delta \bar { \mathcal { H } }$ -distance between $T$ and $A$ , and measures the divergence between the feature distributions of $A$ and $T$ . $e _ { A } ( h , h ^ { ' } )$ and $e _ { T } ( h , h ^ { ' } )$ represents the probability that $h$ disagrees with $h ^ { ' }$ on the label of an input in the domain space $A$ and $T$ respectively.
$$\begin{array} { r } { d _ { \mathcal { H } \Delta \mathcal { H } } ( A , T ) = \underset { h , h ^ { \prime } \in \mathcal { H } } { \operatorname* { s u p } } | e _ { A } ( h , h ^ { ' } ) - e _ { T } ( h , h ^ { ' } ) | } \\ { d _ { \mathcal { H } \Delta \mathcal { H } } ( A , T ) = \operatorname* { s u p } _ { h , h ^ { \prime } \in \mathcal { H } } | \mathbb { E } _ { X \sim S } [ | ( h ( x ) - h ^ { ' } ( x ) | ] | } \\ { - | \mathbb { E } _ { X \sim T } [ | ( h ( x ) - h ^ { ' } ( x ) | ] | | } \end{array}$$
Divergence $d _ { \mathcal { H } \Delta \mathcal { H } }$ measures the divergence between feature distributions $A$ and $T$ . Higher $d _ { \mathcal { H } \Delta \mathcal { H } }$ indicates less shared features between 2 domains. The greater the intersection between feature distributions, the greater the proportion of domain-variant features; one approach to domain adaptation is learning domain-invariant features representations (Zhao et al., 2019) to minimize $d _ { \mathcal { H } \Delta \mathcal { H } }$ .
Table 3: After-defense accuracy performance of different defensive methods.
<table><tr><td>Target Domain</td><td colspan="3">magazine</td><td colspan="3">baby</td></tr><tr><td>Attack Domain</td><td>baby</td><td>dvd</td><td>book</td><td>dvd</td><td>book</td><td>magazine</td></tr><tr><td>After-attack Accuracy</td><td>0.381</td><td>0.366</td><td>0.343</td><td>0.365</td><td>0.386</td><td>0.401</td></tr><tr><td>After-defense Accuracy</td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>Adversarial training</td><td>0.639</td><td>0.559</td><td>0.657</td><td>0.558</td><td>0.577</td><td>0.661</td></tr><tr><td>Defensive distillation</td><td>0.549</td><td>0.561</td><td>0.597</td><td>0.588</td><td>0.629</td><td>0.577</td></tr><tr><td>SharedVocab defense</td><td>0.628</td><td>0.653</td><td>0.631</td><td>0.664</td><td>0.668</td><td>0.621</td></tr><tr><td>Domain-adapted adversarial training</td><td>0.608</td><td>0.637</td><td>0.620</td><td>0.604</td><td>0.620</td><td>0.587</td></tr><tr><td>Learn2Weight</td><td>0.796</td><td>0.842</td><td>0.843</td><td>0.774</td><td>0.751</td><td>0.737</td></tr></table>
Explaining similarity-domain attacks. As demonstrated by empirical results, $e ( A , T )$ increases in a similarity-based attack setting, and this would arise if $d _ { \mathcal { H } \Delta \mathcal { H } }$ increases correspondingly. $d _ { \mathcal { H } \Delta \mathcal { H } }$ computes inconsistent labels from inconsistent feature distributions, and attributes the success of the attack to domain-variant features.
FGSM and variants adjust the input data to maximize the loss based on the backpropagated gradients of a model trained on $S$ . As our pipeline used correctly-labelled sentences before adversarially perturbing them, we can infer that perturbations applied to $S$ were not class-dependent (i.e. the success of the attack is not based on the removal of class-specific features), but class-independent features. It is already difficult for a model trained on $S$ to classify when there is insufficient classdependent features (hence a high $t f ( A , T ) )$ ; in a cross-domain setting, it must be even more difficult for a model trained on $T$ to classify given a shortage of domain-invariant, class-dependent features.
$$\begin{array} { c } { { d _ { { \mathcal { H } } \Delta { \mathcal { H } } } \leq e ( A , T ) - e ( T , T ) - \lambda } } \\ { { d _ { { \mathcal { H } } \Delta { \mathcal { H } } } \leq t f ( A , T ) - \lambda } } \end{array}$$
Explaining Learn2Weight. $L 2 W$ minimizes divergence by training on $\{ d _ { \mathcal { H } \Delta \mathcal { H } } ( S _ { j } , T ) : \Delta W _ { A . S _ { j } } \}$ pairs, $d _ { \mathcal { H } \Delta \mathcal { H } } ( S _ { j } , T )$ being reconstructed from the difference between S $x _ { i } ^ { S _ { j } }$ and $x _ { i } ^ { T }$ . $L 2 W$ is trained on $\{ d _ { \mathcal { H } \Delta \mathcal { H } } ^ { S _ { j } } \} _ { j = 0 } ^ { N } : \{ \Delta W ^ { S _ { j } } \} _ { j = 0 } ^ { N }$ pairs, such that . Intuitively the target model possesses a decision boundary (Liu et al., 2019) to classify inputs based on whether they cross the boundary or not; adversarial inputs have a tendency of being near the boundary and fooling it. Weights transfer learning applies perturbations to the decision boundary such that the boundary covers certain adversarial inputs otherwise misclassified, and in this way blocks transferability. The advantage of training on multiple domains $\{ S _ { j } \} _ { j = 0 } ^ { M }$ is that the after- $. L 2 W$ divergence between $A$ and $T$ is smaller because $L 2 W$ ’s weight perturbations render the decision boundary more precise in classifying inputs.
Explaining tf-optimization. We have attributed why adversarial sentences $A$ are computed to be domain-dissimilar despite originating from $S$ due to insufficient domain-invariant, class-dependent features resulting in low $e ( A , T )$ , i.e. low $t f ( A , T )$ . To replicate this phenomenon in natural domains, we use $t f$ -optimization to iteratively perturb $T$ to increase the proportion of class-independent features. This approximates the real-world similarity-based attack scenario where class-dependent features may be limited for inference. By generating the synthetic data, we are feeding $L 2 W$ attack data with variations in $d _ { \mathcal { H } \Delta \mathcal { H } }$ and class-independent feature distributions. This prepares $L 2 W$ to robustify weights in $f ( T )$ when such feature distributions are encountered.
# 6 EXPERIMENTS
# 6.1 BASELINES
We consider two defense strategies that are empirically effective and are widely used for general black-box adversarial attacks: adversarial training (Goodfellow et al., 2014; Madry et al., 2017) and defensive distillation (Papernot et al., 2016b; 2017). In addition we consider two ablation baselines.
Defensive distillation: The high-level implementation of defensive distillation (Papernot et al., 2016b; 2017) is to first train an initial model against target domain inputs and labels, and retrieve the raw class probability scores. The predicted probability values would be used as the new labels for the same target sentences, and we would train a new model based on this new label-sentence pair.
Table 4: Learn2Weight comparison against different attack model architectures.
<table><tr><td>Target</td><td>Original</td><td>Attack</td><td colspan="4">Attack Model After-attack Accuracy</td><td colspan="6">After-Defense Accuracy</td></tr><tr><td>Domain</td><td>Accuracy Target Model: LSTM</td><td>Domain</td><td colspan="4"></td><td colspan="4">LogReg</td><td>CNN</td><td>LogReg</td></tr><tr><td colspan="4"></td><td colspan="4">BERT LSTM</td><td colspan="4">BERT LSTM</td></tr><tr><td rowspan="3">book</td><td rowspan="3">0.880</td><td>dvd</td><td>0.342</td><td>0.413</td><td>GRU 0.477</td><td>CNN 0.335</td><td>0.440</td><td>0.786</td><td>0.847</td><td>0.804</td><td>0.816</td><td>0.782</td></tr><tr><td>kitchenware</td><td>0.350</td><td>0.372</td><td>0.325</td><td>0.353</td><td>0.425</td><td>0.765</td><td>0.826</td><td>0.795</td><td>0.742</td><td>0.767</td></tr><tr><td>electronics</td><td>0.400</td><td>0.389</td><td>0.416</td><td>0.315</td><td>0.460</td><td>0.792</td><td>0.812</td><td>0.784</td><td>0.770</td><td>0.725</td></tr><tr><td rowspan="3">dvd</td><td rowspan="3">0.920</td><td></td><td>0.326</td><td>0.434</td><td>0.479</td><td>0.383</td><td>0.490</td><td>0.816</td><td>0.795</td><td>0.824</td><td>0.804</td><td>0.794</td></tr><tr><td>book kitchenware</td><td>0.355</td><td>0.370</td><td>0.379</td><td>0.359</td><td>0.490</td><td>0.728</td><td>0.796</td><td>0.755</td><td>0.735</td><td>0.695</td></tr><tr><td>electronics</td><td>0.387</td><td>0.377</td><td>0.332</td><td>0.348</td><td>0.455</td><td>0.825</td><td>0.836</td><td>0.812</td><td>0.834</td><td>0.796</td></tr><tr><td rowspan="3">electronics</td><td rowspan="3">0.910</td><td>book</td><td>0.425</td><td>0.394</td><td>0.473</td><td>0.358</td><td>0.474</td><td>0.775</td><td>0.821</td><td>0.795</td><td>0.782</td><td>0.712</td></tr><tr><td>dvd</td><td>0.342</td><td>0.395</td><td>0.452</td><td>0.368</td><td>0.493</td><td>0.784</td><td>0.845</td><td>0.855</td><td>0.842</td><td>0.792</td></tr><tr><td>kitchenware</td><td>0.390</td><td>0.384</td><td>0.464</td><td>0.329</td><td>0.432</td><td>0.730</td><td>0.824</td><td>0.753</td><td>0.724</td><td>0.678</td></tr></table>
Adversarial training: It is shown that injecting adversarial examples throughout training increases the robustness of target neural network models. In this baseline, target model is trained with both original training data and adversarial examples generated from original training data. However, since the adversarial examples are still generated from the target domain, it is unlikely that the method can defend similar-domain attack which is the result of domain-variant features.
SharedVocab defense. Given that it is the domain-variant features that cause the success of similardomain attack, a simple baseline is to remove those words that are not in the target domain’s vocabulary. This tests whether the effect of perturbing target model weights w.r.t domain-variant features will yield incremental after-attack accuracy in the similar-domain attack setting.
Domain-adapted adversarial training. This ablation baseline tests for incremental performance to a baseline defense using domain-variant inputs. We adapt adversarial training to be trained on adversarial sentences from attack domain $S$ , whereas the traditional adversarial training generates adversarial samples $X ^ { a d v , T }$ from its training data $T$ , this adapted version uses adversarial samples $X ^ { a d v , S }$ generated from $S$ .
# 6.2 LEARN2WEIGHT PERFORMANCE
Defense performance. We present the results of different defense baselines in Table 3. First, we can see that Learn2Weight achieves the highest after-defense accuracy against the adversarial attack. Take the magazine as target domain for example, if the adversary chooses to use book data as the attack domain, it would reduce the target model accuracy to 0.343. However, the Learn2Weight method can improve the performance to 0.843, which is a significant and substantial improvement against the attack. This improvements also exist across different target/attack domain pairs. Second, we see that all defense methods can improve the accuracy to some extent which indicates the importance and effectiveness of having robust training for machine learning models. Third, it is interesting to note that two simple baselines SharedVocab defense and Domain-adapted adversarial training yield overall better performance compared to adversarial training and defensive distillation.
Attack model architectures. So far, all the results are conducted using the same LSTM as the target/attack model due to simplicity purpose. Here, we keep the target model unchanged, but vary the architecture of the attack model for the generation of adversarial examples. A variation of a Recurrent Neural Network is a Gated Recurrent Unit (GRU) network, with 512 GRU cells, $60 \%$ dropout and tanh activation function. We have also tested other attack model variants that are commonly-used in sentiment classification, including Bidirectional Encoder Representations from Transformers (BERT) (Devlin et al., 2019), Convolutional Neural Network (CNN) (Kim, 2014), and Logistic Regression (Maas et al., 2011). For both RNN and CNN, we use pre-computed Glove embeddings2 to encode words. All models are trained with enough epochs after ensuring the model achieved near state-of-the-art validation accuracy before proceeding to tests of adversarial attacks and defenses.
We present the results of different attack model architectures in Table 4. First, similar-domain attack is model-agnostic and it does not require the target and attack model to have identical architectures.
We can see that all four attack model architectures are able to reduce the target model accuracy. Second, the results suggest that Learn2Weight is also model-agnostic as it can substantially improve the after-defense accuracy regardless which attack model is used.
# 7 CONCLUSION
In this newly-proposed, empirically-effective similar-domain attack, an adversary can choose a similar domain to the target task, build a substitute model and produce adversarial examples to fool the target model. We also propose a defense strategy, Learn2Weight, that learns to adapt the target model’s weight using crafted adversarial examples. Compared with other adversarial defense strategies, Learn2Weight can improve the target model robustness against the similar-domain attack. Our method demonstrates properties of a good adversarial defense, such as adopting defense architectures that adapt to situations/inputs rather than compromising standard error versus robustness error, to leverage class-independent properties in domain-variant text, and factoring in domain similarity in adversarial robustness exercises.
# REFERENCES
Shai Ben-David, John Blitzer, Koby Crammer, Alex Kulesza, Fernando Pereira, and Jennifer Vaughan. A theory of learning from different domains. Machine Learning, 79:151–175, 2010. URL http://www.springerlink.com/content/q6qk230685577n52/.
John Blitzer, Mark Dredze, and Fernando Pereira. Biographies, bollywood, boom-boxes and blenders: Domain adaptation for sentiment classification. In ACL, pp. 440–447, 2007.
Shuyu Cheng, Yinpeng Dong, Tianyu Pang, Hang Su, and Jun Zhu. Improving black-box adversarial attacks with a transfer-based prior. In H. Wallach, H. Larochelle, A. Beygelzimer, F. d'Alche-Buc, E. Fox, and R. Garnett (eds.), ´ Advances in Neural Information Processing Systems 32, pp. 10934–10944. Curran Associates, Inc., 2019. URL http://papers.nips.cc/paper/ 9275-improving-black-box-adversarial-attacks-with-a-transfer-based-prior. pdf.
Jacob Devlin, Ming-Wei Chang, Kenton Lee, and Kristina Toutanova. BERT: Pre-training of deep bidirectional transformers for language understanding. In Proceedings of the 2019 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, Volume 1 (Long and Short Papers), pp. 4171–4186, Minneapolis, Minnesota, June 2019. Association for Computational Linguistics. doi: 10.18653/v1/N19-1423. URL https: //www.aclweb.org/anthology/N19-1423.
Javid Ebrahimi, Anyi Rao, Daniel Lowd, and Dejing Dou. Hotflip: White-box adversarial examples for text classification. In ACL, pp. 31–36, 2018.
Samuel G. Finlayson, John D. Bowers, Joichi Ito, Jonathan L. Zittrain, Andrew L. Beam, and Isaac S. Kohane. Adversarial attacks on medical machine learning. Science, 363(6433):1287–1289, 2019. ISSN 0036-8075. doi: 10.1126/science.aaw4399. URL https://science.sciencemag.org/ content/363/6433/1287.
Xavier Glorot, Antoine Bordes, and Yoshua Bengio. Domain adaptation for large-scale sentiment classification: A deep learning approach. In ICML, pp. 513–520, 2011.
Ian J Goodfellow, Jonathon Shlens, and Christian Szegedy. Explaining and harnessing adversarial examples. arXiv preprint arXiv:1412.6572, 2014.
David Ha, Andrew Dai, and Quoc V Le. Hypernetworks. arXiv preprint arXiv:1609.09106, 2016.
Ronghang Hu, Piotr Dollar, Kaiming He, Trevor Darrell, and Ross Girshick. Learning to segment ´ every thing. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pp. 4233–4241, 2018.
Di Jin, Zhijing Jin, Joey Tianyi Zhou, and Peter Szolovits. Is bert really robust? natural language attack on text classification and entailment. arXiv preprint arXiv:1907.11932, 2019.
Yoon Kim. Convolutional neural networks for sentence classification. In EMNLP, pp. 1746–1751, 2014.
Jason Kuen, Federico Perazzi, Zhe Lin, Jianming Zhang, and Yap-Peng Tan. Scaling object detection by transferring classification weights. In Proceedings of the IEEE International Conference on Computer Vision, pp. 6044–6053, 2019.
Alexey Kurakin, Ian Goodfellow, and Samy Bengio. Adversarial machine learning at scale. arXiv preprint arXiv:1611.01236, 2016a.
Alexey Kurakin, Ian Goodfellow, and Samy Bengio. Adversarial examples in the physical world. arXiv preprint arXiv:1607.02533, 2016b.
Alex Lamb, Vikas Verma, Juho Kannala, and Yoshua Bengio. Interpolated adversarial training: Achieving robust neural networks without sacrificing too much accuracy. In Proceedings of the 12th ACM Workshop on Artificial Intelligence and Security, AISec’19, pp. 95–103, New York, NY, USA, 2019. Association for Computing Machinery. ISBN 9781450368339. doi: 10.1145/3338501.3357369. URL https://doi.org/10.1145/3338501.3357369.
Hong Liu, Mingsheng Long, Jianmin Wang, and Michael Jordan. Transferable adversarial training: A general approach to adapting deep classifiers. In Kamalika Chaudhuri and Ruslan Salakhutdinov (eds.), Proceedings of the 36th International Conference on Machine Learning, volume 97 of Proceedings of Machine Learning Research, pp. 4013–4022, Long Beach, California, USA, 09–15 Jun 2019. PMLR. URL http://proceedings.mlr.press/v97/liu19b.html.
Andrew L. Maas, Raymond E. Daly, Peter T. Pham, Dan Huang, Andrew Y. Ng, and Christopher Potts. Learning word vectors for sentiment analysis. In ACL, pp. 142–150, 2011.
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.
Seyed-Mohsen Moosavi-Dezfooli, Alhussein Fawzi, and Pascal Frossard. Deepfool: a simple and accurate method to fool deep neural networks. In CVPR, pp. 2574–2582, 2016.
Nicolas Papernot, Patrick McDaniel, and Ian Goodfellow. Transferability in machine learning: from phenomena to black-box attacks using adversarial samples. arXiv preprint arXiv:1605.07277, 2016a.
Nicolas Papernot, Patrick McDaniel, Xi Wu, Somesh Jha, and Ananthram Swami. Distillation as a defense to adversarial perturbations against deep neural networks. In 2016 IEEE Symposium on Security and Privacy (SP), pp. 582–597. IEEE, 2016b.
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, ASIA CCS ’17, pp. 506–519, New York, NY, USA, 2017. Association for Computing Machinery. ISBN 9781450349444. doi: 10.1145/3052973.3053009. URL https://doi.org/10.1145/3052973.3053009.
Aditi Raghunathan, Sang Michael Xie, Fanny Yang, John C Duchi, and Percy Liang. Adversarial training can hurt generalization. arXiv preprint arXiv:1906.06032, 2019.
Ludwig Schmidt, Shibani Santurkar, Dimitris Tsipras, Kunal Talwar, and Aleksander Madry. Adversarially robust generalization requires more data. In Proceedings of the 32nd International Conference on Neural Information Processing Systems, NIPS’18, pp. 5019–5031, Red Hook, NY, USA, 2018. Curran Associates Inc.
Dong Su, Huan Zhang, Hongge Chen, Jinfeng Yi, Pin-Yu Chen, and Yupeng Gao. Is robustness the cost of accuracy?–a comprehensive study on the robustness of 18 deep image classification models. In Proceedings of ECCV, pp. 631–648, 2018.
Ilya Sutskever, Oriol Vinyals, and Quoc V. Le. Sequence to sequence learning with neural networks. In Proceedings of the 27th International Conference on Neural Information Processing Systems - Volume 2, NIPS’14, pp. 3104–3112, Cambridge, MA, USA, 2014. MIT Press.
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.
Florian Tramer, Alexey Kurakin, Nicolas Papernot, Ian Goodfellow, Dan Boneh, and Patrick Mc- \` Daniel. Ensemble adversarial training: Attacks and defenses. arXiv preprint arXiv:1705.07204, 2017.
Eric Wallace, Shi Feng, Nikhil Kandpal, Matt Gardner, and Sameer Singh. Universal adversarial triggers for attacking and analyzing nlp. In EMNLP, pp. 2153–2162, 2019.
Haohan Wang, Songwei Ge, Zachary Lipton, and Eric Xing. Learning robust global representations by penalizing local predictive power. Neural Information Processing Systems, pp. 10506–10518, 2019.
Jenq-Haur Wang, Ting-Wei Liu, Xiong Luo, and Long Wang. An LSTM approach to short text sentiment classification with word embeddings. In ROCLING, pp. 214–223, 2018.
Cihang Xie, Zhishuai Zhang, Yuyin Zhou, Song Bai, Jianyu Wang, Zhou Ren, and Alan Yuille. Improving transferability of adversarial examples with input diversity, 2018.
Puyudi Yang, Jianbo Chen, Cho-Jui Hsieh, Jane-Ling Wang, and Michael I. Jordan. Greedy attack and gumbel attack: Generating adversarial examples for discrete data, 2018.
Jason Yosinski, Jeff Clune, Yoshua Bengio, and Hod Lipson. How transferable are features in deep neural networks? In Proceedings of the 27th International Conference on Neural Information Processing Systems - Volume 2, NIPS’14, pp. 3320–3328, Cambridge, MA, USA, 2014. MIT Press.
Hongyang Zhang, Yaodong Yu, Jiantao Jiao, Eric Xing, Laurent El Ghaoui, and Michael Jordan. Theoretically principled trade-off between robustness and accuracy. In Proceedings of ICML, pp. 7472–7482, 2019a.
Huan Zhang, Hongge Chen, Zhao Song, Duane Boning, Inderjit S. Dhillon, and Cho-Jui Hsieh. The limitations of adversarial training and the blind-spot attack, 2019b.
Wei Emma Zhang, Quan Z Sheng, Ahoud Alhazmi, and Chenliang Li. Adversarial attacks on deep-learning models in natural language processing: A survey. ACM Transactions on Intelligent Systems and Technology (TIST), 11(3):1–41, 2020.
Yuchen Zhang, Tianle Liu, Mingsheng Long, and Michael Jordan. Bridging theory and algorithm for domain adaptation. In Kamalika Chaudhuri and Ruslan Salakhutdinov (eds.), Proceedings of the 36th International Conference on Machine Learning, volume 97 of Proceedings of Machine Learning Research, pp. 7404–7413, Long Beach, California, USA, 09–15 Jun 2019c. PMLR. URL http://proceedings.mlr.press/v97/zhang19i.html.
Han Zhao, Remi Tachet Des Combes, Kun Zhang, and Geoffrey Gordon. On learning invariant representations for domain adaptation. In Kamalika Chaudhuri and Ruslan Salakhutdinov (eds.), Proceedings of the 36th International Conference on Machine Learning, volume 97 of Proceedings of Machine Learning Research, pp. 7523–7532, Long Beach, California, USA, 09–15 Jun 2019. PMLR. URL http://proceedings.mlr.press/v97/zhao19a.html.123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294# Stable Neural ODE with Lyapunov-Stable Equilibrium Points for Defending Against Adversarial Attacks
# Qiyu Kang∗
Continental-NTU Corporate Lab Nanyang Technological University 50 Nanyang Avenue, 639798, Singapore kang0080@e.ntu.edu.sg
Yang Song∗ School of Electrical and Electronic Engineering Nanyang Technological University 50 Nanyang Avenue, 639798, Singapore songy@ntu.edu.sg
# Qinxu Ding
School of Business Singapore University of Social Sciences 463 Clementi Road, 599494, Singapore qinxuding@suss.edu.sg
Wee Peng Tay School of Electrical and Electronic Engineering Nanyang Technological University 50 Nanyang Avenue, 639798, Singapore wptay@ntu.edu.sg
# Abstract
Deep neural networks (DNNs) are well-known to be vulnerable to adversarial attacks, where malicious human-imperceptible perturbations are included in the input to the deep network to fool it into making a wrong classification. Recent studies have demonstrated that neural Ordinary Differential Equations (ODEs) are intrinsically more robust against adversarial attacks compared to vanilla DNNs. In this work, we propose a stable neural ODE with Lyapunov-stable equilibrium points for defending against adversarial attacks (SODEF). By ensuring that the equilibrium points of the ODE solution used as part of SODEF is Lyapunov-stable, the ODE solution for an input with a small perturbation converges to the same solution as the unperturbed input. We provide theoretical results that give insights into the stability of SODEF as well as the choice of regularizers to ensure its stability. Our analysis suggests that our proposed regularizers force the extracted feature points to be within a neighborhood of the Lyapunov-stable equilibrium points of the ODE. SODEF is compatible with many defense methods and can be applied to any neural network’s final regressor layer to enhance its stability against adversarial attacks.
# 1 Introduction
Although deep learning has found successful applications in many tasks such as image classification [1, 2], speech recognition [3], and natural language processing [4], the vulnerability of deep learning to adversarial attacks (e.g., see [5]) has limited its real-world applications due to performance and safety concerns in critical applications. Inputs corrupted with human-imperceptible perturbations can easily fool many vanilla deep neural networks (DNNs) into mis-classifying them and thus significantly impact their performance.
Recent studies [6–8] have applied neural Ordinary Differential Equations (ODEs) [9] to defend against adversarial attacks. Some works like [6] have revealed interesting intrinsic properties of
ODEs that make them more stable than conventional convolutional neural networks (CNNs). The paper [6] proposes a time-invariant steady neural ODE (TisODE) using the property that the integral curves from a ODE solution starting from different initial points (inputs) do not intersect and always preserve uniqueness in the solution function space. However, this does not guarantee that small perturbations of the initial point lead to small perturbations of the integral curve output at a later time $T$ . The authors thus proposed a regularizer to limit the evolution of the curves by forcing the integrand to be close to zero. However, neither the non-intersecting property nor the steady-state constraint used in TisODE can guarantee robustness against input perturbations since these constraints do not ensure that the inputs are within a neighborhood of Lyapunov-stable equilibrium points. An example is an ODE that serves as an identity mapping is not robust to input perturbations but satisfies all the constraints proposed in [6].
In this paper, our objective is to design a neural ODE such that the features extracted are within a neighborhood of the Lyapunov-stable equilibrium points of the ODE. We first develop a diversity promoting technique applied in the final fully connected (FC) layer to improve the ODE’s stability and analyze the reasons why. We then propose a stable neural ODE with Lyapunov-stable equilibrium points to eliminate the effects of perturbations in the input. From linear control theory [10], a linear time-invariant system $\mathrm { d } { \mathbf { z } ( t ) } / \mathrm { d } t = { \mathbf { A } } { \mathbf { z } ( t ) }$ , where $\mathbf { A }$ is a constant matrix, is exponentially stable if all eigenvalues of $\mathbf { A }$ have negative real parts. Specifically, we propose to force the Jacobian matrix of the ODE used in the neural ODE to have eigenvalues with negative real parts. Instead of directly imposing constraints on the eigenvalues of the matrix, which lead to high computational complexity when the Jacobian matrix is large, we instead add constraints to the matrix elements to implicitly force the real parts of its eigenvalues to be negative.
Our main contributions are summarized as follows:
1. Based on the concept of Lyapunov-stable equilibrium points, we propose a simple yet effective technique to improve the robustness of neural ODE networks by fixing the final FC layer to be a matrix whose rows have unit norm and such that the maximum cosine similarity between any two rows is minimized. Such a FC layer can be constructed off-line. 2. We propose a stable neural ODE for deFending against adversarial attacks (SODEF) to suppress the input perturbations. We derive an optimization formulation for SODEF to force the extracted feature points to be within a neighborhood of the Lyapunov-stable equilibrium points of the SODEF ODE. We provide sufficient conditions for learning a robust feature representation under SODEF. 3. We test SODEF on several widely used datasets MNIST [11], CIFAR-10 and CIFAR-100 [12] under well-known adversarial attacks. We demonstrate that SODEF is robust against adversarial white-box attacks with improvement in classification accuracy of adversarial examples under PGD attack [13] of up to $4 4 . 0 2 \%$ , $5 2 . 5 4 \%$ and $1 8 . 9 1 \%$ percentage points compared to another current state-of-the-art neural ODE network TisODE [6] on MNIST, CIFAR-10 and CIFAR-100, respectively. Similar improvements in classification accuracy of adversarial examples of up to $\bar { 4 3 . 6 9 \% }$ , $5 2 . 3 8 \%$ and $\mathrm { \bar { 1 8 . 9 9 \% } }$ percentage points compared to ODE net [9] are also obtained.
The rest of this paper is organized as follows. We provide essential preliminaries on neural ODE and its stability analysis in Section 2. In Section 3, we present SODEF model architecture and its training method. We show how to maximize the distance between stable equilibrium points of neural ODEs. We propose an optimization and present theoretical results on its stability properties. We summarize experimental results in Section 4 and conclude the paper in Section 5. The proofs for all lemmas and theorems proposed in this paper are given in the supplementary material. We also refer interested readers to the supplementary material for a more detailed account of related works [14–16, 6] and some popular adversarial attacks [17, 13] that are used to verify the robustness of our proposed SODEF. In the paper, we use lowercase boldface characters like $\mathbf { z }$ to denote vectors in $\mathbb { R } ^ { n }$ , capital boldface characters like $\mathbf { A }$ to denote matrices in $\mathbb { R } ^ { n \times n }$ , and normal characters like $z$ to denote scalars except that the notation $( x , y )$ are normal characters reserved to denote the input and label pairs. A vector $\mathbf { z } \in \mathbb { R } ^ { n }$ is represented as $( \mathbf { z } ^ { ( 1 ) } , \mathbf { z } ^ { ( 2 ) } , \ldots , \mathbf { z } ^ { ( n ) } )$ . The $( i , j )$ -th element of a matrix $\mathbf { A }$ is $\mathbf { A } _ { i j }$ or $[ \mathbf { A } ] _ { i j }$ . The Jacobian matrix of a function $f : \mathbb { R } ^ { n } \mapsto \mathbb { R } ^ { n }$ evaluated at $\mathbf { z }$ is denoted as $\nabla f ( \mathbf { z } )$ The set of functions $\mathbb { R } ^ { n } \mapsto \mathbb { R } ^ { n }$ with continuous first derivatives is denoted as $C ^ { 1 } ( \mathbb { R } ^ { n } , \mathbb { R } ^ { n } )$ .
# 2 Preliminaries: Neural ODE and Stability
In a neural ODE layer, the relation between the layer input ${ \bf z } ( 0 )$ and output ${ \mathbf z } ( T )$ is described as the following differential equation:
$$\frac { \mathrm { d } \mathbf { z } ( t ) } { \mathrm { d } t } = f _ { \pmb { \theta } } ( \mathbf { z } ( t ) , t )$$
where $f _ { \pmb \theta } : \mathbb { R } ^ { n } \times [ 0 , \infty ) \mapsto \mathbb { R } ^ { n }$ denotes the non-linear trainable layers that are parameterized by weights $\pmb { \theta }$ and $\mathbf { z } : [ 0 , \infty ) \mapsto \mathbb { R } ^ { n }$ represents the $n$ -dimensional state of the neural ODE. Neural ODEs are the continuous analog of residual networks where the hidden layers of residual networks can be regarded as discrete-time difference equations ${ \bf z } ( t + 1 ) = { \bf z } ( t ) + { f _ { \theta } } ( { \bf z } ( t ) , t )$ . In this work, for simplicity, we only consider the time-invariant (autonomous) case $f _ { \pmb \theta } ( \mathbf { z } ( t ) , t ) = f _ { \pmb \theta } ( \mathbf { z } ( t ) )$ , where the dynamical system does not explicitly depend on $t$ . For such non-linear dynamical systems, the following theorem shows that under mild conditions, its behaviour can be studied via linearization near special points called hyperbolic equilibrium points.
Theorem 1 (Hartman–Grobman Theorem [18]). Consider a system evolving in time with state $\mathbf { z } ( t ) \in \mathbb { R } ^ { n }$ that satisfies the differential equation $\frac { \mathrm { d } { \bf z } ( t ) } { \mathrm { d } t } = f ( { \bf z } ( t ) )$ for some $f \in C ^ { 1 } ( \mathbb { R } ^ { n } , \mathbb { R } ^ { n } ) ;$ , $f ( \mathbf { z } ) = ( f ^ { ( 1 ) } ( \mathbf { z } ) , \ldots , f ^ { ( n ) } ( \mathbf { z } ) )$ . Suppose the map has a hyperbolic equilibrium state $\mathbf { z } ^ { \ast } \in \mathbb { R } ^ { n }$ , i.e., $f ( { \bf z } ^ { * } ) = 0$ and the Jacobian matrix with real part equal to zer $\nabla f = [ \partial f ^ { ( i ) } / \partial \mathbf { z } ^ { ( j ) } ] _ { i , j = 1 } ^ { n }$ of hb $f$ evalurhood at of $\textbf { z } = \textbf { z } ^ { * }$ has nolibrium $N _ { \mathbf { z } ^ { * } }$ point $\mathbf { z } ^ { \ast }$ and a homeomorphism $g : N _ { \mathbf { z } ^ { * } } \mapsto \mathbb { R } ^ { n }$ , such that $g ( \mathbf { z } ^ { * } ) = 0$ and in the neighbourhood $N _ { \mathbf { z } ^ { * } }$ , the flow of $\frac { \mathrm { d } { \bf z } ( t ) } { \mathrm { d } t } = f ( { \bf z } ( t ) )$ is topologically conjugate by the continuous map $\bar { \mathbf { z } } ( t ) = g ( \mathbf { z } ( t ) )$ to the flow of its linearization $\frac { \mathrm { d } \bar { \mathbf { z } } ( t ) } { \mathrm { d } t } = \nabla f ( \mathbf { z } ^ { * } ) \cdot \bar { \mathbf { z } } ( t ) .$
The theorem states that when the Jacobian matrix at the zeros of $f$ has no eigenvalue with zero real part, the behaviour of the original dynamical system can be studied using the simpler linearization of the system around those zeros. We next review some definitions and theorems from linear control theory [10].
Definition 1 (Lyapunov Stability [10]). The linear time-invariant system $\frac { \mathrm { d } \bar { \mathbf { z } } ( t ) } { \mathrm { d } t } = \mathbf { A } \bar { \mathbf { z } } ( t )$ with constant matrix A is marginally stable or stable in the sense of Lyapunov if every finite initial state $\bar { \mathbf { z } } ( 0 )$ excites a bounded response. It is asymptotically stable if every finite initial state excites $a$ bounded response, which, in addition, approaches 0 as $t \to \infty$ .
Theorem 2 (Lyapunov Stability Theorem [10]). a) The equation $\frac { \mathrm { d } \bar { \mathbf { z } } ( t ) } { \mathrm { d } t } = \mathbf { A } \bar { \mathbf { z } } ( t ) )$ is marginally stable if and only if all eigenvalues of A have zero or negative real parts and those with zero real parts are simple roots of the minimal polynomial of A. $^ b$ ) The equation $\frac { \mathrm { d } \bar { \mathbf { z } } ( t ) } { \mathrm { d } t } = \mathbf { A } \bar { \mathbf { z } } ( t )$ is asymptotically stable if and only if all eigenvalues of A have negative real parts.
In Theorem 1, we say that a hyperbolic equilibrium point is Lyapunov-stable if all eigenvalues of the Jacobian matrix evaluated at it have negative real parts. From Theorems 1 and 2, we see that a small perturbation around the Lyapunov-stable equilibrium point ${ \bf z } ( 0 )$ leads to $\tilde { \mathbf { z } } ( t ) \to \mathbf { z } ( 0 )$ as $t \to \infty$ , i.e., $\exists \delta > 0$ such that for all $\tilde { \mathbf { z } } ( 0 )$ with $\lVert { \mathbf z } ( 0 ) \dot { - } \tilde { { \mathbf z } } ( 0 ) \rVert _ { 2 } \dot { < } \delta$ , we have $\| \widetilde { \mathbf { z } } ( t ) - \mathbf { z } ( 0 ) \| _ { 2 } \to \dot { 0 }$ as $t \to \infty$ , where $\tilde { \mathbf { z } } ( t )$ is the ODE solution for the perturbed input $\tilde { \mathbf { z } } ( 0 )$ . In the context of neural network adversarial attacks, if the malicious perturbations around the ODE input ${ \bf z } ( 0 )$ is small, then the output ${ \mathbf z } ( T )$ for large enough $T$ will not be affected significantly by the perturbation. Consequently, the succeeding network layers after the neural ODE layer can still perform well without being affected by the input perturbation. The perturbation weakening phenomenon around Lyapunov-stable equilibrium points works like a noise filter and acts as a defense against adversarial attacks.
We require the following definition and result in our stability analysis.
Definition 2 (Strictly diagonally dominant [19]). Let $\mathbf { A } \in \mathbb { C } ^ { n \times n }$ . We say that A is strictly diagonally dominant if $\begin{array} { r } { \left| { { { \mathbf { A } } _ { i i } } } \right| > \sum _ { j \neq i } \left| { { { \mathbf { A } } _ { i j } } } \right| } \end{array}$ for all $i = 1 , . . . , n$ .
Theorem 3 (Levy–Desplanques theorem [19]). If $\mathbf { A } \in \mathbb { C } ^ { n \times n }$ is strictly diagonally dominant and if every main diagonal entry of A is real and negative, then $A$ is non-singular and every eigenvalue of A has negative real part.
 Fig. 1: SODEF model architecture.
Lemma 1. Given $k$ distinct points $\mathbf { z } _ { i } \in \mathbb { R } ^ { n }$ and matrices $\mathbf { A } _ { i } \in \mathbb { R } ^ { n \times n }$ , $i = 1 , . . . , k$ , there exists a function $f \in C ^ { 1 } ( \mathbb { R } ^ { n } , \mathbb { R } ^ { n } )$ such that $f ( \mathbf { z } _ { i } ) = 0$ and $\nabla f _ { \pmb { \theta } } ( \mathbf { z } _ { i } ) = \mathbf { A } _ { i }$ .
# 3 SODEF Architecture
We consider a classification problem with $L$ classes. The proposed SODEF model architecture is shown in Fig. 1. The input $x \in X$ (e.g., an image) is first passed through a feature extractor $h _ { \phi } : X \mapsto \mathbb { R } ^ { n }$ to obtain an embedding feature representation ${ \bf z } ( 0 )$ . A neural ODE layer $f _ { \theta }$ follows as a nonlinear feature mapping to stabilize the feature representation output ${ \bf z } ( 0 )$ from $h _ { \phi }$ . The final FC layer $\mathbf { V }$ serves as a linear mapping to generate a prediction vector based on the output $\mathbf { \dot { z } } ( T )$ of the neural ODE layer. The parameters $\phi , \theta$ and $\mathbf { V }$ are parameterized weights for the feature extractor, neural ODE layer and FC layer, respectively.
We provide motivation and design guidance for the FC layer V in Section 3.1, which attempts to separate Lyapunov-stable equilibrium points implicitly by maximizing the similarity distance between feature representations corresponding to the $L$ different classes. Experimental results demonstrate the advantages of our diversity promoting FC layer in Section 3.1 with comparisons to traditional neural ODEs without diversity promoting.
However, the embedded features after using diversity promoting are not guaranteed to locate near the Lyapunov-stable equilibrium points. In Section 3.2, we formulate an optimization problem to force embedding features to locate near the Lyapunov-stable equilibrium points. We introduce optimization constraints to force the Jacobian matrix of the ODE in our neural ODE layer to have eigenvalues with negative real parts at the Lyapunov-stable equilibrium points. Instead of directly imposing constraints on the eigenvalue of the matrix, which may be computationally complex especially when the matrix is large, we add constraints to the matrix elements instead.
# 3.1 Maximizing the Distance between Lyapunov-Stable Equilibrium Points
From Section 2, we observe that points in a small neighbourhood of a Lyapunov-stable equilibrium point is robust against adversarial perturbations. We call this neighborhood a stable neighborhood. However Lyapunov-stable equilibrium points for different classes may very well locate near each other and therefore each stable neighborhood may be very small, leading to poor adversarial defense. In this section, we propose to add a FC layer after the neural ODE layer given by (1) to avoid this scenario. The purpose of the FC layer is to map the output of the neural ODE layer to a feature vector $\mathbf { v } _ { l }$ if the input $x$ belongs to the class $l = 1 , \ldots , L$ . We design the FC layer so that the cosine similarities between different $\mathbf { v } _ { l }$ ’s are minimized.
Lemma 2. Given a set of $k$ unit vectors $\mathbf { v } _ { 1 } , \ldots , \mathbf { v } _ { k }$ in $\mathbb { R } ^ { n }$ , where $n \geq k$ , let $a ( \mathbf { v } _ { 1 } , \ldots , \mathbf { v } _ { k } ) =$ $\mathrm { m a x } _ { i \neq j } { \mathbf { \Delta v } _ { i } ^ { \mathsf { T } } } { \mathbf { v } _ { j } }$ . Then $\operatorname* { m i n } a ( \mathbf { v } _ { 1 } , . . . , \mathbf { v } _ { k } ) = 1 / ( 1 - k )$ , where the minimum is taken over all possible sets of $k$ unit vectors $\mathbf { v } _ { 1 } , \ldots , \mathbf { v } _ { k }$ .
Corollary 1. Consider a $k \times k$ matrix $\mathbf { B } = [ b _ { i j } ] _ { i , j = 1 } ^ { k }$ with $b _ { i i } = 1$ and $b _ { i j } = 1 / ( 1 - k )$ , $\forall i \ne j$ Let the eigen decomposition of $\mathbf { B }$ be $\mathbf { B } = \mathbf { U } \pmb { \Sigma } \bar { \mathbf { U } } ^ { \dag }$ . For any $n \geq k$ and $i = 1 , \ldots , k$ , let $\mathbf { v } _ { i }$ be the $i$ -th column of $\mathbf { Q } \mathbf { \Sigma } ^ { \mathrm { { X } ^ { 1 / 2 } \bar { U } ^ { \top } } }$ , where $\mathbf { Q }$ is any $n \times k$ matrix such that $\mathbf { Q } ^ { \intercal } \mathbf { Q } = \mathbf { I } _ { k }$ . Then, $a ( \mathbf { v } _ { 1 } , \ldots , \mathbf { v } _ { k } ) = \operatorname* { m a x } _ { i \neq j } \mathbf { v } _ { i } ^ { \mathsf { T } } \mathbf { v } _ { j } = { 1 } / ( 1 - k )$ .
Corollary 1 suggests a diversity promoting scheme to maximally separate the equilibrium points of the neural ODE layer. The FC layer is represented by an $n \times L$ matrix $\mathbf { V } = \left[ \mathbf { v } _ { 1 } , \ldots , \mathbf { v } _ { L } \right]$ , where $n$ is the dimension of ${ \mathbf z } ( T )$ , the output from the neural ODE layer. If ${ \mathbf z } ( T )$ is generated from an input from class $l$ , it is mapped to $\mathbf { v } _ { l }$ . By minimizing the maximum cosine similarity $a ( \mathbf { v } _ { 1 } , \ldots , \mathbf { v } _ { k } ) = \operatorname* { m a x } _ { i \neq j } \mathbf { v } _ { i } ^ { \mathsf { T } } \mathbf { v } _ { j }$ between the representations from two different classes, we ensure that the output of SODEF is robust to perturbations in the input. Corollary 1 provides a way to choose the FC layer weights $\mathbf { V }$ .
To validate our observations, we conduct experiments to compare the robustness of ODE net [9] and TisODE [6] with and without our proposed FC layer V, on two standard datasets: MNIST [2] and CIFAR10 [12] 2. On the MNIST dataset, all models consist of four convolutional layers and one fully-connected layer. On the CIFAR10 dataset, the networks are similar to those for MNIST except the down-sampling network is a stack of 2 ResNet blocks. In practice, the neural ODE can be solved with different numerical solvers such as the Euler method and the Runge-Kutta methods [9]. Here, we use Runge-Kutta of order 5 in our experiments. Our implementation builds on the open-source neural ODE codes.3 During training, no Gaussian noise or adversarial examples are augmented into the training set. We test the performance of our model in defending against white-box attacks FGSM [17] and PGD [13] . The parameters for different attack methods used in this paper are given in the supplementary material. From Tables 1 and 2, we observe that for both datasets, our fixed FC layer improves each network’s defense ability by a significant margin. We visualize the features before the final FC layer using t-SNE [20] in Figs. 2 and 3. We observe that with the FC layer, the features for different classes are well separated even under attacks.
Table 1: Classification accuracy $( \% )$ on adversarial MNIST examples, where the superscript + indicates the last FC layer is fixed to be $\mathbf { V }$ .
<table><tr><td>Attack</td><td>Para.</td><td>ODE</td><td>ODE+</td><td>TisODE</td><td>TisODE+</td></tr><tr><td>None</td><td>-</td><td>99.6</td><td>99.7</td><td>99.5</td><td>99.7</td></tr><tr><td>FGSM</td><td>∈ = 0.3</td><td>31.4</td><td>52.8</td><td>45.9</td><td>63.5</td></tr><tr><td>PGD</td><td>∈=0.3</td><td>0.29</td><td>0.30</td><td>0.4</td><td>20.20</td></tr></table>
Table 2: Classification accuracy $( \% )$ on adversarial CIFAR10 examples, where the superscript + indicates the last FC layer is fixed to be $\mathbf { V }$ .
<table><tr><td>Attack</td><td>Para.</td><td>ODE ODE+</td><td>TisODE</td><td>TisODE+</td></tr><tr><td>None</td><td>-</td><td>87.0 85.0</td><td>87.4</td><td>81.8</td></tr><tr><td>FGSM</td><td>∈ = 0.1</td><td>12.9 47.6</td><td>13.1</td><td>41.9</td></tr><tr><td>PGD</td><td>∈=0.1</td><td>7.8 14.7</td><td>7.4</td><td>16.2</td></tr></table>
 Fig. 2: t-SNE visualization results on the features before the final FC layer. The input is the test set of MNIST. Left: trained with TisODE, middle: TisODE using a randomly chosen orthogonal matrix as the final FC, right: TisODE using proposed $\mathbf { V }$ as the final FC.
# 3.2 Objective Formulation and Stability
In this subsection, we formulate an optimization framework for SODEF to force output features to locate within the stable neighborhood of Lyapunov-stable equilibrium points. We make the following assumption.
Assumption 1. The input x takes values in a compact metric space $X$ and has probability distribution $\mu$ . The feature extractor $h _ { \phi }$ is injective and continuous.
 Fig. 3: t-SNE visualization results on the features before the final FC layer. The input is the adversarial examples of the test set of MNIST generated using FGSM method at $\epsilon = 0 . 3$ . Left: trained with TisODE, middle: TisODE using a randomly chosen orthogonal matrix as the final FC, right: TisODE using proposed $\mathbf { V }$ as the final FC.
The above assumption is satisfied if the input $x$ (e.g., an image) resides in a bounded and closed set of a Euclidean space. We denote the pushforward measure (still a probability distribution) of $\mu$ under the continuous feature extractor mapping $h _ { \phi }$ as $\nu _ { \phi } = \mu \circ h _ { \phi } ^ { - 1 }$ , where $\circ$ denotes function composition. The conditional probability distribution for the embedding of each class $l \in \{ 1 , . . . , L \}$ has compact support $E _ { l } \subset \mathbb { R } ^ { n }$ since $E _ { l }$ is closed and $h _ { \phi } ( X )$ is bounded in $\mathbb { R } ^ { n }$ . In Section 3.1, the FC layer $\mathbf { V }$ tries to maximize the distance between $E _ { l }$ , $l = 1 , \ldots , L$ . In this section for analysis purposes, we also assume the following.
Assumption 2. We have $E _ { l } \bigcap E _ { l ^ { \prime } } = \varnothing i f l \neq l ^ { \prime }$ , i.e., the supports of each class are pairwise disjoint.
Our objective function is formulated as follows, which is explained in detail in the sequel:
$$\begin{array} { r l } & { \underset { \theta , \phi } { \operatorname* { m i n } } \mathbb { E } _ { \boldsymbol { \mu } } \ell ( { \mathbf { V } } ^ { \top } ( { \mathbf { z } } ( T ) ) , y _ { i } ) } \\ & { \mathrm { s . t . } \ \mathbb { E } _ { \boldsymbol { \nu } _ { \phi } } \| f _ { \theta } ( { \mathbf { z } } ( 0 ) ) \| _ { 2 } < \epsilon , \ f _ { \theta } \in C ^ { 1 } ( \mathbb { R } ^ { n } , \mathbb { R } ^ { n } ) , } \\ & { \quad \quad \quad \mathbb { E } _ { \boldsymbol { \nu } _ { \phi } } \left[ \nabla f _ { \theta } ( { \mathbf { z } } ( 0 ) ) \right] _ { i i } < 0 , \ \forall i = 1 , \ldots , n , } \\ & { \quad \quad \mathbb { E } _ { \boldsymbol { \nu } _ { \phi } } \left[ | [ \nabla f _ { \theta } ( { \mathbf { z } } ( 0 ) ) ] _ { i i } | - \sum _ { j \neq i } | [ \nabla f _ { \theta } ( { \mathbf { z } } ( 0 ) ) ] _ { i j } | \right] > 0 , \ \forall i = 1 , \ldots , n , } \end{array}$$
$\mathbf { z } ( 0 ) = h _ { \phi } ( x )$ , and ${ \mathbf z } ( T )$ is the output of (1) with input ${ \bf z } ( 0 )$ .
Here, $\ell$ is a loss function and $\epsilon > 0$ is a positive constant. The constraints (3) to (5) force ${ \bf z } ( 0 )$ to be near the Lyapunov-stable equilibrium points with strictly diagonally dominant derivatives. We limit the $f _ { \theta }$ to be in $C ^ { 1 } ( \mathbb { R } ^ { n } , \mathbb { R } ^ { n } )$ to satisfy the condition in Theorem 1. From [21], we also know that standard multi-layer feed forward networks with as few as a single hidden layer and arbitrary bounded and non-constant activation function are universal approximators for $C ^ { 1 ^ { \prime } } ( \mathbb { R } ^ { n } , \mathbb { R } ^ { n } )$ functions with respect to some performance criteria provided only that sufficiently many hidden units are available.
As a comparison, TisODE [6] only includes a constraint similar to (3), which in general provides no guarantee to force ${ \bf z } ( 0 )$ near the Lyapunov-stable equilibrium points. In the extreme case with parameters $\theta = 0$ for $f _ { \theta }$ such that $f _ { \pmb { \theta } } = 0$ , the ODE degenerates to an identity mapping. No $\mathbf { z } ( 0 ) \in \mathbb { R } ^ { n }$ can now be a Lyapunov-stable equilibrium point, and no stability can therefore be guaranteed to defend against adversarial attacks even though the ODE curves still possess the nonintersecting property and steady-state constraint, which were cited as reasons for the stability of TisODE.
Instead of directly optimizing the above objective function, in our implementation, we optimize the following empirical Lagrangian with a training set $\left\{ \left( x _ { k } , y _ { k } \right) : k = 1 , { \overset { - } { \ldots } } , N \right\}$ :
$$\begin{array} { l } { \displaystyle \operatorname* { m i n } _ { \theta , \phi } \frac { 1 } { N } \sum _ { k = 0 } ^ { N - 1 } \bigg ( \ell \big ( \mathbf { V } ^ { \top } \mathbf { z } _ { k } ( T ) , y _ { k } \big ) + \alpha _ { 1 } \| f _ { \theta } \big ( \mathbf { z } _ { k } ( 0 ) \big ) \| _ { 2 } + \alpha _ { 2 } g _ { 1 } \Big ( \displaystyle \sum _ { i = 1 } ^ { n } [ \nabla f _ { \theta } ( \mathbf { z } _ { k } ( 0 ) ) ] _ { i i } \Big ) } \\ { \displaystyle \quad \quad + \alpha _ { 3 } g _ { 2 } \Big ( \displaystyle \sum _ { i = 1 } ^ { n } ( - | [ \nabla f _ { \theta } ( \mathbf { z } _ { k } ( 0 ) ) ] _ { i i } | + \displaystyle \sum _ { j \neq i } \vert [ \nabla f _ { \theta } ( \mathbf { z } _ { k } ( 0 ) ) ] _ { i j } | ) \Big ) \bigg ) } \end{array}$$
s. t. $\mathbf { z } _ { k } ( 0 ) = h _ { \phi } ( x _ { k } )$ , and ${ \mathbf z } _ { k } ( T )$ is the output of (1) with input $\mathbf { z } _ { k } ( 0 ) , \forall k = 1 , . . . , N$ (8)
where $\alpha _ { 1 } , \alpha _ { 2 }$ and $\alpha _ { 3 }$ are hyperparameter weights, $g _ { 1 }$ and $g _ { 2 }$ are chosen monotonically increasing functions bounded below to eliminate the unbounded impact of the two regularizers that can otherwise dominate the loss. In this paper, we set $g _ { 1 } ( \cdot ) = g _ { 2 } ( \cdot ) \bar { = } \exp ( \cdot )$ . We call these two latter terms the SODEF regularizers.
Suppose for each class $l = 1 , \ldots , L$ , the embedding feature set $E _ { l } = \{ \mathbf { z } _ { 1 } ^ { ( l ) } , \dots , \mathbf { z } _ { k } ^ { ( l ) } \}$ z(l)k } is finite. For each $i = 1 , \ldots , k$ , let $\mathbf { A } _ { i } \in \mathbb { R } ^ { n \times n }$ be strictly diagonally dominant matrix with every main diagonal entry be negative such that the eigenvalues for $\mathbf { A } _ { i }$ all have negative real part. From Theorem 3, each $\mathbf { A } _ { i }$ is non-singular and every eigenvalue of $\mathbf { A } _ { i }$ has negative real part. Therefore, from Theorem 2 and Lemma 1, there exists a function $f _ { \theta }$ such that all $\mathbf { z } _ { i } ^ { ( l ) }$ are Lyapunov-stable equilibrium points with corresponding first derivative $\nabla f _ { \pmb \theta } ( \mathbf z _ { i } ^ { ( l ) } ) = \mathbf { A } _ { i }$ . This shows that if there exist only finite representation points for each class, we can find a function $f _ { \theta }$ such that all inputs to the neural ODE layer are Lyapunov-stable equilibrium points for $f _ { \theta }$ and
$$\begin{array} { r l } & { \mathbb { E } _ { \boldsymbol \nu _ { \phi } } \left\| f _ { \boldsymbol \theta } ( \mathbf { z } ( 0 ) ) \right\| _ { 2 } = 0 , } \\ & { \mathbb { E } _ { \boldsymbol \nu _ { \phi } } \left[ \nabla f _ { \boldsymbol \theta } ( \mathbf { z } ( 0 ) ) \right] _ { i i } < 0 , \forall i = 1 , \ldots , n , } \\ & { \mathbb { E } _ { \boldsymbol \nu _ { \phi } } \left[ | [ \nabla f _ { \boldsymbol \theta } ( \mathbf { z } ( 0 ) ) ] _ { i i } | - \sum _ { j \neq i } \vert [ \nabla f _ { \boldsymbol \theta } ( \mathbf { z } ( 0 ) ) ] _ { i j } \vert \right] > 0 , \forall i = 1 , \ldots , n . } \end{array}$$
If the input space $X$ has infinite cardinality, then an injective and continuous feature extractor $h _ { \phi }$ results in a $\nu _ { \phi }$ with non-finite support, i.e., at least one $E _ { l }$ , $l = 1 , \ldots , L$ , is infinite. It is not obvious whether we can obtain a $f _ { \theta }$ where every point in $\textstyle E = \bigcup _ { l } E _ { l }$ is a stable equilibrium point. The following result gives a negative answer if $\nu _ { \phi }$ is a continuous measure (i.e., absolutely continuous with respect to (w.r.t.) Lebesgue measure) on some subset.
Lemma 3. If the restriction of $\nu _ { \phi }$ to some open set $E ^ { \prime } \subset E$ is a continuous measure, there is no continuous function fθ such that for $\nu _ { \phi }$ -almost surely all $\mathbf { z } \in E$ , $f _ { \pmb \theta } ( \mathbf z ) = 0$ and all the eigenvalues of $\nabla f _ { \boldsymbol { \theta } } ( \mathbf { z } )$ have negative real parts. In other words, there is no continuous function fθ such that almost surely all $\mathbf { z }$ in $E$ are Lyapunov-stable equilibrium points.
Lemma 3 indicates that it is too much to hope for all points in $E$ to be Lyapunov-stable equilibrium points. In the following, we relax this requirement and show that under mild conditions, for all $\epsilon > 0$ , we can find a continuous function $f _ { \theta }$ with finitely many stable equilibrium points such that conditions (b) and (c) above hold and condition (a) is replaced by $\mathbb { E } _ { \boldsymbol { \nu } _ { \phi } } \bar { \| } f _ { \theta } ( \mathbf { z } ( 0 ) ) \| _ { 2 } ^ { - } < \epsilon$ . This motivates the optimization constraints in (3) to (5).
Theorem 4. Suppose Assumptions $I$ and 2. If $\nu _ { \phi }$ is not a continuous uniform measure on $E _ { l }$ for each $l = 1 , \ldots , L$ , then the following holds: 1) The function space satisfying the constraints in (3) to (5) is non-empty for all $\epsilon > 0$ . 2) If additionally the restriction of $\nu _ { \phi }$ to any open set $O \subset E _ { l }$ is not a continuous uniform measure, there exist functions in this space such that each support $E _ { l }$ contains at least one Lyapunov-stable equilibrium point.
# 4 Experiments
In this section, we evaluate the robustness of SODEF under adversarial attacks with different attack parameters. We conduct experiments to compare the robustness of ODE net [9] and TisODE net [6] on three standard datasets: MNIST [2], CIFAR10 and CIFAR100 [3]. Since SODEF is compatible with many defense methods, it can be applied to any neural network’s final regressor layer to enhance its stability against adversarial attacks. Our experiment codes are provided in https://github.com/KANGQIYU/SODEF.
# 4.1 Setup
We use open-source pre-trained models that achieve the top accuracy on each dataset as the feature extractor $h _ { \phi }$ . Specifically for simple MNIST task, we use the ResNet18 model provided in Pytorch. We use the model provided by [22], which obtains nearly $8 8 \%$ clean accuracy on CIFAR100 using EfficientNet [23] and the model provided by [24], which has nearly $9 5 \%$ clean accuracy on CIFAR10. In the neural ODE layer, $f _ { \theta }$ consists of 2 FC layers. During the trainings of SODEF (except in the experiment included in Section 4.2), we train the neural network with the fixed FC introduced in Section 3.1. In the first 30 epochs, we fixed $f _ { \theta }$ to let the feature extractor $h _ { \phi }$ learn a feature representation with only the cross-entropy loss $\ell$ , and in the remaining 120 epochs, we release $h _ { \phi }$ to further train $f _ { \theta }$ using (7) with $\alpha _ { 1 } = 1$ and $\alpha _ { 2 } = \alpha _ { 3 } = 0 . 0 5$ . For CIFAR10 and CIFAR100, the pixel values are normalized by $( x - \mu ) / \sigma$ where $\mu = [ 0 . 4 9 1 4 , 0 . 4 8 2 2 , 0 . 4 4 6 5 ]$ and $\sigma = [ 0 . 2 0 2 3 , 0 . 1 9 9 4 , 0 . 2 0 1 0 ] ^ { 4 }$ . To show that our SODEF is compatible with many defense methods and can be applied to any neural network’s final regression layer, we conduct an experiment where we use a recently proposed robust network TRADES [25] as the feature extractor in our SODEF. The pretrained model is provided here 5, and we choose the model with architecture "WRN- $3 4 \mathrm { - } 1 0 "$ to conduct our experiments. Besides the two vanilla white-box attacks FGSM and PGD as metioned in Section 3.1, we also include a strong ensemble attack AutoAttack [26], which sequentially performs attack using all of the following four individual attacks: three white-box attacks APGDCE, APGDTDLR and FABT[27], and one black-box Square attack [28]. We refer the reader to the the supplementary material for more details of the attacks used in this paper, where, in additional, more experiments are included.
# 4.2 Compatibility of SODEF
Adversarial training (AT) is one of the most effective strategies for defending adversarial attacks. TRADES [25] is one of the adversarial training defense methods with combinations of tricks of warmup, early stopping, weight decay, batch size and other hyper parameter settings. In this experiment we fix the pretained TRADES model (except the final FC layer (size $6 4 0 \mathrm { x } 1 0 )$ ) as our feature extractor $h _ { \phi }$ . We then append our (trainable) SODEF with integration time $T = 5$ to the output of the feature extractor. To evaluate model robustness, we use AutoAttack and attack the models using both the $\mathcal { L } _ { 2 }$ norm $\epsilon = 0 . 5$ ) and $\mathcal { L } _ { \infty }$ norm $( \epsilon = 8 / 2 5 5 )$ ). The results are shown in Table 3. We clearly observe that our SODEF can enhance TRADES’s robustness under all the four individual attacks and the strongest ensemble AutoAttack. For the strong $\mathcal { L } _ { 2 }$ AutoAttack, our SODEF have improved the model robustness from $5 9 . 4 2 \%$ to $6 7 . 7 5 \%$ . Our experiment show that SODEF can be applied to many defense models’ regression layer to enhance their stability against attacks.
Table 3: Classification accuracy $( \% )$ using TRADES (w/ and w/o SODEF) under AutoAttack on adversarial CIFAR10 examples with $\mathcal { L } _ { 2 }$ norm $\epsilon = 0 . 5 )$ and $\mathcal { L } _ { \infty }$ norm $( \epsilon = 8 / 2 5 5 )$ .
<table><tr><td colspan="4">Attack /ModelTRADES LTRADES+SODEF LTRADES L2TRADES+SODEF L2</td></tr><tr><td>Clean</td><td>85.48</td><td>85.18</td><td>85.48 85.18</td></tr><tr><td>APGDcE</td><td>56.08</td><td>70.90</td><td>61.74 74.35</td></tr><tr><td>APGDDLR</td><td>53.70</td><td>64.15</td><td>59.22 68.55</td></tr><tr><td>FABT</td><td>54.18</td><td>82.92</td><td>60.31 83.15</td></tr><tr><td>Square</td><td>59.12</td><td>62.21</td><td>72.65 76.02</td></tr><tr><td>AutoAttack</td><td>53.69</td><td>57.76</td><td>59.42 67.75</td></tr></table>
# 4.3 Influence of Integration Time $T$
From the discussion after Theorems 1 and 2, we know if the malicious perturbations around the ODE input Lyapunov-stable equilibrium point ${ \bf z } ( 0 )$ is small, then the output ${ \mathbf z } ( T )$ for large enough $T$ will not be affected significantly by the perturbation: $\| \tilde { { \mathbf z } } ( t ) - { \mathbf z } ( 0 ) \| _ { 2 } \dot { \to } 0$ as $t \to \infty$ . Consequently, the succeeding network layers after the neural ODE layer can still perform well without being affected by the input perturbation. In this section, we test the influence of the SODEF integration time $T$ using CIFAR100. We use the model EfficientNet provided by [23] as $h _ { \phi }$ (Note, unlike Section 4.2, $h _ { \phi }$ is trainable in this experiments). We use AutoAttack with $\mathcal { L } _ { 2 }$ norm $\epsilon = 0 . 5$ ). We observe that for all the four individual attacks and the strongest ensemble AutoAttack, SODEF performs generally better for large integration time $T$ . We also test larger integration time $T > 1 0$ , but do not see any obvious improvements.
# 4.4 Performance Comparison Under AutoAttack
For a comparison, we provide the results of applying AutoAttack to other baseline models mentioned in the paper. We set the same integration time for ODE, TisODE and SODEF. We observe that for the
Table 4: Classification accuracy $( \% )$ under AutoAttack on adversarial CIFAR100 examples with $\mathcal { L } _ { 2 }$ norm, $\epsilon = 0 . 5$ and different integration time $T$ for SODEF.
<table><tr><td>Attack/T</td><td>1</td><td>3</td><td>5</td><td>6</td><td>7</td><td>8</td><td>9</td><td>10</td></tr><tr><td>Clean</td><td>88.00</td><td>88.12</td><td>88.15</td><td>88.00</td><td>87.92</td><td>88.00</td><td>88.05</td><td>88.10</td></tr><tr><td>APGDcE</td><td>17.20</td><td>21.33</td><td>21.05</td><td>23.67</td><td>69.67</td><td>85.33</td><td>87.10</td><td>86.88</td></tr><tr><td>APGDLR</td><td>21.02</td><td>21.00</td><td>22.00</td><td>26.00</td><td>63.30</td><td>86.90</td><td>86.20</td><td>86.54</td></tr><tr><td>FABT</td><td>86.33</td><td>85.10</td><td>86.36</td><td>87.70</td><td>87.67</td><td>86.55</td><td>86.22</td><td>85.93</td></tr><tr><td>Square</td><td>84.67</td><td>86.22</td><td>87.05</td><td>87.20</td><td>86.90</td><td>86.33</td><td>87.05</td><td>86.75</td></tr><tr><td>AutoAttack</td><td>2.00</td><td>3.53</td><td>4.87</td><td>4.33</td><td>30.66</td><td>78.80</td><td>78.97</td><td>79.10</td></tr></table>
strongest AutoAttack, our SODEF outperforms the other baseline models by a significant margin. In this case, SODEF achieves $7 9 . 1 0 \%$ accuracy while other models only get less than $3 \%$ accuracy.
Table 5: Classification accuracy $( \% )$ under AutoAttack on adversarial CIFAR100 examples with $\mathcal { L } _ { 2 }$ norm, $\epsilon = 0 . 5$ and $T = 1 0$ .
<table><tr><td>Attack/Model</td><td>NoODE</td><td>ODE</td><td>TisODE</td><td>SODEF</td></tr><tr><td>Clean</td><td>88.00</td><td>87.90</td><td>88.00</td><td>88.10</td></tr><tr><td>APGDCE</td><td>23.30</td><td>6.75</td><td>14.32</td><td>86.88</td></tr><tr><td></td><td>7.33</td><td>22.00</td><td>24.20</td><td>86.54</td></tr><tr><td>FAB</td><td>79.30</td><td>78.67</td><td>77.16</td><td>85.93</td></tr><tr><td>Square</td><td>84.52</td><td>85.67</td><td>86.32</td><td>86.75</td></tr><tr><td>AutoAttack</td><td>0.00</td><td>1.33</td><td>4.06</td><td>79.10</td></tr></table>
# 4.5 Performance Under PGD and FGSM Attacks
White-box adversaries have knowledge of the classifier models, including training data, model architectures and parameters. We test the performance of our model in defending against the whitebox attacks, PGD and FGSM. We set $T = 5$ as the integration time for the neural ODE layer. The parameters for different attack methods used are given in the supplementary material. The subsequent experiments use these settings by default, unless otherwise stated.
Table 6: Classification accuracy $( \% )$ on adversarial MNIST examples.
<table><tr><td>Attack</td><td>Para.</td><td>no ode</td><td>ODE</td><td>TisODE</td><td>SODEF</td></tr><tr><td>None</td><td>-</td><td>99.45</td><td>99.42</td><td>99.43</td><td>99.44</td></tr><tr><td>FGSM</td><td>∈=0.3</td><td>10.03</td><td>29.6</td><td>36.70</td><td>63.36</td></tr><tr><td>PGD</td><td>∈= 0.3</td><td>0.31</td><td>1.56</td><td>1.82</td><td>45.25</td></tr></table>
The classification results on MNIST are shown in Table 6. We observe that while maintaining the state-of-the-art accuracy on normal images, SODEF improves the adversarial robustness as compared to the other two methods. For the most effective attack in this experiment, i.e., PGD attack, SODEF shows a $4 5 . 2 5 \% - 1 . 5 6 \% = 4 3 . 6 9 \%$ improvement over ODE and a $4 5 . 2 5 \% - 1 . 2 3 \% = 4 4 . 0 2 \%$ improvement over TisODE.
Table 7: Classification accuracy $( \% )$ on adversarial CIFAR10 examples.
<table><tr><td>Attack</td><td>Para.</td><td>no ode</td><td>ODE</td><td>TisODE</td><td>SODEF</td></tr><tr><td>None</td><td>-</td><td>95.2</td><td>94.9</td><td>95.1</td><td>95.0</td></tr><tr><td>FGSM</td><td>∈=0.1</td><td>47.31</td><td>45.23</td><td>43.28</td><td>68.05</td></tr><tr><td>PGD</td><td>∈=0.1</td><td>3.09</td><td>3.21</td><td>3.80</td><td>55.59</td></tr></table>
For CIFAR-10, we see from Table 7 that SODEF maintains high accuracy on normal examples and makes the best predictions under adversarial attacks. In particular, SODEF achieves an absolute percentage point improvement over ODE net up to $5 2 . 3 8 \%$ and over TisODE up to $5 2 . 5 4 \%$ for PGD attack.
For CIFAR-100, the results in the supplementary material shows that the most effective attack causes the classification accuracy to drop relatively by $\begin{array} { r } { 7 4 . 6 \% = \frac { 8 8 . 0 - 2 2 . 3 5 } { 8 8 . 0 } } \end{array}$ 88.0−22.35 for SODEF and by $\begin{array} { r } { 9 7 . 3 \% = \frac { 8 8 . 3 - 2 . 3 9 } { 8 8 . 3 } } \end{array}$ for vanilla EfficientNet, which is pre-trained on ImageNet to obtain a top clean accuracy. Neither ODE net nor TisODE net can improve the classification accuracy under PGD attack by a big margin, e.g. TisODE net only improves the classification accuracy from $2 . 3 9 \%$ to $3 . 4 4 \%$ , while SODEF still shows clear defense capability in this scenario.
# 4.6 Ablation Studies
The impact of the ODE with and without the SODEF regularizers in (7) has been presented in the above comparisons between SODEF and ODE. In this section, we show the necessity of diversity promoting using the FC introduced in Section 3.1 and conduct transferability study.
# 4.6.1 Impact of Diversity Promotion
Table 8: Classification accuracy $( \% )$ on adversarial MNIST examples, where the superscript indicates the last FC layer is not fixed to be $\mathbf { V }$ and is set to be a trainable layer.
<table><tr><td>Attack</td><td>Para.</td><td>SODEF</td><td>SODEF-</td></tr><tr><td>None</td><td>-</td><td>95.0</td><td>95.1</td></tr><tr><td>FGSM</td><td>∈=0.1</td><td>63.36</td><td>51.6</td></tr><tr><td>PGD</td><td>∈=0.1</td><td>45.25</td><td>34.9</td></tr></table>
Table 8 shows the difference of the defense performance when fixing the final FC be $\mathbf { V }$ or setting it to a trainable linear layer. It can be seen that having diversity control improves the robustness. One possible reason for this phenomenon given in Section 3 is that diversity promotion with a fixed designed FC attempts to make the embedding feature support $E _ { l }$ of each class $l$ disjoint to each other and therefore the Lyapunov-stable equilibrium points for each $E _ { l }$ are well separated.
# 4.6.2 Transferability Study
Transferability study is carried out on CIFAR-10, where the adversarial examples are generated using FGSM and PGD attacks using ResNet18 without any ODEs. The classification accuracy drops from $6 8 . 0 5 \%$ to $5 9 \%$ for FGSM with $\epsilon = 0 . 3$ , and from $5 5 . 5 9 \%$ to $3 4 \%$ for PGD with $\epsilon = 0 . 1$ . One possible reason for this phenomenon is that ODEs have obfuscated gradient masking effect as discussed in [15], and a transfer attack may deteriorate the defense effect. However, as we observe from Table 7, even with a transfer attack on SODEF, it still performs better than other ODEs without transfer attacks.
# 5 Conclusion
In this paper, we have developed a new neural ODE network, SODEF, to suppress input perturbations. SODEF is compatible with any existing neural networks and can thus be appended to the state-of-theart networks to increase their robustness to adversarial attacks. We demonstrated empirically and theoretically that the robustness of SODEF mainly derives from its stability and proposed a training method that imposes constraints to ensure all eigenvalues of the Jacobian matrix of the neural ODE layer have negative real parts. When each classification class converges to its own equilibrium points, we showed that the last FC layer can be designed in such a way that the distance between the stable equilibrium points is maximized, which further improves the network’s robustness. The effectiveness of SODEF has been verified under several popular while-box attacks.
# Acknowledgments and Disclosure of Funding
This research is supported in part by A\*STAR under its RIE2020 Advanced Manufacturing and Engineering (AME) Industry Alignment Fund – Pre Positioning (IAF-PP) (Grant No. A19D6a0053) and the RIE2020 Industry Alignment Fund – Industry Collaboration Projects (IAF-ICP) Funding Initiative, as well as cash and in-kind contribution from the industry partner(s). The computational work for this article was partially performed on resources of the National Supercomputing Centre, Singapore (https://www.nscc.sg).
# Broader Impact
Our work, which contributes to more robust DNNs, is supposed to mitigate the threat of adversarial attacks. However, on the hand, the reliable deployment of DNNs in automation of tasks will potentially bring mass-scale unemployment and social unrest. As DNNs become more robust and more tasks, especially those whose failures will bring high risks to human lives or large property losses under adversarial attacks, fall into the automatic task category, massive jobs could disappear.
# References
[1] A. Krizhevsky, I. Sutskever, and G. E. Hinton, “ImageNet classification with deep convolutional neural networks,” in Proc. Advances Neural Inf. Process. Syst., 2012. [2] Y. Lecun, L. Bottou, Y. Bengio, and P. Haffner, “Gradient-based learning applied to document recognition,” Proceedings of the IEEE, vol. 86, no. 11, pp. 2278–2324, Nov. 1998. [3] G. Hinton, L. Deng, D. Yu, G. E. Dahl, A. Mohamed, N. Jaitly, A. Senior, V. Vanhoucke, P. Nguyen, T. N. Sainath, and B. Kingsbury, “Deep neural networks for acoustic modeling in speech recognition: The shared views of four research groups,” IEEE Signal Process. Mag., vol. 29, no. 6, pp. 82–97, Nov. 2012. [4] D. Andor, C. Alberti, D. Weiss, A. Severyn, A. Presta, K. Ganchev, S. Petrov, and M. Collins, “Globally normalized transition-based neural networks,” in Proc. Annu. Meeting Assoc, Comput. Linguistics, 2016. [5] C. Szegedy, W. Zaremba, I. Sutskever, J. Bruna, D. Erhan, I. Goodfellow, and R. Fergus, “Intriguing properties of neural networks,” in Proc. Int. Conf. Learning Representations, 2013. [6] H. Yan, J. Du, V. Y. Tan, and J. Feng, “On robustness of neural ordinary differential equations,” in Proc. Advances Neural Inf. Process. Syst., 2018, pp. 1–13. [7] E. Haber and L. Ruthotto, “Stable architectures for deep neural networks,” Inverse Problems, vol. 34, no. 1, pp. 1–23, Dec. 2017. [8] X. Liu, S. Si, Q. Cao, S. Kumar, and C.-J. Hsieh, “How does noise help robustness? Explanation and exploration under the neural sde framework,” in Proc. Conf. Comput. Vision Pattern Recognition, 2020, pp. 282–290. [9] R. T. Chen, Y. Rubanova, J. Bettencourt, and D. Duvenaud, “Neural ordinary differential equations,” arXiv preprint arXiv:1806.07366, 2018. [10] C.-T. Chen and B. Shafai, Linear system theory and design. New York: Oxford university press New York, 1999. [11] Y. LeCun, C. Corte, and C. Burges, “MNIST handwritten digit database,” ATT Labs [Online]. Available: http://yann.lecun.com/exdb/mnist, vol. 2, 2010, (Last accessed: Dec 1, 2020). [12] A. Krizhevsky and G. Hinton, “Learning multiple layers of features from tiny images,” Master’s thesis, Department of Computer Science, University of Toronto, 2009. [13] A. M ˛adry, A. Makelov, L. Schmidt, D. Tsipras, and A. Vladu, “Towards deep learning models resistant to adversarial attacks,” in Proc. Int. Conf. Learning Representations, 2018. [14] E. Haber and L. Ruthotto, “Stable architectures for deep neural networks,” Inverse Problems, vol. 34, no. 1, 2018. [15] Y. Huang, Y. Yu, H. Zhang, Y. Ma, and Y. Yao, “Adversarial robustness of stabilized neuralodes might be from obfuscated gradients,” arXiv preprint arXiv:2009.13145, 2020. [16] L. Mingjie, H. Lingshen, and L. Zhouchen, “Implicit Euler skip connections: Enhancing adversarial robustness via numerical stability,” in Proc. Int. Conf. Machine Learning, 2020. [17] I. J. Goodfellow, J. Shlens, and C. Szegedy, “Explaining and harnessing adversarial examples,” in Proc. Int. Conf. Learning Representations, 2015. [18] D. Arrowsmith and C. M. Place, Dynamical systems: differential equations, maps, and chaotic behaviour. London: CRC Press, 1992. [19] R. A. Horn and C. R. Johnson, Matrix analysis. New York: Cambridge university press, 2012. [20] L. Van der Maaten and G. Hinton, “Visualizing data using t-sne,” J. Mach. Learning Res., vol. 9, no. 11, pp. 2580–2605, Nov. 2008. [21] K. Hornik, “Approximation capabilities of multilayer feedforward networks,” Neural Networks, vol. 4, no. 2, pp. 251–257, Oct. 1991. [22] Y. Luo, Y. Wong, S. M. Kankanhalli, and Q. Zhao, “Direction concentration learning: Enhancing congruency in machine learning,” IEEE Trans. Pattern Anal. Mach. Intell., vol. 43, no. 1, pp. 1928 – 1946, Jun. 2021. [23] M. Tan and Q. Le, “Efficientnet: Rethinking model scaling for convolutional neural networks,” in Proc. Int. Conf. Mach. Learning, 2019, pp. 6105–6114. [24] Github pytorch-cifar repository. Accessed: May 1, 2021. [Online]. Available: https: //github.com/kuangliu/pytorch-cifar [25] T. Pang, X. Yang, Y. Dong, H. Su, and J. Zhu, “Bag of tricks for adversarial training,” in Proc. Int. Conf. Learning Representations, 2021. [26] F. Croce and M. Hein, “Reliable evaluation of adversarial robustness with an ensemble of diverse parameter-free attacks,” in Proc. Int. Conf. Mach. Learning, 2020, pp. 2206–2216. [27] ——, “Minimally distorted adversarial examples with a fast adaptive boundary attack,” in Proc. Int. Conf. Mach. Learning, 2020, pp. 2196–2205. [28] M. Andriushchenko, F. Croce, N. Flammarion, and M. Hein, “Square attack: a query-efficient black-box adversarial attack via random search,” in Proc. European Conf. Comput. Vision. Springer, 2020, pp. 484–501.
# 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? [Yes] (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 Assumption 1 and Assumption 2 (b) Did you include complete proofs of all theoretical results? [Yes] . See supplementary material.
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] . (b) Did you specify all the training details (e.g., data splits, hyperparameters, how they were chosen)? [Yes] . See Sections 3.1 and 4 (c) Did you report error bars (e.g., with respect to the random seed after running experiments multiple times)? [No] Having ODE blocks in our model, it would be too computationally expensive to repeat experiments for many times. We repeated each experiment for 2-3 times and we observe the deviation of the classification results is within $\pm 3 \%$ , though these experimental repetitions are not enough to construct error bars. (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 3.1.
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 Sections 3.1 and 4 for the open-source models we have used from GitHub. (b) Did you mention the license of the assets? [No] . Please see the licenses given in the GitHub link. (c) Did you include any new assets either in the supplemental material or as a URL? [No] No new assets. (d) Did you discuss whether and how consent was obtained from people whose data you’re using/curating? [Yes] MNIST, CIFAR-10 and CIFAR-100 are all open-source datasets. (e) Did you discuss whether the data you are using/curating contains personally identifiable information or offensive content? [No] There is no identifiable information or offensive content in the datasets.
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]123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258# CURRICULARFACE: ADAPTIVE CURRICULUM LEARN-ING LOSS FOR DEEP FACE RECOGNITION
Anonymous authors Paper under double-blind review
# ABSTRACT
As an emerging topic in face recognition, designing margin-based loss functions can increase the feature margin between different classes for enhanced discriminability. More recently, absorbing the idea of mining-based strategies is adopted to emphasize the misclassified samples and achieve promising results. However, during the entire training process, the prior methods either do not explicitly emphasize the sample based on its importance that renders the hard samples not fully exploited; or explicitly emphasize the effects of semi-hard/hard samples even at the early training stage that may lead to convergence issue. In this work, we propose a novel Adaptive Curriculum Learning loss (CurricularFace) that embeds the idea of curriculum learning into the loss function to achieve a novel training strategy for deep face recognition, which mainly addresses easy samples in the early training stage and hard ones in the later stage. Specifically, our CurricularFace adaptively adjusts the relative importance of easy and hard samples during different training stages. In each stage, different samples are assigned with different importance according to their corresponding difficultness. Extensive experimental results on popular benchmarks demonstrate the superiority of our CurricularFace over the state-of-the-art competitors. Code will be available upon publication.
# INTRODUCTION
The success of Convolutional Neural Networks (CNNs) on face recognition can be mainly credited to : enormous training data, network architectures, and loss functions. Recently, designing appropriate loss functions that enhance discriminative power is pivotal for training deep face CNNs.
Current state-of-the-art face recognition methods mainly adopt softmax-based classification loss. Since the learned features with the original softmax is not discriminative enough for the open-set face recognition problem, several margin-based variants have been proposed to enhance features’ discriminative power. For example, explicit margin, i.e., CosFace (Wang et al., 2018a), Sphereface (Li et al., 2017), ArcFace (Deng et al., 2019), and implicit margin, i.e., Adacos (Zhang et al., 2019a), supplement the original softmax function to enforce greater intra-class compactness and inter-class discrepancy, which are shown to result in more discriminate features. However, these margin-based loss functions do not explicitly emphasize each sample according to its importance.
As demonstrated in Chen et al. (2019), hard sample mining is also a critical step to further improve the final accuracy. Recently, Triplet loss (Schroff et al., 2015) and SV-Arc-Softmax (Wang et al., 2018b) integrate the motivations of both margin and mining into one framework for deep face recognition. Triplet loss adopts a semi-hard mining strategy to obtain semi-hard triplets and enlarge the margin between triplet samples. SV-Arc-Softmax (Wang et al., 2018b) clearly defines hard samples as misclassified samples and emphasizes them by increasing the weights of their negative cosine similarities with a preset constant. In a nutshell, mining-based loss functions explicitly emphasize the effects of semi-hard or hard samples.
However, there are drawbacks in training strategies of both margin- and mining-based loss functions. For margin-based methods, mining strategy is ignored and thus the difficultness of each sample is not fully exploited, which may lead to convergence issues when using a large margin on small backbones, e.g., MobileFaceNet (Chen et al., 2018). As shown in Fig. 1, the modulation coefficient for the negative cosine similarities $I ( \cdot )$ is fixed as a constant 1 in ArcFace for all samples during the entire training process. For mining-based methods, over-emphasizing hard samples in early training stage may hinder the model to converge. As SV-Arc-Softmax claimed, the manually defined constant $t$ plays a key role in the model convergence property and a slight larger value (e.g., ${ > } 1 . 4$ ) may cause the model difficult to converge. Thus $t$ needs to be carefully tuned.
 Figure 1: Different training strategies for modulating negative cosine similarities of hard samples (i.e., the mis-classified sample) in ArcFace, SV-Arc-Softmax and our CurricularFace. Left: The modulation coefficients $I ( t , \cos \theta _ { j } )$ for negative cosine similarities of hard samples in different methods, where $t$ is an adaptively estimated parameter and $\theta _ { j }$ denotes the angle between the hard sample and the non-ground truth $j$ -class center. Right: The corresponding hard samples’ negative cosine similarities $N ( t , \cos \theta _ { j } ) = I ( t , \cos \theta _ { j } ) \cos \theta _ { j } + c$ after modulation, where $c$ indicates a constant. On one hand, during early training stage (e.g., $t$ is close to 0), hard sample’s negative cosine similarities is usually reduced and thus leads to smaller hard sample loss than the original one. Therefore, easier samples are relatively emphasized; during later training stage (e.g., $t$ is close to 1), the hard sample’s negative cosine similarities are enhanced and thus leads to larger hard sample loss. On the other hand, in the same training stage, we modulate the hard samples’ negative cosine similarities with $\cos \theta _ { j }$ . Specifically, the smaller the angle $\theta _ { j }$ is, the larger the modulation coefficient should be.
In this work, we propose a novel adaptive curriculum learning loss, termed CurricularFace, to achieve a novel training strategy for deep face recognition. Motivated by the nature of human learning that easy cases are learned first and then come the hard ones (Bengio et al., 2009), our CurricularFace incorporates the idea of Curriculum Learning (CL) into face recognition in an adaptive manner, which differs from the traditional CL in two aspects. First, the curriculum construction is adaptive. In traditional CL, the samples are ordered by the corresponding difficultness, which are often defined by a prior and then fixed to establish the curriculum. In CurricularFace, the samples are randomly selected in each mini-batch, while the curriculum is established adaptively via mining the hard samples online, which shows the diversity in samples with different importance. Second, the importance of hard samples are adaptive. On one hand, the relative importance between easy and hard samples is dynamic and could be adjusted in different training stages. On the other hand, the importance of each hard sample in current mini-batch depends on its own difficultness.
Specifically, the mis-classified samples in mini-batch are chosen as hard samples and weighted by adjusting the modulation coefficients $I ( t , c o s \theta _ { j } )$ of cosine similarities between the sample and the non-ground truth class center vectors, i.e., negative cosine similarity $N ( t , c o s \theta _ { j } )$ . To achieve the goal of adaptive curricular learning in the entire training, we design a novel coefficient function $I ( \cdot )$ that is determined by two factors: 1) the adaptively estimated parameter $t$ that utilizes moving average of positive cosine similarities between samples and the corresponding ground-truth class center to unleash the burden of manually tuning; and 2) the angle $\theta _ { j }$ that defines the difficultness of hard samples to achieve adaptive assignment. To sum up, the contributions of this work are:
• We propose an adaptive curriculum learning loss for face recognition, which automatically emphasizes easy samples first and hard samples later. To the best of our knowledge, it is the first work to introduce the idea of adaptive curriculum learning for face recognition. We design a novel modulation coefficient function $I ( \cdot )$ to achieve adaptive curriculum learning during training, which connects positive and negative cosine similarity simultaneously without the need of manually tuning any additional hyper-parameter. • We conduct extensive experiments on popular facial benchmarks, which demonstrate the superiority of our CurricularFace over the state-of-the-art competitors.
# RELATED WORK
Margin-based loss function Loss design is pivotal for large-scale face recognition. Current stateof-the-art deep face recognition methods mostly adopt softmax-based classification loss. Since the learned features with the original softmax loss are not guaranteed to be discriminative enough for open-set face recognition problem, margin-based losses (Liu et al., 2016; Li et al., 2017; Deng et al., 2019) are proposed. Though the margin-based loss functions are verified to obtain good performance, they do not take the difficultness of each sample into consideration, while our CurricularFace emphasizes easy samples first and hard samples later, which is more reasonable and effectiveness.
Mining-based loss function Though some mining-based loss function such as Focal loss (Lin et al., 2017), Online Hard Sample Mining (OHEM) (Shrivastava et al., 2016) are prevalent in the field of object detection, they are rarely used in face recognition. OHEM focuses on the large-loss samples in one mini-batch, in which the percentage of the hard samples is empirically determined and easy samples are completely discarded. Focal loss is a soft mining variant that rectifies the loss function to an elaborately designed form, where two hyper-parameters should be tuned with a lot of efforts to decide the weights of each samples and hard samples are emphasized by reducing the weight of easy samples. The recent work, SV-Arc-Softmax (Wang et al., 2018b) fuses the motivations of both margin and mining into one framework for deep face recognition. They define hard samples as misclassified samples and enlarge the weight of hard samples with a preset constant. Our method differs from SV-Arc-Softmax in three aspects: 1) We do not always emphasize the hard samples, especially in the early training stages. 2) We assign different weights for hard samples according to their corresponding difficultness. 3) There’s no need in our method to manually tune the additional hyper-parameter $t$ , which is estimated adaptively.
Curriculum Learning Learning from easier samples first and harder samples later is a common strategy in Curriculum Learning (CL) (Bengio et al., 2009), (Zhou & Bilmes, 2018). The key problem in CL is to define the difficultness of each sample. For example, Basu & Christensen (2013) takes the negative distance to the boundary as the indicator for easiness in classification. However, the ad-hoc curriculum design in CL turns out to be difficult to implement in different problems. To alleviate this issue, Kumar et al. (2010) designs a new formulation, called Self-Paced Learning (SPL), where examples with lower losses are considered to be easier and emphasized during training. The key differences between our CurricularFace with SPL are: 1) Our method focuses on easier samples in the early training stage and emphasizes hard samples in the later training stage. 2) Our method proposes a novel modulation function $N ( \cdot )$ for negative cosine similarities, which achieves not only adaptive assignment on modulation coefficients $I ( \cdot )$ for different samples in the same training stage, but also adaptive curriculum learning strategy in different training stages.
# THE PROPOSED CURRICULARFACE
PRELIMINARY KNOWLEDGE ON LOSS FUNCTION
The original softmax loss is formulated as follows:
$$\mathcal { L } = - \log \frac { e ^ { W _ { y _ { i } } x _ { i } + b _ { y _ { i } } } } { \sum _ { j = 1 } ^ { n } e ^ { W _ { j } x _ { i } + b _ { j } } } ,$$
where $x _ { i } \in R ^ { d }$ denotes the deep feature of $i$ -th sample which belongs to the $y _ { i }$ class, $W _ { j } \in R ^ { d }$ denotes the $j$ -th column of the weight $W \in R ^ { d \times n }$ and $b _ { j }$ is the bias term. The class number and the embedding feature size are $n$ and $d$ , respectively. In practice, the bias is usually set to $b _ { j } = 0$ and the individual weight is set to $| | W _ { j } | | = 1$ by $l _ { 2 }$ normalization. The deep feature is also normalized and re-scaled to $s$ . Thus, the original softmax can be modified as follows:
$$\mathcal { L } = - \log \frac { e ^ { s ( \cos \theta _ { y _ { i } } ) } } { e ^ { s ( \cos \theta _ { y _ { i } } ) } + \sum _ { j = 1 , j \neq y _ { i } } ^ { n } e ^ { s ( \cos \theta _ { j } ) } } .$$
Since the learned features with original softmax loss may not be discriminative enough for open-set face recognition problem, several variants are proposed and can be formulated in a general form:
$$\mathcal { L } = - G ( \boldsymbol { p } ( \boldsymbol { x } _ { i } ) ) \log \frac { e ^ { s T ( \cos \theta _ { y _ { i } } ) } } { e ^ { s T ( \cos \theta _ { y _ { i } } ) + \sum _ { j = 1 , j \neq y _ { i } } ^ { n } e ^ { s N ( t , \cos \theta _ { j } ) } } , }$$
where $\begin{array} { r l r } { p ( x _ { i } ) } & { = } & { \frac { e ^ { s T ( \cos \theta _ { y _ { i } } ) } } { e ^ { s T ( \cos \theta _ { y _ { i } } ) + \sum _ { j = 1 , j \neq y _ { i } } ^ { n } e ^ { s N ( t , \cos \theta _ { j } ) } } } } \end{array}$ esN(t,cos θj) is the predicted ground truth probability and $G ( \boldsymbol { p } ( \boldsymbol { x } _ { i } ) )$ is an indicator function. $T ( \cos \theta _ { y _ { i } } )$ and $N ( t , \cos \theta _ { j } ) = I ( t , \cos \theta _ { j } ) \cos \theta _ { j } + c$ are the functions to modulate the positive and negative cosine similarities, respectively, where $c$ is a constant, and $I ( t , \cos \theta _ { j } )$ denotes the modulation coefficients of negative cosine similarities. In margin-based loss function, e.g, ArcFace, $G ( p ( x _ { i } ) ) = 1$ , $T ( \cos \theta _ { y _ { i } } ) = \cos ( \theta _ { y _ { i } } + m )$ , and $N ( t , \cos \theta _ { j } ) = \cos \theta _ { j }$ . It only modifies the positive cosine similarity of each sample to enhance the feature discrimination. As shown in Fig. 1, the modulation coefficients of each sample’ negative cosine similarity $I ( \cdot )$ is fixed as 1. The recent work, SV-Arc-Softmax emphasizes hard samples by increasing $I ( t , \cos \theta _ { j } )$ for hard samples. That is, $G ( p ( x _ { i } ) ) = 1$ and $N ( t , \mathrm { c o s } _ { \theta _ { j } } )$ is formulated as follows:
$$N ( t , c o s _ { \theta _ { j } } ) = \left\{ \begin{array} { l l } { \cos \theta _ { j } , } & { T ( \cos \theta _ { y _ { i } } ) - \cos \theta _ { j } \geq 0 } \\ { t \cos \theta _ { j } + t - 1 , } & { T ( \cos \theta _ { y _ { i } } ) - \cos \theta _ { j } < 0 . } \end{array} \right.$$
If a sample is defined to be easy, its negative cosine similarity is kept the same as the original one, $\cos \theta _ { j }$ ; if as a hard sample, its negative cosine similarity becomes $t \cos \theta _ { j } + t - 1$ . That is, as shown in Fig. 1, $I ( \cdot )$ is a constant and determined by a preset hyper-parameter $t$ . Meanwhile, since $t$ is always larger than 1, $t \cos \theta _ { j } + t - 1 > \cos \theta _ { j }$ always holds true, which means the model always focuses on hard samples, even in the early training stage. However, the parameter $t$ is sensitive that a large pre-defined value $( e . g . , > 1 . 4 ,$ ) may lead to convergence issue.
# ADAPTIVE CURRICULAR LEARNING LOSS
Next, we present the details of our proposed adaptive curriculum learning loss, which is the first attempt to introduce adaptive curriculum learning into deep face recognition. The formulation of our loss function is also contained in the general form, where $G ( p ( x _ { i } ) ) = 1$ , positive and negative cosine similarity functions are defined as follows:
$$T ( \cos \theta _ { y _ { i } } ) = \cos ( \theta _ { y _ { i } } + m ) ,$$
$$N ( t , \cos _ { \theta _ { j } } ) = \left\{ { \begin{array} { l l } { \cos \theta _ { j } , } & { T ( \cos \theta _ { y _ { i } } ) - \cos \theta _ { j } \geq 0 } \\ { \cos \theta _ { j } ( t + \cos \theta _ { j } ) , } & { T ( \cos \theta _ { y _ { i } } ) - \cos \theta _ { j } < 0 . } \end{array} } \right.$$
It should be noted that the positive cosine similarity can adopt any margin-based loss functions and here we adopt ArcFace as the example. As shown in Fig. 1, the modulation coefficient of hard sample negative cosine similarity $I ( t , \bar { \theta _ { j } } )$ depends on both the value of $t$ and $\theta _ { j }$ . In the early training stage, learning from easy samples is beneficial to model convergence. Thus, $t$ should be close to zero and $I ( \cdot )$ is smaller than 1. Therefore, the weights of hard samples are reduced and the easy samples are emphasized relatively. As training goes on, the model gradually focuses on the hard samples, i.e., the value of $t$ shall increase and $I ( \cdot )$ is larger than 1. Then, the weights of hard samples are enlarged, which are thus emphasized. Moreover, within the same training stage, $I ( \cdot )$ is monotonically decreasing with $\theta _ { j }$ so that harder sample can be assigned with larger coefficient according to its difficultness. The value of the parameter $t$ is automatically estimated in our CurricularFace, otherwise it would require a lot of efforts for manually tuning.
Adaptive estimation of $t$ It is critical to determine appropriate values of $t$ in different training stages. Ideally the value of $t$ can indicate the model training process. We empirically find the average of positive cosine similarities is a good indicator. However, mini-batch statistic-based methods usually face an issue: when many extreme data are sampled in one mini-batch, the statistics can be vastly noisy and the estimation will be unstable. Exponential Moving Average (EMA) is a common solution to address this issue (Li et al., 2019). Specifically, let $r ^ { ( k ) }$ be the average of the positive cosine similarities of the $k$ -th batch and be formulated as $\begin{array} { r } { r ^ { ( k ) } = \sum _ { i } \cos \theta _ { y _ { i } } } \end{array}$ , we have:
$$t ^ { ( k ) } = \alpha r ^ { ( k ) } + ( 1 - \alpha ) t ^ { ( k - 1 ) } ,$$
where $t ^ { 0 } = 0$ , $\alpha$ is the momentum parameter and set to 0.99. As shown in Fig. 2, the parameter $t$ increases with the model training, thus the gradient modulation coefficients’ range of hard sample, $M ( \cdot ) = 2 \cos \theta _ { j } + t$ , also increases. Therefore, hard samples are emphasized gradually. With the EMA, we avoid the hyper-parameter tuning and make the modulation coefficients of hard sample
# Algorithm 1: CurricularFace
Input: The deep feature of $_ { i }$ -th sample $x _ { i }$ with its corresponding label $y _ { i }$ , last fully-connected layer parameters $W$ , cosine similarity $\cos \theta _ { j }$ between two vectors, embedding network parameters $\Theta$ , learning rate $\lambda$ , number of iteration $k$ , parameter $t$ , and margin $m$ $k 0$ , $t \gets 0$ , $m \gets 0 . 5$ ; while not converged do $k \gets k + 1$ ; if $\cos ( \theta _ { y _ { i } } + m ) > \cos \theta _ { j }$ then $N ( t , \cos \theta _ { j } ) = \cos \theta _ { j }$ ; else $\begin{array} { r l } { \small \int _ { - \infty } ( t , \cos \theta _ { j } ) = ( t ^ { ( k ) } + \cos \theta _ { j } ) \cos \theta _ { j } \ ; } \end{array}$ end $T ( \cos \theta _ { y _ { i } } ) = \cos ( \theta _ { y _ { i } } + m )$ ; Compute the loss $\mathcal { L }$ by Eq. 8; Compute the back-propagation error of $x _ { i }$ and $W _ { j }$ by Eq. 9; Update the parameters $W$ and $\Theta$ by: $\begin{array} { r } { \boldsymbol { W } ^ { ( k + 1 ) } = \boldsymbol { W } ^ { ( k ) } - \lambda ^ { ( k ) } \frac { \partial \boldsymbol { L } } { \partial \boldsymbol { W } } , \Theta ^ { ( k + 1 ) } = \Theta ^ { ( k ) } - \lambda ^ { ( k ) } \frac { \partial \boldsymbol { L } } { \partial x _ { i } } \frac { \partial x _ { i } } { \partial \Theta ^ { ( k ) } } ; } \end{array}$ Update the parameter $t$ by Eq. 7;
negative cosine similarities $I ( \cdot )$ adaptive to the current training stage. To sum up, the loss function of our CurricularFace is formulated as follows:
$$\mathcal { L } = - \log \frac { e ^ { s \cos ( \theta _ { y _ { i } } + m ) } } { e ^ { s \cos ( \theta _ { y _ { i } } + m ) } + \sum _ { j = 1 , j \neq y _ { i } } ^ { n } e ^ { s N ( t ^ { ( k ) } , \cos \theta _ { j } ) } } ,$$
where $N ( t ^ { ( k ) } , \cos \theta _ { j } )$ is defined in Eq. 6. The entire training process is summarized in Algorithm 1.
Fig. 3 illustrates how the loss changes from ArcFace to our CurricularFace during training. Here are some observations: 1) As we excepted, hard samples are suppressed in early training stage but emphasized later. 2) The ratio is monotonically increasing with $c o s \theta _ { j }$ , since the larger $c o s \theta _ { j }$ is, the harder the sample is. 3) The positive cosine similarity of a perceptualwell image is often large. However, during the early training stage, the negative cosine similarities of the perceptual-well image may also be large so that it could be classified as the hard one.
Optimization Next, we show our CurricularFace can be easily optimized by the conventional stochastic gradient descent. Assuming $x _ { i }$ denotes the deep feature of $i$ -th sample which belongs to the $y _ { i }$ class, the input of the proposed function is the logit $f _ { j }$ , where $j$ denotes the $j$ -th class.
 Figure 2: Illustrations on the adaptive parameter $t$ (red line) and gradient modulation coefficients $M ( \cdot ) = 2 \cos \theta _ { j } + t$ of hard samples (green area). Since the number of mined hard samples reduces with the model training, the green area $M ( \cdot )$ is relatively smooth in early stage and there are some burrs in later stage.
In the forwarding process, when $j ~ = ~ y _ { i }$ , it is the same as the ArcFace, i.e., $f _ { j } = s T ( \cos \theta _ { y _ { i } } )$ $T ( \cos \theta _ { y _ { i } } ) = \cos ( \theta _ { y _ { i } } + m )$ . When $j \neq y _ { i }$ , it has two cases, if $x _ { i }$ is an easy sample, it is the the same as the original softmax, i.e., $f _ { j } = s \cos \theta _ { j }$ . Otherwise, it will be modulated as $f _ { j } = s N ( t , \cos \theta _ { j } )$ , where $N ( t , \cos \theta _ { j } ) = ( t + \cos \theta _ { j } ) \cos \theta _ { j }$ . In the backward propagation process, the gradient of $x _ { i }$ and $W _ { j }$ can also be divided into three cases and formulated as follows:
$$\frac { \partial L } { \partial x _ { i } } = \left\{ \begin{array} { l l } { \frac { \partial L } { \partial f _ { y _ { i } } } ( s \frac { \sin ( \theta _ { y _ { i } } + m ) } { \sin \theta _ { y _ { i } } } ) W _ { y _ { i } } , } & { j = y _ { i } } \\ { \frac { \partial L } { \partial f _ { j } } s W _ { j } , } & { j \neq y _ { i } , \mathrm { e a s y } , \frac { \partial L } { \partial W _ { j } } = \left\{ \begin{array} { l l } { \frac { \partial L } { \partial f _ { y _ { i } } } ( s \frac { \sin ( \theta _ { y _ { i } } + m ) } { \sin \theta _ { y _ { i } } } ) x _ { i } , } & { j = y _ { i } } \\ { \frac { \partial L } { \partial f _ { j } } s x _ { i } , } & { j \neq y _ { i } , \mathrm { e a s y } } \\ { \frac { \partial L } { \partial f _ { j } } s ( 2 \cos \theta _ { j } + t ) W _ { j } } & { j \neq y _ { i } , \mathrm { h a r d } } \end{array} \right. , } \end{array} \right.$$
Based on the above formulations, we can find the gradient magnitude of the hard sample is determined by two parts, the negative cosine similarity $N ( \cdot )$ and the value of $t$ .
 Figure 3: Illustrations on (ratio between our loss and ArcFace, maximum $c o s \theta _ { j }$ ) from early (Top) to later (Bottom) training stages.
Table 1: Decision boundaries of popular loss functions.
<table><tr><td rowspan=1 colspan=1>Loss</td><td rowspan=1 colspan=1>Decision Boundary</td></tr><tr><td rowspan=1 colspan=1>Softmax</td><td rowspan=1 colspan=1>cosOy=cos0j</td></tr><tr><td rowspan=1 colspan=1>SphereFace</td><td rowspan=1 colspan=1>cos(m0y)=cos0j</td></tr><tr><td rowspan=1 colspan=1>CosFace</td><td rowspan=1 colspan=1>cosθy-m=cos0j</td></tr><tr><td rowspan=1 colspan=1>ArcFace</td><td rowspan=1 colspan=1>cos(0y;+m)=cos0j</td></tr><tr><td rowspan=1 colspan=1>SV-Arc-Softmax</td><td rowspan=1 colspan=1>cos(0y+m)=cos0j(easy)cos(0y;+m)=tcos0j+t-i(hard)</td></tr><tr><td rowspan=1 colspan=1>CurricularFace (Ours)</td><td rowspan=1 colspan=1>cos(0yi+m)=cos0j (easy)cos(0y:+m)=(t+cos0j) cos0j(hard)</td></tr></table>
Table 2: Verification performance of different values of $t$
<table><tr><td>Dataset (%)</td><td>t=0</td><td>t=0.3</td><td>t=0.7</td><td>t=1</td><td>Adaptive t</td></tr><tr><td>LFW</td><td>99.32</td><td>99.37</td><td>99.42</td><td>99.45</td><td>99.47</td></tr><tr><td>CFP-FP</td><td>95.90</td><td>96.47</td><td>96.66</td><td>93.94</td><td>96.96</td></tr></table>
# DISCUSSIONS WITH SOTA LOSS FUNCTIONS
Comparison with ArcFace and SV-Arc-Softmax We first discuss the difference between our CurricularFace and the two competitors, ArcFace and SV-Arc-Softmax, from the perspective of the decision boundary in Tab. 1. ArcFace introduces a margin function $T ( \cos \theta _ { y _ { i } } ) \dot { ~ = ~ } \dot { \cos ( \theta _ { y _ { i } } + m ) }$ from the perspective of positive cosine similarity. As shown in Fig. 4, its decision condition changes from $\cos \theta _ { y _ { i } } = \cos \theta _ { j }$ (i.e., blue line) to $\cos ( \dot { \theta } _ { y _ { i } } + m ) = \cos \bar { \theta } _ { j }$ (i.e., red line) for each sample. SV-Arc-Softmax introduces additional margin from the perspective of negative cosine similarity for hard samples, and the decision boundary becomes $\cos ( \theta _ { y _ { i } } + m ) = t \cos \theta _ { j } + t - 1$ (i.e., green line). Conversely, we adaptively adjust the weights of hard samples in different training stages. The decision condition becomes $\cos ( \theta _ { y _ { i } } + m ) = ( t + \cos \theta _ { j } ) \cos \theta _ { j }$ (i.e., purple line). During the training stage, the decision boundary for hard samples changes from one purple line (early stage) to another (later stage), which emphasizes easy samples first and hard samples later.
Comparison with Focal loss Focal loss is a soft mining-based loss, which is formulated as: $G ( \bar { p ( x ) } ) = \alpha ( 1 - p ( x _ { i } ) ) ^ { \beta }$ , where $\alpha$ and $\beta$ are modulating factors that need to be tuned manually. The definition of hard samples in Focal loss is ambiguous, since it always focuses on relatively hard samples by reducing the weight of easier samples during the entire training process. In contrast, the definition of hard samples in our CurricularFace is more clear, i.e., mis-classified samples. Meanwhile, the weights of hard samples are adaptively determined in different training stages.
# EXPERIMENTS
# IMPLEMENTATION DETAILS
Datasets We separately employ CASIA-WebFace (Yi et al., 2014) and refined MS1MV2 (Deng et al., 2019) as our training data for fair comparisons with other methods. We extensively test our method on several popular benchmarks, including LFW (Huang et al., 2007), CFP-FP (Sengupta et al., 2016), CPLFW (Zheng et al., 2018), AgeDB (Moschoglou et al., 2017), CALFW (Zheng et al., 2017), IJB-B (Whitelam et al., 2017), IJB-C (Maze et al., 2018), and MegaFace (KemelmacherShlizerman et al., 2016).
Training Setting We follow Deng et al. (2019) to generate the normalised faces $( 1 1 2 \times 1 1 2 )$ with five landmarks (Zhang et al., 2016). For the embedding network, we adopt ResNet50 and ResNet100 as in Deng et al. (2019). Our framework is implemented in Pytorch (Paszke et al., 2017). We train models on 4 NVIDIA Tesla P40 (24GB) GPU with batch size 512. The models are trained with SGD algorithm, with momentum 0.9 and weight decay $5 e - 4$ . On CASIA-WebFace, the learning rate starts from 0.1 and is divided by 10 at 28, 38, 46 epochs. The training process is finished at 50 epochs. On MS1MV2, we divide the learning rate at 10, 18, 22 epochs and finish at 24 epochs. We follow the common setting as Deng et al. (2019) to set scale $s = 6 4$ and margin $m = 0 . 5$ , respectively. Last but not least, since we only modify the loss function but use the same backbone as previous methods (e.g., ArcFace), NO additional time complexity is introduced for inference.
 Figure 4: From left to right, decision boundaries of ArcFace, SV-Arc-Softmax, and ours. Blue line, red line, green line and purple line denote the decision boundary of Softmax, ArcFace, SV-Arc-Softmax, and ours, respectively. $m$ denotes the angular margin added by ArcFace. $d$ denotes the additional margin of SVArc-Softmax and ours. In SV-Arc-Softmax, $d = ( t - 1 ) \cos \theta _ { j } +$ $t - 1$ . In ours, $d = ( t + \cos \theta _ { j } - 1 ) \cos \theta _ { j }$ .
Table 3: Verification performance of different strategies for setting t.
 Figure 5: Illustration on convergence issue with small backbone.
# ABLATION STUDY
Effects on Fixed vs. Adaptive Parameter $t$ We first investigate the effect of adaptive estimation of $t$ . We choose four fixed values between 0 and 1 for comparison. Specifically, 0 means the modulation coefficient $I ( \cdot )$ of each hard sample’s negative cosine similarity is always reduced based on its difficultness. In contrast, 1 means the hard samples are always emphasized. 0.3 and 0.7 are between the two cases. Tab. 2 shows that it is more effective to learn from easier samples first and hard samples later based on our adaptively estimated parameter $t$ .
Effects on Different Statistics for Estimating $t$ We now investigate the effects of several other statistics, i.e., mode of positive cosine similarities in a mini-batch, or mean of the predicted ground truth probability for estimating $t$ in our loss. As Tab. 3 shows, on one hand, the mean of positive cosine similarities is better than the mode. On the other hand, the positive cosine similarity is more accurate than the predicted ground truth probability to indicate the training stages.
Robustness on Training Convergence As claimed in Li (2019), ArcFace exists divergence issue when using small backbones like MobileFaceNet. As the result, softmax loss must be incorporated for pre-training. To illustrate the robustness of our loss function on convergence issue with small backbone, we use the MobileFaceNet as the network architecture and train it on CASIA-WebFace. As shown in Fig. 5, when the margin $m$ is set to 0.5, the model trained with our loss achieves 99.25 accuracy on LFW, while the model trained with ArcFace does not converge and the loss is NAN at about 2, 400-th step. When the margin $m$ is set to 0.45, both losses can converge, but our loss achieves better performance $( 9 9 . 2 0 \%$ vs. $9 9 . 1 0 \%$ ). Comparing the yellow and red curves, since the losses of hard samples are reduced in early training stages, our loss converges much faster in the beginning, leading to lower loss than ArcFace. Later on, the value of our loss is slightly larger than ArcFace, because we emphasize the hard samples in later stages. The results prove that learning from easy samples first and hard samples later is beneficial to model convergence.
# COMPARISONS WITH SOTA METHODS
Results on LFW, CFP-FP, CPLFW, AgeDB and CALFW Next, we train our CurricularFace on dataset MS1MV2 with ResNet100, and compare with the SOTA competitors on various benchmarks, including LFW for unconstrained face verification, CFP-FP and CPLFW for large pose variations, AgeDB and CALFW for age variations. As reported in Tab. 4, our CurricularFace achieves comparable result (i.e., $9 9 . 8 0 \%$ ) with the competitors on LFW where the performance is near saturated. While for both CFP-FP and CPLFW, our method shows superiority over the baselines including general methods, e.g., (Wen et al., 2016), (Cao et al., 2018b), and cross-pose methods, e.g., (Tran et al., 2017), (Peng et al., 2017), (Cao et al., 2018a) and (Deng et al., 2018). As a recent face recognition method, SV-Arc-Softmax achieves better performance than ArcFace, but still worse than Our CurricularFace. Finally, for AgeDB and CALFW, as Tab. 4 shows, our CurricularFace again achieves the best performance than all of the other state-of-the-art methods.
Table 4: Verification comparison with SOTA methods on various small-scale benchmarks.
<table><tr><td>Methods (%)</td><td>LFW</td><td>CFP-FP</td><td>CPLFW</td><td>AgeDB</td><td>CALFW</td></tr><tr><td>Center Loss (ECCV'16)</td><td>98.75</td><td>1</td><td>77.48</td><td>1</td><td>85.48</td></tr><tr><td>SphereFace (CVPR'17)</td><td>99.27</td><td>一</td><td>81.40</td><td></td><td>90.30</td></tr><tr><td>DRGAN (CVPR'17)</td><td>1</td><td>93.41</td><td>1</td><td></td><td>1</td></tr><tr><td>Peng et al. (ICCV'17)</td><td>一</td><td>93.76</td><td>一</td><td></td><td>一</td></tr><tr><td>VGGFace2 (FG'18)</td><td>99.43</td><td>一</td><td>84.00</td><td></td><td>90.57</td></tr><tr><td>Dream (CVPR'18)</td><td>1</td><td>93.98</td><td>一</td><td></td><td>一</td></tr><tr><td>Deng et al.(CVPR'18)</td><td>99.60</td><td>94.05</td><td></td><td></td><td></td></tr><tr><td>ArcFace (CVPR'19)</td><td>99.77</td><td>98.27</td><td>92.08</td><td>98.15</td><td>95.45</td></tr><tr><td>SV-Arc-Softmax</td><td>99.78</td><td>98.28</td><td>92.83</td><td>97.95</td><td>96.10</td></tr><tr><td>CurricularFace (Ours)</td><td>99.80</td><td>98.37</td><td>93.13</td><td>98.32</td><td>96.20</td></tr></table>
Table 5: 1:1 verification TAR ( ${ \bf @ F A R = }$ 1e − 4) on IJB-B and IJB-C.
<table><tr><td>Methods (%)</td><td>IJB-B</td><td>IJB-C</td></tr><tr><td>SENet50 (FG'18)</td><td>80.0</td><td>84.1</td></tr><tr><td>Multicolumn (BMVC'18)</td><td>83.1</td><td>86.2</td></tr><tr><td>DCN (ECCV'18)</td><td>84.9</td><td>88.5</td></tr><tr><td>ArcFace-R100 (CVPR'19)</td><td>94.2</td><td>95.6</td></tr><tr><td>Adacos (CVPR'19)</td><td>1</td><td>92.4</td></tr><tr><td>P2SGrad (CVPR'19)</td><td>1</td><td>92.3</td></tr><tr><td>PFE (ICCV'19)</td><td>一</td><td>93.3</td></tr><tr><td>SV-Arc-Softmax</td><td>93.6</td><td>95.2</td></tr><tr><td>CurricularFace (Ours)</td><td>94.8</td><td>96.1</td></tr></table>
Table 6: Verification comparison with SOTA methods on MegaFace Challenge 1 using FaceScrub as the probe set. Left table: ‘Id’ refers to the rank-1 face identification accuracy with 1M distractors, and ‘Ver’ refers to the face verification TAR at $1 0 ^ { - 6 }$ FAR. ‘R’ refers to data refinement on both probe set and 1M distractors. Right figure: Rank-1 identification results of recent SOTA methods on probe set refined from ArcFace.
<table><tr><td>CASIA(%)</td><td>Id</td><td>Ver</td><td>MS1MV2(%)</td><td>Id</td><td>Ver</td><td>CosFace(CVPR’18)- 97.91</td><td></td></tr><tr><td>Contrastive Loss (CVPR'14)</td><td>65.21</td><td>78.86</td><td>CosFace-MS1MV2-R100</td><td>80.56</td><td>96.56</td><td></td><td></td></tr><tr><td>Triplet (CVPR'15)</td><td>64.79</td><td>78.32</td><td>CosFace-MS1MV2-R100, R</td><td>97.91</td><td>97.91</td><td></td><td>Adacos (CVPR'19)-97.41</td></tr><tr><td>Center Loss (ECCV'16)</td><td>65.49</td><td>80.14</td><td>ArcFace-MS1MV2-R100</td><td>81.03</td><td>96.98</td><td></td><td></td></tr><tr><td>SphereFace(CVPR'17)</td><td>72.73</td><td>85.56</td><td>ArcFace-MS1MV2-R100, R</td><td>98.35</td><td>98.48</td><td></td><td>P2SGrad (CVPR’19)-97.25</td></tr><tr><td>CosFace (CVRP'18)</td><td>77.11</td><td>89.88</td><td>PFE (ICCV'19)</td><td>78.95</td><td>92.51</td><td></td><td>AreFace (CVPR'19)-98.35</td></tr><tr><td>AM-Softmax (SPL'18)</td><td>72.47</td><td>84.44</td><td>Adacos,R(CVPR'19')</td><td>97.41</td><td></td><td></td><td></td></tr><tr><td>ArcFace-CASIA-R50 (CVPR'19)</td><td>77.50</td><td>92.34</td><td>P2SGrad,R(CVPR'19')</td><td>97.25</td><td></td><td></td><td>SV-Arc-Softmax (arXiv'19)- 97.14</td></tr><tr><td>ArcFace-CASIA-R50, R</td><td>91.75</td><td>93.69</td><td>SV-Arc-Softmax,R</td><td>97.14</td><td>97.57</td><td></td><td></td></tr><tr><td>Ours-CASIA-R50</td><td>77.65</td><td>92.91</td><td>Ours-MS1MV2-R100</td><td>81.26</td><td>97.26</td><td></td><td>CurricularFace (Ours)-98.71</td></tr><tr><td>Ours-CASIA-R50, R</td><td>92.48</td><td>94.55</td><td>Ours-MS1MV2-R100, R</td><td>98.71</td><td>98.64</td><td>97</td><td></td></tr></table>
Results on IJB-B and IJB-C The IJB-B dataset contains 1, 845 subjects with 21.8K still images and 55K frames from 7, 011 videos. In the 1:1 verification, there are 10, 270 positive matches and 8M negative matches. The IJB-C dataset is a further extension of IJB-B, which contains about 3, 500 identities with a total of 31, 334 images and 117, 542 unconstrained video frames. In the 1:1 verification, there are 19, 557 positive matches and 15, 638, 932 negative matches. On IJB-B and IJB-C datasets, we employ MS1MV2 and the ResNet100 for a fair comparison with recent methods. We follow the testing protocol in ArcFace and take the average of the image features as the corresponding template representation without bells and whistles. Tab. 5 exhibits the performance of different methods, e.g., Multicolumn (Xie & Zisserman, 2018), DCN (Xie et al., 2018), Adacos (Zhang et al., 2019a), P2SGrad (Zhang et al., 2019b), PFE (Shi et al., 2019) and SV-Arc-Softmax (Wang et al., 2018b) on IJB-B and IJB-C 1:1 verification, our method again achieves the best performance.
Results on MegaFace Finally, we evaluate the performance on the MegaFace Challenge. The gallery set of MegaFace includes 1M images of 690K subjects, and the probe set includes 100K photos of 530 unique individuals from FaceScrub. We report the two testing results under two protocols (large or small training set). Here, we use CASIA-WebFace and MS1MV2 under the small protocol and large protocol, respectively. In Tab. 6, our method achieves the best singlemodel identification and verification performance under both protocols, surpassing the recent strong competitors, e.g., CosFace, ArcFace, Adacos, P2SGrad and PFE. We also report the results following the ArcFace testing protocol, which refines both the probe set and the gallery set. As shown from the figure in Tab. 6, our method still clearly outperforms the competitors and achieves the best performance on both verification and identification.
# CONCLUSIONS
In this paper, we propose a novel Adaptive Curriculum Learning Loss that embeds the idea of adaptive curriculum learning into deep face recognition. Our key idea is to address easy samples in the early training stage and hard ones in the later stage. Our method is easy to implement and robust to converge. Extensive experiments on popular facial benchmarks demonstrate the effectiveness of our method compared to the state-of-the-art competitors. Following the main idea of this work, future research can be expanded in various aspects, including designing a better function $N ( \cdot )$ for negative cosine similarity that shares similar adaptive characteristic during training, and investigating the effects of noise samples that could be optimized as hard samples.
# REFERENCES
Sumit Basu and Janara Christensen. Teaching classification boundaries to humans. In AAAI, 2013.
Yoshua Bengio, Jer´ ome Louradour, Ronan Collobert, and Jason Weston. Curriculum learning. In ˆ ICML, 2009.
Kaidi Cao, Yu Rong, Cheng Li, Xiaoou Tang, and Chen Change Loy. Pose-robust face recognition via deep residual equivariant mapping. In CVPR, 2018a.
Qiong Cao, Li Shen, Weidi Xie, Omkar M. Parkhi, and Andrew Zisserman. Vggface2: A dataset for recognising faces across pose and age. In FG, 2018b.
Beidi Chen, Weiyang Liu, Animesh Garg, Zhiding Yu, Anshumali Shrivastava, and Anima Anandkumar. Angular visual hardness. In ICML Workshop on Deep Phenomena, 2019.
Sheng Chen, Yang Liu, Xiang Gao, and Zhen Han. Mobilefacenets: Efficient cnns for accurate real-time face verification on mobile devices. In CCBR, 2018.
Jiankang Deng, Shiyang Cheng, Niannan Xue, Yuxiang Zhou, and Stefanos Zafeiriou. Uv-gan: Adversarial facial uv map completion for pose-invariant face recognition. In CVPR, 2018.
Jiankang Deng, Jia Guo, and Stefanos Zafeiriou. ArcFace: Additive angular margin loss for deep face recognition. In CVPR, 2019.
Gary B. Huang, Manu Ramesh, Tamara Berg, and Erik Learned-Miller. Labeled faces in the wild: A database for studying face recognition in unconstrained environments. Technical Report 07-49, University of Massachusetts, Amherst, October 2007.
Ira Kemelmacher-Shlizerman, Steven M Seitz, Daniel Miller, and Evan Brossard. The megaface benchmark: 1 million faces for recognition at scale. In CVPR, 2016.
M Pawan Kumar, Benjamin Packer, and Daphne Koller. Self-paced learning for latent variable models. In NIPS, 2010.
Buyu Li, Yu Liu, and Xiaogang Wang. Gradient harmonized single-stage detector. In AAAI, 2019.
Weiyang Li, Yandong Wen, Zhiding Yu, Ming Li, Bhiksha Raj, and Le Song. Sphereface: Deep hypersphere embedding for face recognition. In CVPR, 2017.
Xianyang Li. Airface: Lightweight and efficient model for face recognition. arXiv:1907.12256, 2019.
Tsung-Yi Lin, Priya Goyal, Ross Girshick, Kaiming He, and Piotr Dollar. Focal loss for dense object ´ detection. In ICCV, pp. 2980–2988, 2017.
Weiyang Liu, Yandong Wen, Zhiding Yu, and Meng Yang. Large-margin softmax loss for convolutional neural networks. In ICML, 2016.
Brianna Maze, Jocelyn Adams, James A Duncan, Nathan Kalka, Tim Miller, Charles Otto, Anil K Jain, W Tyler Niggel, Janet Anderson, Jordan Cheney, et al. Iarpa janus benchmark-c: Face dataset and protocol. In ICB, 2018.
Stylianos Moschoglou, Athanasios Papaioannou, Christos Sagonas, Jiankang Deng, Irene Kotsia, and Stefanos Zafeiriou. Agedb: the first manually collected, in-the-wild age database. In CVPR Workshops, 2017.
Adam Paszke, Sam Gross, Soumith Chintala, Gregory Chanan, Edward Yang, Zachary DeVito, Zeming Lin, Alban Desmaison, Luca Antiga, and Adam Lerer. Automatic differentiation in PyTorch. In NIPS Autodiff Workshop, 2017.
Xi Peng, Xiang Yu, Kihyuk Sohn, Dimitris Metaxas, and Manmohan Chandraker. Reconstructionbased disentanglement for poseinvariant face recognition. In ICCV, 2017.
Florian Schroff, Dmitry Kalenichenko, and James Philbin. Facenet: A unified embedding for face recognition and clustering. In CVPR, 2015.
S. Sengupta, J.-C. Chen, C. Castillo, V. M. Patel, R. Chellappa, and D.W. Jacobs. Frontal to profile face verification in the wild. In WACV, 2016.
Yichun Shi, Anil K Jain, and Nathan D Kalka. Probabilistic face embeddings. In ICCV, 2019.
Abhinav Shrivastava, Abhinav Gupta, and Ross Girshick. Training region-based object detectors with online hard example mining. In CVPR, 2016.
Luan Tran, Xi Yin, and Xiaoming Liu. Disentangled representation learning GAN for pose-invariant face recognition. In CVPR, 2017.
Hao Wang, Yitong Wang, Zheng Zhou, Xing Ji, Dihong Gong, Jingchao Zhou, Zhifeng Li, and Wei Liu. Cosface: Large margin cosine loss for deep face recognition. In CVPR, 2018a.
Xiaobo Wang, Shuo Wang, Shifeng Zhang, Tianyu Fu, Hailin Shi, and Tao Mei. Support vector guided softmax loss for face recognition. arXiv:1812.11317, 2018b.
Yandong Wen, Kaipeng Zhang, Zhifeng Li, and Yu Qiao. A discriminative feature learning approach for deep face recognition. In ECCV, 2016.
Cameron Whitelam, Emma Taborsky, Austin Blanton, Brianna Maze, Jocelyn Adams, Tim Miller, Nathan Kalka, Anil K Jain, James A Duncan, Kristen Allen, et al. Iarpa janus benchmark-b face dataset. In CVPR Workshops, 2017.
Weidi Xie and Andrew Zisserman. Multicolumn networks for face recognition. In BMVC, 2018.
Weidi Xie, Li Shen, and Andrew Zisserman. Comparator networks. In ECCV, 2018.
Dong Yi, Zhen Lei, Shengcai Liao, and Stan Z. Li. Learning face representation from scratch. arXiv:1411.7923, 2014.
Kaipeng Zhang, Zhanpeng Zhang, Zhifeng Li, and Yu Qiao. Joint face detection and alignment using multitask cascaded convolutional networks. IEEE Signal Processing Letters, 23(10):1499–1503, 2016.
Xiao Zhang, Rui Zhao, Yu Qiao, Xiaogang Wang, and Hongsheng Li. Adacos: Adaptively scaling cosine logits for effectively learning deep face representations. In CVPR, 2019a.
Xiao Zhang, Rui Zhao, Junjie Yan, Mengya Gao, Yu Qiao, Xiaogang Wang, and Hongsheng Li. P2sgrad: Refined gradients for optimizing deep face models. In CVPR, 2019b.
Tianyue Zheng, Weihong Deng, and Jiani Hu. Cross-age lfw: A database for studying cross-age face recognition in unconstrained environments. arXiv:1708.08197, 2017.
Tianyue Zheng, Weihong Deng, and Jiani Hu. Cross-pose lfw: A database for studying cross-pose face recognition in unconstrained environments. Technical Report 18-01, Beijing University of Posts and Telecommunications, February 2018.
Tianyi Zhou and Jeff Bilmes. Minimax curriculum learning: Machine teaching with desirable difficulties and scheduled diversity. In ICLR, 2018. URL https://openreview.net/forum? id $=$ BywyFQlAW.123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442# DEEP DOUBLE DESCENT: WHERE BIGGER MODELS AND MORE DATA HURT
Preetum Nakkiran∗ Harvard University
Gal Kaplun† Harvard University
Yamini Bansal† Harvard University
Tristan Yang Harvard University
Boaz Barak Harvard University
Ilya Sutskever OpenAI
# ABSTRACT
We show that a variety of modern deep learning tasks exhibit a “double-descent” phenomenon where, as we increase model size, performance first gets worse and then gets better. Moreover, we show that double descent occurs not just as a function of model size, but also as a function of the number of training epochs. We unify the above phenomena by defining a new complexity measure we call the effective model complexity and conjecture a generalized double descent with respect to this measure. Furthermore, our notion of model complexity allows us to identify certain regimes where increasing (even quadrupling) the number of train samples actually hurts test performance.
# 1 INTRODUCTION
 Figure 1: Left: Train and test error as a function of model size, for ResNet18s of varying width on CIFAR-10 with $15 \%$ label noise. Right: Test error, shown for varying train epochs. All models trained using Adam for 4K epochs. The largest model (width 64) corresponds to standard ResNet18.
The bias-variance trade-off is a fundamental concept in classical statistical learning theory (e.g., Hastie et al. (2005)). The idea is that models of higher complexity have lower bias but higher variance. According to this theory, once model complexity passes a certain threshold, models “overfit” with the variance term dominating the test error, and hence from this point onward, increasing model complexity will only decrease performance (i.e., increase test error). Hence conventional wisdom in classical statistics is that, once we pass a certain threshold, “larger models are worse.”
However, modern neural networks exhibit no such phenomenon. Such networks have millions of parameters, more than enough to fit even random labels (Zhang et al. (2016)), and yet they perform much better on many tasks than smaller models. Indeed, conventional wisdom among practitioners is that “larger models are better’’ (Krizhevsky et al. (2012), Huang et al. (2018), Szegedy et al.
 Figure 2: Left: Test error as a function of model size and train epochs. The horizontal line corresponds to model-wise double descent–varying model size while training for as long as possible. The vertical line corresponds to epoch-wise double descent, with test error undergoing double-descent as train time increases. Right Train error of the corresponding models. All models are Resnet18s trained on CIFAR-10 with $15 \%$ label noise, data-augmentation, and Adam for up to 4K epochs.
(2015), Radford et al. (2019)). The effect of training time on test performance is also up for debate. In some settings, “early stopping” improves test performance, while in other settings training neural networks to zero training error only improves performance. Finally, if there is one thing both classical statisticians and deep learning practitioners agree on is “more data is always better”.
In this paper, we present empirical evidence that both reconcile and challenge some of the above “conventional wisdoms.” We show that many deep learning settings have two different regimes. In the under-parameterized regime, where the model complexity is small compared to the number of samples, the test error as a function of model complexity follows the U-like behavior predicted by the classical bias/variance tradeoff. However, once model complexity is sufficiently large to interpolate i.e., achieve (close to) zero training error, then increasing complexity only decreases test error, following the modern intuition of “bigger models are better”. Similar behavior was previously observed in Opper (1995; 2001), Advani & Saxe (2017), Spigler et al. (2018), and Geiger et al. (2019b). This phenomenon was first postulated in generality by Belkin et al. (2018) who named it “double descent”, and demonstrated it for decision trees, random features, and 2-layer neural networks with $\ell _ { 2 }$ loss, on a variety of learning tasks including MNIST and CIFAR-10.
Main contributions. We show that double descent is a robust phenomenon that occurs in a variety of tasks, architectures, and optimization methods (see Figure 1 and Section 5; our experiments are summarized in Table A). Moreover, we propose a much more general notion of “double descent” that goes beyond varying the number of parameters. We define the effective model complexity (EMC) of a training procedure as the maximum number of samples on which it can achieve close to zero training error. The EMC depends not just on the data distribution and the architecture of the classifier but also on the training procedure—and in particular increasing training time will increase the EMC.
We hypothesize that for many natural models and learning algorithms, double descent occurs as a function of the EMC. Indeed we observe “epoch-wise double descent” when we keep the model fixed and increase the training time, with performance following a classical U-like curve in the underfitting stage (when the EMC is smaller than the number of samples) and then improving with training time once the EMC is sufficiently larger than the number of samples (see Figure 2). As a corollary, early stopping only helps in the relatively narrow parameter regime of critically parameterized models.
Sample non-monotonicity. Finally, our results shed light on test performance as a function of the number of train samples. Since the test error peaks around the point where EMC matches the number of samples (the transition from the under- to over-parameterization), increasing the number of samples has the effect of shifting this peak to the right. While in most settings increasing the number of samples decreases error, this shifting effect can sometimes result in a setting where more data is worse! For example, Figure 3 demonstrates cases in which increasing the number of samples by a factor of 4.5 results in worse test performance.
 Figure 3: Test loss (per-token perplexity) as a function of Transformer model size (embedding dimension $d _ { m o d e l . }$ ) on language translation (IWSLT‘14 German-to-English). The curve for $1 8 \mathrm { k }$ samples is generally lower than the one for $4 \mathrm { k }$ samples, but also shifted to the right, since fitting 18k samples requires a larger model. Thus, for some models, the performance for $1 8 \mathrm { k }$ samples is worse than for $4 \mathrm { k \Omega }$ samples.
# 2 OUR RESULTS
To state our hypothesis more precisely, we define the notion of effective model complexity. We define a training procedure $\tau$ to be any procedure that takes as input a set $S = \{ ( x _ { 1 } , y _ { 1 } ) , \dots , ( x _ { n } , y _ { n } ) \}$ of labeled training samples and outputs a classifier $\mathcal { T } ( S )$ mapping data to labels. We define the effective model complexity of $\tau$ (w.r.t. distribution $\mathcal { D }$ ) to be the maximum number of samples $n$ on which $\tau$ achieves on average $\approx 0$ training error.
Definition 1 (Effective Model Complexity) The Effective Model Complexity (EMC) of a training procedure $\tau$ , with respect to distribution $\mathcal { D }$ and parameter $\epsilon > 0$ , is defined as:
$$\operatorname { E M C } _ { { \mathscr { D } } , \epsilon } ( { \mathscr { T } } ) : = \operatorname* { m a x } \left\{ n \mid \mathbb { E } _ { S \sim { \mathscr { D } } ^ { n } } [ \operatorname { E r r o r } _ { S } ( { \mathscr { T } } ( S ) ) ] \leq \epsilon \right\}$$
where Error $s ( M )$ is the mean error of model $M$ on train samples $S$ .
Our main hypothesis can be informally stated as follows:
Hypothesis 1 (Generalized Double Descent hypothesis, informal) For any natural data distribution $\mathcal { D }$ , neural-network-based training procedure $\tau$ , and small $\epsilon > 0$ , if we consider the task of predicting labels based on n samples from $\mathcal { D }$ then:
Under-paremeterized regime. If $\cdot _ { \mathrm { E M C } _ { { \mathscr D } , \epsilon } } ( \mathcal T )$ is sufficiently smaller than $n _ { \ast }$ , any perturbation of $\tau$ that increases its effective complexity will decrease the test error.
Over-parameterized regime. If $\mathrm { E M C } _ { { \cal D } , \epsilon } ( T )$ is sufficiently larger than $n$ , any perturbation of $\tau$ that increases its effective complexity will decrease the test error.
Critically parameterized regime. I $f \mathrm { E M C } _ { \mathcal { D } , \epsilon } ( \mathcal { T } ) \approx n$ , then a perturbation of $\tau$ that increases its effective complexity might decrease or increase the test error.
Hypothesis 1 is informal in several ways. We do not have a principled way to choose the parameter $\epsilon$ (and currently heuristically use $\epsilon = 0 . 1$ ). We also are yet to have a formal specification for “sufficiently smaller” and “sufficiently larger”. Our experiments suggest that there is a critical interval around the interpolation threshold when $\mathrm { E M C } _ { \mathcal { D } , \epsilon } ( \mathcal { T } ) = n$ : below and above this interval increasing complexity helps performance, while within this interval it may hurt performance. The width of the critical interval depends on both the distribution and the training procedure in ways we do not yet completely understand.
We believe Hypothesis 1 sheds light on the interaction between optimization algorithms, model size, and test performance and helps reconcile some of the competing intuitions about them. The main result of this paper is an experimental validation of Hypothesis 1 under a variety of settings, where we considered several natural choices of datasets, architectures, and optimization algorithms, and we changed the “interpolation threshold” by varying the number of model parameters, the length of training, the amount of label noise in the distribution, and the number of train samples.
Model-wise Double Descent. In Section 5, we study the test error of models of increasing size, for a fixed large number of optimization steps. We show that “model-wise double-descent” occurs for various modern datasets (CIFAR-10, CIFAR-100, IWSLT‘14 de-en, with varying amounts of label noise), model architectures (CNNs, ResNets, Transformers), optimizers (SGD, Adam), number of train samples, and training procedures (data-augmentation, and regularization). Moreover, the peak in test error systematically occurs at the interpolation threshold. In particular, we demonstrate realistic settings in which bigger models are worse.
Epoch-wise Double Descent. In Section 6, we study the test error of a fixed, large architecture over the course of training. We demonstrate, in similar settings as above, a corresponding peak in test performance when models are trained just long enough to reach $\approx 0$ train error. The test error of a large model first decreases (at the beginning of training), then increases (around the critical regime), then decreases once more (at the end of training)—that is, training longer can correct overfitting.
Sample-wise Non-monotonicity. In Section 7, we study the test error of a fixed model and training procedure, for varying number of train samples. Consistent with our generalized double-descent hypothesis, we observe distinct test behavior in the “critical regime”, when the number of samples is near the maximum that the model can fit. This often manifests as a long plateau region, in which taking significantly more data might not help when training to completion (as is the case for CNNs on CIFAR-10). Moreover, we show settings (Transformers on IWSLT‘14 en-de), where this manifests as a peak—and for a fixed architecture and training procedure, more data actually hurts.
Remarks on Label Noise. We observe all forms of double descent most strongly in settings with label noise in the train set (as is often the case when collecting train data in the real-world). However, we also show several realistic settings with a test-error peak even without label noise: ResNets (Figure 4a) and CNNs (Figure 20) on CIFAR-100; Transformers on IWSLT‘14 (Figure 8). Moreover, all our experiments demonstrate distinctly different test behavior in the critical regime— often manifesting as a “plateau” in the test error in the noiseless case which develops into a peak with added label noise. See Section 8 for further discussion.
# 3 RELATED WORK
Model-wise double descent was first proposed as a general phenomenon by Belkin et al. (2018). Similar behavior had been observed in Opper (1995; 2001), Advani & Saxe (2017), Spigler et al. (2018), and Geiger et al. (2019b). Subsequently, there has been a large body of work studying the double descent phenomenon. A growing list of papers that theoretically analyze it in the tractable setting of linear least squares regression includes Belkin et al. (2019); Hastie et al. (2019); Bartlett et al. (2019); Muthukumar et al. (2019); Bibas et al. (2019); Mitra (2019); Mei & Montanari (2019). Moreover, Geiger et al. (2019a) provide preliminary results for model-wise double descent in convolutional networks trained on CIFAR-10. Our work differs from the above papers in two crucial aspects: First, we extend the idea of double-descent beyond the number of parameters to incorporate the training procedure under a unified notion of “Effective Model Complexity”, leading to novel insights like epoch-wise double descent and sample non-monotonicity. The notion that increasing train time corresponds to increasing complexity was also presented in Nakkiran et al. (2019). Second, we provide an extensive and rigorous demonstration of double-descent in modern deep learning, spanning a variety of architectures, datasets, and optimization procedures. An extended discussion of the related work is provided in Appendix C.
# 4 EXPERIMENTAL SETUP
We briefly describe the experimental setup here; full details are in Appendix B 1. We consider three families of architectures: ResNets, standard CNNs, and Transformers. ResNets: We parameterize a family of ResNet18s (He et al. (2016)) by scaling the width (number of filters) of convolutional layers. Specifically, we use layer widths $[ k , 2 k , \bar { 4 } k , 8 k ]$ for varying $k$ . The standard ResNet18 corresponds to $k = 6 4$ . Standard CNNs: We consider a simple family of 5-layer CNNs, with 4 convolutional layers of widths $[ k , 2 k , 4 k , 8 k ]$ for varying $k$ , and a fully-connected layer. For context, the CNN with width $k = 6 4$ , can reach over $9 0 \%$ test accuracy on CIFAR-10 with dataaugmentation. Transformers: We consider the 6 layer encoder-decoder from Vaswani et al. (2017), as implemented by Ott et al. (2019). We scale the size of the network by modifying the embedding dimension $d _ { \mathrm { m o d e l } }$ , and setting the width of the fully-connected layers proportionally $( d _ { \mathrm { f f } } = 4 \cdot d _ { \mathrm { m o d e l } } )$ .
For ResNets and CNNs, we train with cross-entropy loss, and the following optimizers: (1) Adam with learning-rate 0.0001 for 4K epochs; (2) SGD with learning rate $\propto \frac { 1 } { \sqrt { T } }$ for 500K gradient steps. We train Transformers for 80K gradient steps, with $10 \%$ label smoothing and no drop-out.
Label Noise. In our experiments, label noise of probability $p$ refers to training on a samples which have the correct label with probability $( 1 - p )$ , and a uniformly random incorrect label otherwise (label noise is sampled only once and not per epoch). Figure 1 plots test error on the noisy distribution, while the remaining figures plot test error with respect to the clean distribution (the two curves are just linear rescaling of one another).
# 5 MODEL-WISE DOUBLE DESCENT
 (a) CIFAR-100. There is a peak in test error even with no label noise. Figure 4: Model-wise double descent for ResNet18s. Trained on CIFAR-100 and CIFAR-10, with varying label noise. Optimized using Adam with LR 0.0001 for 4K epochs, and data-augmentation.
 (b) CIFAR-10. There is a “plateau” in test error around the interpolation point with no label noise, which develops into a peak for added label noise.
In this section, we study the test error of models of increasing size, when training to completion (for a fixed large number of optimization steps). We demonstrate model-wise double descent across different architectures, datasets, optimizers, and training procedures. The critical region exhibits distinctly different test behavior around the interpolation point and there is often a peak in test error that becomes more prominent in settings with label noise.
For the experiments in this section (Figures 4, 5, 6, 7, 8), notice that all modifications which increase the interpolation threshold (such as adding label noise, using data augmentation, and increasing the number of train samples) also correspondingly shift the peak in test error towards larger models. Additional plots showing the early-stopping behavior of these models, and additional experiments showing double descent in settings with no label noise (e.g. Figure 19) are in Appendix E.2. We also observed model-wise double descent for adversarial training, with a prominent robust test error peak even in settings without label noise. See Figure 26 in Appendix E.2.
Discussion. Fully understanding the mechanisms behind model-wise double descent in deep neural networks remains an important open question. However, an analog of model-wise double descent occurs even for linear models. A recent stream of theoretical works analyzes this setting (Bartlett et al. (2019); Muthukumar et al. (2019); Belkin et al. (2019); Mei & Montanari (2019); Hastie et al. (2019)). We believe similar mechanisms may be at work in deep neural networks.
Informally, our intuition is that for model-sizes at the interpolation threshold, there is effectively only one model that fits the train data and this interpolating model is very sensitive to noise in the train set and/or model mis-specification. That is, since the model is just barely able to fit the train data, forcing it to fit even slightly-noisy or mis-specified labels will destroy its global structure, and result in high test error. (See Figure 28 in the Appendix for an experiment demonstrating this noise sensitivity, by showing that ensembling helps significantly in the critically-parameterized regime). However for over-parameterized models, there are many interpolating models that fit the train set, and SGD is able to find one that “memorizes” (or “absorbs”) the noise while still performing well on the distribution.
 Figure 5: Effect of Data Augmentation. 5-layer CNNs on CIFAR10, with and without dataaugmentation. Data-augmentation shifts the interpolation threshold to the right, shifting the test error peak accordingly. Optimized using SGD for 500K steps. See Figure 27 for larger models.

 Figure 6: SGD vs. Adam. 5-Layer CNNs on CIFAR-10 with no label noise, and no data augmentation. Optimized using SGD for 500K gradient steps, and Adam for 4K epochs.
 Figure 7: Noiseless settings. 5-layer CNNs on CIFAR-100 with no label noise; note the peak in test error. Trained with SGD and no data augmentation. See Figure 20 for the early-stopping behavior of these models.
The above intuition is theoretically justified for linear models. In general, this situation manifests even without label noise for linear models (Mei & Montanari (2019)), and occurs whenever there is model mis-specification between the structure of the true distribution and the model family. We believe this intuition extends to deep learning as well, and it is consistent with our experiments.
 Figure 8: Transformers on language translation tasks: Multi-head-attention encoderdecoder Transformer model trained for $8 0 \mathrm { k }$ gradient steps with labeled smoothed cross-entropy loss on IWSLT‘14 Germanto-English (160K sentences) and WMT‘14 English-to-French (subsampled to 200K sentences) dataset. Test loss is measured as pertoken perplexity.
# 6 EPOCH-WISE DOUBLE DESCENT
In this section, we demonstrate a novel form of double-descent with respect to training epochs, which is consistent with our unified view of effective model complexity (EMC) and the generalized double descent hypothesis. Increasing the train time increases the EMC—and thus a sufficiently large model transitions from under- to over-parameterized over the course of training.
 Figure 9: Left: Training dynamics for models in three regimes. Models are ResNet18s on CIFAR10 with $20 \%$ label noise, trained using Adam with learning rate 0.0001, and data augmentation. Right: Test error over (Model size $\times$ Epochs). Three slices of this plot are shown on the left.
As illustrated in Figure 9, sufficiently large models can undergo a “double descent” behavior where test error first decreases then increases near the interpolation threshold, and then decreases again. In contrast, for “medium sized” models, for which training to completion will only barely reach $\approx 0$ error, the test error as a function of training time will follow a classical U-like curve where it is better to stop early. Models that are too small to reach the approximation threshold will remain in the “under parameterized” regime where increasing train time monotonically decreases test error. Our experiments (Figure 10) show that many settings of dataset and architecture exhibit epoch-wise double descent, in the presence of label noise. Further, this phenomenon is robust across optimizer variations and learning rate schedules (see additional experiments in Appendix E.1). As in modelwise double descent, the test error peak is accentuated with label noise.
Conventional wisdom suggests that training is split into two phases: (1) In the first phase, the network learns a function with a small generalization gap (2) In the second phase, the network starts to over-fit the data leading to an increase in test error. Our experiments suggest that this is not the complete picture—in some regimes, the test error decreases again and may achieve a lower value at the end of training as compared to the first minimum (see Fig 10 for $10 \%$ label noise).
 Figure 10: Epoch-wise double descent for ResNet18 and CNN (width $\scriptstyle 1 = 1 2 8$ ). ResNets trained using Adam with learning rate 0.0001, and CNNs trained with SGD with inverse-squareroot learning rate.
# 7 SAMPLE-WISE NON-MONOTONICITY
In this section, we investigate the effect of varying the number of train samples, for a fixed model and training procedure. Previously, in model-wise and epoch-wise double descent, we explored behavior in the critical regime, where $\mathrm { E M C } _ { \mathcal { D } , \epsilon } ( \mathcal { T } ) \approx n$ , by varying the EMC. Here, we explore the critical regime by varying the number of train samples $n$ . By increasing $n$ , the same training procedure $\tau$ can switch from being effectively over-parameterized to effectively under-parameterized.
We show that increasing the number of samples has two different effects on the test error vs. model complexity graph. On the one hand, (as expected) increasing the number of samples shrinks the area under the curve. On the other hand, increasing the number of samples also has the effect of “shifting the curve to the right” and increasing the model complexity at which test error peaks.


(a) Model-wise double descent for 5-layer CNNs on CIFAR-10, for varying dataset sizes. Top: There is a range of model sizes (shaded green) where training on $2 \times$ more samples does not improve test error. Bottom: There is a range of model sizes (shaded red) where training on $4 \times$ more samples does not improve test error.
(b) Sample-wise non-monotonicity. Test loss (per-word perplexity) as a function of number of train samples, for two transformer models trained to completion on IWSLT’14. For both model sizes, there is a regime where more samples hurt performance. Compare to Figure 3, of model-wise double-descent in the identical setting.
Figure 11: Sample-wise non-monotonicity.
These twin effects are shown in Figure 11a. Note that there is a range of model sizes where the effects “cancel out”—and having $4 \times$ more train samples does not help test performance when training to completion. Outside the critically-parameterized regime, for sufficiently under- or overparameterized models, having more samples helps. This phenomenon is corroborated in Figure 12, which shows test error as a function of both model and sample size, in the same setting as Figure 11a.
 Figure 12: Left: Test Error as a function of model size and number of train samples, for 5-layer CNNs on CIFAR- $10 + 2 0 \%$ noise. Note the ridge of high test error again lies along the interpolation threshold. Right: Three slices of the left plot, showing the effect of more data for models of different sizes. Note that, when training to completion, more data helps for small and large models, but does not help for near-critically-parameterized models (green).
In some settings, these two effects combine to yield a regime of model sizes where more data actually hurts test performance as in Figure 3 (see also Figure 11b). Note that this phenomenon is not unique to DNNs: more data can hurt even for linear models (see Appendix D).
# 8 CONCLUSION AND DISCUSSION
We introduce a generalized double descent hypothesis: models and training procedures exhibit atypical behavior when their Effective Model Complexity is comparable to the number of train samples. We provide extensive evidence for our hypothesis in modern deep learning settings, and show that it is robust to choices of dataset, architecture, and training procedures. In particular, we demonstrate “model-wise double descent” for modern deep networks and characterize the regime where bigger models can perform worse. We also demonstrate “epoch-wise double descent,” which, to the best of our knowledge, has not been previously proposed. Finally, we show that the double descent phenomenon can lead to a regime where training on more data leads to worse test performance. Preliminary results suggest that double descent also holds as we vary the amount of regularization for a fixed model (see Figure 22).
We also believe our characterization of the critical regime provides a useful way of thinking for practitioners—if a model and training procedure are just barely able to fit the train set, then small changes to the model or training procedure may yield unexpected behavior (e.g. making the model slightly larger or smaller, changing regularization, etc. may hurt test performance).
Early stopping. We note that many of the phenomena that we highlight often do not occur with optimal early-stopping. However, this is consistent with our generalized double descent hypothesis: if early stopping prevents models from reaching 0 train error then we would not expect to see doubledescent, since the EMC does not reach the number of train samples. Further, we show at least one setting where model-wise double descent can still occur even with optimal early stopping (ResNets on CIFAR-100 with no label noise, see Figure 19). We have not observed settings where more data hurts when optimal early-stopping is used. However, we are not aware of reasons which preclude this from occurring. We leave fully understanding the optimal early stopping behavior of double descent as an important open question for future work.
Label Noise. In our experiments, we observe double descent most strongly in settings with label noise. However, we believe this effect is not fundamentally about label noise, but rather about model mis-specification. For example, consider a setting where the label noise is not truly random, but rather pseudorandom (with respect to the family of classifiers being trained). In this setting, the performance of the Bayes optimal classifier would not change (since the pseudorandom noise is deterministic, and invertible), but we would observe an identical double descent as with truly random label noise. Thus, we view adding label noise as merely a proxy for making distributions “harder”— i.e. increasing the amount of model mis-specification.
Other Notions of Model Complexity. Our notion of Effective Model Complexity is related to classical complexity notions such as Rademacher complexity, but differs in several crucial ways: (1) EMC depends on the true labels of the data distribution, and (2) EMC depends on the training procedure, not just the model architecture.
Other notions of model complexity which do not incorporate features (1) and (2) would not suffice to characterize the location of the double-descent peak. Rademacher complexity, for example, is determined by the ability of a model architecture to fit a randomly-labeled train set. But Rademacher complexity and VC dimension are both insufficient to determine the model-wise double descent peak location, since they do not depend on the distribution of labels— and our experiments show that adding label noise shifts the location of the peak.
Moreover, both Rademacher complexity and VC dimension depend only on the model family and data distribution, and not on the training procedure used to find models. Thus, they are not capable of capturing train-time double-descent effects, such as “epoch-wise” double descent, and the effect of data-augmentation on the peak location.
# ACKNOWLEDGMENTS
We thank Mikhail Belkin for extremely useful discussions in the early stages of this work. We thank Christopher Olah for suggesting the Model Size $\times$ Epoch visualization, which led to the investigation of epoch-wise double descent, as well as for useful discussion and feedback. We also thank Alec Radford, Jacob Steinhardt, and Vaishaal Shankar for helpful discussion and suggestions. P.N. thanks OpenAI, the Simons Institute, and the Harvard Theory Group for a research environment that enabled this kind of work.
We thank Dimitris Kalimeris, Benjamin L. Edelman, and Sharon Qian, and Aditya Ramesh for comments on an early draft of this work.
This work supported in part by NSF grant CAREER CCF 1452961, BSF grant 2014389, NSF USICCS proposal 1540428, a Google Research award, a Facebook research award, a Simons Investigator Award, a Simons Investigator Fellowship, and NSF Awards CCF 1715187, CCF 1565264, CCF 1301976, IIS 1409097, and CNS 1618026. Y.B. would like to thank the MIT-IBM Watson AI Lab for contributing computational resources for experiments.
# REFERENCES
Madhu S Advani and Andrew M Saxe. High-dimensional dynamics of generalization error in neural networks. arXiv preprint arXiv:1710.03667, 2017.
Peter L Bartlett, Philip M Long, Gabor Lugosi, and Alexander Tsigler. Benign overfitting in linear ´ regression. arXiv preprint arXiv:1906.11300, 2019.
Mikhail Belkin, Daniel Hsu, Siyuan Ma, and Soumik Mandal. Reconciling modern machine learning and the bias-variance trade-off. arXiv preprint arXiv:1812.11118, 2018.
Mikhail Belkin, Daniel Hsu, and Ji Xu. Two models of double descent for weak features. arXiv preprint arXiv:1903.07571, 2019.
Koby Bibas, Yaniv Fogel, and Meir Feder. A new look at an old problem: A universal learning approach to linear regression. arXiv preprint arXiv:1905.04708, 2019.
Mauro Cettolo, Christian Girardi, and Marcello Federico. Wit3: Web inventory of transcribed and translated talks. In Proceedings of the $l 6 ^ { t h }$ Conference of the European Association for Machine Translation (EAMT), pp. 261–268, Trento, Italy, May 2012.
Robert PW Duin. Small sample size generalization. In Proceedings of the Scandinavian Conference on Image Analysis, volume 2, pp. 957–964. PROCEEDINGS PUBLISHED BY VARIOUS PUBLISHERS, 1995.
Robert PW Duin. Classifiers in almost empty spaces. In Proceedings 15th International Conference on Pattern Recognition. ICPR-2000, volume 2, pp. 1–7. IEEE, 2000.
Mario Geiger, Arthur Jacot, Stefano Spigler, Franck Gabriel, Levent Sagun, Stephane d’Ascoli, ´ Giulio Biroli, Clement Hongler, and Matthieu Wyart. Scaling description of generalization with ´ number of parameters in deep learning. arXiv preprint arXiv:1901.01608, 2019a.
Mario Geiger, Stefano Spigler, Stephane d’Ascoli, Levent Sagun, Marco Baity-Jesi, Giulio Biroli, ´ and Matthieu Wyart. Jamming transition as a paradigm to understand the loss landscape of deep neural networks. Physical Review E, 100(1):012115, 2019b.
Ian J Goodfellow, Jonathon Shlens, and Christian Szegedy. Explaining and harnessing adversarial examples. arXiv preprint arXiv:1412.6572, 2014.
Trevor Hastie, Robert Tibshirani, Jerome Friedman, and James Franklin. The elements of statistical learning: data mining, inference and prediction. The Mathematical Intelligencer, 27(2):83–85, 2005.
Trevor Hastie, Andrea Montanari, Saharon Rosset, and Ryan J Tibshirani. Surprises in highdimensional ridgeless least squares interpolation. arXiv preprint arXiv:1903.08560, 2019.
Kaiming He, Xiangyu Zhang, Shaoqing Ren, and Jian Sun. Identity mappings in deep residual networks. In European conference on computer vision, pp. 630–645. Springer, 2016.
Yanping Huang, Yonglong Cheng, Dehao Chen, HyoukJoong Lee, Jiquan Ngiam, Quoc V. Le, and Zhifeng Chen. Gpipe: Efficient training of giant neural networks using pipeline parallelism. CoRR, abs/1811.06965, 2018. URL http://arxiv.org/abs/1811.06965.
Alex Krizhevsky. Learning multiple layers of features from tiny images. Technical report, 2009.
Alex Krizhevsky, Ilya Sutskever, and Geoffrey E Hinton. Imagenet classification with deep convolutional neural networks. In Advances in neural information processing systems, pp. 1097–1105, 2012.
Marco Loog and Robert PW Duin. The dipping phenomenon. In Joint IAPR International Workshops on Statistical Techniques in Pattern Recognition (SPR) and Structural and Syntactic Pattern Recognition (SSPR), pp. 310–317. Springer, 2012.
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.
Song Mei and Andrea Montanari. The generalization error of random features regression: Precise asymptotics and double descent curve. arXiv preprint arXiv:1908.05355, 2019.
Partha P. Mitra. Understanding overfitting peaks in generalization error: Analytical risk curves for l2 and l1 penalized interpolation. ArXiv, abs/1906.03667, 2019.
Vidya Muthukumar, Kailas Vodrahalli, and Anant Sahai. Harmless interpolation of noisy data in regression. arXiv preprint arXiv:1903.09139, 2019.
Preetum Nakkiran, Gal Kaplun, Dimitris Kalimeris, Tristan Yang, Benjamin L Edelman, Fred Zhang, and Boaz Barak. Sgd on neural networks learns functions of increasing complexity. arXiv preprint arXiv:1905.11604, 2019.
Brady Neal, Sarthak Mittal, Aristide Baratin, Vinayak Tantia, Matthew Scicluna, Simon LacosteJulien, and Ioannis Mitliagkas. A modern take on the bias-variance tradeoff in neural networks. arXiv preprint arXiv:1810.08591, 2018.
Manfred Opper. Statistical mechanics of learning: Generalization. The Handbook of Brain Theory and Neural Networks, 922-925., 1995.
Manfred Opper. Learning to generalize. Frontiers of Life, 3(part 2), pp.763-775., 2001.
Myle Ott, Sergey Edunov, Alexei Baevski, Angela Fan, Sam Gross, Nathan $\mathrm { N g }$ , David Grangier, and Michael Auli. fairseq: A fast, extensible toolkit for sequence modeling. In Proceedings of NAACL-HLT 2019: Demonstrations, 2019.
David Page. How to train your resnet. https://myrtle.ai/ how-to-train-your-resnet-4-architecture/, 2018.
Adam Paszke, Sam Gross, Soumith Chintala, Gregory Chanan, Edward Yang, Zachary DeVito, Zeming Lin, Alban Desmaison, Luca Antiga, and Adam Lerer. Automatic differentiation in PyTorch. In NeurIPS Autodiff Workshop, 2017.
Alec Radford, Jeff Wu, Rewon Child, David Luan, Dario Amodei, and Ilya Sutskever. Language models are unsupervised multitask learners. 2019.
Ali Rahimi and Benjamin Recht. Random features for large-scale kernel machines. In Advances in neural information processing systems, pp. 1177–1184, 2008.
Rico Sennrich, Barry Haddow, and Alexandra Birch. Neural machine translation of rare words with subword units. ArXiv, abs/1508.07909, 2015.
Marina Skurichina and Robert PW Duin. Bagging, boosting and the random subspace method for linear classifiers. Pattern Analysis & Applications, 5(2):121–135, 2002.
Stefano Spigler, Mario Geiger, Stephane d’Ascoli, Levent Sagun, Giulio Biroli, and Matthieu Wyart.´ A jamming transition from under-to over-parametrization affects loss landscape and generalization. arXiv preprint arXiv:1810.09665, 2018.
Christian Szegedy, Wei Liu, Yangqing Jia, Pierre Sermanet, Scott Reed, Dragomir Anguelov, Dumitru Erhan, Vincent Vanhoucke, and Andrew Rabinovich. Going deeper with convolutions. In Computer Vision and Pattern Recognition (CVPR), 2015. URL http://arxiv.org/abs/ 1409.4842.
Gerard V Trunk. A problem of dimensionality: A simple example. IEEE Transactions on pattern analysis and machine intelligence, (3):306–307, 1979.
Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N. Gomez, Lukasz Kaiser, and Illia Polosukhin. Attention is all you need. CoRR, abs/1706.03762, 2017.
Chiyuan Zhang, Samy Bengio, Moritz Hardt, Benjamin Recht, and Oriol Vinyals. Understanding deep learning requires rethinking generalization. ICLR, abs/1611.03530, 2016.
A SUMMARY TABLE OF EXPERIMENTAL RESULTS
<table><tr><td rowspan="2">Dataset</td><td rowspan="2">Architecture</td><td rowspan="2">Opt.</td><td rowspan="2">Aug.</td><td rowspan="2">% Noise</td><td colspan="2">Double-Descent</td><td rowspan="2">Figure(s)</td></tr><tr><td>Model</td><td>Epoch</td></tr><tr><td>CIFAR 10</td><td>CNN</td><td>SGD</td><td>√</td><td>0</td><td>X</td><td>×</td><td>5,27</td></tr><tr><td rowspan="10"></td><td></td><td></td><td>√</td><td>10</td><td>广</td><td>广</td><td>5,27,6</td></tr><tr><td></td><td></td><td>√</td><td>20</td><td></td><td></td><td>5,27</td></tr><tr><td></td><td></td><td></td><td>0</td><td>X</td><td>x√</td><td>5,25</td></tr><tr><td></td><td></td><td></td><td>10</td><td></td><td></td><td>5</td></tr><tr><td></td><td></td><td></td><td>20</td><td>√</td><td>√</td><td>5</td></tr><tr><td></td><td>SGD + w.d.</td><td>√</td><td>20</td><td>√</td><td>√</td><td>21</td></tr><tr><td>ResNet</td><td>Adam</td><td></td><td>0</td><td>√</td><td></td><td>25</td></tr><tr><td>Adam</td><td>√</td><td>0</td><td>X</td><td></td><td>X</td><td>4,10</td></tr><tr><td></td><td>√</td><td>5</td><td>√</td><td></td><td></td><td>4</td></tr><tr><td></td><td>√</td><td>10</td><td></td><td></td><td></td><td>4,10</td></tr><tr><td></td><td></td><td>√</td><td>15</td><td>√</td><td></td><td>4,2</td></tr><tr><td rowspan="2"></td><td></td><td>Various</td><td>√</td><td>20</td><td>√</td><td></td><td>4,9,10</td></tr><tr><td></td><td></td><td>√</td><td>20</td><td></td><td>√</td><td>16, 17, 18</td></tr><tr><td rowspan="2">(subsampled)</td><td>CNN</td><td>SGD SGD</td><td>√</td><td>10</td><td>√</td><td></td><td>11a</td></tr><tr><td></td><td></td><td>√</td><td>20</td><td>√</td><td></td><td>11a, 12</td></tr><tr><td>(adversarial)</td><td>ResNet</td><td>SGD</td><td></td><td>0</td><td>Robust err.</td><td></td><td>26</td></tr><tr><td rowspan="4">CIFAR 100</td><td>ResNet</td><td>Adam</td><td></td><td>0</td><td>√</td><td>X</td><td>4,19,10</td></tr><tr><td></td><td></td><td>>></td><td>10</td><td>√</td><td>√</td><td>4,10</td></tr><tr><td>CNN</td><td>SGD</td><td>√</td><td>20</td><td>√</td><td>√</td><td>4,10</td></tr><tr><td></td><td></td><td></td><td>0</td><td>√</td><td>X</td><td>20</td></tr><tr><td>IWSLT '14 de-en</td><td>Transformer</td><td>Adam</td><td></td><td>0</td><td>√</td><td>X</td><td>8,24</td></tr><tr><td>(subsampled)</td><td>Transformer</td><td>Adam</td><td></td><td>0</td><td>√</td><td>X</td><td>11b,23</td></tr><tr><td>WMT'14 en-fr</td><td>Transformer</td><td>Adam</td><td></td><td>0</td><td>√</td><td>X</td><td>8,24</td></tr></table>
# B APPENDIX: EXPERIMENTAL DETAILS
# B.1 MODELS
We use the following families of architectures. The PyTorch Paszke et al. (2017) specification of our ResNets and CNNs are available at https://gitlab.com/ harvard-machine-learning/double-descent/tree/master.
ResNets. We define a family of ResNet18s of increasing size as follows. We follow the Preactivation ResNet18 architecture of He et al. (2016), using 4 ResNet blocks, each consisting of two BatchNorm-ReLU-Convolution layers. The layer widths for the 4 blocks are $[ k , 2 k , 4 k , 8 k ]$ for varying $k \in \mathbb N$ and the strides are [1, 2, 2, 2]. The standard ResNet18 corresponds to $k = 6 4$ convolutional channels in the first layer. The scaling of model size with $k$ is shown in Figure 13b. Our implementation is adapted from https://github.com/kuangliu/pytorch-cifar.
Standard CNNs. We consider a simple family of 5-layer CNNs, with four Conv-BatchNormReLU-MaxPool layers and a fully-connected output layer. We scale the four convolutional layer widths as $[ k , 2 k , 4 k , 8 k ]$ . The MaxPool is [1, 2, 2, 8]. For all the convolution layers, the kernel size $= 3$ , stride $= 1$ and padding $^ { = 1 }$ . This architecture is based on the “backbone” architecture from Page (2018). For $k = 6 4$ , this CNN has 1558026 parameters and can reach $> 9 0 \%$ test accuracy on CIFAR-10 (Krizhevsky (2009)) with data-augmentation. The scaling of model size with $k$ is shown in Figure 13a.
Transformers. We consider the encoder-decoder Transformer model from Vaswani et al. (2017) with 6 layers and 8 attention heads per layer, as implemented by fairseq Ott et al. (2019). We scale the size of the network by modifying the embedding dimension $( d _ { \mathrm { m o d e l } } )$ , and scale the width of the fully-connected layers proportionally $\begin{array} { r } { \dot { \mathcal { d } } _ { \mathrm { f f } } = 4 { d } _ { \mathrm { m o d e l } } ) } \end{array}$ . We train with $10 \%$ label smoothing and no drop-out, for 80 gradient steps.
 Figure 13: Scaling of model size with our parameterization of width & embedding dimension.
B.2 IMAGE CLASSIFICATION: EXPERIMENTAL SETUP
We describe the details of training for CNNs and ResNets below.
Loss function: Unless stated otherwise, we use the cross-entropy loss for all the experiments.
Data-augmentation: In experiments where data-augmentation was used, we apply RandomCrop(32, padding ${ \cdot = } 4$ ) and RandomHorizontalFlip. In experiments with added label noise, the label for all augmentations of a given training sample are given the same label.
Regularization: No explicit regularization like weight decay or dropout was applied unless explicitly stated.
Initialization: We use the default initialization provided by PyTorch for all the layers.
# Optimization:
• Adam: Unless specified otherwise, learning rate was set at constant to 1e−4 and all other parameters were set to their default PyTorch values. SGD: Unless specified otherwise, learning rate schedule inverse-square root (defined below) was used with initial learning rate $\gamma _ { 0 } = 0 . 1$ and updates every $L = 5 1 2$ gradient steps. No momentum was used.
We found our results are robust to various other natural choices of optimizers and learning rate schedule. We used the above settings because (1) they optimize well, and (2) they do not require experiment-specific hyperparameter tuning, and allow us to use the same optimization across many experiments.
Batch size: All experiments use a batchsize of 128.
# Learning rate schedule descriptions:
• Inverse-square root $( \gamma _ { 0 } , L )$ : At gradient step $t$ , the learning rate is set to $\gamma ( t ) : =$ $\frac { \gamma _ { 0 } } { \sqrt { 1 + \lfloor t / 5 1 2 \rfloor } }$ . We set learning-rate with respect to number of gradient steps, and not epochs, in order to allow comparison between experiments with varying train-set sizes. • Dynamic drop ( $\mathrm { \Delta } \cdot \mathrm { \Delta } \gamma _ { 0 }$ , drop, patience): Starts with an initial learning rate of $\gamma _ { 0 }$ and drops by a factor of ’drop’ if the training loss has remained constant or become worse for ’patience’ number of gradient steps.
B.3 NEURAL MACHINE TRANSLATION: EXPERIMENTAL SETUP
Here we describe the experimental setup for the neural machine translation experiments.
# Training procedure.
In this setting, the distribution $\mathcal { D }$ consists of triples
$$( x , y , i ) : x \in V _ { s r c } ^ { * } , y \in V _ { t g t } ^ { * } , i \in \{ 0 , \ldots , | y | \}$$
where $V _ { s r c }$ and $V _ { t g t }$ are the source and target vocabularies, the string $x$ is a sentence in the source language, $y$ is its translation in the target language, and $i$ is the index of the token to be predicted by the model. We assume that $i | x , y$ is distributed uniformly on $\{ 0 , \ldots , | y | \}$ .
A standard probabilistic model defines an autoregressive factorization of the likelihood:
$$p _ { M } ( y | x ) = \prod _ { i = 1 } ^ { | y | } p _ { M } ( y _ { i } | y _ { < i } , x ) .$$
Given a set of training samples $S$ , we define
$$\operatorname { E r r o r } _ { S } ( M ) = { \frac { 1 } { | S | } } \sum _ { ( x , y , i ) \in S } - \log p _ { M } ( y _ { i } | y _ { < i } , x ) .$$
In practice, $S$ is not constructed from independent samples from $D$ , but rather by first sampling $( x , y )$ and then including all $( x , y , 0 ) , \dotsc , ( x , y , | y | )$ in $S$ .
For training transformers, we replicate the optimization procedure specified in Vaswani et al. (2017) section 5.3, where the learning rate schedule consists of a “warmup” phase with linearly increasing learning rate followed by a phase with inverse square-root decay. We preprocess the data using byte pair encoding (BPE) as described in Sennrich et al. (2015). We use the implementation provided by fairseq (https://github.com/pytorch/fairseq).
Datasets. The IWSLT ’14 German to English dataset contains TED Talks as described in Cettolo et al. (2012). The WMT ’14 English to French dataset is taken from http://www.statmt. org/wmt14/translation-task.html.
# B.4 PER-SECTION EXPERIMENTAL DETAILS
Here we provide full details for experiments in the body, when not otherwise provided.
Introduction: Experimental Details Figure 1: All models were trained using Adam with learningrate 0.0001 for 4K epochs. Plotting means and standard deviations for 5 trials, with random network initialization.
Model-wise Double Descent: Experimental Details Figure 7: Plotting means and standard deviations for 5 trials, with random network initialization.
Sample-wise Nonmonotonicity: Experimental Details Figure 11a: All models are trained with SGD for 500K epochs, and data-augmentation. Bottom: Means and standard deviations from 5 trials with random initialization, and random subsampling of the train set.
# C EXTENDED DISCUSSION OF RELATED WORK
Belkin et al. (2018): This paper proposed, in very general terms, that the apparent contradiction between traditional notions of the bias-variance trade-off and empirically successful practices in deep learning can be reconciled under a double-descent curve—as model complexity increases, the test error follows the traditional “U-shaped curve”, but beyond the point of interpolation, the error starts to decrease. This work provides empirical evidence for the double-descent curve with fully connected networks trained on subsets of MNIST, CIFAR10, SVHN and TIMIT datasets. They use the $l _ { 2 }$ loss for their experiments. They demonstrate that neural networks are not an aberration in this regard—double-descent is a general phenomenon observed also in linear regression with random features and random forests.
Theoretical works on linear least squares regression: A variety of papers have attempted to theoretically analyze this behavior in restricted settings, particularly the case of least squares regression under various assumptions on the training data, feature spaces and regularization method.
1. Advani & Saxe (2017); Hastie et al. (2019) both consider the linear regression problem stated above and analyze the generalization behavior in the asymptotic limit $N , D \to \infty$ using random matrix theory. Hastie et al. (2019) highlight that when the model is misspecified, the minimum of training error can occur for over-parameterized models 2. Belkin et al. (2019) Linear least squares regression for two data models, where the input data is sampled from a Gaussian and a Fourier series model for functions on a circle. They provide a finite-sample analysis for these two cases 3. Bartlett et al. (2019) provides generalization bounds for the minimum $l _ { 2 }$ -norm interpolant for Gaussian features 4. Muthukumar et al. (2019) characterize the fundamental limit of of any interpolating solution in the presence of noise and provide some interesting Fourier-theoretic interpretations. 5. Mei & Montanari (2019): This work provides asymptotic analysis for ridge regression over random features
Similar double descent behavior, in restricted settings, was investigated in Trunk (1979); Opper (1995; 2001); Skurichina & Duin (2002).
Neal et al. (2018) conducts a study of bias and variance in modern neural networks, observing that both bias and variance can decrease with increasing model size, contrary to conventional wisdom.
Geiger et al. (2019b) showed that deep fully connected networks trained on the MNIST dataset with hinge loss exhibit a “jamming transition” when the number of parameters exceeds a threshold that allows training to near-zero train loss. Geiger et al. (2019a) provide further experiments on CIFAR10 with a convolutional network. They also highlight interesting behavior with ensembling around the critical regime, which is consistent with our informal intuitions in Section 5 and our experiments in Figures 28, 29.
Advani & Saxe (2017); Geiger et al. (2019b;a) also point out that double-descent is not observed when optimal early-stopping is used.
The study of sample non-monotonicity in learning algorithms had also existed prior to double descent, including in Duin (1995; 2000); Opper (2001); Loog & Duin (2012).
 Figure 14: Random Fourier Features on the Fashion MNIST dataset. The setting is equivalent to two-layer neural network with $e ^ { - i x }$ activation, with randomly-initialized first layer that is fixed throughout training. The second layer is trained using gradient flow.
In this section, for completeness sake, we show that both the model- and sample-wise double descent phenomena are not unique to deep neural networks—they exist even in the setting of Random Fourier Features of Rahimi & Recht (2008). This setting is equivalent to a two-layer neural network with $e ^ { - i x }$ activation. The first layer is initialized with a $\textstyle { \hat { \mathcal { N } } } ( 0 , { \frac { 1 } { d } } )$ Gaussian distribution and then fixed throughout training. The width (or embedding dimension) $\dot { d }$ of the first layer parameterizes the model size. The second layer is initialized with 0s and trained with MSE loss.
Figure 14 shows the grid of Test Error as a function of both number of samples $n$ and model size $d$ . Note that in this setting $\mathrm { E M C } = d$ (the embedding dimension). As a result, as demonstrated in the figure, the peak follows the path of $n = d$ . Both model-wise and sample-wise (see figure 15) double descent phenomena are captured, by horizontally and vertically crossing the grid, respectively.
 Figure 15: Sample-wise double-descent slice for Random Fourier Features on the Fashion MNIST dataset. In this figure the embedding dimension (number of random features) is 1000.
# E APPENDIX: ADDITIONAL EXPERIMENTS
E.1 EPOCH-WISE DOUBLE DESCENT: ADDITIONAL RESULTS
Here, we provide a rigorous evaluation of epoch-wise double descent for a variety of optimizers and learning rate schedules. We train ResNet18 on CIFAR-10 with data-augmentation and $20 \%$ label noise with three different optimizers—Adam, SGD, SGD $^ +$ Momentum (momentum set to 0.9) and three different learning rate schedules—constant, inverse-square root, dynamic drop for differnet values of initial learning rate. We observe that double-descent occurs reliably for all optimizers and learning rate schedules and the peak of the double descent curve shifts with the interpolation point.
 Figure 16: Epoch-wise double descent for ResNet18 trained with Adam and multiple learning rate schedules
A practical recommendation resulting from epoch-wise double descent is that stopping the training when the test error starts to increase may not always be the best strategy. In some cases, the test error may decrease again after reaching a maximum, and the final value may be lower than the minimum earlier in training.
 Figure 17: Epoch-wise double descent for ResNet18 trained with SGD and multiple learning rate schedules
 Figure 18: Epoch-wise double descent for ResNet18 trained with $\mathrm { S G D + I }$ Momentum and multiple learning rate schedules
E.2 MODEL-WISE DOUBLE DESCENT: ADDITIONAL RESULTS
# E.2.1 CLEAN SETTINGS WITH MODEL-WISE DOUBLE DESCENT
CIFAR100, ResNet18
 Figure 19: Top: Train and test performance as a function of both model size and train epochs. Bottom: Test error dynamics of the same model (ResNet18, on CIFAR-100 with no label noise, data-augmentation and Adam optimizer trained for $4 \mathrm { k }$ epochs with learning rate 0.0001). Note that even with optimal early stopping this setting exhibits double descent.
 Figure 20: Top: Train and test performance as a function of both model size and train epochs. Bottom: Test error dynamics of the same models. 5-Layer CNNs, CIFAR-100 with no label noise, no data-augmentation Trained with SGD for 1e6 steps. Same experiment as Figure 7.
 Figure 21: Left: Test error dynamics with weight decay of 5e-4 (bottom left) and without weight decay (top left). Right: Test and train error and test loss for models with varying amounts of weight decay. All models are 5-Layer CNNs on CIFAR-10 with $10 \%$ label noise, trained with data-augmentation and SGD for 500K steps.
Here, we now study the effect of varying the level of regularization on test error. We train CIFAR10 with data-augmentation and $20 \%$ label noise on ResNet18 for weight decay co-efficients $\lambda$ ranging from 0 to 0.1. We train the networks using $\mathrm { S G D + }$ inverse-square root learning rate. Figure below shows a picture qualitatively very similar to that observed for model-wise double descent wherein ”model complexity” is now controlled by the regularization parameter. This confirms our generalized double descent hypothesis along yet another axis of Effective Model Complexity.
 Figure 22: Generalized double descent for weight decay. We found that using the same initial learning rate for all weight decay values led to training instabilities. This resulted in some noise in the Test Error (Weight Decay $\times$ Epochs) plot shown above.
Language models
 Figure 23: Model-wise test error dynamics for a subsampled IWSLT‘14 dataset. Left: 4k samples, Right: 18k samples. Note that with optimal early-stopping, more samples is always better.
 Figure 24: Model-wise test error dynamics for a IWSLT‘14 de-en and subsampled WMT‘14 en-fr datasets. Left: IWSLT‘14, Right: subsampled (200k samples) WMT‘14. Note that with optimal early-stopping, the test error is much lower for this task.
CIFAR10, $10 \%$ noise, SGD
 Figure 25: Top: Train and test performance as a function of both model size and train epochs. Bottom: Test error dynamics of the same model (CNN, on CIFAR-10 with $10 \%$ label noise, dataaugmentation and SGD optimizer with learning rate $\propto 1 / \sqrt { T } )$ ).
# E.2.4 TRAINING PROCEDURE
 Figure 26: Model-wise double descent for adversarial training ResNet18s on CIFAR-10 (subsampled to $2 5 \mathrm { k }$ train samples) with no label noise. We train for L2 robustness of radius $\epsilon = 0 . 5$ and $\epsilon = 1 . 0$ , using 10-step PGD (Goodfellow et al. (2014); Madry et al. (2017)). Trained using SGD (batch size 128) with learning rate 0.1 for 400 epochs, then 0.01 for 400 epochs.
 Figure 27
 Figure 28: Effect of Ensembling (ResNets, $15 \%$ label noise). Test error of an ensemble of 5 models, compared to the base models. The ensembled classifier is determined by plurality vote over the 5 base models. Note that emsembling helps most around the critical regime. All models are ResNet18s trained on CIFAR-10 with $15 \%$ label noise, using Adam for 4K epochs (same setting as Figure 1). Test error is measured against the original (not noisy) test set, and each model in the ensemble is trained using a train set with independently-sampled $15 \%$ label noise.
 Figure 29: Effect of Ensembling (CNNs, no label noise). Test error of an ensemble of 5 models, compared to the base models. All models are 5-layer CNNs trained on CIFAR-10 with no label noise, using SGD and no data augmentation. (same setting as Figure 7).123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438# GENERALIZING HAMILTONIAN MONTE CARLO WITH NEURAL NETWORKS
Daniel Levy1∗, Matthew D. Hoffman2, Jascha Sohl-Dickstein3 1Stanford University, 2Google AI Perception , 3Google Brain danilevy@cs.stanford.edu, {mhoffman,jaschasd}@google.com
# ABSTRACT
We present a general-purpose method to train Markov chain Monte Carlo kernels, parameterized by deep neural networks, that converge and mix quickly to their target distribution. Our method generalizes Hamiltonian Monte Carlo and is trained to maximize expected squared jumped distance, a proxy for mixing speed. We demonstrate large empirical gains on a collection of simple but challenging distributions, for instance achieving a $1 0 6 \times$ improvement in effective sample size in one case, and mixing when standard HMC makes no measurable progress in a second. Finally, we show quantitative and qualitative gains on a real-world task: latent-variable generative modeling. We release an open source TensorFlow implementation of the algorithm.
# 1 INTRODUCTION
High-dimensional distributions that are only analytically tractable up to a normalizing constant are ubiquitous in many fields. For instance, they arise in protein folding (Schutte et al., 1999), physics ¨ simulations (Olsson, 1995), and machine learning (Andrieu et al., 2003). Sampling from such distributions is a critical task for learning and inference (MacKay, 2003), however it is an extremely hard problem in general.
Markov Chain Monte Carlo (MCMC) methods promise a solution to this problem. They operate by generating a sequence of correlated samples that converge in distribution to the target. This convergence is most often guaranteed through detailed balance, a sufficient condition for the chain to have the target equilibrium distribution. In practice, for any proposal distribution, one can ensure detailed balance through a Metropolis-Hastings (Hastings, 1970) accept/reject step.
Despite theoretical guarantees of eventual convergence, in practice convergence and mixing speed depend strongly on choosing a proposal that works well for the task at hand. What’s more, it is often more art than science to know when an MCMC chain has converged (“burned-in”), and when the chain has produced a new uncorrelated sample (“mixed”). Additionally, the reliance on detailed balance, which assigns equal probability to the forward and reverse transitions, often encourages random-walk behavior and thus slows exploration of the space (Ichiki & Ohzeki, 2013).
For densities over continuous spaces, Hamiltonian Monte Carlo (HMC; Duane et al., 1987; Neal, 2011) introduces independent, auxiliary momentum variables, and computes a new state by integrating Hamiltonian dynamics. This method can traverse long distances in state space with a single Metropolis-Hastings test. This is the state-of-the-art method for sampling in many domains. However, HMC can perform poorly in a number of settings. While HMC mixes quickly spatially, it struggles at mixing across energy levels due to its volume-preserving dynamics. HMC also does not work well with multi-modal distributions, as the probability of sampling a large enough momentum to traverse a very low-density region is negligibly small. Furthermore, HMC struggles with ill-conditioned energy landscapes (Girolami & Calderhead, 2011) and deals poorly with rapidly changing gradients (Sohl-Dickstein et al., 2014).
Recently, probabilistic models parameterized by deep neural networks have achieved great success at approximately sampling from highly complex, multi-modal empirical distributions (Kingma &
Welling, 2013; Rezende et al., 2014; Goodfellow et al., 2014; Bengio et al., 2014; Sohl-Dickstein et al., 2015). Building on these successes, we present a method that, given an analytically described distribution, automatically returns an exact sampler with good convergence and mixing properties, from a class of highly expressive parametric models. The proposed family of samplers is a generalization of HMC; it transforms the HMC trajectory using parametric functions (deep networks in our experiments), while retaining theoretical guarantees with a tractable Metropolis-Hastings accept/reject step. The sampler is trained to minimize a variation on expected squared jumped distance (similar in spirit to Pasarica & Gelman (2010)). Our parameterization reduces easily to standard HMC. It is further capable of emulating several common extensions of HMC such as withintrajectory tempering (Neal, 1996) and diagonal mass matrices (Bennett, 1975).
We evaluate our method on distributions where HMC usually struggles, as well as on a the real-world task of training latent-variable generative models.
Our contributions are as follows:
• We introduce a generic training procedure which takes as input a distribution defined by an energy function, and returns a fast-mixing MCMC kernel. • We show significant empirical gains on various distributions where HMC performs poorly. • We finally evaluate our method on the real-world task of training and sampling from a latent variable generative model, where we show improvement in the model’s log-likelihood, and greater complexity in the distribution of posterior samples.
# 2 RELATED WORK
Adaptively modifying proposal distributions to improve convergence and mixing has been explored in the past (Andrieu & Thoms, 2008). In the case of HMC, prior work has reduced the need to choose step size (Neal, 2011) or number of leapfrog steps (Hoffman & Gelman, 2014) by adaptively tuning those parameters. Salimans et al. (2015) proposed an alternate scheme based on variational inference. We adopt the much simpler approach of Pasarica & Gelman (2010), who show that choosing the hyperparameters of a proposal distribution to maximize expected squared jumped distance is both principled and effective in practice.
Previous work has also explored applying models from machine learning to MCMC tasks. Kernel methods have been used both for learning a proposal distribution (Sejdinovic et al., 2014) and for approximating the gradient of the energy (Strathmann et al., 2015). In physics, Restricted and semiRestricted Boltzmann machines have been used both to build approximations of the energy function which allow more rapid sampling (Liu et al., 2017; Huang & Wang, 2017), and to motivate new hand-designed proposals (Wang, 2017).
Most similar to our approach is recent work from Song et al. (2017), which uses adversarial training of a volume-preserving transformation, which is subsequently used as an MCMC proposal distribution. While promising, this technique has several limitations. It does not use gradient information, which is often crucial to maintaining high acceptance rates, especially in high dimensions. It also can only indirectly measure the quality of the generated sample using adversarial training, which is notoriously unstable, suffers from “mode collapse” (where only a portion of a target distribution is covered), and often requires objective modification to train in practice (Arjovsky et al., 2017). Finally, since the proposal transformation preserves volume, it can suffer from the same difficulties in mixing across energy levels as HMC, as we illustrate in Section 5.
To compute the Metropolis-Hastings acceptance probability for a deterministic transition, the operator must be invertible and have a tractable Jacobian. Recent work (Dinh et al., 2016), introduces RNVP, an invertible transformation that operates by, at each layer, modifying only a subset of the variables by a function that depends solely on the remaining variables. This is exactly invertible with an efficiently computable Jacobian. Furthermore, by chaining enough of these layers, the model can be made arbitrarily expressive. This parameterization will directly motivate our extension of the leapfrog integrator in HMC.
# 3 BACKGROUND
# 3.1 MCMC METHODS AND METROPOLIS-HASTINGS
Let $p$ be a target distribution, analytically known up to a constant, over a space $\mathcal { X }$ . Markov chain Monte Carlo (MCMC) methods (Neal, 1993) aim to provide samples from $p$ . To that end, MCMC methods construct a Markov Chain whose stationary distribution is the target distribution $p$ . Obtaining samples then corresponds to simulating a Markov Chain, i.e., given an initial distribution $\pi _ { 0 }$ and a transition kernel $K$ , constructing the following sequence of random variables:
$$X _ { 0 } \sim \pi _ { 0 } , \quad X _ { t + 1 } \sim K ( \cdot | X _ { t } ) .$$
In order for $p$ to be the stationary distribution of the chain, three conditions must be satisfied: $K$ must be irreducible and aperiodic (these are usually mild technical conditions) and $p$ has to be a fixed point of $K$ . This last condition can be expressed as: $\begin{array} { r } { p ( x ^ { \prime } ) = \int K ( x ^ { \prime } | x ) p ( x ) \mathrm { d } x } \end{array}$ . This condition is most often satisfied by satisfying the stronger detailed balance condition, which can be written as: $p ( x ^ { \prime } ) K ( x | x ^ { \prime } ) = p ( x ) \dot { K } ( x ^ { \prime } | \dot { x } )$ .
Given any proposal distribution $q$ , satisfying mild conditions, we can easily construct a transition kernel that respects detailed balance using Metropolis-Hastings (Hastings, 1970) accept/reject rules. More formally, starting from $x _ { 0 } \sim \pi _ { 0 }$ , at each step $t$ , we sample $x ^ { \prime } \sim q ( \cdot | X _ { t } )$ , and with probability $\begin{array} { r } { A ( x ^ { \prime } | x _ { t } ) = \operatorname* { m i n } \left( 1 , \frac { p ( x ^ { \prime } ) q ( x _ { t } | x ^ { \prime } ) } { p ( x _ { t } ) q ( x ^ { \prime } | x _ { t } ) } \right) } \end{array}$ , accept $x ^ { \prime }$ as the next sample $x _ { t + 1 }$ in the chain. If we reject $x ^ { \prime }$ , then we retain the previous state and $x _ { t + 1 } ~ = ~ x _ { t }$ . For typical proposals this algorithm has strong asymptotic guarantees. But in practice one must often choose between very low acceptance probabilities and very cautious proposals, both of which lead to slow mixing. For continuous state spaces, Hamiltonian Monte Carlo (HMC; Neal, 2011) tackles this problem by proposing updates that move far in state space while staying roughly on iso-probability contours of $p$ .
# 3.2 HAMILTONIAN MONTE CARLO
Without loss of generality, we assume $p \left( x \right)$ to be defined by an energy function $U \left( x \right)$ , s.t. $p ( x ) \propto \exp ( - U ( { \bar { x } } ) )$ , and where the state $x \in \mathbb { R } ^ { n }$ . HMC extends the state space with an additional momentum vector $v \in \mathbb { R } ^ { n }$ , where $v$ is distributed independently from $x$ , as $p ( v ) \propto \exp ( - \frac { 1 } { 2 } v ^ { T } v )$ (i.e., identity-covariance Gaussian). From an augmented state $\xi \triangleq ( x , v )$ , HMC produces a proposed state $\xi ^ { \prime } = ( \dot { x } ^ { \prime } , v ^ { \prime } )$ by approximately integrating Hamiltonian dynamics jointly on $x$ and $v$ , with $U \left( x \right)$ taken to be the potential energy, and $\scriptstyle { \frac { 1 } { 2 } } v ^ { \overline { { T } } } v$ the kinetic energy. Since Hamiltonian dynamics conserve the total energy of a system, their approximate integration moves along approximate iso-probability contours of $p \bar { ( \boldsymbol { x } , \boldsymbol { v } ) } = \bar { p } ( \boldsymbol { x } ) p ( \boldsymbol { v } )$ .
The dynamics are typically simulated using the leapfrog integrator (Hairer et al., 2003; Leimkuhler & Reich, 2004), which for a single time step consists of:
$$\begin{array} { r } { v ^ { \frac { 1 } { 2 } } = v - \frac { \epsilon } { 2 } \partial _ { x } U ( x ) ; \quad x ^ { \prime } = x + \epsilon v ^ { \frac { 1 } { 2 } } ; \quad v ^ { \prime } = v - \frac { \epsilon } { 2 } \partial _ { x } U ( x ^ { \prime } ) . } \end{array}$$
Following Sohl-Dickstein et al. (2014), we write the action of the leapfrog integrator in terms of an operator $\mathbf { L }$ : $\mathbf { L } \boldsymbol { \xi } \triangleq \mathbf { L } ( \boldsymbol { x } , \boldsymbol { v } ) \triangleq ( \boldsymbol { x } ^ { \prime } , \boldsymbol { v } ^ { \prime } )$ , and introduce a momentum flip operator $\mathbf { F }$ : $\mathbf { F } ( x , v ) \triangleq$ $( x , - v )$ . It is important to note two properties of these operators. First, the transformation $\mathbf { F L }$ is an involution, i.e. $\mathbf { F L F L } ( x , v ) = \mathbf { F L } ( x ^ { \prime } , - v ^ { \prime } ) = ( x , v )$ . Second, the transformations from $( x , v )$ to $( x , v ^ { \frac { 1 } { 2 } } )$ , from $( x , v ^ { \frac { 1 } { 2 } } )$ to $( x ^ { \prime } , v ^ { \frac { 1 } { 2 } } )$ , and from $( x ^ { \prime } , v ^ { \frac { 1 } { 2 } } )$ to $( x ^ { \prime } , v ^ { \prime } )$ are all volume-preserving shear transformations i.e., only one of the variables ( $x$ or $v$ ) changes, by an amount determined by the other one. The determinant of the Jacobian, $\left. \frac { \partial [ \mathbf { F } \mathbf { L } \xi ] } { \partial \xi ^ { T } } \right.$ , is thus easy to compute. For vanilla HMC $\begin{array} { r } { \left| \frac { \partial [ \mathbf { F } \mathbf { L } \xi ] } { \partial \xi ^ { T } } \right| = 1 } \end{array}$ , but we will leave it in symbolic form for use in Section 4. The Metropolis-HastingsGreen (Hastings, 1970; Green, 1995) acceptance probability for the HMC proposal is made simple by these two properties, and is
$$\begin{array} { r } { A ( \mathbf { F } \mathbf { L } \xi | \xi ) = \operatorname* { m i n } \left( 1 , \frac { p ( \mathbf { F } \mathbf { L } \xi ) } { p ( \xi ) } \left| \frac { \partial [ \mathbf { F } \mathbf { L } \xi ] } { \partial \xi ^ { T } } \right| \right) . } \end{array}$$
# 4 L2HMC: TRAINING MCMC SAMPLERS
In this section, we describe our proposed method L2HMC (for ‘Learning To Hamiltonian Monte Carlo’). Given access to only an energy function $U$ (and not samples), L2HMC learns a parametric leapfrog operator $\mathbf { L } _ { \theta }$ over an augmented state space. We begin by describing what desiderata we have for $\mathbf { L } _ { \theta }$ , then go into detail on how we parameterize our sampler. Finally, we conclude this section by describing our training procedure.
# 4.1 AUGMENTING HMC
HMC is a powerful algorithm, but it can still struggle even on very simple problems. For example, a two-dimensional multivariate Gaussian with an ill-conditioned covariance matrix can take arbitrarily long to traverse (even if the covariance is diagonal), whereas it is trivial to sample directly from it. Another problem is that HMC can only move between energy levels via a random walk (Neal, 2011), which leads to slow mixing in some models. Finally, HMC cannot easily traverse low-density zones. For example, given a simple Gaussian mixture model, HMC cannot mix between modes without recourse to additional tricks, as illustrated in Figure 1b. These observations determine the list of desiderata for our learned MCMC kernel: fast mixing, fast burn-in, mixing across energy levels, and mixing between modes.
While pursuing these goals, we must take care to ensure that our proposal operator retains two key features of the leapfrog operator used in HMC: it must be invertible, and the determinant of its Jacobian must be tractable. The leapfrog operator satisfies these properties by ensuring that each sub-update only affects a subset of the variables, and that no sub-update depends nonlinearly on any of the variables being updated. We are free to generalize the leapfrog operator in any way that preserves these properties. In particular, we are free to translate and rescale each sub-update of the leapfrog operator, so long as we are careful to ensure that these translation and scale terms do not depend on the variables being updated.
# 4.1.1 STATE SPACE
As in HMC, we begin by augmenting the current state $x \in \mathbb { R } ^ { n }$ with a continuous momentum variable $v \in \mathbb { R } ^ { n }$ drawn from a standard normal. We also introduce a binary direction variable $d \in \{ - 1 , 1 \}$ , drawn from a uniform distribution. We will denote the complete augmented state as $\xi \triangleq ( x , v , d )$ , with probability density $p ( \xi ) = p ( x ) p ( v ) p ( d )$ . Finally, to each step $t$ of the operator $\mathbf { L } _ { \theta }$ we assign a fixed random binary mask $m ^ { t } \in \{ 0 , 1 \} ^ { n }$ that will determine which variables are affected by each sub-update. We draw $m ^ { t }$ uniformly from the set of binary vectors satisfying $\begin{array} { r } { \sum _ { i = 1 } ^ { n } m _ { i } ^ { t } = \lfloor \frac { n } { 2 } \rfloor } \end{array}$ , that is, half of the entries of $m ^ { t }$ are 0 and half are 1. For convenience, we write $\bar { m } ^ { t } = 1 - m ^ { t }$ and $x _ { m ^ { t } } = x \odot m ^ { t }$ $\odot$ denotes element-wise multiplication, and $\mathbb { 1 }$ the all ones vector).
# 4.1.2 UPDATE STEPS
We now describe the details of our augmented leapfrog integrator $\mathbf { L } _ { \theta }$ , for a single time-step $t$ , and for direction $d = 1$ .
We first update the momenta $v$ . This update can only depend on a subset $\zeta _ { 1 } \triangleq ( x , \partial _ { x } U ( x ) , t )$ of the full state, which excludes $v$ . It takes the form
We have introduced three new functions of $\zeta _ { 1 } \colon T _ { v }$ , $Q _ { v }$ , and $S _ { v }$ . $T _ { v }$ is a translation, $\exp ( Q _ { v } )$ rescales the gradient, and $\exp ( \frac { \epsilon } { 2 } S _ { v } )$ rescales the momentum. The determinant of the Jacobian of this transformation is exp $, \left( \frac { \epsilon } { 2 } \mathbb { 1 } \cdot S _ { v } ( \zeta _ { 1 } ) \right)$ . Note that if $T _ { v }$ , $Q _ { v }$ , and $S _ { v }$ are all zero, then we recover the standard leapfrog momentum update.
We now update $x$ . As hinted above, to make our transformation more expressive, we first update a subset of the coordinates of $x$ , followed by the complementary subset. The first update, which yields $x ^ { \prime }$ and affects only $x _ { m } t$ , depends on the state subset $\zeta _ { 2 } \triangleq ( x _ { \bar { m } ^ { t } } , v , t )$ . Conversely, with $x ^ { \prime }$ defined below, the second update only affects $\boldsymbol { x } _ { \bar { m } ^ { t } } ^ { \prime }$ and depends only on $\zeta _ { 3 } \triangleq ( x _ { m ^ { t } } ^ { \prime } , v , t )$ :
$$\begin{array} { l } { { x ^ { \prime } = x _ { \bar { m } ^ { t } } + m ^ { t } \odot [ x \odot \exp ( \epsilon S _ { x } ( \zeta _ { 2 } ) ) + \epsilon ( v ^ { \prime } \odot \exp ( \epsilon Q _ { x } ( \zeta _ { 2 } ) ) + T _ { x } ( \zeta _ { 2 } ) ) ] } } \\ { { x ^ { \prime \prime } = x _ { m ^ { t } } ^ { \prime } + \bar { m } ^ { t } \odot [ x ^ { \prime } \odot \exp ( \epsilon S _ { x } ( \zeta _ { 3 } ) ) + \epsilon ( v ^ { \prime } \odot \exp ( \epsilon Q _ { x } ( \zeta _ { 3 } ) ) + T _ { x } ( \zeta _ { 3 } ) ) ] . } } \end{array}$$
Again, $T _ { x }$ is a translation, $\exp ( Q _ { x } )$ rescales the effect of the momenta, $\exp ( \epsilon S _ { x } )$ rescales the positions $x$ , and we recover the original leapfrog position update if $T _ { x } = Q _ { x } = S _ { x } = 0$ . The determinant of the Jacobian of the first transformation is $\bar { \exp { ( \epsilon m ^ { t } \cdot S _ { x } ( \zeta _ { 2 } ) ) } }$ , and the determinant of the Jacobian of the second transformation is $\exp { ( \epsilon \bar { m } ^ { t } \cdot S _ { x } ( \zeta _ { 3 } ) ) }$ .
Finally, we update $v$ again, based on the subset $\zeta _ { 4 } \triangleq ( x ^ { \prime \prime } , \partial _ { x } U ( x ^ { \prime \prime } ) , t )$ :
$$\begin{array} { r } { v ^ { \prime \prime } = v ^ { \prime } \odot \exp ( \frac { \epsilon } { 2 } S _ { v } ( \zeta _ { 4 } ) ) - \frac { \epsilon } { 2 } ( \partial _ { x } U ( x ^ { \prime \prime } ) \odot \exp ( \epsilon Q _ { v } ( \zeta _ { 4 } ) ) + T _ { v } ( \zeta _ { 4 } ) ) . } \end{array}$$
This update has the same form as the momentum update in equation 4.
To give intuition into these terms, the scaling applied to the momentum can enable, among other things, acceleration in low-density zones, to facilitate mixing between modes. The scaling term applied to the gradient of the energy may allow better conditioning of the energy landscape (e.g., by learning a diagonal inertia tensor), or partial ignoring of the energy gradient for rapidly oscillating energies.
The corresponding integrator for $d = - 1$ is given in Appendix A; it essentially just inverts the updates in equations 4, 5 and 6. For all experiments, the functions $Q , S , T$ are implemented using multi-layer perceptrons, with shared weights. We encode the current time step in the MLP input.
Our leapfrog operator $\mathbf { L } _ { \theta }$ corresponds to running $M$ steps of this modified leapfrog, $\begin{array} { r l } { \mathbf { L } _ { \theta } \boldsymbol { \xi } } & { { } = } \end{array}$ ${ \bf L } _ { \theta } ( x , v , d ) \stackrel { } { = } ( x ^ { \prime \prime \times M } , v ^ { \prime \prime \times M } , d )$ , and our flip operator $\mathbf { F }$ reverses the direction variable $d$ , $\mathbf { F } \xi =$ $( x , v , - d )$ . Written in terms of these modified operators, our proposal and acceptance probability are identical to those for standard HMC. Note, however, that this parameterization enables learning non-volume-preserving transformations, as the determinant of the Jacobian is a function of $S _ { x }$ and $S _ { v }$ that does not necessarily evaluate to 1. This quantity is derived in Appendix B.
# 4.1.3 MCMC TRANSITIONS
For convenience, we denote by $\mathbf { R }$ an operator that re-samples the momentum and direction. I.e., given $\xi ~ = ~ ( x , v , d )$ , $\mathbf { R } \xi = ( x , v ^ { \prime } , d ^ { \prime } )$ where $v ^ { \prime } \sim \mathcal { N } ( 0 , I ) , d ^ { \prime } \sim \mathcal { U } \left( \{ - 1 , 1 \} \right)$ . Sampling thus consists of alternating application of the $\mathbf { F L } _ { \theta }$ and $\mathbf { R }$ , in the following two steps each of which is a Markov transition that satisfies detailed balance with respect to $p$ :
1. $\boldsymbol { \xi } ^ { \prime } = \mathbf { F } \mathbf { L } _ { \boldsymbol { \theta } } \boldsymbol { \xi }$ with probability $A ( \mathbf { F L } _ { \theta } \xi | \xi )$ (Equation 3), otherwise $\xi ^ { \prime } = \xi$ 2. $\boldsymbol { \xi } ^ { \prime } = \mathbf { R } \boldsymbol { \xi }$
This parameterization is effectively a generalization of standard HMC as it is non-volume preserving, with learnable parameters, and easily reduces to standard HMC for $Q , S , T = 0$ .
# 4.2 LOSS AND TRAINING PROCEDURE
We need some criterion to train the parameters $\theta$ that control the functions $Q , S$ , and $T$ . We choose a loss designed to reduce mixing time. Specifically, we aim to minimize lag-one autocorrelation. This is equivalent to maximizing expected squared jumped distance (Pasarica & Gelman, 2010). For $\xi , \xi ^ { \prime }$ in the extended state space, we define $\delta ( \xi ^ { \bar { \prime } } , \xi ) \ = \ \delta ( ( x ^ { \prime } , v ^ { \prime } , d ^ { \prime } ) , ( x , v , d ) ) \ = \ | | x - x ^ { \prime } | | _ { 2 } ^ { 2 }$ . Expected squared jumped distance is thus $\mathbb { E } _ { \xi \sim p ( \xi ) } \left[ \delta ( \mathbf { F L } _ { \theta } \xi , \xi ) A ( \mathbf { F L } _ { \theta } \xi | \xi ) \right]$ . However, this loss need not encourage mixing across the entire state space. Indeed, maximizing this objective can lead to regions of state space where almost no mixing occurs, so long as the average squared distance traversed remains high. To optimize both for typical and worst case behavior, we include a reciprocal term in the loss,
$$\begin{array} { r } { \ell _ { \lambda } ( \xi , \xi ^ { \prime } , A ( \xi ^ { \prime } | \xi ) ) = \frac { \lambda ^ { 2 } } { \delta ( \xi , \xi ^ { \prime } ) A ( \xi ^ { \prime } | \xi ) } - \frac { \delta ( \xi , \xi ^ { \prime } ) A ( \xi ^ { \prime } | \xi ) } { \lambda ^ { 2 } } , } \end{array}$$
where $\lambda$ is a scale parameter, capturing the characteristic length scale of the problem. The second term encourages typical moves to be large, while the first term strongly penalizes the sampler if it is ever in a state where it cannot move effectively – $\delta ( \xi , \xi ^ { \prime } )$ being small resulting in a large loss value. We train our sampler by minimizing this loss over both the target distribution and initialization distribution. Formally, given an initial distribution $\pi _ { 0 }$ over $\mathcal { X }$ , we define $q ( \xi ) = \pi _ { 0 } ( x ) \mathcal { N } ( v ; 0 , I ) p ( d )$ , and minimize
$$\begin{array} { r } { \mathcal { L } ( \boldsymbol { \theta } ) \triangleq \mathbb { E } _ { p ( \boldsymbol { \xi } ) } \left[ \ell _ { \lambda } ( \boldsymbol { \xi } , \mathbf { F } \mathbf { L } _ { \boldsymbol { \theta } } \boldsymbol { \xi } , A ( \mathbf { F } \mathbf { L } _ { \boldsymbol { \theta } } \boldsymbol { \xi } | \boldsymbol { \xi } ) ) \right] + \lambda _ { b } \mathbb { E } _ { q ( \boldsymbol { \xi } ) } \left[ \ell _ { \lambda } ( \boldsymbol { \xi } , \mathbf { F } \mathbf { L } _ { \boldsymbol { \theta } } \boldsymbol { \xi } , A ( \mathbf { F } \mathbf { L } _ { \boldsymbol { \theta } } \boldsymbol { \xi } | \boldsymbol { \xi } ) ) \right] . } \end{array}$$
The first term of this loss encourages mixing as it considers our operator applied on draws from the distribution; the second term rewards fast burn-in; $\lambda _ { b }$ controls the strength of the ‘burn-in’ regularization. Given this loss, we exactly describe our training procedure in Algorithm 1. It is important to note that each training iteration can be done with only one pass through the network and can be efficiently batched. We further emphasize that this training procedure can be applied to any learnable operator whose Jacobian’s determinant is tractable, making it a general framework for training MCMC proposals.
# Algorithm 1 Training L2HMC
Input: Energy function $U : \mathcal { X } \mathbb { R }$ and its gradient $\nabla _ { x } U : x x$ , initial distribution over the augmented state space $q$ , number of iterations $n _ { \mathrm { i t e r s } }$ , number of leapfrogs $M$ , learning rate schedule (αt)t≤n , batch size $N$ , scale parameter $\lambda$ and regularization strength $\lambda _ { b }$ . Initialize the parameters of the sampler $\theta$ . Initialize $\{ \xi _ { p } ^ { ( i ) } \} _ { i \le N }$ from $q ( \xi )$ . for $t = 0$ to $n _ { \mathrm { i t e r s } } - 1$ do Sample a minibatch $\{ \xi _ { q } ^ { ( i ) } \} _ { i \leq N }$ from $q ( \xi )$ . $\mathcal { L } 0$ for r $\begin{array} { r l } & { \xi _ { p } ^ { ( i ) } \gets \mathbf { R } \xi _ { p } ^ { ( i ) } } \\ & { \mathcal { L } \gets \mathcal { L } + \ell _ { \lambda } \left( \xi _ { p } ^ { ( i ) } , \mathbf { F L } _ { \theta } \xi _ { p } ^ { ( i ) } , A ( \mathbf { F L } _ { \theta } \xi _ { p } ^ { ( i ) } | \xi _ { p } ^ { ( i ) } ) \right) + \lambda _ { b } \ell _ { \lambda } \left( \xi _ { q } ^ { ( i ) } , \mathbf { F L } _ { \theta } \xi _ { q } ^ { ( i ) } , A ( \mathbf { F L } _ { \theta } \xi _ { q } ^ { ( i ) } | \xi _ { q } ^ { ( i ) } ) \right) } \\ & { } \end{array}$ $i = 1$ to $N$ do $\begin{array} { r } { \xi _ { p } ^ { ( i ) } \mathbf { F L } _ { \theta } \xi _ { p } ^ { ( i ) } } \end{array}$ with probability $A ( \mathbf { F L } _ { \theta } \xi _ { p } ^ { ( i ) } | \xi _ { p } ^ { ( i ) } )$ . end for θ θ α t θ end for
# 5 EXPERIMENTS
We present an empirical evaluation of our trained sampler on a diverse set of energy functions. We first present results on a collection of toy distributions capturing common pathologies of energy landscapes, followed by results on a task from machine learning: maximum-likelihood training of deep generative models. For each, we compare against HMC with well-tuned step length and show significant gains in mixing time. Code implementing our algorithm is available online1.
# 5.1 VARIED COLLECTION OF ENERGY FUNCTIONS
We evaluate our L2HMC sampler on a diverse collection of energy functions, each posing different challenges for standard HMC.
Ill-Conditioned Gaussian (ICG): Gaussian distribution with diagonal covariance spaced loglinearly between $1 0 ^ { - 2 }$ and $1 0 ^ { 2 }$ . This demonstrates that L2HMC can learn a diagonal inertia tensor.
Strongly correlated Gaussian (SCG): We rotate a diagonal Gaussian with variances $[ 1 0 ^ { 2 } , 1 0 ^ { - 2 } ]$ by $\frac { \pi } { 4 }$ . This is an extreme version of an example from Neal (2011). This problem shows that, although our parametric sampler only applies element-wise transformations, it can adapt to structure which is not axis-aligned.
Mixture of Gaussians (MoG): Mixture of two isotropic Gaussians with $\sigma ^ { 2 } = 0 . 1$ , and centroids separated by distance 4. The means are thus about 12 standard deviations apart, making it almost impossible for HMC to mix between modes.
Rough Well: Similar to an example from Sohl-Dickstein et al. (2014), for a given $\eta > 0 , U ( x ) =$ $\begin{array} { r } { \frac { 1 } { 2 } x ^ { T } \overset { \smile } { x } + \eta \sum _ { i } \cos ( \frac { x _ { i } } { \eta } ) } \end{array}$ . For small $\eta$ the energy itself is altered negligibly, but its gradient is perturbed by a high frequency noise oscillating between $- 1$ and 1. In our experiments, we choose $\eta = 1 0 ^ { - 2 }$ .
For each of these distributions, we compare against HMC with the same number of leapfrog steps and a well-tuned step-size. To compare mixing time, we plot auto-correlation for each method and report effective sample size (ESS). We compute those quantities in the same way as Sohl-Dickstein et al. (2014). We observe that samplers trained with L2HMC show greatly improved autocorrelation and ESS on the presented tasks, providing more than $1 0 6 \times$ improved ESS on the SCG task. In addition, for the MoG, we show that L2HMC can easily mix between modes while standard HMC gets stuck in a mode, unable to traverse the low density zone. Experimental details, as well as a comparison with LAHMC (Sohl-Dickstein et al., 2014), are shown in Appendix C.
 Figure 1: L2HMC mixes faster than well-tuned HMC, and than A-NICE-MC, on a collection of toy distributions.
Comparison to A-NICE-MC (Song et al., 2017) In addition to the well known challenges associated with adversarial training (Arjovsky et al., 2017), we note that parameterization using a volume-preserving operator can dramatically fail on simple energy landscapes. We build off of the mog2 experiment presented in (Song et al., 2017), which is a 2-d mixture of isotropic Gaussians separated by a distance of 10 with variances 0.5. We consider that setup but increase the ratio of variances: $\dot { \sigma } _ { 1 } ^ { 2 } = 3 , \sigma _ { 2 } ^ { 2 } = 0 . 0 5$ . We show in Figure 1d sample chains trained with L2HMC and A-NICE-MC; A-NICE-MC cannot effectively mix between the two modes as only a fraction of the volume of the large mode can be mapped to the small one, making it highly improbable to traverse. This is also an issue for HMC. On the other hand, L2HMC can both traverse the low-density region between modes, and map a larger volume in the left mode to a smaller volume in the right mode. It is important to note that the distance between both clusters is less than in the mog2 case, and it is thus a good diagnostic of the shortcomings of volume-preserving transformations.
# 5.2 LATENT-VARIABLE GENERATIVE MODEL
We apply our learned sampler to the task of training, and sampling from the posterior of, a latentvariable generative model. The model consists of a latent variable $z \sim p ( z )$ , where we choose $p ( z ) = \breve { \mathscr { N } } ( z ; 0 , I )$ , and a conditional distribution $p ( x | z )$ which generates the image $x$ . Given a family of parametric ‘decoders’ $\{ z \mapsto p ( x | z ; \phi ) , \phi \in \Phi \}$ , and a set of samples $\mathcal { D } = \{ x ^ { ( i ) } \} _ { i \leq N }$ training involves finding $\begin{array} { r } { \phi ^ { * } = \arg \operatorname* { m a x } _ { \phi \in \Phi } p ( \mathcal { D } ; \phi ) } \end{array}$ . However, the log-likelihood is intractable as $\begin{array} { r } { p ( x ; \boldsymbol { \phi } ) = \int p ( x | \boldsymbol { z } ; \boldsymbol { \phi } ) p ( \boldsymbol { z } ) \mathrm { d } \boldsymbol { z } } \end{array}$ . To remedy that problem, Kingma $\&$ Welling (2013) proposed jointly training an approximate posterior $q _ { \psi }$ that maximizes a tractable lower-bound on the log-likelihood:
 Figure 2: Training and held-out log-likelihood for models trained with L2HMC, HMC, and the ELBO (VAE).
$$\mathcal { L } _ { \mathrm { E L B O } } ( x , \phi , \psi ) = \mathbb { E } _ { q _ { \psi } ( z | x ) } \left[ p ( x | z ; \phi ) \right] - \mathrm { K L } ( q _ { \psi } ( z | x ) | | p ( z ) ) \leq p ( x ) ,$$
where $q _ { \psi } ( z | x )$ is a tractable conditional distribution with parameters $\psi$ , typically parameterized by a neural network. Recently, to improve upon well-known pitfalls like over-pruning (Burda et al., 2015) of the VAE, Hoffman (2017) proposed HMC-DLGM. For a data sample $x ^ { ( i ) }$ , after obtaining a sample from the approximate posterior $q _ { \psi } ( \cdot | x ^ { ( i ) } )$ , Hoffman (2017) runs a MCMC algorithm with energy function $U ( z , x ^ { ( i ) } ) = - \log p ( z ) - \log p ( x ^ { ( i ) } | z ; \phi )$ to obtain a more exact posterior sample from $p ( \boldsymbol { z } | \boldsymbol { x } ^ { ( i ) } ; \boldsymbol { \phi } )$ . Given that better posterior sample $z ^ { \prime }$ , the algorithm maximizes $\log p ( x ^ { ( i ) } | z ^ { \prime } ; \phi )$ .
To show the benefits of L2HMC, we borrow the method from Hoffman (2017), but replace HMC by jointly training an L2HMC sampler to improve the efficiency of the posterior sampling. We call this model L2HMC-DLGM. A diagram of our model and a formal description of our training procedure are presented in Appendix D. We define, for $\xi = \{ z , v , d \} , r ( \xi | x ; \psi ) \triangleq$ $q _ { \psi } ( z | x ) \mathcal { N } ( v ; \bar { 0 , I } ) \mathcal { U } ( d ; \{ - 1 , \bar { 1 } \} )$ .
In the subsequent sections, we compare our method to the standard VAE model from Kingma & Welling (2013) and HMC-DGLM from Hoffman (2017). It is important to note that, since our sampler is trained jointly with $p _ { \phi }$ and $q _ { \psi }$ , it performs exactly the same number of gradient computations of the energy function as HMC. We first show that training a latent variable generative model with L2HMC results in better generative models both qualitatively and quantitatively. We then show that our improved sampler enables a more expressive, non-Gaussian, posterior.
Implementation details: Our decoder $( p _ { \phi } )$ is a neural network with 2 fully connected layers, with 1024 units each and softplus non-linearities, and outputs Bernoulli activation probabilities for each pixel. The encoder $( q _ { \psi } )$ has the same architecture, returning mean and variance for the approximate posterior. Our model was trained for 300 epochs with Adam (Kingma & Ba, 2014) and a learning rate $\alpha = 1 0 ^ { - 3 }$ . All experiments were done on the dynamically binarized MNIST dataset (LeCun).
# 5.2.1 SAMPLE QUALITY AND DATA LIKELIHOOD
We first present samples from decoders trained with L2HMC, HMC and the ELBO (i.e. vanilla VAE). Although higher log likelihood does not necessarily correspond to better samples (Theis et al., 2015), we can see in Figure 5, shown in the Appendix, that the decoder trained with L2HMC generates sharper samples than the compared methods.
We now compare our method to HMC in terms of log-likelihood of the data. As we previously stated, the marginal likelihood of a data point $x \in \mathcal { X }$ is not tractable as it requires integrating $p ( x , z )$ over a high-dimensional space. However, we can estimate it using annealed importance sampling (AIS; Neal (2001)). Following Wu et al. (2016), we evaluate our generative models on both training and held-out data. In Figure 2, we plot the data’s log-likelihood against the number of gradient computation steps for both HMC-DGLM and L2HMC-DGLM. We can see that for a similar number of gradient computations, L2HMC-DGLM achieves higher likelihood for both training and held-out data. This is a strong indication that L2HMC provides significantly better posterior samples.

(a) Block Gibbs inpainting of the top half of an MNIST digit, using (top) L2HMC as a posterior sampler, and (bottom) $q _ { \psi }$ as a posterior sampler.
 (b) Non-Gaussian posterior Figure 3: Demonstrations of the value of a more expressive posterior approximation.
# 5.2.2 INCREASED EXPRESSIVITY OF THE POSTERIOR
In the standard VAE framework, approximate posteriors are often parametrized by a Gaussian, thus making a strong assumption of uni-modality. In this section, we show that using L2HMC to sample from the posterior enables learning of a richer posterior landscape.
Block Gibbs Sampling To highlight our ability to capture more expressive posteriors, we in-paint the top of an image using Block Gibbs Sampling using the approximate posterior or L2HMC. Formally, let $x _ { 0 }$ be the starting image. We denote top or bottom-half pixels as $x _ { 0 } ^ { \mathrm { t o p } }$ and $x _ { 0 } ^ { \mathrm { b o t t o m } }$ . At each step $t$ , we sample $z ^ { ( t ) } \sim p ( z | x _ { t } ; \theta )$ , sample $\tilde { x } \sim p ( x | z _ { t } ; \theta )$ . We then set $x _ { t + 1 } ^ { \mathrm { t o p } } = \tilde { x } ^ { \mathrm { t o p } }$ and $x _ { t + 1 } ^ { \mathrm { b o t t o m } } = x _ { 0 } ^ { \mathrm { b o t t o m } }$ . We compare the results obtained by sampling from ior) vs. our trained sampler. The results are reported i $p ( z | x ; \theta )$ using a. We $q _ { \psi }$ (i.e. the see that L2HMC easily mixes between modes (3, 5, 8, and plausibly 9 in the figure) while the approximate posterior gets stuck on the same reconstructed digit (3 in the figure).
Visualization of the posterior After training a decoder with L2HMC, we randomly choose an element $x _ { 0 } \in \mathcal { D }$ and run 512 parallel L2HMC chains for 20, 000 Metropolis-Hastings steps. We then find the direction of highest variance, project the samples along that direction and show a histogram in Figure 3b. This plot shows non-Gaussianity in the latent space for the posterior. Using our improved sampler enables the decoder to make use of a more expressive posterior, and enables the encoder to sample from this non-Gaussian posterior.
# 6 FUTURE WORK
The loss in Section 4.2 targets lag-one autocorrelation. It should be possible to extend this to also target lag-two and higher autocorrelations. It should also be possible to extend this loss to reward fast decay in the autocorrelation of other statistics of the samples, for instance the sample energy as well as the sample position. These additional statistics could also include learned statistics of the samples, combining benefits of the adversarial approach of (Song et al., 2017) with the current work.
Our learned generalization of HMC should prove complementary to several other research directions related to HMC. It would be interesting to explore combining our work with the use of HMC in a minibatch setting (Chen et al., 2014); with shadow Hamiltonians (Izaguirre & Hampton, 2004); with gradient pre-conditioning approaches similar to those used in Riemannian HMC (Girolami et al., 2009; Betancourt, 2013); with the use of alternative HMC accept-reject rules (Sohl-Dickstein et al., 2014; Berger et al., 2015); with the use of non-canonical Hamiltonian dynamics (Tripuraneni et al., 2016); with variants of AIS adapted to HMC proposals (Sohl-Dickstein & Culpepper, 2012); with the extension of HMC to discrete state spaces (Zhang et al., 2012); and with the use of alternative Hamiltonian integrators (Creutz & Gocksch, 1989; Chao et al., 2015).
Finally, our work is also complementary to other methods not utilizing gradient information. For example, we could incorporate the intuition behind Multiple Try Metropolis schemes (Martino & Read, 2013) by having several parametric operators and training each one when used. In addition, one could draw inspiration from the adaptive literature (Haario et al., 2001; Andrieu & Thoms, 2008) or component-wise strategies (Gilks & Wild, 1992).
# 7 CONCLUSION
In this work, we presented a general method to train expressive MCMC kernels parameterized with deep neural networks. Given a target distribution $p$ , analytically known up to a constant, our method provides a fast-mixing sampler, able to efficiently explore the state space. Our hope is that our method can be utilized in a “black-box” manner, in domains where sampling constitutes a huge bottleneck such as protein foldings (Schutte et al., 1999) or physics simulations (Olsson, 1995). ¨
# ACKNOWLEDGMENTS
We would like to thank Ben Poole, Aditya Grover, David Belanger, and Colin Raffel for insightful comments on the draft, Mohammad Norouzi for support and encouragement launching the project, and Jiaming Song for discussions and help running A-NICE-MC.
# REFERENCES
Christophe Andrieu and Johannes Thoms. A tutorial on adaptive MCMC. Statistics and computing, 18(4): 343–373, 2008.
Christophe Andrieu, Nando De Freitas, Arnaud Doucet, and Michael I Jordan. An introduction to MCMC for machine learning. Machine learning, 50(1-2):5–43, 2003.
Martin Arjovsky, Soumith Chintala, and Leon Bottou. Wasserstein GAN. ´ arXiv preprint arXiv:1701.07875, 2017.
Yoshua Bengio, Eric Laufer, Guillaume Alain, and Jason Yosinski. Deep generative stochastic networks trainable by backprop. In International Conference on Machine Learning, pp. 226–234, 2014.
Charles H Bennett. Mass tensor molecular dynamics. Journal of Computational Physics, 19(3):267–279, 1975.
Andrew B Berger, Mayur Mudigonda, Michael R DeWeese, and Jascha Sohl-Dickstein. A Markov jump process for more efficient Hamiltonian Monte Carlo. arXiv preprint arXiv:1509.03808, 2015.
Michael Betancourt. A general metric for Riemannian manifold Hamiltonian Monte Carlo. In Geometric science of information, pp. 327–334. Springer, 2013.
Yuri Burda, Roger Grosse, and Ruslan Salakhutdinov. Importance weighted autoencoders. arXiv preprint arXiv:1509.00519, 2015.
Wei-Lun Chao, Justin Solomon, Dominik Michels, and Fei Sha. Exponential integration for Hamiltonian Monte Carlo. In Proceedings of the 32nd International Conference on Machine Learning (ICML-15), pp. 1142–1151, 2015.
Tianqi Chen, Emily Fox, and Carlos Guestrin. Stochastic gradient Hamiltonian Monte Carlo. In International Conference on Machine Learning, pp. 1683–1691, 2014.
Michael Creutz and Andreas Gocksch. Higher-order hybrid Monte Carlo algorithms. Physical Review Letters, 63(1):9, 1989.
Laurent Dinh, Jascha Sohl-Dickstein, and Samy Bengio. Density estimation using real NVP. arXiv preprint arXiv:1605.08803, 2016.
Simon Duane, Anthony D Kennedy, Brian J Pendleton, and Duncan Roweth. Hybrid Monte Carlo. Physics letters B, 195(2):216–222, 1987.
Walter R Gilks and Pascal Wild. Adaptive rejection sampling for gibbs sampling. Applied Statistics, pp. 337–348, 1992.
Mark Girolami and Ben Calderhead. Riemann manifold Langevin and Hamiltonian Monte Carlo methods. Journal of the Royal Statistical Society: Series B (Statistical Methodology), 73(2):123–214, 2011.
Mark Girolami, Ben Calderhead, and Siu A Chin. Riemannian manifold Hamiltonian Monte Carlo. arXiv preprint arXiv:0907.1100, 2009.
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.
Peter J Green. Reversible jump markov chain monte carlo computation and bayesian model determination. Biometrika, 82(4):711–732, 1995.
Heikki Haario, Eero Saksman, Johanna Tamminen, et al. An adaptive metropolis algorithm. Bernoulli, 7(2): 223–242, 2001.
Ernst Hairer, Christian Lubich, and Gerhard Wanner. Geometric numerical integration illustrated by the Stormer–Verlet method. ¨ Acta numerica, 12:399–450, 2003.
W Keith Hastings. Monte Carlo sampling methods using Markov chains and their applications. Biometrika, 57 (1):97–109, 1970.
Matthew D Hoffman. Learning deep latent Gaussian models with Markov chain Monte Carlo. In International Conference on Machine Learning, pp. 1510–1519, 2017.
Matthew D Hoffman and Andrew Gelman. The no-U-turn sampler: adaptively setting path lengths in Hamiltonian Monte Carlo. Journal of Machine Learning Research, 15(1):1593–1623, 2014.
Li Huang and Lei Wang. Accelerated monte carlo simulations with restricted boltzmann machines. Physical Review B, 95(3):035105, 2017.
Akihisa Ichiki and Masayuki Ohzeki. Violation of detailed balance accelerates relaxation. Physical Review E, 88(2):020101, 2013.
Jesus A Izaguirre and Scott S Hampton. Shadow hybrid Monte Carlo: an efficient propagator in phase space of ´ macromolecules. Journal of Computational Physics, 200(2):581–604, 2004.
Diederik Kingma and Jimmy Ba. Adam: A method for stochastic optimization. arXiv preprint arXiv:1412.6980, 2014.
Diederik P Kingma and Max Welling. Auto-encoding variational Bayes. arXiv preprint arXiv:1312.6114, 2013.
Yann LeCun. The MNIST database of handwritten digits. http://yann. lecun. com/exdb/mnist/.
Benedict Leimkuhler and Sebastian Reich. Simulating Hamiltonian dynamics, volume 14. Cambridge University Press, 2004.
Junwei Liu, Yang Qi, Zi Yang Meng, and Liang Fu. Self-learning monte carlo method. Physical Review B, 95 (4):041101, 2017.
David JC MacKay. Information theory, inference and learning algorithms. Cambridge university press, 2003.
Luca Martino and Jesse Read. On the flexibility of the design of multiple try metropolis schemes. Computational Statistics, 28(6):2797–2823, 2013.
Radford M Neal. Probabilistic inference using Markov chain Monte Carlo methods. 1993.
Radford M Neal. Sampling from multimodal distributions using tempered transitions. Statistics and computing, 6(4):353–366, 1996.
Radford M Neal. Annealed importance sampling. Statistics and computing, 11(2):125–139, 2001.
Radford M Neal. MCMC using Hamiltonian dynamics. Handbook of Markov Chain Monte Carlo, 2(11), 2011.
Peter Olsson. Two phase transitions in the fully frustrated XY model. Physical review letters, 75(14):2758, 1995.
Cristian Pasarica and Andrew Gelman. Adaptively scaling the Metropolis algorithm using expected squared jumped distance. Statistica Sinica, pp. 343–364, 2010.
Danilo Jimenez Rezende, Shakir Mohamed, and Daan Wierstra. Stochastic backpropagation and approximate inference in deep generative models. In ICML, 2014.
Tim Salimans, Diederik Kingma, and Max Welling. Markov chain Monte Carlo and variational inference: Bridging the gap. In Proceedings of the 32nd International Conference on Machine Learning (ICML-15), pp. 1218–1226, 2015.
Ch Schutte, Alexander Fischer, Wilhelm Huisinga, and Peter Deuflhard. A direct approach to conformational¨ dynamics based on hybrid Monte Carlo. Journal of Computational Physics, 151(1):146–168, 1999.
Dino Sejdinovic, Heiko Strathmann, Maria Lomeli Garcia, Christophe Andrieu, and Arthur Gretton. Kernel adaptive metropolis-hastings. In International Conference on Machine Learning, pp. 1665–1673, 2014. Jascha Sohl-Dickstein and Benjamin J Culpepper. Hamiltonian annealed importance sampling for partition function estimation. arXiv preprint arXiv:1205.1925, 2012. Jascha Sohl-Dickstein, Mayur Mudigonda, and Michael R DeWeese. Hamiltonian Monte Carlo without detailed balance. pp. 719–726, 2014. Jascha Sohl-Dickstein, Eric A Weiss, Niru Maheswaranathan, and Surya Ganguli. Deep unsupervised learning using nonequilibrium thermodynamics. arXiv preprint arXiv:1503.03585, 2015. Jiaming Song, Shengjia Zhao, and Stefano Ermon. A-nice-mc: Adversarial training for mcmc. In Advances in Neural Information Processing Systems, pp. 5146–5156, 2017. Heiko Strathmann, Dino Sejdinovic, Samuel Livingstone, Zoltan Szabo, and Arthur Gretton. Gradient-free hamiltonian monte carlo with efficient kernel exponential families. In Advances in Neural Information Processing Systems, pp. 955–963, 2015. Lucas Theis, Aaron van den Oord, and Matthias Bethge. A note on the evaluation of generative models. ¨ arXiv preprint arXiv:1511.01844, 2015. Nilesh Tripuraneni, Mark Rowland, Zoubin Ghahramani, and Richard Turner. Magnetic Hamiltonian Monte Carlo. arXiv preprint arXiv:1607.02738, 2016. Lei Wang. Can boltzmann machines discover cluster updates? arXiv preprint arXiv:1702.08586, 2017. Yuhuai Wu, Yuri Burda, Ruslan Salakhutdinov, and Roger Grosse. On the quantitative analysis of decoderbased generative models. arXiv preprint arXiv:1611.04273, 2016. Yichuan Zhang, Zoubin Ghahramani, Amos J Storkey, and Charles A Sutton. Continuous relaxations for discrete hamiltonian monte carlo. In Advances in Neural Information Processing Systems, pp. 3194–3202, 2012.
# Appendix
# A REVERSE LEAPFROG OPERATOR
Let $\xi = \{ x , v , d \}$ in the extended state space with $d = - 1$ . Here, we describe the leapfrog updates for a single time step $t$ , this consists of inverting the equations presented in the corresponding section.
Let $\zeta _ { 1 } = \{ x , v , t \}$ , we have:
$$v ^ { \prime } = \left[ v + \frac { \epsilon } { 2 } \left( \partial _ { x } U ( x ) \odot \exp ( \epsilon Q _ { v } ( \zeta _ { 1 } ) ) + T _ { v } ( \zeta _ { 1 } ) \right) \right] \odot \exp ( - S _ { v } ( \zeta _ { 1 } ) ) .$$
With the notation from Section 4, let $\zeta _ { 2 } \triangleq \{ x _ { m ^ { t } } , v , t \}$
$$x ^ { \prime } = x _ { m ^ { t } } + \bar { m } ^ { t } \odot [ ( x - \epsilon ( \exp ( \epsilon Q _ { x } ( \zeta _ { 2 } ) ) \odot v ^ { \prime } + T _ { x } ( \zeta _ { 2 } ) ) ] \odot \exp ( - \epsilon S _ { v } ( \zeta _ { 2 } ) ) .$$
Let us denote $\zeta _ { 3 } \triangleq \{ x _ { \bar { m } ^ { t } } ^ { \prime } , v , t \}$ :
$$x ^ { \prime \prime } = x _ { \bar { m } ^ { t } } + m ^ { t } \odot [ ( x ^ { \prime } - \epsilon ( \exp ( \epsilon Q _ { x } ( \zeta _ { 3 } ) ) \odot v ^ { \prime } + T _ { x } ( \zeta _ { 3 } ) ) ] \odot \exp ( - \epsilon S _ { v } ( \zeta _ { 3 } ) ) .$$
Finally, the last update, with $\zeta _ { 4 } \triangleq \{ x ^ { \prime \prime } , \partial _ { x } U ( x ^ { \prime \prime } ) , t \}$ :
$$v ^ { \prime } = \left[ v + { \frac { \epsilon } { 2 } } \left( \partial _ { x } U ( x ^ { \prime \prime } ) \odot \exp ( \epsilon Q _ { v } ( \zeta _ { 4 } ) ) + T _ { v } ( \zeta _ { 4 } ) \right) \right] \odot \exp ( - S _ { v } ( \zeta _ { 4 } ) ) .$$
It is important to note that to invert $\mathbf { L } _ { \theta }$ , these steps should be ran for $t$ from $M$ to 1.
# B DETERMINANT OF THE JACOBIAN
Given the derivations (and notations) from Section 4, for the forward operator $\mathbf { L } _ { \theta }$ , we can immediately compute the Jacobian:
$$\log \left| \frac { \partial [ \mathbf { F } \mathbf { L } _ { \theta } \boldsymbol { \xi } ] } { \partial \boldsymbol { \xi } ^ { T } } \right| = d \sum _ { t \leq M } \left[ \frac { \epsilon } { 2 } \mathbf { 1 } \cdot S _ { v } ( \boldsymbol { \zeta } _ { 1 } ^ { t } ) + \epsilon m ^ { t } \cdot S _ { x } ( \boldsymbol { \zeta } _ { 2 } ^ { t } ) + \epsilon \bar { m } ^ { t } \cdot S _ { x } ( \boldsymbol { \zeta } _ { 3 } ^ { t } ) + \frac { \epsilon } { 2 } \mathbf { 1 } \cdot S _ { v } ( \boldsymbol { \zeta } _ { 4 } ^ { t } ) \right] .$$
Where $\zeta _ { i } ^ { t }$ denotes the intermediary variable $\zeta _ { i }$ at time step $t$ and $d$ is the direction of $\xi$ i.e. $\xi =$ $\{ x , v , d \}$ .
# C EXPERIMENTAL DETAILS OF SECTION 5
# C.1 IMPLEMENTATION DETAILS
First of all, we keep separate parameters for the network responsible for updating $v$ and those updating $x$ . The architectures are the same. Let us take the example of $Q _ { v } , S _ { v } , T _ { v }$ . The time step $t$ is given as input to the MLP, encoded as $\begin{array} { r } { \tau ( t ) = ( \cos ( \frac { 2 \pi t } { M } ) , \sin ( \frac { 2 \pi { \hat { t } } } { M } ) ) } \end{array}$ . $\sigma ( \cdot )$ denotes the ReLU non-linearity.
For $n _ { h }$ hidden units per layer:
• We first compute $h _ { 1 } = \sigma ( W _ { 1 } x + W _ { 2 } v + W _ { 3 } \tau ( t ) + b ) ( h \in \mathbb { R } ^ { n _ { h } } ) .$ · $h _ { 2 } = \sigma ( W _ { 4 } h + b _ { 4 } ) \in \mathbb { R } ^ { n _ { h } }$ • $S _ { v } = \lambda _ { s } \mathtt { t a n h } ( W _ { s } h _ { 2 } + b _ { s } ) , Q _ { v } = \lambda _ { q } \mathtt { t a n h } ( W _ { q } h _ { 2 } + b _ { q } ) , T _ { v } = W _ { t } h _ { 2 } + b _ { t } .$
In Section 5.1, the $Q , S , T$ are neural networks with 2 hidden layers with 10 (100 for the 50-d ICG) units and ReLU non-linearities. We train with Adam (Kingma & Ba, 2014) and a learning rate $\alpha = 1 0 ^ { - 3 }$ . We train for 5, 000 iterations with a batch size of 200.
$\lambda _ { b }$ was set to 0 for ICG and SCG and to 1 for MoG and Rough Well. For the MoG tasks, we train our sampler with a temperature parameter that we continuously anneal; we evaluate the trained sampler without using temperature.
 Figure 4: Diagram of our L2HMC-DGLM model. Nodes are functions of their parents. Round nodes are deterministic, diamond nodes are stochastic and the doubly-circled node is observed.
# C.2 AUTO-CORRELATION AND ESS
Let $( x _ { \tau } ) _ { \tau \leq T }$ be a set of correlated samples converging to the distribution $p$ with mean $\mu$ and covariance $\Sigma$ . We define auto-correlation at time $t$ as:
$$\rho _ { t } \triangleq \frac { 1 } { \mathrm { T r a c e } ( \Sigma ) ( T - t ) } \sum _ { \tau \leq T - t - 1 } ( x _ { \tau } - \mu ) ^ { T } ( x _ { \tau + t } - \mu ) .$$
We can now define effective sample size (ESS) as:
$$\mathrm { E S S } \left( ( x _ { \tau } ) _ { \tau \leq T } \right) \triangleq \frac { 1 } { 1 + 2 \sum _ { t } \rho _ { t } } .$$
Similar to Hoffman & Gelman (2014), we truncate the sum when the auto-correlation goes below 0.05.
# C.3 COMPARISON WITH LAHMC
We compare our trained sampler with LAHMC (Sohl-Dickstein et al., 2014). Results are reported in Table 1. L2HMC largely outperforms LAHMC on all task. LAHMC is also unable to mix between modes for the MoG task. We also note that L2HMC could be easily combined with LAHMC, by replacing the leapfrog integrator of LAHMC with the learned one of L2HMC.
Table 1: ESS for a fixed number of gradient evaluations.
<table><tr><td>Distribution</td><td>Gradient Evaluations</td><td>ESS-L2HMC</td><td>ESS-LAHMC</td><td>Ratio</td></tr><tr><td>50-d ICG</td><td>2000</td><td>156.6</td><td>21.4</td><td>7.3</td></tr><tr><td>Rough Well</td><td>200</td><td>12.5</td><td>8.6</td><td>1.5</td></tr><tr><td>2-d SCG</td><td>5000</td><td>116</td><td>16.7</td><td>14.9</td></tr><tr><td>MoG</td><td>20,000</td><td>65.0</td><td><0.53</td><td>> 123.5</td></tr></table>
# D L2HMC-DGLM
# D.1 TRAINING ALGORITHM
In this section, we present our training algorithm as well as a diagram explaining L2HMC-DGLM. For conciseness, given our operator $\mathbf { L } _ { \theta }$ , we denote by $\mathbf { K } _ { \theta } ( \cdot | x )$ the distribution over next state given sampling of a momentum and direction and the Metropolis-Hastings step.
# D.2 IMPLEMENTATION DETAILS OF L2HMC-DGLM
Similar to our L2HMC training on unconditional sampling, we share weights across $Q , S$ and $T$ . In addition, the auxiliary variable $x$ (here the image from MNIST) is first passed through a 2-layer neural network, with softplus non-linearities and 512 hidden units. This input is given to both
# Algorithm 2 L2HMC for latent variable generative models
Input: dataset $\mathcal { D }$ , number of iterations $n _ { \mathrm { i t e r s } }$ , number of Metropolis-Hastings step $J$ , number of leapfrogs M , and learning rate schedule (αt)t≤niters . Randomly initialize the decoder’s parameters $\phi$ and the approximate posterior $\psi$ . Initialize the parameters of the sampler $\theta$ with $M$ leapfrog steps. for $t = 0$ to $n _ { \mathrm { i t e r s } } - 1$ do Randomly sample a minibatch $\boldsymbol { B }$ from the dataset $\mathcal { D }$ . $\mathcal { L } _ { \mathrm { E L B O } } , \mathcal { L } _ { \mathrm { S a m p l e r } } , \mathcal { L } _ { \mathrm { D e c o d e r } } 0$ for $\boldsymbol { x } ^ { ( b ) } \in B \mathrm { d } \mathbf { 0 }$ ∈Sample $\xi _ { 0 } ^ { ( b ) } \sim r ( \cdot | x ^ { ( b ) } ; \psi )$ . $\mathcal { L } _ { \mathrm { E L B O } } p ( x ^ { ( b ) } | z _ { 0 } ^ { ( b ) } ; \phi ) - \mathrm { K L } ( q _ { \psi } ( z | x ^ { ( b ) } ) | | p ( z ) )$ . With ξ(b)0 = {z(b)0 , v(b)0 , d(b)0 } Define the energy function $U _ { x ^ { ( b ) } } ( z ) = - \log p ( x ^ { ( b ) } | z ; \theta ) - \log p ( z )$ $\mathcal { L } _ { \mathrm { S a m p l e r } } 0$ $\lambda \sqrt { \mathrm { V a r } ( q _ { \psi } ( z _ { 0 } ^ { ( b ) } | x ^ { ( b ) } ) }$ for $j = 0$ to $J - 1$ do ξ (j −b) ← Rξ(b)j LSampler ← LSampler + \`λ(ξ(b)j , FLθξ(b)j , A(FLθξ(b)j |ξ(b)j )) Set $\xi _ { j + 1 } ^ { ( b ) }$ to $\mathbf { F L } _ { \theta } \boldsymbol { \xi } _ { j } ^ { ( b ) }$ with probability $A ( \mathbf { F L } _ { \theta } \xi _ { j } ^ { ( b ) } | \xi _ { j } ^ { ( b ) } )$ . $\begin{array} { r } { \begin{array} { l l } { \frac { \operatorname { c a s s a } ^ { \ast } \operatorname { s o r } } { \mathcal { L } _ { \mathrm { D e c o d e r } } } \mathcal { L } _ { \mathrm { D e c o d e r } } + \log p ( x ^ { ( b ) } | z _ { J } ^ { ( s ) } ; \phi ) } & { \qquad \mathrm { ~ s ~ W i t h ~ } \xi _ { J } ^ { ( b ) } = \{ z _ { J } ^ { ( b ) } , v _ { J } ^ { ( b ) } , d _ { J } ^ { ( b ) } \} } \end{array} } \end{array}$ end for $\begin{array} { l } { \phi \phi + \alpha _ { t } \nabla _ { \phi } \mathcal { L } _ { \mathrm { D e c o d e r } } } \\ { \psi \psi + \alpha _ { t } \nabla _ { \psi } \mathcal { L } _ { \mathrm { E L B O } } } \\ { \theta \theta + \alpha _ { t } \nabla _ { \theta } \mathcal { L } _ { \mathrm { S a m p l e r } } } \end{array}$ end for $\begin{array} { r l } { 3 } & { 0 } & { 1 \leq 9 \leq 9 \leq 2 \leq 9 \leq 5 } \\ { 2 } & { 4 \times 1 \leq 2 \leq 3 \leq 6 } \\ { 6 } & { 5 \leq 2 \leq 3 \leq 5 } \\ { 3 } & { 6 \leq 8 \leq 7 \leq 3 \leq 4 } \\ { 4 \leq 9 \leq 4 \leq 9 \leq 4 } \\ { 7 \geq 5 \leq 5 \leq 5 \leq 2 \leq 4 \leq 6 } \\ { 0 \leq 6 \leq 1 \leq 2 \leq 2 \leq 4 \leq 6 } \\ { 3 \geq 6 \leq 8 \leq 5 \leq 4 } \end{array}$ 644又9 7 1 9 9 3 / 2 3 S 6 a a 8 7 2 4 一 6 8 9 9 4 D 4 B 7 5 3 6 9 7 7 9 2 4 6 7 0 8 7 ?6 4S q 1 1 23 3 7 9 1 972 076997 090q499 65『6630295147309 h0?b414593&84076 (a) L2HMC (b) HMC (c) VAE
networks $\{ \cdot \} _ { x }$ and $\{ \cdot \} _ { v }$ . The architecture then consists of 2 hidden layers of 200 units and ReLU non-linearities. For $\lambda$ (scale parameter of the loss), we use the standard deviation of the approximate posterior.
AIS Evaluation For each data point, we run 20 Markov Chains in parallel, 10, 000 annealing steps with 10 leapfrogs per step and choose the step size for an acceptance rate of 0.65.
# D.3 MNIST SAMPLES
We show in Figure 5 samples from the three evaluated models: VAE (Kingma & Welling, 2013), HMC-DGLM (Hoffman, 2017) and L2HMC-DGLM.123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236# VISUALIZING DEEP NEURAL NETWORK DECISIONS: PREDICTION DIFFERENCE ANALYSIS
Luisa M Zintgraf1,3, Taco S Cohen1, Tameem Adel1, Max Welling1,2 1University of Amsterdam, 2Canadian Institute of Advanced Research, 3Vrije Universiteit Brussel {lmzintgraf,tameem.hesham}@gmail.com, {t.s.cohen, m.welling}@uva.nl
# ABSTRACT
This article presents the prediction difference analysis method for visualizing the response of a deep neural network to a specific input. When classifying images, the method highlights areas in a given input image that provide evidence for or against a certain class. It overcomes several shortcoming of previous methods and provides great additional insight into the decision making process of classifiers. Making neural network decisions interpretable through visualization is important both to improve models and to accelerate the adoption of black-box classifiers in application areas such as medicine. We illustrate the method in experiments on natural images (ImageNet data), as well as medical images (MRI brain scans).
# 1 INTRODUCTION
Over the last few years, deep neural networks (DNNs) have emerged as the method of choice for perceptual tasks such as speech recognition and image classification. In essence, a DNN is a highly complex non-linear function, which makes it hard to understand how a particular classification comes about. This lack of transparency is a significant impediment to the adoption of deep learning in areas of industry, government and healthcare where the cost of errors is high.
In order to realize the societal promise of deep learning - e.g., through self-driving cars or personalized medicine - it is imperative that classifiers learn to explain their decisions, whether it is in the lab, the clinic, or the courtroom. In scientific applications, a better understanding of the complex dependencies learned by deep networks could lead to new insights and theories in poorly understood domains.
In this paper, we present a new, probabilistically sound methodology for explaining classification decisions made by deep neural networks. The method can be used to produce a saliency map for each (instance, node) pair that highlights the parts (features) of the input that constitute most evidence for or against the activation of the given (internal or output) node. See figure 1 for an example.
In the following two sections, we review related work and then present our approach. In section 4 we provide several demonstrations of our technique for deep convolutional neural networks (DCNNs) trained on ImageNet data, and further how the method can be applied when classifying MRI brain scans of HIV patients with neurodegenerative disease.
 Figure 1: Example of our visualization method: explains why the DCNN (GoogLeNet) predicts "cockatoo". Shown is the evidence for (red) and against (blue) the prediction. We see that the facial features of the cockatoo are most supportive for the decision, and parts of the body seem to constitute evidence against it. In fact, the classifier most likely considers them evidence for the second-highest scoring class, white wolf.
# 2 RELATED WORK
Broadly speaking, there are two approaches for understanding DCNNs through visualization investigated in the literature: find an input image that maximally activates a given unit or class score to visualize what the network is looking for (Erhan et al., 2009; Simonyan et al., 2013; Yosinski et al., 2015), or visualize how the network responds to a specific input image in order to explain a particular classification made by the network. The latter will be the subject of this paper.
One such instance-specific method is class saliency visualization proposed by Simonyan et al. (2013) who measure how sensitive the classification score is to small changes in pixel values, by computing the partial derivative of the class score with respect to the input features using standard backpropagation. They also show that there is a close connection to using deconvolutional networks for visualization, proposed by Zeiler & Fergus (2014). Other methods include Shrikumar et al. (2016), who compare the activation of a unit when a specific input is fed forward through the net to a reference activation for that unit. Zhou et al. (2016) and Bach et al. (2015) also generate interesting visualization results for individual inputs, but are both not as closely related to our method as the two papers mentioned above. The idea of our method is similar to another analysis Zeiler & Fergus (2014) make: they estimate the importance of input pixels by visualizing the probability of the (correct) class as a function of a gray patch occluding parts of the image. In this paper, we take a more rigorous approach at both removing information from the image and evaluating the effect of this.
In the field of medical image classification specifically, a widely used method for visualizing feature importances is to simply plot the weights of a linear classifier (Klöppel et al., 2008; Ecker et al., 2010), or the p-values of these weights (determined by permutation testing) (Mourao-Miranda et al., 2005; Wang et al., 2007). These are independent of the input image, and, as argued by Gaonkar & Davatzikos (2013) and Haufe et al. (2014), interpreting these weights can be misleading in general.
The work presented in this paper is based on an instance-specific method by Robnik-Šikonja & Kononenko (2008), the prediction difference analysis, which is reviewed in the next section. Our main contributions are three substantial improvements of this method: conditional sampling (section 3.1), multivariate analysis (section 3.2), and deep visualization (section 3.3).
# 3 APPROACH
Our method is based on the technique presented by Robnik-Šikonja & Kononenko (2008), which we will now review. For a given prediction, the method assigns a relevance value to each input feature with respect to a class $c$ . The basic idea is that the relevance of a feature $x _ { i }$ can be estimated by measuring how the prediction changes if the feature is unknown, i.e., the difference between $p ( c | \mathbf { x } )$ and $p ( c | \mathbf { x } _ { \backslash i } )$ , where $\mathbf { x } _ { \backslash i }$ denotes the set of all input features except $x _ { i }$ .
To find $p ( c | \mathbf { x } _ { \backslash i } )$ , i.e., evaluate the prediction when a feature is unknown, the authors propose three strategies. The first is to label the feature as unknown (which only few classifiers allow). The second is to re-train the classifier with the feature left out (which is clearly infeasible for DNNs and high-dimensional data like images). The third approach is to simulate the absence of a feature by marginalizing the feature:
$$p ( c | \mathbf { x } _ { \backslash i } ) = \sum _ { x _ { i } } p ( x _ { i } | \mathbf { x } _ { \backslash i } ) p ( c | \mathbf { x } _ { \backslash i } , x _ { i } )$$
(with the sum running over all possible values for $x _ { i }$ ). However, modeling $p ( x _ { i } | \mathbf { x } _ { \backslash i } )$ can easily become infeasible with a large number of features. Therefore, the authors approximate equation (1) by assuming that feature $x _ { i }$ is independent of the other features, $\mathbf { x } _ { \backslash i }$ :
$$p ( c | \mathbf { x } _ { \backslash i } ) \approx \sum _ { x _ { i } } p ( x _ { i } ) p ( c | \mathbf { x } _ { \backslash i } , x _ { i } ) .$$
The prior probability $p ( x _ { i } )$ is usually approximated by the empirical distribution for that feature.
Once the class probability $p ( c | \mathbf { x } _ { \backslash i } )$ is estimated, it can be compared to $p ( c | \mathbf { x } )$ . We stick to an evaluation proposed by the authors referred to as weight of evidence, given by
$$\begin{array} { r } { \mathbf { W E } _ { i } ( c | \mathbf { x } ) = \log _ { 2 } \left( \operatorname { o d d s } ( c | \mathbf { x } ) \right) - \log _ { 2 } \left( \operatorname { o d d s } ( c | \mathbf { x } _ { \backslash i } ) \right) , } \end{array}$$
 Figure 2: Simple illustration of the sampling procedure in algorithm 1. Given the input image $x$ , we select every possible patch $x _ { w }$ (in a sliding window fashion) of size $k \times k$ and place a larger patch $\hat { x } _ { w }$ of size $l \times l$ around it. We can then conditionally sample $x _ { w }$ by conditioning on the surrounding patch $\hat { x } _ { w }$ .
Algorithm 1 Evaluating the prediction difference using conditional and multivariate sampling Input: classifier with outputs $\mathsf { p } ( \mathsf { c } | \mathbf { x } )$ , input image $\mathbf { x }$ of size $n \times n$ , inner patch size $k$ , outer patch size $l > k$ , class of interest $c$ , probabilistic model over patches of size $l \times l$ , number of samples $S$ Initialization: $\mathrm { W E = z e r o s ( n ^ { * } n ) }$ , counts $\mathbf { \mu } _ { \mathrm { : } } = \mathbf { Z } \mathbf { e }$ ros $( \mathfrak { n } ^ { * } \mathfrak { n } )$ for every patch $\mathbf { x } _ { w }$ of size $k \times k$ in $\mathbf { x }$ do $\mathbf { x } ^ { \prime } = { \bar { \mathrm { c o p y } } } ( \mathbf { x } )$ $\mathrm { s u m } _ { w } = 0$ define patch $\hat { \mathbf { x } } _ { w }$ of size $l \times l$ that contains $\mathbf { x } _ { w }$ for $s = 1$ to $S$ do $\mathbf { x } _ { w } ^ { \prime } \gets \mathbf { x } _ { w }$ sampled from $p ( \mathbf { x } _ { w } | \hat { \mathbf { x } } _ { w } \backslash \mathbf { x } _ { w } )$ $\mathrm { s u m } _ { w } \mathrel { + { = } } p ( c | \mathbf { x } ^ { \prime } )$ . evaluate classifier end for $p ( c | \mathbf x \backslash \mathbf x _ { w } ) : = \mathtt { s u m } _ { w } / S$ WE[coordinates of $\mathbf { x } _ { w } ] + = \log _ { 2 } ( \operatorname { o d d s } ( c | \mathbf { x } ) ) - \log _ { 2 } ( \operatorname { o d d s } ( c | \mathbf { x } \backslash \mathbf { x } _ { w } ) )$ counts[coordinates of $\mathbf { x } _ { w } ] + = 1$ end for Output: WE / counts . point-wise division where $\mathrm { o d d s } ( c | \mathbf { x } ) = p ( c | \mathbf { x } ) / ( 1 - p ( c | \mathbf { x } ) )$ . To avoid problems with zero probabilities, Laplace correction $p \gets ( p N + 1 ) / ( N + K )$ is used, where $N$ is the number of training instances and $K$ the number of classes.
The method produces a relevance vector $( \mathrm { W E } _ { i } ) _ { i = 1 \dots m }$ ( $\textbar { m }$ being the number of features) of the same size as the input, which reflects the relative importance of all features. A large prediction difference means that the feature contributed substantially to the classification, whereas a small difference indicates that the feature was not important for the decision. A positive value $\mathrm { W E } _ { i }$ means that the feature has contributed evidence for the class of interest: removing it would decrease the confidence of the classifier in the given class. A negative value on the other hand indicates that the feature displays evidence against the class: removing it also removes potentially conflicting or irritating information and the classifier becomes more certain in the investigated class.
# 3.1 CONDITIONAL SAMPLING
In equation (3), the conditional probability $p ( x _ { i } | \mathbf { x } _ { \backslash i } )$ of a feature $x _ { i }$ is approximated using the marginal distribution $p ( x _ { i } )$ . This is a very crude approximation. In images for example, a pixel’s value is highly dependent on other pixels. We propose a much more accurate approximation, based on the following two observations: a pixel depends most strongly on a small neighborhood around it, and the conditional of a pixel given its neighborhood does not depend on the position of the pixel in the image. For a pixel $x _ { i }$ , we can therefore find a patch $\hat { \mathbf { x } } _ { i }$ of size $l \times l$ that contains $x _ { i }$ , and condition on the remaining pixels in that patch:
$$p ( x _ { i } | \mathbf { x } _ { \backslash i } ) \approx p ( x _ { i } | \hat { \mathbf { x } } _ { \backslash i } ) .$$
This greatly improves the approximation while remaining completely tractable.
For a feature to become relevant when using conditional sampling, it now has to satisfy two conditions: being relevant to predict the class of interest, and be hard to predict from the neighboring pixels. Relative to the marginal method, we therefore downweight the pixels that can easily be predicted and are thus redundant in this sense.
# 3.2 MULTIVARIATE ANALYSIS
Robnik-Šikonja & Kononenko (2008) take a univariate approach: only one feature at a time is removed. However, we would expect that a neural network is relatively robust to just one feature of a high-dimensional input being unknown, like a pixel in an image. Therefore, we will remove several features at once by again making use of our knowledge about images by strategically choosing these feature sets: patches of connected pixels. Instead of going through all individual pixels, we go through all patches of size $k \times k$ in the image ( $k \times k \times 3$ for RGB images and $k \times k \times k$ for 3D images like MRI scans), implemented in a sliding window fashion. The patches are overlapping, so that ultimately an individual pixel’s relevance is obtained by taking the average relevance obtained from the different patches it was in.
Algorithm 1 and figure 2 illustrate how the method can be implemented, incorporating the proposed improvements.
# 3.3 DEEP VISUALIZATION OF HIDDEN LAYERS
When trying to understand neural networks and how they make decisions, it is not only interesting to analyze the input-output relation of the classifier, but also to look at what is going on inside the hidden layers of the network. We can adapt the method to see how the units of any layer of the network influence a node from a deeper layer. Mathematically, we can formulate this as follows. Let h be the vector representation of the values in a layer $H$ in the network (after forward-propagating the input up to this layer). Further, let $z = z ( \mathbf { h } )$ be the value of a node that depends on $\mathbf { h }$ , i.e., a node in a subsequent layer. Then the analog of equation (2) is given by the expectation:
$$g ( z | \mathbf { h } _ { \setminus i } ) \equiv \mathbb { E } _ { p ( h _ { i } | \mathbf { h } _ { \setminus i } ) } \left[ z ( \mathbf { h } ) \right] = \sum _ { h _ { i } } p ( h _ { i } | \mathbf { h } _ { \setminus i } ) z ( \mathbf { h } _ { \setminus i } , h _ { i } ) ,$$
which expresses the distribution of $z$ when unit $h _ { i }$ in layer $H$ is unobserved. The equation now works for arbitrary layer/unit combinations, and evaluates to the same as equation (1) when the input-output relation is analyzed. To evaluate the difference between $g ( z | \mathbf { h } )$ and $g ( z | \mathbf { h } _ { \backslash i } )$ , we will in general use the activation difference, $\mathrm { A D } _ { i } ( z | \mathbf { h } ) = g ( z | \mathbf { h } ) - g ( z | \mathbf { h } _ { \backslash i } )$ , for the case when we are not dealing with probabilities (and equation (3) is not applicable).
# 4 EXPERIMENTS
In this section, we illustrate how the proposed visualization method can be applied, on the ImageNet dataset of natural images when using DCNNs (section 4.1), and on a medical imaging dataset of MRI scans when using a logistic regression classifier (section 4.2). For marginal sampling we always use the empirical distribution, i.e., we replace a feature (patch) with samples taken directly from other images, at the same location. For conditional sampling we use a multivariate normal distribution. For both sampling methods we use 10 samples to estimate $p ( c | \mathbf { x } _ { \backslash i } )$ (since no significant difference was observed with more samples). Note that all images are best viewed digital and in color.
Our implementation is available at github.com/lmzintgraf/DeepVis-PredDiff.
# 4.1 IMAGENET: UNDERSTANDING HOW A DCNN MAKES DECISIONS
We use images from the ILSVRC challenge (Russakovsky et al., 2015) (a large dataset of natural images from 1000 categories) and three DCNNs: the AlexNet (Krizhevsky et al., 2012), the GoogLeNet (Szegedy et al., 2015) and the (16-layer) VGG network (Simonyan & Zisserman, 2014). We used the publicly available pre-trained models that were implemented using the deep learning framework caffe (Jia et al., 2014). Analyzing one image took us on average 20, 30 and 70 minutes for the respective classifiers AlexNet, GoogLeNet and VGG (using the GPU implementation of caffe and mini-batches with the standard settings of 10 samples and a window size of $k = 1 0$ ).
The results shown here are chosen from among a small set of images in order to show a range of behavior of the algorithm. The shown images are quite representative of the performance of the method in general. Examples on randomly selected images, including a comparison to the sensitivity analysis of Simonyan et al. (2013), can be seen in appendix A.
 Figure 3: Visualization of the effects of marginal versus conditional sampling using the GoogLeNet classifier. The classifier makes correct predictions (ostrich and saxophone), and we show the evidence for (red) and against (blue) this decision at the output layer. We can see that conditional sampling gives more targeted explanations compared to marginal sampling. Also, marginal sampling assigns too much importance on pixels that are easily predictable conditioned on their neighboring pixels.
 Figure 4: Visualization of how different window sizes influence the visualization result. We used the conditional sampling method and the AlexNet classifier with $l = k + 4$ and varying $k$ . We can see that even when removing single pixels $k = 1 ,$ ), this has a noticeable effect on the classifier and more important pixels get a higher score. By increasing the window size we can get a more easily interpretable, smooth result until the image gets blurry for very large window sizes.
We start this section by demonstrating our proposed improvements (sections 3.1 - 3.3).
# Marginal vs Conditional Sampling
Figure 3 shows visualizations of the spatial support for the highest scoring class, using marginal and conditional sampling (with $k = 1 0$ and $l = 1 4$ ). We can see that conditional sampling leads to results that are more refined in the sense that they concentrate more around the object. We can also see that marginal sampling leads to pixels being declared as important that are very easily predictable conditioned on their neighboring pixels (like in the saxophone example). Throughout our experiments, we have found that conditional sampling tends to give more specific and fine-grained results than marginal sampling. For the rest of our experiments, we therefore show results using conditional sampling only.
# Multivariate Analysis
For ImageNet data, we have observed that setting $k = 1 0$ gives a good trade-off between sharp results and a smooth appearance. Figure 4 shows how different window sizes influence the resolution of the visualization. Surprisingly, removing only one pixel does have a measurable effect on the prediction, and the largest effect comes from sensitive pixels. We expected that removing only one pixel does not have any effect on the classification outcome, but apparently the classifier is sensitive even to these small changes. However when using such a small window size, it is difficult to make sense of the sign information in the visualization. If we want to get a good impression of which parts in the image are evidence for/against a class, it is therefore better to use larger windows. If $k$ is chosen too large however, the results tend to get blurry. Note that these results are not just simple averages of one another, but a multivariate approach is indeed necessary to observe the presented results.
# Deep Visualization of Hidden Network Layers
Our third main contribution is the extension of the method to neural networks; to understand the role of hidden layers in a DNN. Figure 5 shows how different feature maps in three different layers of the GoogLeNet react to the input of a tabby cat (see figure 6, middle image). For each feature map in a convolutional layer, we first compute the relevance of the input image for each hidden unit in that map. To estimate what the feature map as a whole is doing, we show the average of the relevance vectors over all units in that feature map. The first convolutional layer works with different types of simple image filters (e.g., edge detectors), and what we see is which parts of the input image respond positively or negatively to these filters. The layer we picked from somewhere in the middle of the network is specialized to higher level features (like facial features of the cat). The activations of the last convolutional layer are very sparse across feature channels, indicating that these units are highly specialized.
 Figure 5: Visualization of feature maps from thee different layers of the GoogLeNet (l.t.r.: ”conv $1 / 7 \mathrm { x } 7 \_ \mathrm { s } 2 ^ { \cdot \prime }$ , ”inception_3a/output”, ”inception_5b/output”), using conditional sampling and patch sizes $k = 1 0$ and $l = 1 4$ (see alg. 1). For each feature map in the convolutional layer, we first evaluate the relevance for every single unit, and then average the results over all the units in one feature map to get a sense of what the unit is doing as a whole. Red pixels activate a unit, blue pixels decreased the activation.
 Figure 6: Visualization of three different feature maps, taken from the ”inception_ $3 \mathrm { a } I$ output” layer of the GoogLeNet (from the middle of the network). Shown is the average relevance of the input features over all activations of the feature map. We used patch sizes $k = 1 0$ and $l = 1 4$ (see alg. 1). Red pixels activate a unit, blue pixels decreased the activation.
To get a sense of what single feature maps in convolutional layers are doing, we can look at their visualization for different input images and look for patterns in their behavior. Figure 6 shows this for four different feature maps from a layer from the middle of the GoogLeNet network. We can directly see which kind of features the model has learned at this stage in the network. For example, one feature map is mostly activated by the eyes of animals (third row), and another is looking mostly at the background (last row).
# Penultimate vs Output Layer
If we visualize the influence of the input features on the penultimate (pre-softmax) layer, we show only the evidence for/against this particular class, without taking other classes into consideration. After the softmax operation however, the values of the nodes are all interdependent: a drop in the probability for one class could be due to less evidence for it, or because a different class becomes more likely. Figure 7 compares visualizations for the last two layers. By looking at the top three scoring classes, we can see that the visualizations in the penultimate layer look very similar if the classes are similar (like different dog breeds). When looking at the output layer however, they look rather different. Consider the case of the elephants: the top three classes are different elephant subspecies, and the visualizations of the penultimate layer look similar since every subspecies can be identified by similar characteristics. But in the output layer, we can see how the classifier decides for one of the three types of elephants and against the others: the ears in this case are the crucial difference.
 Figure 7: Visualization of the support for the top-three scoring classes in the penultimate- and output layer. Next to the input image, the first row shows the results with respect to the penultimate layer; the second row with respect to the output layer. For each image, we additionally report the values of the units. We used the AlexNet with conditional sampling and patch sizes $k = 1 0$ and $l = 1 4$ (see alg. 1). Red pixels are evidence for a class, and blue against it.
 Figure 8: Comparison of the prediction visualization of different DCNN architectures. For two input images, we show the results of the prediction difference analysis when using different neural networks - the AlexNet, GoogLeNet and VGG network.
# Network Comparison
When analyzing how neural networks make decisions, we can also compare how different network architectures influence the visualization. Here, we tested our method on the AlexNet, the GoogLeNet and the VGG network. Figure 8 shows the results for the three different networks, on two input images. The AlexNet seems to more on contextual information (the sky in the balloon image), which could be attributed to it having the least complex architecture compared to the other two networks. It is also interesting to see that the VGG network deems the basket of the balloon as very important compared to all other pixels. The second highest scoring class in this case was a parachute - presumably, the network learned to not confuse a balloon with a parachute by detecting a square basket (and not a human).
# 4.2 MRI DATA: EXPLAINING CLASSIFIER DECISIONS IN MEDICAL IMAGING
To illustrate how our visualization method can also be useful in a medical domain, we show some experimental results on an MRI dataset of HIV and healthy patients. In such settings, it is crucial that the practitioner has some insight into the algorithm’s decision when classifying a patient, to weigh this information and incorporate it in the overall diagnosis process.
The dataset used here is referred to as the COBRA dataset. It contains 3D MRIs from $1 0 0 \ \mathrm { H I V }$ patients and 70 healthy individuals, included in the Academic Medical Center (AMC) in Amsterdam, The Netherlands. Of these subjects, diffusion weighted MRI data were acquired. Preprocessing of the data was performed with software developed in-house, using the HPCN-UvA Neuroscience Gateway and using resources of the Dutch e-Science Grid Shahand et al. (2015). As a result, Fractional Anisotropy (FA) maps were computed. FA is sensitive to microstructural damage and therefore expected to be, on average, decreased in patients. Subjects were scanned on two 3.0 Tesla scanner systems, 121 subjects on a Philips Intera system and 39 on a Philips Ingenia system. Patients and controls were evenly distributed. FA images were spatially normalized to standard space Andersson et al. (2007), resulting in volumes with $9 1 \times 1 0 9 \times 9 1 = 9 0 2 , 6 2 9$ voxels.
We trained an L2-regularized Logistic Regression classifier on a subset of the MRI slices (slices 29-40 along the first axis) and on a balanced version of the dataset (by taking the first 70 samples of the HIV class) to achieve an accuracy of $6 9 . 3 \%$ in a 10-fold cross-validation test. Analyzing one image took around half an hour (on a CPU, with $k = 3$ and $l = 7$ , see algorithm 1). For conditional sampling, we also tried adding location information in equation (2), i.e., we split up the 3D image into a $2 0 \times 2 0 \times 2 0$ grid and also condition on the index in that grid. We found that this slightly improved the interpretability of the results, since the pixel values in the special case of MRI scans does depend on spacial location as well.
Figure 9 (first row) shows one way via which the prediction difference results could be presented to a physician, for an HIV sample. By overlapping the prediction difference and the MRI image, the exact regions can be pointed out that are evidence for (red parts) or against (blue parts) the classifier’s decision. The second row shows the results using the weights of the logistic regression classifier, which is a commonly used method in neuroscientific literature. We can see that they are considerably noisier (in the sense that, compared to our method, the voxels relevant for the classification decisions are more scattered), and also, they are not specific to the given image. Figure 10 shows the visualization results for four healthy, and four HIV samples. We can clearly see that the patterns for the two classes are distinct, and there is some pattern to the decision of the classifier, but which is still specific to the input image. Figure 11 shows the same (HIV) sample as in figure 9 along different axes, and figure 12 shows how the visualization changes with different patch sizes. We believe that both varying the slice and patch size can give different insights to a clinician, and in clinical practice, a 3D animation where these parameters can be adjusted would be very useful for analyzing the visualization result.
In general we can assume that the better the classifier, the closer the explanations for its decisions are to the true class difference. For clinical practice it is therefore crucial to have very good classifiers. This will increase computation time, but in many medical settings, longer waiting times for test results are common and worth the wait if the patient is not in an acute life threatening condition (e.g., when predicting HIV or Alzheimer from MRI scans, or the field of cancer diagnosis and detection). The presented results here are for demonstration purposes of the visualization method, and we claim no medical validity. A thorough qualitative analysis incorporating expert knowledge was outside the scope of this paper.
# 5 FUTURE WORK
In our experiments, we used a simple multivariate normal distribution for conditional sampling. We can imagine that using more sophisticated generative models will lead to better results: pixels that are easily predictable by their surrounding are downweighted even more. However this will also significantly increase the computational resources needed to produce the explanations. Similarly, we could try to modify equation (4) to get an even better approximation by using a conditional distribution that takes more information about the whole image into account (like adding spatial information for the MRI scans).
To make the method applicable for clinical analysis and practice, a better classification algorithm is required. Also, software that visualizes the results as an interactive 3D model will improve the usability of the system.
# 6 CONCLUSION
We presented a new method for visualizing deep neural networks that improves on previous methods by using a more powerful conditional, multivariate model. The visualization method shows which pixels of a specific input image are evidence for or against a node in the network. The signed information offers new insights - for research on the networks, as well as the acceptance and usability in domains like healthcare. While our method requires significant computational resources, real-time 3D visualization is possible when visualizations are pre-computed. With further optimization and powerful GPUs, pre-computation time can be reduced a lot further. In our experiments, we have presented several ways in which the visualization method can be put into use for analyzing how DCNNs make decisions.
 Figure 9: Visualization of the support for the correct classification ”HIV”, using the Prediction Difference method and Logistic Regression Weights. For an HIV sample, we show the results with the prediction difference (first row), and using the weights of the logistic regression classifier (second row), for slices 29 and 40 (along the first axis). Red are positive values, and blue negative. For each slice, the left image shows the original image, overlaid with the relevance values. The right image shows the original image with reversed colors and the relevance values. Relevance values are shown only for voxels with (absolute) relevance value above $1 5 \%$ of the (absolute) maximum value.
 Figure 10: Prediction difference visualization for different samples. The first four samples are of the class ”healthy”; the last four of the class ”HIV”. All images show slice 39 (along the first axis). All samples are correctly classified, and the results show evidence for (red) and against (blue) this decision. Prediction differences are shown only for voxels with (absolute) relevance value above $1 5 \%$ of the (absolute) maximum value.
 Figure 11: Visualization results across different slices of the MRI image, using the same input image as shown in 9. Prediction differences are shown only for voxels with (absolute) relevance value above $1 5 \%$ of the (absolute) maximum value.
 Figure 12: How the patch size influences the visualization. For the input image (HIV sample, slice 39 along the first axis) we show the visualization with different patch sizes $k$ in alg. 1). Prediction differences are shown only for voxels with (absolute) relevance value above $1 5 \%$ of the (absolute) maximum (for $k = 2$ it is $10 \%$ ).
# ACKNOWLEDGMENTS
This work was supported by AWS in Education Grant award. We thank Facebook and Google for financial support, and our reviewers for their time and valuable, constructive feedback.
This work was also in part supported by: Innoviris, the Brussels Institute for Research and Innovation, Brussels, Belgium; the Nuts-OHRA Foundation (grant no. 1003-026), Amsterdam, The Netherlands; The Netherlands Organization for Health Research and Development (ZonMW) together with AIDS Fonds (grant no 300020007 and 2009063). Additional unrestricted scientific grants were received from Gilead Sciences, ViiV Healthcare, Janssen Pharmaceutica N.V., Bristol-Myers Squibb, Boehringer Ingelheim, and Merck&Co.
We thank Barbara Elsenga, Jane Berkel, Sandra Moll, Maja Totté, and Marjolein Martens for running the AGEhIV study program and capturing our data with such care and passion. We thank Yolanda Ruijs-Tiggelman, Lia Veenenberg-Benschop, Sima Zaheri, and Mariska Hillebregt at the HIV Monitoring Foundation for their contributions to data management. We thank Aafien Henderiks and Hans-Erik Nobel for their advice on logistics and organization at the Academic Medical Center. We thank all HIV-physicians and HIV-nurses at the Academic Medical Center for their efforts to include the HIV-infected participants into the AGEhIV Cohort Study, and the Municipal Health Service Amsterdam personnel for their efforts to include the HIV-uninfected participants into the AGEhIV Cohort Study. We thank all study participants without whom this research would not be possible.
AGEhIV Cohort Study Group. Scientific oversight and coordination: P. Reiss (principal investigator), F.W.N.M. Wit, M. van der Valk, J. Schouten, K.W. Kooij, R.A. van Zoest, E. Verheij, B.C. Elsenga (Academic Medical Center (AMC), Department of Global Health and Amsterdam Institute for Global Health and Development (AIGHD)). M. Prins (co-principal investigator), M.F. Schim van der Loeff, M. Martens, S. Moll, J. Berkel, M. Totté, G.R. Visser, L. May, S. Kovalev, A. Newsum, M. Dijkstra (Public Health Service of Amsterdam, Department of Infectious Diseases). Datamanagement: S. Zaheri, M.M.J. Hillebregt, Y.M.C. Ruijs, D.P. Benschop, A. el Berkaoui (HIV Monitoring Foundation). Central laboratory support: N.A. Kootstra, A.M. Harskamp-Holwerda, I. Maurer, T. Booiman, M.M. Mangas Ruiz, A.F. Girigorie, B. Boeser-Nunnink (AMC, Laboratory for Viral Immune Pathogenesis and Department of Experimental Immunology). Project management and administrative support: W. Zikkenheiner, F.R. Janssen (AIGHD). Participating HIV physicians and nurses: S.E. Geerlings, M.H. Godfried, A. Goorhuis, J.W.R. Hovius, J.T.M. van der Meer, F.J.B. Nellen, T. van der Poll, J.M. Prins, P. Reiss, M. van der Valk, W.J. Wiersinga, M. van Vugt, G. de Bree, F.W.N.M. Wit; J. van Eden, A.M.H. van Hes, M. Mutschelknauss , H.E. Nobel, F.J.J. Pijnappel, M. Bijsterveld, A. Weijsenfeld, S. Smalhout (AMC, Division of Infectious Diseases). Other collaborators: J. de Jong, P.G. Postema (AMC, Department of Cardiology); P.H.L.T. Bisschop, M.J.M. Serlie (AMC, Division of Endocrinology and Metabolism); P. Lips (Free University Medical Center Amsterdam); E. Dekker (AMC, Department of Gastroenterology); N. van der Velde (AMC, Division of Geriatric Medicine); J.M.R. Willemsen, L. Vogt (AMC, Division of Nephrology); J. Schouten, P. Portegies, B.A. Schmand, G.J. Geurtsen (AMC, Department of Neurology); F.D. Verbraak, N. Demirkaya (AMC, Department of Ophthalmology); I. Visser (AMC, Department of Psychiatry); A. Schadé (Free University Medical Center Amsterdam, Department of Psychiatry); P.T. Nieuwkerk, N. Langebeek (AMC, Department of Medical Psychology); R.P. van Steenwijk, E. Dijkers (AMC, Department of Pulmonary medicine); C.B.L.M. Majoie, M.W.A. Caan, T. Su (AMC, Department of Radiology); H.W. van Lunsen, M.A.F. Nievaard (AMC, Department of Gynaecology); B.J.H. van den Born, E.S.G. Stroes, (AMC, Division of Vascular Medicine); W.M.C. Mulder (HIV Vereniging Nederland).
# REFERENCES
Jesper LR Andersson, Mark Jenkinson, and Stephen Smith. Non-linear optimisation. fmrib technical report tr07ja1. University of Oxford FMRIB Centre: Oxford, UK, 2007.
Sebastian Bach, Alexander Binder, Grégoire Montavon, Frederick Klauschen, Klaus-Robert Müller, and Wojciech Samek. On pixel-wise explanations for non-linear classifier decisions by layer-wise relevance propagation. PloS one, 10(7):e0130140, 2015.
Christine Ecker, Andre Marquand, Janaina Mourão-Miranda, Patrick Johnston, Eileen M Daly, Michael J Brammer, Stefanos Maltezos, Clodagh M Murphy, Dene Robertson, Steven C Williams, et al. Describing the brain in autism in five dimensions—magnetic resonance imaging-assisted diagnosis of autism spectrum disorder using a multiparameter classification approach. The Journal of Neuroscience, 30(32):10612–10623, 2010.
Dumitru Erhan, Yoshua Bengio, Aaron Courville, and Pascal Vincent. Visualizing higher-layer features of a deep network. Dept. IRO, Université de Montréal, Tech. Rep, 4323, 2009.
Bilwaj Gaonkar and Christos Davatzikos. Analytic estimation of statistical significance maps for support vector machine based multi-variate image analysis and classification. NeuroImage, 78:270–283, 2013.
Stefan Haufe, Frank Meinecke, Kai Görgen, Sven Dähne, John-Dylan Haynes, Benjamin Blankertz, and Felix Bießmann. On the interpretation of weight vectors of linear models in multivariate neuroimaging. Neuroimage, 87:96–110, 2014.
Yangqing Jia, Evan Shelhamer, Jeff Donahue, Sergey Karayev, Jonathan Long, Ross Girshick, Sergio Guadarrama, and Trevor Darrell. Caffe: Convolutional architecture for fast feature embedding. arXiv preprint arXiv:1408.5093, 2014.
Stefan Klöppel, Cynthia M Stonnington, Carlton Chu, Bogdan Draganski, Rachael I Scahill, Jonathan D Rohrer, Nick C Fox, Clifford R Jack, John Ashburner, and Richard SJ Frackowiak. Automatic classification of mr scans in alzheimer’s disease. Brain, 131(3):681–689, 2008.
Alex Krizhevsky, Ilya Sutskever, and Geoffrey E Hinton. Imagenet classification with deep convolutional neural networks. In Advances in neural information processing systems, pp. 1097–1105, 2012.
Janaina Mourao-Miranda, Arun LW Bokde, Christine Born, Harald Hampel, and Martin Stetter. Classifying brain states and determining the discriminating activation patterns: Support vector machine on functional mri data. NeuroImage, 28(4):980–995, 2005.
Marko Robnik-Šikonja and Igor Kononenko. Explaining classifications for individual instances. Knowledge and Data Engineering, IEEE Transactions on, 20(5):589–600, 2008.
Olga Russakovsky, Jia Deng, Hao Su, Jonathan Krause, Sanjeev Satheesh, Sean Ma, Zhiheng Huang, Andrej Karpathy, Aditya Khosla, Michael Bernstein, Alexander C. Berg, and Li Fei-Fei. ImageNet Large Scale Visual Recognition Challenge. International Journal of Computer Vision (IJCV), 115(3):211–252, 2015. doi: 10.1007/s11263-015-0816-y.
Shayan Shahand, Ammar Benabdelkader, Mohammad Mahdi Jaghoori, Mostapha al Mourabit, Jordi Huguet, Matthan WA Caan, Antoine HC Kampen, and Sílvia D Olabarriaga. A data-centric neuroscience gateway: design, implementation, and experiences. Concurrency and Computation: Practice and Experience, 27(2): 489–506, 2015.
Avanti Shrikumar, Peyton Greenside, Anna Shcherbina, and Anshul Kundaje. Not just a black box: Learning important features through propagating activation differences. arXiv preprint arXiv:1605.01713, 2016.
Karen Simonyan and Andrew Zisserman. Very deep convolutional networks for large-scale image recognition. arXiv preprint arXiv:1409.1556, 2014.
Karen Simonyan, Andrea Vedaldi, and Andrew Zisserman. Deep inside convolutional networks: Visualising image classification models and saliency maps. arXiv preprint arXiv:1312.6034, 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.
Ze Wang, Anna R Childress, Jiongjiong Wang, and John A Detre. Support vector machine learning-based fmri data group analysis. NeuroImage, 36(4):1139–1151, 2007.
Jason Yosinski, Jeff Clune, Anh Nguyen, Thomas Fuchs, and Hod Lipson. Understanding neural networks through deep visualization. arXiv preprint arXiv:1506.06579, 2015.
Matthew D Zeiler and Rob Fergus. Visualizing and understanding convolutional networks. In Computer vision–ECCV 2014, pp. 818–833. Springer, 2014.
Bolei Zhou, Aditya Khosla, Agata Lapedriza, Aude Oliva, and Antonio Torralba. Learning deep features for discriminative localization. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pp. 2921–2929, 2016.
# A RANDOM RESULTS
 Figure 13: Results on 34 randomly chosen ImageNet images. Middle columns: original image; left columns: sensitivity maps (Simonyan et al., 2013) where the red pixels indicate high sensitivity, and white pixels mean no sensitivity (note that we show the absolute values of the partial derivatives, since the sign cannot be interpreted like in our method); right columns: results from our method. For both methods, we visualize the results with respect to the correct class which is given above the image. In brackets we see how the classifier ranks this class, i.e., a (1) means it was correctly classified, whereas a (4) means that it was misclassified, and the correct class was ranked fourth. For our method, red areas show evidence for the correct class, and blue areas show evidence against the class (e.g., the scuba diver looks more like a tea pot to the classifier).123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567# CONSERVATIVE UNCERTAINTY ESTIMATION BY FITTING PRIOR NETWORKS
Kamil Ciosek1, Vincent Fortuin1,2, Ryota Tomioka1, Katja Hofmann1, Richard Turner1,3
# ABSTRACT
Obtaining high-quality uncertainty estimates is essential for many applications of deep neural networks. In this paper, we theoretically justify a scheme for estimating uncertainties, based on sampling from a prior distribution. Crucially, the uncertainty estimates are shown to be conservative in the sense that they never underestimate a posterior uncertainty obtained by a hypothetical Bayesian algorithm. We also show concentration, implying that the uncertainty estimates converge to zero as we get more data. Uncertainty estimates obtained from random priors can be adapted to any deep network architecture and trained using standard supervised learning pipelines. We provide experimental evaluation of random priors on calibration and out-of-distribution detection on typical computer vision tasks, demonstrating that they outperform deep ensembles in practice.
# 1 INTRODUCTION
Deep learning has achieved huge success in many applications. In particular, increasingly often, it is used as a component in decision-making systems. In order to have confidence in decisions made by such systems, it is necessary to obtain good uncertainty estimates, which quantify how certain the network is about a given output. In particular, if the cost of failure is large, for example where the automated system has the capability to accidentally hurt humans, the availability and quality of uncertainty estimates can determine whether the system is safe to deploy at all (Carvalho, 2016; Leibig et al., 2017; Michelmore et al., 2018). Moreover, when decisions are made sequentially, good uncertainty estimates are crucial for achieving good performance quickly (Bellemare et al., 2016; Houthooft et al., 2016; Ostrovski et al., 2017; Burda et al., 2018).
Because any non-Bayesian inference process is potentially sub-optimal (De Finetti, 1937), these uncertainty estimates should ideally be relatable to Bayesian inference with a useful prior. Deep ensembles (Lakshminarayanan et al., 2017), one of the most popular methods available for uncertainty estimation in deep networks today, struggle with this requirement. While deep ensembles can be related (Rubin, 1981) to Bayesian inference in settings where the individual models are trained on subsets of the data, this is not how they are used in practice. In order to improve data efficiency, all ensembles are typically trained using the same data (Lakshminarayanan et al., 2017), resulting in a method which does not have a theoretical justification. Moreover, deep ensembles can give overconfident uncertainty estimates in practice. On the other hand, Monte-Carlo dropout can be viewed (Gal & Ghahramani, 2016) as a certain form of Bayesian inference. However, doing so requires requires either a limit to be taken or a generalization of variational inference to a quasi-KL divergence (Hron et al., 2018). In practice, MC dropout can give arbitrarily overconfident estimates (Foong et al., 2019). More broadly, a category of approaches, known as Bayesian Neural Networks (Blundell et al., 2015; Welling & Teh, 2011; Neal, 1996), maintains a distribution over the weights of the neural network. These methods have a sound Bayesian justification, but training them is both difficult and carries an accuracy penalty, particularly for networks with convolutional architectures (Osawa et al., 2019). Moreover, tuning BNNs is hard and achieving a good approximation to the posterior is difficult (Brosse et al., 2018).
We use another way of obtaining uncertainties for deep networks, based on fitting random priors (Osband et al., 2018; 2019). Random priors are easy to train and were found to work very well in practice (Burda et al., 2018). To obtain the uncertainty estimates, Affiliations: 1. Microsoft Research Cambridge; 2. ETH Zurich; 3. University of Cambridge. The second author was an intern at Microsoft when contributing to this work.
we first train a predictor network to fit a prior. Two examples of prior-predictor pairs are shown in the top two plots of Figure 1.Faced with a novel input point, we obtain an uncertainty (Figure 1, bottom plot) by measuring the error of the predictor network against this pattern. Intuitively, these errors will be small close to the training points, but large far from them. The patterns themselves are drawn from randomly initialized (and therefore untrained) neural networks. While this way of estimating uncertainties was known before (Osband et al., 2019), it did not have a theoretical justification beyond Bayesian linear regression, which is too limiting for modern applications.
Contributions We provide a sound theoretical framework for obtaining uncertainty estimates by fitting random priors, a method previously lacking a principled justification. Specifically, we justify estimates in the uncertainty of the output of neural networks with any architecture. In particular, we show in Lemma 1 and Proposition 1 that these uncertainty estimates are conservative, meaning they are never more certain than a Bayesian algorithm would be. Moreover, in Proposition 2 we show concentration, i.e. that the uncertainties become zero with infinite data. Empirically, we evaluate the calibration and out-of-distribution performance of our uncertainty estimates on typical computer vision tasks, showing a practical benefit over deep ensembles and MC dropout.
# 2 PRELIMINARIES
We are going to reason about uncertainty within the formal framework of stochastic processes. We now introduce the required notations.
 Figure 1: On top, two predictors (green) were trained to fit two randomlygenerated priors (red). On the bottom, we obtain uncertainties from the difference between predictors and priors. Dots correspond to training points $x _ { i }$ .
A stochastic process is a collection of random variables $\{ f ( x ) \}$ . We consider processes where $\boldsymbol { x } \in \mathbb { R } ^ { K }$ and the random-variable $f ( x )$ takes values in $\mathbb { R } ^ { M }$ . A stochastic process has exchangeable outputs if the distribution does not change when permuting the $M$ entries in the output vector. Allowing a slight abuse of notation, we denote the finite-dimensional distribution of the process $\{ f ( x ) \}$ for the set $X =$ $\{ x _ { i } \} _ { i = 1 , \ldots , N }$ as $f ( x _ { 1 } , \dots , x _ { N } ) = f ( X )$ . In practice, the finite-dimensional distribution reflects the idea of restricting the process to points $x _ { 1 } , \ldots , x _ { N }$ and marginalizing over all the other points. Inference can be performed on stochastic processes similarly to probability distributions. In particular, we can start with some prior process $\{ f ( x ) \}$ , observe a set of $N$ training points $X = \{ x _ { i } \} _ { i = 1 , \dots , N }$ and labels $y = \{ y _ { i } \} _ { i = 1 , \dots , N }$ and then consider the posterior process $\{ f _ { X y } ( x ) \}$ , whose finite-dimensional distributions are given by $f _ { X y } ( x _ { 1 } ^ { \star } \ldots x _ { N ^ { \prime } } ^ { \star } ) = f ( x _ { 1 } ^ { \star } \ldots x _ { N ^ { \prime } } ^ { \star } | x _ { 1 } , \ldots , x _ { N } , y _ { 1 } , \ldots , y _ { N } )$ for any set of testing points $x _ { 1 } ^ { \star } \ldots x _ { N ^ { \prime } } ^ { \star }$ . We use subscripts to denote conditioning on the dataset throughout the paper. We denote the variance of $f _ { X y } ( x _ { \star } )$ with $\sigma _ { X f } ^ { 2 } ( x _ { \star } )$ . A stochastic process is called Gaussian if if all its finite-dimensional distributions are Gaussian. Given a test point $x _ { \star }$ , we denote the posterior GP mean with $\mu _ { X y } ( x _ { \star } )$ and posterior GP variance with $\sigma _ { X } ^ { 2 } ( x _ { \star } )$ . We provide more background on GPs in Appendix D.
# 3 ESTIMATING UNCERTAINTY FROM RANDOM PRIORS
Intuition Uncertainties obtained from random priors have an appealing intuitive justification. Consider the networks in the top part of Figure 1. We start with a randomly initialized prior network, shown in red. Whenever we see a datapoint, we train the predictor network (green) to match this prior. Uncertainties can then be obtained by considering the squared error between the prior and the predictor at a given point. An example uncertainty estimate is shown as the shaded blue area in the bottom of Figure 1. While it may at first seem that the squared error is a poor measure of uncertainty because it can become very small by random chance, we formally show in Section 4.1 that this is very improbable. In Section 4.2, we show that this error goes down to zero as we observe more data. Similarly to GP inference, uncertainty estimation in our framework does not depend on the regression label. The prediction mean (blue curve in the bottom part of Figure 1) is obtained by fitting a completely separate neural network. In section 6, we discuss how this framework avoids the overconfidence characteristic of deep ensembles (Lakshminarayanan et al., 2017).
Prior The process of obtaining network uncertainties involves randomly initialized prior networks, which are never trained. While this may at first appear very different from they way deep learning is normally done, these random networks are a crucial component of our method. We show in Section 4.1 that the random process that corresponds to initializing these networks can be interpreted as a prior of a Bayesian inference procedure. A prior conveys the information about how the individual data points are related. The fact that we are using random networks has both practical and theoretical benefits. Practically, since the prior does not depend on the data, there is no way that it can overfit. The use of random priors also has strong empirical support – randomly initialized networks have been recently used as priors to obtain state-of-the-art performance on computer vision tasks (Ulyanov et al., 2018; Cheng et al., 2019). Theoretically, using random priors satisfies the likelihood principle (Robert, 2007). Moreover, random priors can be viewed as a safe choice since they make the minimum reasonable assumption that the network architecture is appropriate for the task. In fact, whenever deep learning is used, with or without uncertainty estimates, practitioners are already implicitly making that assumption.
Algorithm The process of training the predictor networks is shown in Algorithm 1. The function TRAIN-UNCERTAINTIES first generates random priors, i.e. neural networks with random weights. In our notation, it corresponds to sampling functions from the prior process $\{ f ( x ) \}$ . These priors, evaluated at points from the dataset $X = \{ x _ { i } \} _ { i = 1 , \dots , N }$ are then used as labels for supervised learning, performed by the function FIT. After training, when we want to obtain an uncertainty estimate $\phi$ at a given test point $x _ { \star }$ , we use the formula
<table><tr><td>Algorithm 1 Training the predictors.</td></tr><tr><td>function TRAIN-UNCERTAINTIES(X) fori=1...Bdo fi~{f(x)} > random prior hxfi ←FIT(X,fi(X)) end for</td></tr><tr><td>return fi,hx fi end function</td></tr><tr><td>function FIT(X, fi(X))</td></tr><tr><td>L(h)=∑x∈x If²(x)-h(x)ll² h xfi← OPTIMIZE(L)>SGD or similar return h x fi >return trained predictor</td></tr></table>
$$\hat { \sigma } ^ { 2 } ( x _ { \star } ) = \operatorname* { m a x } ( 0 , \hat { \sigma } _ { \mu } ^ { 2 } ( x _ { \star } ) + \beta \hat { v } _ { \sigma } ( x _ { \star } ) - \sigma _ { A } ^ { 2 } ) .$$
Here, the quantity $\hat { \sigma } _ { \mu } ^ { 2 }$ is the sample mean of the squared error. We will show in Section 4 that it is an unbiased estimator of a variable that models the uncertainty. On the other hand, $\hat { v } _ { \sigma }$ is the samplebased estimate of the standard deviation of squared error across bootstraps, needed to quantify our uncertainty about what the uncertainty is. The hyper-parameter $\beta$ controls the degree to which this uncertainty is taken into account. Formally, the quantities are defined as
$$\begin{array} { r l } & { \hat { \sigma } _ { \mu } ^ { 2 } ( x _ { \star } ) \triangleq \sum _ { i = 1 } ^ { B } \frac { 1 } { M B } \| f ( x _ { \star } ) - h _ { X f _ { i } } ( x _ { \star } ) \| ^ { 2 } , } \\ & { \hat { v } _ { \sigma } ( x _ { \star } ) \triangleq \sqrt { \sum _ { i = 1 } ^ { B } \frac { 1 } { B } ( \hat { \sigma } _ { \mu } ^ { 2 } ( x _ { \star } ) - \frac { 1 } { M } \| f ( x _ { \star } ) - h _ { X f _ { i } } ( x _ { \star } ) \| ^ { 2 } ) ^ { 2 } } . } \end{array}$$
In the above equations, $B$ is the number of prior functions and each prior and predictor network has $M$ outputs. Because the predictors are trained independently, uncertainty estimates obtained from each of the $B$ predictor-prior pairs are independent. We defer the discussion of details of network architecture to Section 5. Our experiments (Section 7) show that it is often sufficient to use $B = 1$ in practice.
# 4 THEORETICAL RESULTS
In Section 3, we introduced a process for obtaining uncertainties in deep learning. We now seek to provide a formal justification. We define the expected uncertainties as
$$\begin{array} { r } { \tilde { \sigma } _ { \mu } ^ { 2 } ( x _ { \star } ) \triangleq \operatorname { E } _ { f } \left[ \hat { \sigma } _ { \mu } ^ { 2 } ( x _ { \star } ) \right] = \operatorname { E } _ { f } \left[ \frac { 1 } { M } \lVert f ( x _ { \star } ) - h _ { X f } ( x _ { \star } ) \rVert ^ { 2 } \right] . } \end{array}$$
In other words, $\tilde { \sigma } _ { \mu } ^ { 2 }$ is the expected version of the sample-based uncertainties $\hat { \sigma } _ { \mu } ^ { 2 } ( x _ { \star } )$ introduced in equation 2. Since Bayesian inference is known to be optimal (De Finetti, 1937; Jaynes, 2003; Robert, 2007), the most appealing way of justifying uncertainty estimates ${ \tilde { \sigma } } _ { \mu } ^ { 2 }$ and $\hat { \sigma } _ { \mu } ^ { 2 }$ is to relate them to a Bayesian posterior $\sigma _ { X f } ^ { 2 } ( x _ { \star } )$ . We do this in two stages. First, in Section 4.1, we prove that the obtained uncertainties are larger than ones arrived at by Bayesian inference. This means that our uncertainties are conservative, ensuring that our algorithm is never more certain than it should be. Next, in Section 4.2, we show that uncertainties concentrate, i.e., they become small as we get more and more data. These two properties are sufficient to justify the use of our uncertainties in many applications.
# 4.1 UNCERTAINTIES FROM RANDOM PRIORS ARE CONSERVATIVE
From the point of view of safety, it is preferable to overestimate the ground truth uncertainty than to underestimate it. We now show that this property holds for uncertainties obtained from random priors. We first justify conservatism for the expected uncertainty ${ \tilde { \sigma } } _ { \mu } ^ { 2 }$ defined in equation 4 and then for the sampled uncertainty $\hat { \sigma } _ { \mu } ^ { 2 }$ defined in equation 2.
Amortized Conservatism We first consider a weak form of this conservatism, which we call amortized. It guarantees that ${ \tilde { \sigma } } _ { \mu } ^ { 2 }$ is never smaller than the average posterior uncertainty across labels sampled from the prior. Formally, amortized conservatism holds if for any test point $x _ { \star }$ we have
$$\tilde { \sigma } _ { \mu } ^ { 2 } ( x _ { \star } ) \geq \mathrm { E } _ { f ( X ) } \left[ \sigma _ { X f } ^ { 2 } ( x _ { \star } ) \right] .$$
Here $\sigma _ { X f } ^ { 2 }$ corresponds to the second moment of the posterior process $\{ f _ { X f } ( x ) \}$ . We will introduce a stronger version of conservatism, which does not have an expectation on the right-hand side, later in this section (eq. 8). For now, we concentrate on amortized conservatism. In Lemma 1 (proof in appendix), we show that it holds under very general conditions.
Lemma 1. For any function $h : \mathbb { R } ^ { N \times ( K + 1 ) } \mathbb { R } ^ { M }$ , for any test point $\boldsymbol { x } _ { \star } ~ \in ~ \mathbb { R } ^ { K }$ and for any stochastic process $\{ f ( x ) \} _ { x \in \mathbb { R } ^ { K } }$ with all second moments finite and exchangeable outputs
$$\begin{array} { r } { \tilde { \sigma } _ { \mu } ^ { 2 } ( x _ { \star } ) = \mathrm { E } _ { f ( X ) } \left[ \sigma _ { X f } ^ { 2 } ( x _ { \star } ) + \frac { 1 } { M } \| \mu _ { X f } ( x _ { \star } ) - h _ { X f } ( x _ { \star } ) \| ^ { 2 } \right] . } \end{array}$$
Relation to a GP Lemma 1 holds for any prior process $\{ f ( x ) \}$ . However, the prior process used by Algorithm 1 is not completely arbitrary. The fact that prior samples are obtained by initializing neural networks with independently sampled weights gives us additional structure. In fact, it can be shown that randomly initialized neural networks become close to GPs as the width of the layers increases. While the original result due to Neal (1996) held for a simple network with one hidden layer, it has been extended to a wide class of popular architectures, including to CNNs and RNNs of arbitrary depth (Matthews et al., 2018; Lee et al., 2018; Novak et al., 2019; Williams, 1997; Le Roux & Bengio, 2007; Hazan & Jaakkola, 2015; Daniely et al., 2016; Garriga-Alonso et al., 2019). Recently, it has been shown to hold for a broad class of functions trainable by gradient descent (Yang, 2019). While the precise statement of these results involves technicalities which fall beyond the scope of this paper, we recall the key insight. For a family of neural networks $\{ f ^ { W } ( x ) \}$ , where the weights are sampled independently and $W$ is the width of the hidden layers, there exists a limiting kernel function $k _ { \infty }$ such that
$$\operatorname* { l i m } _ { W \infty } [ \{ f ^ { W } ( x ) \} ] = \mathcal { G P } ( 0 , k _ { \infty } ) .$$
In other words, as the size of the hidden layers increases, the stochastic process obtained by initializing networks randomly converges in distribution to a GP. In the context of our uncertainty estimates, this makes it reasonable for $W$ large enough to consider the prior to be a GP. We stress that the GP assumption has to hold only for the prior network, which is never trained. We do not make any assumptions about connections between the predictor training process and GPs.
Strict Conservatism Denoting the posterior GP variance with $\sigma _ { X } ^ { 2 } ( x _ { \star } )$ , we define uncertainty estimates to be strictly conservative when
$$\tilde { \sigma } _ { \mu } ^ { 2 } ( x _ { \star } ) \geq \sigma _ { X } ^ { 2 } ( x _ { \star } ) .$$
This statement is stronger than the amortized conservatism in equation 5. Intuitively, equation 8 can be interpreted as saying that our uncertainty estimates are never too small. This confirms the intuition expressed by Burda et al. (2018) that random priors do not overfit. Below, in Proposition 1, we outline how to guarantee strict conservatism formally. It is proved in Appendix F.1.
Proposition 1 (Strict Conservatism in Expectation). Assume that $f$ is a GP. Then for any function $h : \bar { \mathbb { R } } ^ { N \times K } \to \bar { \mathbb { R } } ^ { M }$ , we have
$$\tilde { \sigma } _ { \mu } ^ { 2 } ( x _ { \star } ) = \sigma _ { X } ^ { 2 } ( x _ { \star } ) + \underbrace { { \mathrm E } _ { f ( X ) } \left[ \frac { 1 } { M } \| \mu _ { X f } ( x _ { \star } ) - h _ { X f } ( x _ { \star } ) \| ^ { 2 } \right] } _ { \geq 0 } .$$
Moreover, equality holds if and only if $h _ { X f } ( x _ { \star } ) = \mu _ { X f } ( x _ { \star } )$ .
Conservatism with Finite Bootstraps Lemma 1 above shows conservatism for expected uncertainties, i.e. ${ \tilde { \sigma } } _ { \mu } ^ { 2 }$ introduced in equation 5. However, in practice we have to estimate this expectation using a finite number of bootstraps, and use the sampled uncertainties $\hat { \sigma } _ { \mu } ^ { 2 }$ defined in equation 2. We now state a conservatism guarantee that holds even in the case of just one bootstrap $B = 1$ ). The proof is deferred to Appendix F.1.
Corollary 1 (Strict Conservatism for Finite Bootstraps). Assume that $f$ is a GP. Assume that the random variable $\hat { \sigma } _ { \mu } ^ { 2 } ( x _ { \star } )$ has finite variance upper bounded by vUB. Then with probability $1 - \delta$ , for any function $h : \mathbb { R } ^ { N \times K } \to \mathbb { R } ^ { M }$ , we have
$$\begin{array} { r } { \hat { \sigma } _ { \mu } ^ { 2 } ( x _ { \star } ) + \frac { 1 } { \sqrt { \delta } } v _ { U B } \geq \tilde { \sigma } _ { \mu } ^ { 2 } ( x _ { \star } ) \geq \sigma _ { X } ^ { 2 } ( x _ { \star } ) . } \end{array}$$
However, applying Corollary 1 requires the knowledge of $v _ { \mathrm { U B } }$ . We now provide an upper bound.
Lemma 2. Assume that the GP $\{ f ( x ) \}$ is zero mean with exchangeable outputs and the function $h _ { X f }$ takes values in $[ - U , U ] ^ { M }$ . Assume that permuting the outputs of $f$ produces the same permutation in the outputs of $h _ { X f }$ . With probability $1 - \delta$ , we have
$$\operatorname { V a r } _ { f _ { 1 } , \dots , f _ { B } } \left[ \widehat { \sigma } _ { \mu } ^ { 2 } ( x _ { \star } ) \right] \leq v _ { U B } ,$$
where vUB is expressible in terms of observable quantities.
The proof and the explicit formula for $v _ { \mathrm { U B } }$ is deferred to Appendix F.1. In cases where conservatism is desired, but not absolutely essential, we can avoid the torturous calculation of Lemma 2 and replace $v _ { \mathrm { U B } }$ with the sample-based estimate $\hat { v } _ { \sigma } ( x _ { \star } )$ , defined in equation 2. In this case, the conservatism guarantee is only approximate. This is how we obtained equation 1, used by the algorithm in practice.
# 4.2 UNCERTAINTIES FROM RANDOM PRIORS CONCENTRATE
While the conservatism property in Proposition 1 is appealing, it is not sufficient on its own for the uncertainty estimates to be useful. We also need concentration, i.e. a guarantee that the uncertainties $\hat { \sigma } ^ { 2 }$ become small with more data. We can gurantee this formally by assuming that the class of neural networks being fitted is Lipschitz-continuous and bounded. Intuitively, by assumption of Lipschitz continuity, the predictors $h _ { X f }$ cannot behave very differently on points from the training and test sets, since both come from the same data distribution. We can then show concentration by using standard Rademacher tools to obtain a bound on the expected uncertainty in terms of the squared error on the training set. This process is formalized in Proposition 2.
Proposition 2. If the training converges, i.e. the training loss $\begin{array} { r } { \frac { 1 } { M N } \sum _ { i = 1 } ^ { N } \| f ( x _ { i } ) - h _ { X f } ( x _ { i } ) \| ^ { 2 } = \sigma _ { A } ^ { 2 } } \end{array}$ for arbitrarily large training sets, then assuming the predictors $h _ { X f }$ are bounded and Lipschitz continuous with constant $L _ { i }$ , then under technical conditions the uncertainties concentrate, i.e. $\hat { \sigma } ^ { 2 } ( x _ { \star } ) 0$ as $N \to \infty$ and $B \infty$ with probability $^ { l }$ .
 Figure 2: Architecture of the random prior networks $f$ and predictor networks $h _ { X f }$ . The predictor networks $h _ { X f }$ typically share the same architectural core, but have additional layers relative to the prior networks. Both the green and red parts of the predictor networks are trained.
The proof and the technical conditions are given in Appendix F. Proposition 2 assumes that the training error is zero for arbitrarily large training sets, which might at first seem unrealistic. We argue that this assumption is in fact reasonable. The architecture of our predictor networks (Figure 2, right diagram) is a superset of the prior architecture (Figure 2, left diagram), guaranteeing the existence of weight settings for the predictor that make the training loss zero. Recent results on deep learning optimization (Du et al., 2019; Allen-Zhu et al., 2019) have shown that stochastic gradient descent can in general be expected to find representable functions.
# 5 PRACTICAL CONCLUSIONS FROM THE THEORY
We now re-visit the algorithm we defined in Section 3, with the aim of using the theory above to obtain practical improvements in the quality of the uncertainty estimates.
Architecture and Choosing the Number of Bootstraps Our conservatism guarantee in Proposition 1 holds for any architecture for the predictor $h _ { X f }$ . In theory, the predictor could be completely arbitrary and does not even have to be a deep network. In particular, there is no formal requirement for the predictor architecture to be the same as the prior. On the other hand, to show concentration in Proposition 2, we had to ensure that the prior networks are representable by the predictor. In practice, we use the architecture shown in Figure 2, where the predictor mirrors the prior, but has additional layers, giving it more representational power. Moreover, the architecture requires choosing the number of bootstraps $B$ . Our experiments in Section 7 show that even using $B = 1$ , i.e. one bootstrap, produces uncertainty estimates of high quality in practice.
Modeling Epistemic and Aleatoric Uncertainty Proposition 1 and Proposition 2 hold for any Gaussian Process prior. By choosing the process appropriately, we can model both epistemic and aleatoric uncertainty. Denote by $\{ n ( x ) \}$ a stochastic process obtained by randomly initializing neural networks and denote by $\bar { \{ \epsilon ( x ) \sigma _ { A } ^ { 2 } \} }$ the noise term, modeling the aleatoric (observation) noise, where samples are obtained from $\mathsf { \bar { \epsilon } } ( x ) \sim \mathcal { N } ( 0 , 1 )$ at each $x$ independently (see Appendix D for more background on aleatoric noise). We can now choose the prior process as a sum $\dot { \{ f ( x ) \} } = \{ n ( x ) + \epsilon ( \bar { x ) } \sigma _ { A } ^ { 2 } \}$ of epistemic component $\{ n ( x ) \}$ and the noise term. The amount of aleatoric uncertainty can be adjusted by choosing $\sigma _ { A } ^ { 2 }$ .
Prior Choice, Weight Copying and Conservatism One question that can be asked about our architecture (Figure 2) is whether it is possible for the predictor to exactly copy the prior weights, giving zero uncertainty everywhere. A useful edge case to consider here is when we are solving a one-dimensional regression problem, $\sigma _ { A } ^ { 2 } = 0$ and the both the priors and predictors are linear functions. In this case, after training on two points, the predictors will agree with the priors everywhere and uncertainty estimates will be zero. However, this is still consistent with our conservatism guarantee The reason for this is once we assume such a linear prior, we are comparing to a GP with a linear kernel. But a GP with that kernel will also have zero uncertainty after seeing two samples.
In practice, this means that we have to choose the architecture of the prior networks be expressive enough, which is no different from choosing a reasonable prior for Bayesian inference. Empirically, the tested network architecture did not show weight copying.
# 6 PRIOR WORK
Randomized Prior Functions (RPFs) Our work was inspired by, and builds on, Randomised Prior Functions (Osband et al., 2019; 2018), but it is different in two important respects. First, the existing theoretical justification for RPFs only holds for Bayesian linear regression (Osband et al., 2018, equation 3) with non-zero noise1 added to the priors. In contrast, our results are much more general and hold for any deep network with or without added aleatoric noise. Second, we are targeting a different setting. While RPFs were designed as a way of sampling functions from the posterior, we provide estimates of posterior uncertainty at a given test point. Our algorithm is based on the work by Burda et al. (2018), who applied RPFs to exploration in MDPs, obtaining state-of-the art results, but without justifying their uncertainty estimates formally. Our paper provides this missing justification, while also introducing a way of quantifying the error in estimating the uncertainty itself. Moreover, since Burda et al. (2018) focused on the application of RPFs to Reinforcement Learning, they only performed out-of-distribution evaluation on the relatively easy MNIST dataset (LeCun, 1998). In contrast, in Section 7 we evaluate the uncertainties on more complex vision tasks. The term prior networks has also been used (Malinin & Gales, 2018) to denote deep networks that output the parameters of a prior distribution, an approach fundamentally different from our work.
Deep Ensembles The main alternative approach for obtaining uncertainties in deep learning are deep ensembles (Lakshminarayanan et al., 2017). Building on the bootstrap (Efron & Tibshirani, 1994), deep ensembles maintain several models and quantify epistemic uncertainty by measuring how their outputs vary. Crucially, deep ensembles use representations trained on regression labels, and tend to learn similar representations for different inputs with similar labels, which can lead to over-fitting the uncertainty estimates. A useful edge case to consider is if the each of the models in the ensemble is convex in the weights. In this case, models in a deep ensemble will all converge to the same weights and produce zero uncertainty. While deep learning models used in practice aren’t normally convex, we show empirically in section 7 that deep ensembles can give overconfident uncertainty estimates in practical vision tasks, particularly on points that have the same label as points in the training set. Since our method avoids overconfidence, it can be understood as complementary to deep ensembles, to be used in situations where obtaining conservative estimates is more important than the representational benefit of using labels. In practice, deep ensembles also require using more bootstraps to achieve the same OOD performance. Moreover, they do not have theoretical support in the case when all the members of the ensemble are trained on the same data, which is how they are used in practice (Lakshminarayanan et al., 2017).
Dropout In cases where it is not economical to train more than one network, uncertainties can be obtained with dropout (Srivastava et al., 2014; Gal & Ghahramani, 2016). Monte-Carlo dropout can be viewed (Gal & Ghahramani, 2016) as a form of approximate Bayesian inference. However, to do so requires a rather unnatural approximating family from the perspective of approximate inference. Also, one has then either to take a limit or generalize variational inference to a quasi-KL (Hron et al., 2018) divergence. In addition, dropout can be interpreted in terms of MAP inference (Nalisnick et al., 2019). Another alternative view of MC dropout is as an ensemble method in which the ensemble members have shared parameters (which means they are trained together) and where the ensembling is applied at test time too. This latter view is arguably as natural as the Bayesian interpretation. For this reason we discuss MC dropout separately from BNNs. Since dropout implicitly approximates non-Gaussian weight distribution with Gaussians, it exhibits spurious patterns in the obtained uncertainties, which can lead to arbitrarily overconfident estimates (Foong et al., 2019). In contrast, due to the conservatism property, random priors avoid such overconfidence.
Bayesian Neural Networks (BNNs) Bayesian Neural Networks (Blundell et al., 2015; Kingma & Welling, 2014; Rezende et al., 2014; Welling & Teh, 2011; Brosse et al., 2018) explicitly model the distribution over weights of a neural network. While BNNs provide a link between deep learning and Bayesian inference, they are very slow to train. Even recent tuned implementations of BNNs (Osawa et al., 2019) are several times slower than supervised learning. This happens despite using a battery of technical optimizations, including distributed training and batch normalization. Moreover, modern convolutional BNNs still carry a significant accuracy penalty when deployed with realistic settings of prior variance.2
# 7 EXPERIMENTS
Encouraged by the huge empirical success of random priors in Reinforcement Learning (Burda et al., 2018), we wanted to provide an evaluation in a more typical supervised learning setting. We tested the uncertainties in two ways. First, we investigated calibration, i.e. whether we can expect a higher accuracy for more confident estimates. Next, we checked whether the uncertainties can be used for out-of-distribution detection. We compared to two competing approaches for uncertainty detection: deep ensembles (Lakshminarayanan et al., 2017) and spatial concrete dropout (Gal et al., 2017). The same ResNet architecture served as a basis for all methods. Details of the implementation are provided in Appendix A.
Out-Of-Distribution Detection We evaluated the uncertainty estimates on out-ofdistribution detection. To quantify the results, we evaluated the area under the ROC curve (AUROC) for the task of deciding whether a given image comes from the same distribution or not. All methods were trained on four classes from the CIFAR-10 (Krizhevsky et al., 2009) dataset (training details are provided in Appendix A). We then tested the resulting networks on images from withheld classes and on the SVHN dataset (Netzer et al., 2011), which contains completely different images. Results are shown in Table 1. Considering the statistical errors (see Appendix B), random priors performed slightly better than deep ensembles with adversarial training for $B = 1$ and about the same for $B ~ = ~ 1 0$ . For dropout, $B$ refers to the number of dropout samples. Dropout per
Table 1: Out-of-distribution AUROC for random priors (RP), deep ensembles (DE), deep ensembles with adversarial training $( \mathrm { D E + A T } )$ and spatial concrete dropout (DR). Estimated confidence intervals are provided in Appendix B.
<table><tr><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1>RP</td><td rowspan=1 colspan=1>DE</td><td rowspan=1 colspan=1>DE+AT</td><td rowspan=1 colspan=1>DR</td></tr><tr><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1>B=1</td><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1></td></tr><tr><td rowspan=2 colspan=1>Train v. cat/deerTrain v. vehiclesTrain v. excludedTrain v. SVHN</td><td rowspan=2 colspan=1>0.991.001.000.95</td><td rowspan=1 colspan=1>0.83</td><td rowspan=2 colspan=1>0.960.960.960.96</td><td rowspan=2 colspan=1>0.810.760.770.86</td></tr><tr><td rowspan=1 colspan=1>0.820.820.88</td></tr><tr><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1>B=10</td><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1></td></tr><tr><td rowspan=2 colspan=1>Train v.cat/deerTrain v. vehiclesTrain v. excludedTrain v. SVHN</td><td rowspan=1 colspan=1>1.00</td><td rowspan=1 colspan=1>0.95</td><td rowspan=2 colspan=1>0.990.980.980.99</td><td rowspan=2 colspan=1>0.820.780.790.87</td></tr><tr><td rowspan=1 colspan=1>1.001.000.97</td><td rowspan=1 colspan=1>0.920.930.94</td></tr></table>
formed worse, but was cheaper to train. In order to gain a more finely-grained insight into the quality of the uncertainties, we also show uncertainty histograms in Figure 3. The figure shows the distribution of uncertainty estimates for seen data (top row) vs. unseen data (bottom row) for bootstrap sizes $B = \{ 1 , 5 , 1 0 \}$ . The main conclusion is that uncertainties obtained from random priors are already well-separated with $B = 1$ , while deep ensembles need more bootstraps to achieve the full separation between test and train examples. We provide additional experimental results, showing OOD accuracy and an evaluation on CIFAR 100 in Appendix B.
Calibration Good uncertainty estimates have the property that accuracy increases as we become more certain, a property known as calibration. We measured it by evaluating average accuracy on the subset of images with uncertainty smaller than a given value. We trained on four classes from the CIFAR-10 (Krizhevsky et al., 2009) dataset. We then tested the resulting networks on the whole dataset, which included both the seen and unseen classes. Results are shown in Figure 4. Ideally, in a calibrated method, these curves should be increasing, indicating that a method always becomes more accurate as it becomes more confident. In coarse terms, Figure 4 confirms that all methods except a degenerate deep ensemble with only one bootstrap are roughly monotonic. However, uncertainty estimates from random priors are more stable, showing monotonicity on a finer scale as well as on a large scale. Interestingly, calibration improved only slightly when increasing the number of bootstraps $B$ .
 Figure 3: Distribution of uncertainty estimates for various algorithms. Top row shows seen data, bottom row shows unseen data from CIFAR-10. For random priors (RP), uncertainties are $\hat { \sigma } ^ { 2 }$ . For other algorithms, they are $1 - \operatorname* { m a x } ( p _ { \mu } )$ , where $p _ { \mu }$ is the averaged output of models in ensemble (Lakshminarayanan et al., 2017).
 Figure 4: Calibration curves showing the relationship between uncertainty (horizontal axis) and accuracy (vertical axis) for $B = 1 , 5 , 1 0$ on CIFAR-10.
Subsampling Ablation In the previous experiment, we kept the architectural and optimization choices fixed across algorithms. This ensured a level playing field, but meant that we were not able to obtain zero training error on the predictor networks used by random priors. However, we also wanted to evaluate random priors in the setting of near-zero training error. To do this, we used a smaller set of training images, while still keeping the network architecture the same. This allowed us to obtain nearcomplete convergence (details in Appendix A).
Table 2: Out-of-distribution AUROC for the same models as above (see Tab. 1) on subsampled data. Numbers are accurate up to $\pm 0 . 0 1$ .
<table><tr><td></td><td>RP</td><td>DE</td><td>DE +AT</td><td>DR</td></tr><tr><td colspan="5">B=1</td></tr><tr><td>Train v.excluded</td><td>1.00</td><td>0.90</td><td>0.89</td><td>0.91</td></tr><tr><td>Train v. SVHN</td><td>1.00</td><td>0.95</td><td>0.94</td><td>0.97</td></tr><tr><td colspan="5">B=10</td></tr><tr><td>Train v.excluded</td><td>1.00</td><td>0.94</td><td>0.90</td><td>0.92</td></tr><tr><td>Train v. SVHN</td><td>1.00</td><td>0.97</td><td>0.95</td><td>0.97</td></tr></table>
Results of this ablation are shown in Figures 5 and 6, as well as Table 2, analogous to our results on the full dataset presented above. In this sub-sampled regime, the random prior method easily outperformed competing approaches, showing better calibration (Fig. 5). The histograms in Figure 6 also demonstrate good separation between seen and unseen data. In the out-of-distribution benchmarks reported in Table 2, the random prior method has comfortably outperformed the baselines. While this training regime is not practical for real-life tasks, it demonstrates the potential performance of random priors when trained to full convergence.
Sensitivity to Initialization Scale We performed an ablation to test the robustness of our algorithm to the scaling of the weight initialization in the prior. Results are shown in Figure 7, where we plot the relationship between initialization scale (taken from the set $\{ 0 . 0 1 , 0 . 1 , 1 . 0 , 2 . 0 , 5 . 0 , 1 0 . 0 \} )$ and AUROC performance on the CIFAR-10 task. OOD performance is relatively robust with respect to the weight initialization within one order of magnitude.
 Figure 5: The relationship between uncertainty (horizontal axis) and accuracy (vertical axis) for $B =$ 1, 5, 10 on a subset of 75 samples from CIFAR-10. In well-calibrated models, accuracy increases as uncertainty declines.
 Figure 6: Distribution of uncertainty estimates for various algorithms. Top row shows seen data, bottom row shows unseen data from CIFAR-10, where we trained on a sample of 75 images from the training set. For random priors (RP), uncertainties are $\hat { \sigma } ^ { 2 }$ . For other algorithms, they are $1 -$ $\operatorname* { m a x } ( p _ { \mu } )$ , where $p _ { \mu }$ is the averaged output of models in ensemble (Lakshminarayanan et al., 2017).
Summary of experiments We have shown that uncertainties obtained from random priors achieve competitive performance with fewer bootstraps in a regime where the network architecture is typical for standard supervised learning workloads. Random priors showed superior performance in a regime where the predictors can be trained to near-zero loss.
# 8 CONCLUSIONS
We provided a theoretical justification for the use of random priors for obtaining uncertainty estimates in the context of deep learning. We have shown that the obtained uncertainties are conservative and that they concentrate for any neural network architecture. We performed an extensive empirical comparison, showing that random priors perform similarly to deep ensembles in a typical supervised training setting, while outperforming them in a regime where we are able to accomplish near-zero training loss for the predictors.
 Figure 7: Robustness of OOD perfromance to initialization scale. Conf. bars present, but small, denoting high confidence. Horizontal axis is logarithmic.
# REFERENCES
Zeyuan Allen-Zhu, Yuanzhi Li, and Zhao Song. A convergence theory for deep learning via overparameterization. In Kamalika Chaudhuri and Ruslan Salakhutdinov (eds.), Proceedings of the 36th International Conference on Machine Learning, volume 97 of Proceedings of Machine Learning Research, pp. 242–252, Long Beach, California, USA, 09–15 Jun 2019. PMLR. URL http://proceedings. mlr.press/v97/allen-zhu19a.html.
Marc Bellemare, Sriram Srinivasan, Georg Ostrovski, Tom Schaul, David Saxton, and Remi Munos. Unifying count-based exploration and intrinsic motivation. In Advances in Neural Information Processing Systems, pp. 1471–1479, 2016.
Charles Blundell, Julien Cornebise, Koray Kavukcuoglu, and Daan Wierstra. Weight uncertainty in neural networks. arXiv preprint arXiv:1505.05424, 2015.
Nicolas Brosse, Alain Durmus, and Eric Moulines. The promises and pitfalls of stochastic gradient langevin dynamics. In Advances in Neural Information Processing Systems, pp. 8268–8278, 2018.
Yuri Burda, Harrison Edwards, Amos Storkey, and Oleg Klimov. Exploration by random network distillation. arXiv preprint arXiv:1810.12894, 2018.
Ashwin Mark Carvalho. Predictive Control under Uncertainty for Safe Autonomous Driving: Integrating DataDriven Forecasts with Control Design. PhD thesis, UC Berkeley, 2016.
Zezhou Cheng, Matheus Gadelha, Subhransu Maji, and Daniel Sheldon. A bayesian perspective on the deep image prior. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pp. 5443–5451, 2019.
Amit Daniely, Roy Frostig, and Yoram Singer. Toward deeper understanding of neural networks: The power of initialization and a dual view on expressivity. In Advances In Neural Information Processing Systems, pp. 2253–2261, 2016.
Bruno De Finetti. La prevision: ses lois logiques, ses sources subjectives. In ´ Annales de l’institut Henri Poincare´, pp. 1–68, 1937.
Simon Du, Jason Lee, Haochuan Li, Liwei Wang, and Xiyu Zhai. Gradient descent finds global minima of deep neural networks. In International Conference on Machine Learning, pp. 1675–1685, 2019.
John Duchi. Probability bounds, 2009.
Bradley Efron and Robert J. Tibshirani. An Introduction to the Bootstrap. SIAM Review, 36(4):677–678, 1994. doi: 10.1137/1036171.
Andrew YK Foong, David R Burt, Yingzhen Li, and Richard E Turner. Pathologies of factorised gaussian and mc dropout posteriors in bayesian neural networks. arXiv preprint arXiv:1909.00719, 2019.
Yarin Gal and Zoubin Ghahramani. Dropout as a bayesian approximation: Representing model uncertainty in deep learning. In Proceedings of the 33nd International Conference on Machine Learning, ICML 2016, New York City, NY, USA, June 19-24, 2016, pp. 1050–1059, 2016. URL http://proceedings.mlr. press/v48/gal16.html.
Yarin Gal, Jiri Hron, and Alex Kendall. Concrete dropout. In Advances in Neural Information Processing Systems 30: Annual Conference on Neural Information Processing Systems 2017, 4-9 December 2017, Long Beach, CA, USA, pp. 3581–3590, 2017.
Adri Garriga-Alonso, Carl Edward Rasmussen, and Laurence Aitchison. Deep convolutional networks as shallow gaussian processes. In International Conference on Learning Representations, 2019. URL https: //openreview.net/forum?id $\equiv$ Bklfsi0cKm.
Tamir Hazan and Tommi Jaakkola. Steps toward deep kernel methods from infinite neural networks. arXiv preprint arXiv:1508.05133, 2015.
Rein Houthooft, Xi Chen, Yan Duan, John Schulman, Filip De Turck, and Pieter Abbeel. Vime: Variational information maximizing exploration. In Advances in Neural Information Processing Systems, pp. 1109– 1117, 2016.
Jiri Hron, Alexander G. de G. Matthews, and Zoubin Ghahramani. Variational bayesian dropout: pitfalls and fixes. In Proceedings of the 35th International Conference on Machine Learning, ICML 2018, Stockholmsmassan, Stockholm, Sweden, July 10-15, 2018 ¨ , pp. 2024–2033, 2018. URL http: //proceedings.mlr.press/v80/hron18a.html.
Edwin T Jaynes. Probability theory: The logic of science. Cambridge university press, 2003.
Diederik P Kingma and Jimmy Ba. Adam: A method for stochastic optimization. arXiv preprint arXiv:1412.6980, 2014.
Diederik P. Kingma and Max Welling. Auto-encoding variational bayes. In 2nd International Conference on Learning Representations, ICLR 2014, Banff, AB, Canada, April 14-16, 2014, Conference Track Proceedings, 2014. URL http://arxiv.org/abs/1312.6114.
Alex Krizhevsky, Geoffrey Hinton, et al. Learning multiple layers of features from tiny images. Technical report, Citeseer, 2009.
Balaji Lakshminarayanan, Alexander Pritzel, and Charles Blundell. Simple and scalable predictive uncertainty estimation using deep ensembles. In Advances in Neural Information Processing Systems, pp. 6402–6413, 2017.
Nicolas Le Roux and Yoshua Bengio. Continuous neural networks. In Artificial Intelligence and Statistics, pp. 404–411, 2007.
Yann LeCun. The mnist database of handwritten digits. http://yann. lecun. com/exdb/mnist/, 1998.
Jaehoon Lee, Jascha Sohl-dickstein, Jeffrey Pennington, Roman Novak, Sam Schoenholz, and Yasaman Bahri. Deep neural networks as gaussian processes. In International Conference on Learning Representations, 2018. URL https://openreview.net/forum?id $\equiv$ B1EA-M-0Z.
Christian Leibig, Vaneeda Allken, Murat Sec¸kin Ayhan, Philipp Berens, and Siegfried Wahl. Leveraging uncertainty information from deep neural networks for disease detection. Scientific reports, 7(1):17816, 2017.
Ulrike von Luxburg and Olivier Bousquet. Distance-based classification with lipschitz functions. Journal of Machine Learning Research, 5(Jun):669–695, 2004.
Andrey Malinin and Mark Gales. Predictive uncertainty estimation via prior networks. In Advances in Neural Information Processing Systems, pp. 7047–7058, 2018.
AGDG Matthews, M Rowland, J Hron, RE Turner, and Z Ghahramani. Gaussian process behaviour in wide deep neural networks. In Proceedings of the 6th International Conference on Learning Representations., 2018.
Rhiannon Michelmore, Marta Kwiatkowska, and Yarin Gal. Evaluating uncertainty quantification in end-to-end autonomous driving control. arXiv preprint arXiv:1811.06817, 2018.
Mehryar Mohri, Afshin Rostamizadeh, and Ameet Talwalkar. Foundations of machine learning. MIT press, 2018.
Kevin P Murphy. Machine learning: a probabilistic perspective. MIT press, 2012.
Eric Nalisnick, Jose Miguel Hernandez-Lobato, and Padhraic Smyth. Dropout as a structured shrinkage prior. In Kamalika Chaudhuri and Ruslan Salakhutdinov (eds.), Proceedings of the 36th International Conference on Machine Learning, volume 97 of Proceedings of Machine Learning Research, pp. 4712–4722, Long Beach, California, USA, 09–15 Jun 2019. PMLR. URL http://proceedings.mlr.press/v97/ nalisnick19a.html.
Radford M Neal. Bayesian learning for neural networks. Phd Thesis, 1996.
Yuval Netzer, Tao Wang, Adam Coates, Alessandro Bissacco, Bo Wu, and Andrew Y. Ng. Reading digits in natural images with unsupervised feature learning. In NIPS Workshop on Deep Learning and Unsupervised Feature Learning 2011, 2011.
Roman Novak, Lechao Xiao, Yasaman Bahri, Jaehoon Lee, Greg Yang, Daniel A. Abolafia, Jeffrey Pennington, and Jascha Sohl-dickstein. Bayesian deep convolutional networks with many channels are gaussian processes. In International Conference on Learning Representations, 2019. URL https://openreview. net/forum?id=B1g30j0qF7.
K. Osawa, S. Swaroop, A. Jain, R. Eschenhagen, R. E. Turner, R. Yokota, and M. E. Khan. Practical deep learning with bayesian principles. In The 33rd Conference on Neural Information Processing Systems (NeurIPS 2019), Vancouver, Canada, Dec. 8-14 2019.
Ian Osband, John Aslanides, and Albin Cassirer. Randomized prior functions for deep reinforcement learning. In Advances in Neural Information Processing Systems, pp. 8617–8629, 2018.
Ian Osband, Benjamin Van Roy, Daniel J. Russo, and Zheng Wen. Deep exploration via randomized value functions. Journal of Machine Learning Research, 20(124):1–62, 2019. URL http://jmlr.org/papers/ v20/18-339.html.
Georg Ostrovski, Marc G Bellemare, Aaron van den Oord, and R ¨ emi Munos. Count-based exploration with ´ neural density models. In Proceedings of the 34th International Conference on Machine Learning-Volume 70, pp. 2721–2730. JMLR. org, 2017.
F. Pedregosa, G. Varoquaux, A. Gramfort, V. Michel, B. Thirion, O. Grisel, M. Blondel, P. Prettenhofer, R. Weiss, V. Dubourg, J. Vanderplas, A. Passos, D. Cournapeau, M. Brucher, M. Perrot, and E. Duchesnay. Scikit-learn: Machine learning in Python. Journal of Machine Learning Research, 12:2825–2830, 2011.
Danilo Jimenez Rezende, Shakir Mohamed, and Daan Wierstra. Stochastic backpropagation and approximate inference in deep generative models. In Eric P. Xing and Tony Jebara (eds.), Proceedings of the 31st International Conference on Machine Learning, volume 32 of Proceedings of Machine Learning Research, pp. 1278–1286, Bejing, China, 22–24 Jun 2014. PMLR. URL http://proceedings.mlr.press/v32/ rezende14.html.
Christian Robert. The Bayesian choice: from decision-theoretic foundations to computational implementation. Springer Science & Business Media, 2007.
Donald B Rubin. The bayesian bootstrap. The annals of statistics, pp. 130–134, 1981.
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.
Dmitry Ulyanov, Andrea Vedaldi, and Victor Lempitsky. Deep image prior. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pp. 9446–9454, 2018.
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.
Christopher KI Williams. Computing with infinite networks. In Advances in neural information processing systems, pp. 295–301, 1997.
Christopher KI Williams and Carl Edward Rasmussen. Gaussian processes for machine learning. MIT press Cambridge, MA, 2006.
Greg Yang. Wide feedforward or recurrent neural networks of any architecture are gaussian processes. In Neural Information Processing Systems (NeurIPS), 2019.
# APPENDICES
APPENDIX A REPRODUCIBILITY AND DETAILS OF EXPERIMENTAL SETUP
APPENDIX A.1 SYNTHETIC DATA
For the 1D regression experiment on synthetic data (Fig 1), we used feed-forward neural networks with 2 layers of 128 units each and a 1-dimensional output layer. We used an ensemble size of 5. The network was trained on 20 points sampled from the negative domain of a sigmoid function and tested on 20 points sampled from the positive domain.
APPENDIX A.2 EXPERIMENTAL SETUP
Model architecture For the CIFAR-10 experiments, we adapted the setup from the cifar10-fast model.3 For the network predicting the mean, we used the exact same architecture as in this model. For the prior networks in our uncertainty estimators, the architecture for the prior network was the same as the mean network, but using a final linear layer instead of the softmax layer. We used squared error on that last layer to get the uncertainties. For the predictor networks in the uncertainty estimators, we added two additional layers at the end to make sure the prior functions are learnable (see Fig. 2).
We followed Burda et al. (2018) in choosing the output size to be $M = 5 1 2$ and using the Adam optimizer (Kingma & Ba, 2014) with a learning rate of 0.0001. We optimized the initialization scale of our networks as a hyperparameter on the grid $\{ 0 . 0 1 , 0 . 1 , 1 . 0 , 2 . 0 , 1 0 . 0 \}$ and chose 2.0. We chose a scaling factor of $\beta = 1 . 0$ for the uncertainty bonus of the random priors and fixed it for all experiments.
Data For the CIFAR-10 experiment, we trained on the classes {bird, dog, frog, horse} and excluded {cat, deer, airplane, automobile, ship, truck}. For the small CIFAR-10 ablation experiment, we trained on 75 images sampled from the classes $\{ { \mathrm { s h i p } } , { \mathrm { t r u c k } } \}$ and excluded the remaining classes.
Training Error The training error was $0 . 5 7 \pm 0 . 2 0$ on the CIFAR experiment and $0 . 0 3 \pm 0 . 0 2$ on the sub-sampled ablation (the symbol $\pm$ denotes $90 \%$ confidence intervals).
Out-of-distribution classification For computing the areas under the receiver-operator characteristic curves (AUROC) in the OOD classification tables, we used the roc auc score function from the Python package sklearn (Pedregosa et al., 2011), using the predicted uncertainties as predicted label scores and binary labels for whether or not the samples were from the training set.
APPENDIX B ADDITIONAL RESULTS
# APPENDIX B.1 CONFIDENCE INTERVALS FOR AUROCS
We provide confidence intervals for AUROC measurements in Table 3.
<table><tr><td></td><td>RP</td><td>DE</td><td>DE +AT</td><td>DR</td></tr><tr><td colspan="5">B=1</td></tr><tr><td>Train v. cat/deer</td><td>0.99 ± 0.002</td><td>0.83± 0.065</td><td>0.96± 0.008</td><td>0.81 ± 0.001</td></tr><tr><td>Train v. vehicles</td><td>1.00 ± 0.000</td><td>0.82 ± 0.070</td><td>0.96 ± 0.007</td><td>0.76 ± 0.001</td></tr><tr><td>Train v. excluded</td><td>1.00 ± 0.001</td><td>0.82 ± 0.069</td><td>0.96 ± 0.007</td><td>0.77 ± 0.002</td></tr><tr><td>Train v. SVHN</td><td>0.95 ± 0.013</td><td>0.88 ± 0.101</td><td>0.96 ± 0.009</td><td>0.86 ± 0.002</td></tr></table>
Table 3: Out-of-distribution AUROC for random priors (RP), deep ensembles (DE), deep ensembles with adversarial training $( \mathrm { D E + A T } )$ and spatial concrete dropout (DR). The errors are computed from ten samples each in the $B = 1$ case. The $\pm$ symbol denotes one standard error.
# APPENDIX B.2 OOD CLASSIFICATION ACCURACIES
In addition to AUROC results, we also provide accuracy figures on the same OOD tasks. The thresholding for classification was obtained by cross-validation.
They are in Table 4 and 5.
<table><tr><td></td><td>RP</td><td>DE</td><td>DE +AT</td><td>DR</td></tr><tr><td colspan="5">B=1</td></tr><tr><td>Train v.cat/deer</td><td>0.97 ± 0.001</td><td>0.83 ±0.008</td><td>0.97 ± 0.006</td><td>0.82±0.000</td></tr><tr><td>Train v.vehicles</td><td>0.99 ± 0.001</td><td>0.81 ± 0.008</td><td>0.96 ± 0.004</td><td>0.86 ± 0.000</td></tr><tr><td>Train v. excluded</td><td>0.98 ± 0.001</td><td>0.87 ± 0.022</td><td>0.97 ± 0.007</td><td>0.70 ± 0.002</td></tr><tr><td>Train v. SVHN</td><td>0.91 ± 0.006</td><td>0.91 ± 0.025</td><td>0.96 ± 0.008</td><td>0.78 ± 0.001</td></tr><tr><td colspan="5">B=10</td></tr><tr><td>Trainv.cat/deer</td><td>0.98</td><td>0.88</td><td>0.96</td><td>0.82</td></tr><tr><td>Train v.vehicles</td><td>0.99</td><td>0.87</td><td>0.95</td><td>0.86</td></tr><tr><td>Train v. excluded</td><td>0.99</td><td>0.89</td><td>0.96</td><td>0.71</td></tr><tr><td>Train v. SVHN</td><td>0.92</td><td>0.88</td><td>0.96</td><td>0.78</td></tr></table>
Table 4: Out-of-distribution classification accuracy for random priors (RP), deep ensembles (DE), deep ensembles with adversarial training $( \mathrm { D E + A T } )$ and spatial concrete dropout (DR). These values augment the AUROC values reported in Table 1. The $\pm$ symbol denotes one standard error.
<table><tr><td></td><td>RP</td><td>DE</td><td>DE +AT</td><td>DR</td></tr><tr><td colspan="5">B=1</td></tr><tr><td>Train v.excluded</td><td>1.00</td><td>0.90</td><td>0.88</td><td>0.91</td></tr><tr><td>Train v. SVHN</td><td>1.00</td><td>0.95</td><td>0.90</td><td>0.97</td></tr><tr><td colspan="5">B=10</td></tr><tr><td>Trainv. excluded</td><td>1.00</td><td>0.95</td><td>0.89</td><td>0.91</td></tr><tr><td>Train v. SVHN</td><td>1.00</td><td>0.97</td><td>0.95</td><td>0.96</td></tr></table>
Table 5: Out-of-distribution accuracy for the same models as above (see Tab. 4) on subsampled data. These values augment the AUROC values reported in Table 2.
APPENDIX B.3 SUPERVISED IN-DISTRIBUTION CLASSIFICATION ACCURACIES
<table><tr><td></td><td>RP*</td><td>DE</td><td>DE +AT</td><td>DR</td></tr><tr><td>CIFAR-10</td><td>0.86</td><td>0.88</td><td>0.86</td><td>0.86</td></tr><tr><td>Subsampled CIFAR-10</td><td>0.82</td><td>0.81</td><td>0.82</td><td>0.75</td></tr><tr><td>CIFAR-100</td><td>0.90</td><td>0.91</td><td>0.90</td><td>0.89</td></tr></table>
Table 6: In-distribution supervised classification accuracies on the respective test sets of the different data sets for random priors (RP), deep ensembles (DE), deep ensembles with adversarial training $( \mathrm { D E + A T } )$ ) and spatial concrete dropout (DR).
\*Since random priors do not have an intrinsic supervised prediction model, we used the predictions from the $\mathrm { D E + A T }$ model in all our experiments instead, setting $B = 1$ .
# APPENDIX B.4 CIFAR100 EXPERIMENT
As additional empirical support for our method, we ran experiments on another data set, namely CIFAR-100 (Krizhevsky et al., 2009). Again, we include 5 classes in the training set and exclude the remaining classes. The results are reported in the following (Figs. 8, 9; Tabs. 7, 8). They qualitatively and quantitatively support the same conclusions as our previous experiments.
# APPENDIX C BACKGROUND ON BAYES RISK
For completeness, we recall the definition of Bayes Risk. We are often interested in minimizing the Mean Squared Error $\mathrm { E } _ { f } \left[ ( f ( x _ { \star } ) - w ) ^ { 2 } \right]$ , where $x _ { \star }$ is a given test point and $w$ is a variable we are
 Figure 8: Distribution of uncertainty estimates for various algorithms. Top row shows seen data, bottom row shows unseen data from CIFAR-100. For random priors (RP), uncertainties are $\hat { \sigma } ^ { 2 }$ . For other algorithms, they are $1 - \operatorname* { m a x } ( p _ { \mu } )$ , where $p _ { \mu }$ is the averaged output of models in ensemble (Lakshminarayanan et al., 2017).
 Figure 9: The relationship between uncertainty (horizontal axis) and accuracy (vertical axis) for $B =$ 1, 5, 10 on samples from CIFAR-100. In well-calibrated models, accuracy increases as uncertainty declines.
allowed to adjust. A known result of Bayesian decision theory (Robert, 2007; Murphy, 2012) is that the minimizer of the MSE is given by the expected value of $f$ , i.e.
$$\underset { w } { \arg \operatorname* { m i n } } \mathrm { E } _ { f } \left[ ( f ( x _ { \star } ) - w ) ^ { 2 } \right] = \mathrm { E } _ { f } \left[ f ( x _ { \star } ) \right] .$$
Equation 12 holds for any stochastic process $f$ , including when $f$ is a posterior process obtained by conditioning on some dataset. A consequence of equation 12 is that it is impossible to obtain a MSE lower than the one obtained by computing the posterior mean of $f$ .
# APPENDIX D GAUSSIAN PROCESSES
A stochastic process is Gaussian (Williams & Rasmussen, 2006), if all its finite-dimensional distributions are Gaussian. The main advantage of GPs is that the posterior process can be expressed in a tractable way. GPs are often used for regression, where we are learning an unknown function4 $\phi : \mathbb { R } ^ { K } \mathbb { R }$ from noisy observations. Since a Gaussian distribution is completely identified by its first two moments, a GP can be defined by a mean function and a covariance function. Formally, the notation $\mathcal { G P } ( \mu , k )$ refers to a GP with with mean function $\mu : \mathbb { R } ^ { K } \mathbb { R }$ , a positive-definite kernel function $\boldsymbol { k } : \dot { \mathbb { R } ^ { K } } \times \mathbb { R } ^ { K } \mathbb { R }$ . GPs can be used to model two kinds of uncertainty: epistemic uncertainty, which reflects lack of knowledge about unobserved values of $\phi$ and aleatoric uncertainty, which reflects measurement noise. When performing regression, we start with a zero-mean prior $\mathcal { G P } ( 0 , k )$ and then observe $N$ training points $X = \{ x _ { i } \} _ { i = 1 , \dots , N }$ and labels $y = \{ y _ { i } \} _ { i = 1 , \dots , N }$ where $y _ { i } = \phi ( x _ { i } ) + \epsilon _ { i }$ . Here, the i.i.d. random variables $\epsilon _ { i } \sim \mathcal { N } ( 0 , \sigma _ { A } ^ { 2 } )$ model the aleatoric noise. We obtain the posterior process on $\mathcal { G P } ( \mu _ { X y } , k _ { X } )$ . For GPs, the mean and covariance of the posterior GP on $y$ evaluated at $x _ { \star }$ can be expressed as
<table><tr><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1>RP</td><td rowspan=1 colspan=1>DE</td><td rowspan=1 colspan=1>DE+AT</td><td rowspan=1 colspan=1>DR</td></tr><tr><td rowspan=1 colspan=5>B=1</td></tr><tr><td rowspan=1 colspan=1>Train v. excludedTrain v. SVHN</td><td rowspan=1 colspan=1>1.00± 0.0001.00 ± 0.000</td><td rowspan=1 colspan=1>0.93± 0.0030.96 ± 0.004</td><td rowspan=1 colspan=1>0.98 ± 0.0010.99 ± 0.001</td><td rowspan=1 colspan=1>0.88±0.0020.82 ±0.002</td></tr><tr><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1>B=10</td><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1></td></tr><tr><td rowspan=1 colspan=1>Trainv.excludedTrain v. SVHN</td><td rowspan=1 colspan=1>1.001.00</td><td rowspan=1 colspan=1>0.960.99</td><td rowspan=1 colspan=1>0.991.00</td><td rowspan=1 colspan=1>0.900.82</td></tr></table>
Table 7: Out-of-distribution classification AUROCs on CIFAR-100 for random priors (RP), deep ensembles (DE), deep ensembles with adversarial training $( \mathrm { D E + A T } )$ and spatial concrete dropout (DR). The $\pm$ symbol denotes one standard error. Table 8: Out-of-distribution classification accuracy on CIFAR-100 for random priors (RP), deep ensembles (DE), deep ensembles with adversarial training $( \mathrm { D E + A T } )$ and spatial concrete dropout (DR). The $\pm$ symbol denotes one standard error. These values augment the AUROC values reported in Table 7.
<table><tr><td></td><td>RP</td><td>DE</td><td>DE +AT</td><td>DR</td></tr><tr><td colspan="5">B=1</td></tr><tr><td>Train v.excluded Train v. SVHN</td><td>1.00 ± 0.001 0.97 ± 0.003</td><td>0.91 ±0.002 0.95 ± 0.003</td><td>0.97 ± 0.001 0.99 ± 0.001</td><td>0.82±0.003 0.74 ± 0.003</td></tr><tr><td colspan="5">B=10</td></tr><tr><td>Trainv.excluded</td><td>1.00</td><td>0.94</td><td>0.98</td><td>0.83</td></tr><tr><td>Train v. SVHN</td><td>0.98</td><td>0.98</td><td>0.99</td><td>0.74</td></tr></table>
$$\begin{array} { r } { \mu _ { X y } ( x _ { \star } ) = k _ { \star } ^ { \top } ( K + \sigma _ { A } ^ { 2 } I ) ^ { - 1 } y \quad \mathrm { a n d } \qquad } \\ { \sigma _ { X } ^ { 2 } ( x _ { \star } ) \triangleq k _ { X } ( x _ { \star } , x _ { \star } ) + \sigma _ { A } ^ { 2 } = k _ { \star \star } - k _ { \star } ^ { \top } ( K + \sigma _ { A } ^ { 2 } I ) ^ { - 1 } k _ { \star } + \sigma _ { A } ^ { 2 } . } \end{array}$$
In particular, the posterior covariance does not depend on $y$ . In the formula above, we use the kernel matrix $K \in \mathbb { R } ^ { N } \times \mathbb { R } ^ { N }$ defined as $K _ { i j } = k ( x _ { i } , x _ { j } )$ , where $x _ { i }$ and $x _ { j }$ are in the training set. We also use the notation $\boldsymbol { k } _ { \star } \in \mathbb { R } ^ { N }$ for the vector of train-test correlations $\{ k _ { \star } \} _ { i } = k ( x _ { i } , x ^ { \star } )$ , where $x _ { i }$ is in the training set and $k ( x ^ { \star } , x ^ { \star } )$ is similarly defined. The shorthand $\sigma _ { X } ^ { 2 } ( x _ { \star } )$ introduced in equation 14 denotes the posterior variance at a single point.
# APPENDIX E LIST OF SYMBOLS DENOTING VARIANCE
Below, we give a list of symbols used for variance of various random variables.
<table><tr><td>0 .2 O X 8</td><td>posterior variance of stochastic process posterior variance of Gaussian process prior variance of stochastic process sample-based estimate of prior GP variance combined uncertainty estimate (see equation 1) sample-based mean part of uncertainty estimate (see equation 2) Ef[o2]</td></tr></table>
# APPENDIX F PROOFS
We now give formal proofs for the results in the paper.
# APPENDIX F.1 PROOFS RELATING TO CONSERVATISM
Lemma 1. For any function $h : \mathbb { R } ^ { N \times ( K + 1 ) } \mathbb { R } ^ { M }$ , for any test point $\boldsymbol { x } _ { \star } ~ \in ~ \mathbb { R } ^ { K }$ and for any stochastic process $\{ f ( x ) \} _ { x \in \mathbb { R } ^ { K } }$ with all second moments finite and exchangeable outputs
$$\begin{array} { r } { \tilde { \sigma } _ { \mu } ^ { 2 } ( x _ { \star } ) = \mathrm { E } _ { f ( X ) } \left[ \sigma _ { X f } ^ { 2 } ( x _ { \star } ) + \frac { 1 } { M } \| \mu _ { X f } ( x _ { \star } ) - h _ { X f } ( x _ { \star } ) \| ^ { 2 } \right] . } \end{array}$$
Proof. We prove the statement by re-writing the expression on the left.
$$\begin{array} { r l r } { \bar { \sigma } _ { \mu } ^ { 2 } ( { \boldsymbol x } _ { \star } ) = \frac { 1 } { M } { \mathrm { ~ E } } _ { f } ( { \boldsymbol x } ) , f ( | | f ( { \boldsymbol x } _ { \star } ) - h _ { X } f ( { \boldsymbol x } _ { \star } ) | | ^ { 2 } ] } & { \mathrm { ( I 5 ) } } \\ { \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad } \\ { \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad } \\ { \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad } \\ { \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad } \\ \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \end{array}$$
Here, the equality in (16) holds by definition of conditional probability. The equality in (19) holds by definition of posterior mean and the equality 21 follows by assumption that the process has exchangeable outputs. While this argument follows a similar pattern to a standard result about Bayesian Risk (see Appendix Appendix C), it is not identical because the function $h _ { X f }$ depends on $f$ . □
Proposition 1 (Strict Conservatism in Expectation). Assume that $f$ is a GP. Then for any function $h : \bar { \mathbb { R } } ^ { N \times K } \to \bar { \mathbb { R } } ^ { M }$ , we have
$$\tilde { \sigma } _ { \mu } ^ { 2 } ( x _ { \star } ) = \sigma _ { X } ^ { 2 } ( x _ { \star } ) + \underbrace { { \mathrm E } _ { f ( X ) } \left[ \frac { 1 } { M } \| \mu _ { X f } ( x _ { \star } ) - h _ { X f } ( x _ { \star } ) \| ^ { 2 } \right] } _ { \geq 0 } .$$
Moreover, equality holds if and only if $h _ { X f } ( x _ { \star } ) = \mu _ { X f } ( x _ { \star } )$ .
Proof. We instantiate Lemma 1 by setting $f$ to be a GP. By equation 14, the posterior covariance of a GP does not depend on the target values, i.e. $\sigma _ { X f } ^ { 2 } ( x _ { \star } ) \dot { } = \dot { \sigma } _ { X } ^ { 2 } ( x _ { \star } )$ . The first part of the result can be shown by pulling $\sigma _ { X } ^ { 2 } ( x _ { \star } )$ out of the expectation. Moreover, since $\| \cdot \|$ is a norm and hence positive semi-definite, equality holds if and only if $h _ { X f } ( x _ { \star } ) = \mu _ { X f } ( x _ { \star } )$ . □
Lemma 3. Assume that the random variable $\hat { \sigma } _ { \mu } ^ { 2 } ( x _ { \star } )$ has finite variance upper bounded by vUB. With probability $1 - \delta$ , we have $\begin{array} { r } { \hat { \sigma } _ { \mu } ^ { 2 } ( x _ { \star } ) + \frac { 1 } { \sqrt { \delta } } v _ { U B } \ge \tilde { \sigma } _ { \mu } ^ { 2 } ( x _ { \star } ) } \end{array}$ .
Proof. The proof is standard, but we state it in our notation for completeness. Applying Chebyshev’s inequality to the random variable $\hat { \sigma } _ { \mu } ^ { 2 } ( x _ { \star } )$ , we have that $\begin{array} { r } { \mathrm { P r o b } \left( | \tilde { \sigma } _ { \mu } ^ { 2 } ( x _ { \star } ) - \hat { \sigma } _ { \mu } ^ { 2 } ( x _ { \star } ) | \ge \frac { 1 } { \sqrt { \delta } } v _ { \mathrm { U B } } \right) \le \delta , } \end{array}$ , implying the statement. □
Corollary 1 (Strict Conservatism for Finite Bootstraps). Assume that $f$ is a GP. Assume that the random variable $\hat { \sigma } _ { \mu } ^ { 2 } ( x _ { \star } )$ has finite variance upper bounded by vUB. Then with probability $1 - \delta$ , for any function $h : \mathbb { R } ^ { \dot { N } \times K } \to \mathbb { R } ^ { M }$ , we have
$$\begin{array} { r } { \hat { \sigma } _ { \mu } ^ { 2 } ( x _ { \star } ) + \frac { 1 } { \sqrt { \delta } } v _ { U B } \geq \tilde { \sigma } _ { \mu } ^ { 2 } ( x _ { \star } ) \geq \sigma _ { X } ^ { 2 } ( x _ { \star } ) . } \end{array}$$
Proof. Combine Lemma 3 and Proposition 1.
Lemma 2. Assume that the GP $\{ f ( x ) \}$ is zero mean with exchangeable outputs and the function $h _ { X f }$ takes values in $[ - U , U ] ^ { M }$ . Assume that permuting the outputs of $f$ produces the same permutation in the outputs of $h _ { X f }$ . With probability $1 - \delta$ , we have
$$\operatorname { V a r } _ { f _ { 1 } , \dots , f _ { B } } \left[ \widehat { \sigma } _ { \mu } ^ { 2 } ( x _ { \star } ) \right] \leq v _ { U B } ,$$
where vUB is expressible in terms of observable quantities.
Proof. We seek to decompose the variance of $\hat { \sigma } _ { \mu } ^ { 2 } ( x _ { \star } )$ into the part that comes from the prior and the part that comes from the fitted function $h _ { X f ^ { m } }$ .
$$\begin{array} { r l } & { \operatorname { V a r } _ { f _ { 1 } , \ldots , f _ { D } } \big [ \widehat { \mathcal { O } } _ { \sharp } ^ { \sharp } ( x , x ) \big ] } \\ & { = \operatorname { V a r } _ { f _ { 1 } , \ldots , f _ { D } } \bigg [ \sum _ { i = 1 } ^ { B } \frac { 1 } { M L ^ { D } } \big \lVert f ( x , x ) - h _ { X , f _ { i } } ( x , x ) \big \rVert ^ { 2 } \bigg ] } \\ & { = \frac { 1 } { R } \operatorname { V o r } _ { f } \Big [ \frac { 1 } { M } \big \lVert f ( x , x ) - h _ { X , f _ { i } } ( x , x ) \big \rVert ^ { 2 } \Big ] } \\ & { = \frac { 1 } { B } \frac { 1 } { M } \operatorname { V a r } _ { f } \Big [ \big ( \sum _ { m = 1 } ^ { M } \big ( f ^ { m } ( x , x ) - h _ { X , f ^ { m } } ( x , x ) \big ) ^ { 2 } \Big ] } \\ & { = \frac { 1 } { B } \frac { 1 } { M ^ { 2 } } \sum _ { m = 1 } ^ { M } \sum _ { i = 1 } ^ { M } \operatorname { C o r } _ { f } \big [ \big ( f ^ { m } ( x , x ) - h _ { X , f ^ { m } } ( x , x ) \big ) ^ { 2 } , ( f ^ { t } ( x , x ) - h _ { X , f ^ { i } } ( x , x ) \big ) ^ { 2 } \big ] } \\ & { \leq \frac { 1 } { B } \frac { 1 } { M ^ { 2 } } M ^ { 2 } \operatorname { V a r } _ { f } \big [ \big ( f ^ { m } ( x , x ) - h _ { X , f ^ { m } } ( x , x ) \big ) ^ { 2 } \big ] } \\ & { = \frac { 1 } { B } \operatorname { V a r } _ { f } \big [ \big ( f ^ { m } ( x , x ) - h _ { X , f ^ { m } } ( x , x ) \big ) ^ { 2 } \big ] } \\ & { \leq \frac { 1 } { B } \operatorname { E a r } _ { f } \big [ \big ( f ^ { m } ( x , x ) - h _ { X , f ^ { m } } ( x , x ) \big ) ^ { 2 } \big ] } \\ & { = \frac { 1 } { B } \operatorname { V a r } _ { f } \big [ \big ( f ^ { m } ( x , x ) - h _ { X , f ^ { m } } ( x , x ) \big ) ^ { 3 } \big ] } \\ & = \frac { 1 } { B } \operatorname { V a r } _ { f } \big [ \big ( f ^ { m } ( x , x ) - h _ X , f \end{array}$$
Here, line 27 holds by exchangeability of outputs and the Cauchy-Schwarz inequality.
Since $h _ { X f ^ { m } } ( x _ { \star } )$ is has support in $[ - U , U ]$ , we have
$$\begin{array} { r } { \mathrm { E } _ { f } \left[ \left( h _ { X f ^ { m } } ( x _ { \star } ) ) ^ { 2 } ) \right] \leq U ^ { 2 } , \mathrm { E } _ { f } \left[ \left( h _ { X f ^ { m } } ( x _ { \star } ) \right) ^ { 4 } ) \right] \leq U ^ { 4 } , \mathrm { E } _ { f } \left[ \left( h _ { X f ^ { m } } ( x _ { \star } ) \right) ^ { 6 } \right) \right] \leq U ^ { 6 } . } \end{array}$$
Moreover, since $f ( x _ { \star } )$ is Gaussian and zero mean, we can write out the moments explicitly.
$$\begin{array} { r } { \mathrm { E } _ { f } \left[ ( f ^ { m } ( x _ { \star } ) ) ^ { 4 } ) \right] = 3 ( \mathrm { E } _ { f } \left[ ( f ^ { m } ( x _ { \star } ) ) ^ { 2 } ) \right] ) ^ { 2 } } \\ { \mathrm { E } _ { f } \left[ ( f ^ { m } ( x _ { \star } ) ) ^ { 6 } ) \right] = 1 5 ( \mathrm { E } _ { f } \left[ ( f ^ { m } ( x _ { \star } ) ) ^ { 2 } ) \right] ) ^ { 3 } } \end{array}$$
Since $f ( x _ { \star } )$ is Gaussian, we can use a sample-based estimate of the prior variance and obtain an probabilistic confidence interval. In particular, we know that $\begin{array} { r } { \mathrm { E } _ { f } \left[ ( f ^ { m } ( x _ { \star } ) ) ^ { 2 } ) \right] \leq \hat { \sigma } _ { 0 } ^ { 2 } ( x _ { \star } ) \frac { B _ { 0 } - 1 } { \chi _ { I } ^ { 2 } ( \delta ) } } \end{array}$ with probability $1 - \delta$ , where $\chi _ { I } ^ { 2 }$ denotes the inverse CDF of the Chi-Squared distribution with $B _ { 0 } - 1$ degrees of freedom. We denote this upper bound with $\begin{array} { r } { w _ { \mathrm { U B } } = \hat { \sigma } _ { 0 } ^ { 2 } ( x _ { \star } ) \frac { B _ { 0 } - 1 } { \chi _ { I } ^ { 2 } ( \delta ) } } \end{array}$ .
We proceed by bounding the individual terms in equation 30 separately.
$$\begin{array} { r l } & { \quad \mathrm { E } _ { f } \left[ ( f ^ { m } ( x _ { \star } ) ) ^ { 4 } \right] = 3 ( \mathrm { E } _ { f } \left[ ( f ^ { m } ( x _ { \star } ) ) ^ { 2 } \right] ) ^ { 2 } } \\ & { - \mathrm { E } _ { f } \left[ ( f ^ { m } ( x _ { \star } ) ) ^ { 3 } h _ { X f ^ { m } } ( x _ { \star } ) \right] \leq \sqrt { \mathrm { E } _ { f } \left[ ( f ^ { m } ( x _ { \star } ) ) ^ { 6 } \right] \mathrm { E } _ { f } \left[ ( h _ { X f ^ { m } } ( x _ { \star } ) ) ^ { 2 } \right] } } \\ & { \quad \mathrm { E } _ { f } \left[ ( f ^ { m } ( x _ { \star } ) ) ^ { 2 } ( h _ { X f ^ { m } } ( x _ { \star } ) ) ^ { 2 } \right] \leq \sqrt { \mathrm { E } _ { f } \left[ ( f ^ { m } ( x _ { \star } ) ) ^ { 4 } \right] \mathrm { E } _ { f } \left[ ( h _ { X f ^ { m } } ( x _ { \star } ) ) ^ { 4 } \right] } } \\ & { - \mathrm { E } _ { f } \left[ f ^ { m } ( x _ { \star } ) ( h _ { X f ^ { m } } ( x _ { \star } ) ) ^ { 3 } \right] \leq \sqrt { \mathrm { E } _ { f } \left[ ( f ^ { m } ( x _ { \star } ) ) ^ { 2 } \right] \mathrm { E } _ { f } \left[ ( h _ { X f ^ { m } } ( x _ { \star } ) ) ^ { 6 } \right] } } \end{array}$$
Combining the above, equation 30 and the bounds on individual moments in equations 31 and 32, we obtain
$$\begin{array} { r } { \operatorname { V a r } _ { f _ { 1 } , \ldots , f _ { B } } \left[ \widehat \sigma _ { \mu } ^ { 2 } ( x _ { \star } ) \right] \leq \underbrace { \frac { 1 } { B } \left( 3 w _ { \mathrm { U B } } ^ { 2 } + 4 \sqrt { 1 5 w _ { \mathrm { U B } } ^ { 3 } U ^ { 2 } } + 6 \sqrt { 3 w _ { \mathrm { U B } } ^ { 2 } U ^ { 4 } } + 4 \sqrt { w _ { \mathrm { U B } } U ^ { 6 } } + U ^ { 4 } \right) } _ { v _ { \mathrm { U B } } } . } \end{array}$$
Here, $\begin{array} { r } { w _ { \mathrm { U B } } = \hat { \sigma } _ { 0 } ^ { 2 } ( x _ { \star } ) \frac { B _ { 0 } - 1 } { \chi _ { I } ^ { 2 } ( \delta ) } } \end{array}$ , $\hat { \sigma } _ { 0 } ^ { 2 } ( x _ { \star } )$ is a sample-based estimate of the prior variance obtained with $B _ { 0 }$ samples, where $\chi _ { I } ^ { 2 }$ denotes the inverse CDF of the Chi-Squared distribution with $B _ { 0 } - 1$ degrees of freedom.
# APPENDIX F.2 PROOFS RELATING TO CONCENTRATION
We now proceed to the proofs showing concentration. We begin by formally defining a class of predictor networks.
Definition 1 (Class $\mathcal { H } _ { U }$ of Lipschitz networks). Consider functions $h ~ : ~ \mathbb { R } ^ { K } ~ \to ~ \mathbb { R } ^ { M }$ . Let $j , j ^ { \prime } \ = \ 1 , \ldots , M$ , index the outputs of the function. We define $\mathcal { H } _ { U }$ so that each $\textit { h } \in \ \mathcal { H } _ { U }$ has the following properties for each ${ j , j ^ { \prime } }$ . $\mathbf { ( P 1 }$ ) $h _ { j }$ is Lipschitz continuous with constant $L ,$ i.e. $\| h _ { j } ( x ) - h _ { j } ( x ^ { \prime } ) \| _ { 2 } \leq L \| x - x ^ { * } \| _ { 2 }$ for all $x , x ^ { \prime }$ with $\| x \| _ { \infty } \leq 1$ and $\| x ^ { \prime } \| _ { \infty } \leq 1$ , $( \mathbf { P } 2 )$ outputs are exchangeable, i.e. $\{ h _ { j } : h \in \mathcal { H } _ { U } \} = \{ h _ { j ^ { \prime } } : h \in \mathcal { H } _ { U } \}$ , (P3) the class is symmetric around zero, i.e. $h _ { j } \ \in \ \{ h _ { j } \ : \ \bar { h } \ \in \ \mathcal { H } _ { U } \}$ implies $- \bar { h } _ { j } \in \lbrace h _ { j } : h \in \rbrace { \mathcal { H } } _ { U } \rbrace$ . (P4) $h _ { j }$ is bounded, i.e. $\operatorname* { m a x } _ { \| x \| _ { \infty } \leq 1 } | h _ { j } ( x ) | \leq U$ .
While the conditions in Definition 1 look complicated, they are in fact easy to check for predictor networks that follow the architecture in Figure 2. In particular, Lipschitz continuity $( \mathbf { P 1 } )$ has to hold in practice because its absence would indicate extreme sensitivity to input perturbations. Output exchangeability $( \mathbf { P } 2 )$ holds since reordering the outputs does not change our architecture. Symmetry around zero $( { \bf P } { \bf 3 } )$ holds by flipping the sign in the last network layer. Boundedness $\mathbf { ( P 4 ) }$ is easy to ensure by clipping outputs. In the following Lemma, we obtain a bound on the expected uncertainty.
Lemma 4. Consider a target function $f : \mathbb { R } ^ { K } \to \mathbb { R } ^ { M }$ , where $j = 1 , \dots , M$ , with the domain restricted to $\| x \| _ { \infty } \leq 1$ . Introduce a constant $U$ such that $\operatorname* { m a x } _ { \| x \| \infty \leq 1 } | f _ { j } ( x ) | \leq U$ . Denote the data distribution with support on $\{ x : \| x \| _ { \infty } \leq 1 \}$ as $\mathcal { D }$ . Moreover, assume $K \geq 3 .$ . For $h _ { X f } \in \mathcal { H } _ { U }$ , with probability $1 - \delta$ we have
$$\begin{array} { r } { \mathrm { E } _ { x _ { \star } \sim { D } } [ \frac { 1 } { M } \| f ( x _ { \star } ) - h _ { X f } ( x _ { \star } ) \| ^ { 2 } ] \le \frac { 1 } { M N } \sum _ { i = 1 } ^ { N } \| f ( x _ { i } ) - h _ { X f } ( x _ { i } ) \| ^ { 2 } + L U { \cal O } \Big ( \frac { 1 } { \sqrt [ { k _ { \sqrt { N } } } ] { \frac { \log ( 1 / \delta ) } { N } } } \Big ) . } \end{array}$$
Proof. The proof uses standard Rademacher tools. To avoid confusion across several conventions, we explicitly define the Rademacher complexity of a function class $\mathcal { G }$ as:
$$\begin{array} { r } { \hat { \mathfrak { R } } _ { N } ( \mathcal { G } ) \triangleq \mathrm { E } _ { u _ { i } } \left[ \operatorname* { s u p } _ { g \in \mathcal { G } } \frac { 1 } { N } \sum _ { i = 1 } ^ { N } u _ { i } g ( x _ { i } ) \right] = \mathrm { E } _ { u _ { i } } \left[ \operatorname* { s u p } _ { g \in \mathcal { G } } \frac { 1 } { N } \left| \sum _ { i = 1 } ^ { N } u _ { i } ^ { j } g ( x _ { i } ) \right| \right] . } \end{array}$$
Here, the random variables $u _ { i }$ are sampled i.i.d. using a discrete distribution with $\mathrm { P r o b } ( u _ { i } ~ =$ $- 1 ) \ = \ \mathrm { P r o b } ( u _ { i } \ = \ 1 ) \ = \ { \textstyle { \frac { 1 } { 2 } } }$ and the the second equality follows by using property (P3). We start by applying the generic Rademacher bound (Mohri et al., 2018) to the function class $\mathcal { M } =$ $\begin{array} { r } { \{ x _ { 1 } , \ldots , \overset { \left. \right.} { x _ { N } } , t _ { 1 } \ldots , t _ { N } \frac { 1 } { U ^ { 2 } } \frac { 1 } { M } \| t _ { i } - h ( x _ { i } ) \| ^ { 2 } , h \in \mathcal { H } _ { U } \} . } \end{array}$ , which contains the possible errors of the predictor.
$$\begin{array} { r l } & { \mathrm { E } _ { x _ { \star } \sim \mathcal { D } } [ \frac { 1 } { B ^ { 2 } } \frac { 1 } { M } \| f ( x _ { \star } ) - h _ { X f } ( x _ { \star } ) \| ^ { 2 } ] } \\ & { \phantom { \frac { 1 } { \theta } } \leq \frac { 1 } { M N } \frac { 1 } { B ^ { 2 } } \sum _ { i = 1 } ^ { N } \| f ( x _ { i } ) - h _ { X f } ( x _ { i } ) \| ^ { 2 } + \widehat { \mathfrak { R } } _ { N } ( \mathcal { M } ) + O \left( \sqrt { \frac { \log ( 1 / \delta ) } { N } } \right) . } \end{array}$$
We now introduce the function class $\begin{array} { r } { \mathcal { M } ^ { \prime } = \{ x _ { 1 } , \ldots , x _ { N } , t _ { 1 } \ldots , t _ { N } \frac { 1 } { B ^ { 2 } } ( t _ { i } ^ { j } - h ^ { j } ( x _ { i } ) ) ^ { 2 } , h \in \mathcal { H } _ { U } \} } \end{array}$ which models the per-output squared error. Because of property (P2), ${ \bar { \mathcal { M } } } ^ { \prime }$ does not depend on the output index $j$ . By pulling out the sum outside the supremum in equation 35, we get
$$\hat { \Re } _ { N } ( \mathcal { M } ) \leq \hat { \Re } _ { N } ( \mathcal { M } ^ { \prime } ) .$$
by Talagrand’s Lemma (Mohri et al., 2018; Duchi, 2009), we also have
$$\hat { \mathfrak { R } } _ { N } ( \mathcal { M } ^ { \prime } ) \leq 4 \hat { \mathfrak { R } } _ { N } ( \mathcal { H } _ { 1 } ) .$$
Here, $\mathcal { H } _ { 1 } \ = \ \{ \frac { 1 } { \pi } h ^ { j } \ : \ h \in \ \mathcal { H } _ { U } \}$ . By property $( \mathbf { P 1 } )$ , functions in $\mathcal { H } _ { 1 }$ are Lipschitz continuous with constant $L / U$ . Instantiating a known bound for Lipschitz-continuous functions (Luxburg $\&$ Bousquet, 2004, Theorem 18 and Example 4), and using the assumption $K \geq 3$ , we get $\hat { \mathfrak { R } } _ { N } ( \varkappa _ { 1 } ) \leq$ $\begin{array} { r } { \frac { L } { U } O \left( \frac { 1 } { \sqrt [ K ] { N } } \right) } \end{array}$ . The Lemma follows by combining this with equation 37 and equation 38, plugging into equation 36 and re-scaling by $U ^ { 2 }$ . □
Lemma 4 allowed us to relate the error on the training set to the expected error on the test set. It also shows that the two will be closer for small values of the Lipschitz constant $L$ . We now use this Lemma to show our main concentration result (Proposition 2).
Proposition 2. If the training converges, i.e. the training loss $\begin{array} { r } { \frac { 1 } { M N } \sum _ { i = 1 } ^ { N } \| f ( x _ { i } ) - h _ { X f } ( x _ { i } ) \| ^ { 2 } = \sigma _ { A } ^ { 2 } } \end{array}$ for arbitrarily large training sets, then assuming the predictors $h _ { X f }$ are bounded and Lipschitz continuous with constant $L ,$ , then under technical conditions the uncertainties concentrate, i.e. $\hat { \sigma } ^ { 2 } ( x _ { \star } ) 0$ as $N \to \infty$ and $B \infty$ with probability $^ { l }$ .
Proof. We are assuming the technical conditions of Lemma 4. Instantiating Lemma 4, setting the training loss to $\sigma _ { A } ^ { 2 }$ in the RHS of equation 34 and letting $N \infty$ , we obtain the following with probability 1:
$$\operatorname * { l i m } _ { N \infty } \mathrm { E } _ { x _ { \star } \sim \mathcal { D } } [ \widehat { \sigma } _ { \mu } ^ { 2 } ( x _ { \star } ) ] = \sigma _ { A } ^ { 2 } .$$
This implies:
$$\operatorname* { l i m } _ { N \infty } \mathrm { E } _ { x _ { \star } \sim \mathcal { D } } [ \operatorname* { m a x } ( 0 , \hat { \sigma } _ { \mu } ^ { 2 } ( x _ { \star } ) - \sigma _ { A } ^ { 2 } ) ] = 0 .$$
From the continuity of $f$ and $h _ { X f }$ we have that $\hat { \sigma } _ { \mu } ^ { 2 }$ is continuous in $x _ { \star }$ . Together with the property that the expression under the expectation is non-negative, this gives that for every $x _ { \star }$ .
$$\operatorname * { l i m } _ { N \infty } \operatorname * { m a x } ( 0 , \hat { \sigma } _ { \mu } ^ { 2 } ( x _ { \star } ) - \sigma _ { A } ^ { 2 } ) = 0 .$$
Since the right-hand side does not depend on $B$ , we also have
$$\operatorname * { l i m } _ { B \to \infty } \operatorname * { l i m } _ { N \to \infty } \operatorname * { m a x } ( 0 , \hat { \sigma } _ { \mu } ^ { 2 } ( x _ { \star } ) - \sigma _ { A } ^ { 2 } ) = 0 .$$
From the definition of $\hat { v } _ { \sigma }$ , we have that
$$\operatorname * { l i m } _ { B \infty } \operatorname * { l i m } _ { N \infty } \hat { v } _ { \sigma } = 0 .$$
We show the Lemma by combining equation 42 and equation 43 with equation 1.123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240# REVISITING BATCH NORMALIZATION FORPRACTICAL DOMAIN ADAPTATION
Yanghao $\mathbf { L i } ^ { \dagger }$ , Naiyan Wang‡, Jianping $\mathbf { S h i } ^ { \circ }$ , Jiaying $\mathbf { L } \mathbf { i } \mathbf { u } ^ { \dagger }$ , Xiaodi Hou‡
† Institute of Computer Science and Technology, Peking University ‡ TuSimple SenseTime lyttonhao@pku.edu.cn winsty@gmail.com shijianping5000@gmail.com liujiaying@pku.edu.cn xiaodi.hou@gmail.com
# ABSTRACT
Deep neural networks (DNN) have shown unprecedented success in various computer vision applications such as image classification and object detection. However, it is still a common annoyance during the training phase, that one has to prepare at least thousands of labeled images to fine-tune a network to a specific domain. Recent study (Tommasi et al., 2015) shows that a DNN has strong dependency towards the training dataset, and the learned features cannot be easily transferred to a different but relevant task without fine-tuning. In this paper, we propose a simple yet powerful remedy, called Adaptive Batch Normalization (AdaBN) to increase the generalization ability of a DNN. By modulating the statistics from the source domain to the target domain in all Batch Normalization layers across the network, our approach achieves deep adaptation effect for domain adaptation tasks. In contrary to other deep learning domain adaptation methods, our method does not require additional components, and is parameter-free. It archives stateof-the-art performance despite its surprising simplicity. Furthermore, we demonstrate that our method is complementary with other existing methods. Combining AdaBN with existing domain adaptation treatments may further improve model performance.
# 1 INTRODUCTION
Training a DNN for a new image recognition task is expensive. It requires a large amount of labeled training images that are not easy to obtain. One common practice is to use labeled data from other related source such as a different public dataset, or harvesting images by keywords from a search engine. Because 1) the distributions of the source domains (third party datasets or Internet images) are often different from the target domain (testing images); and 2) DNN is particularly good at capturing dataset bias in its internal representation (Torralba & Efros, 2011), which eventually leads to overfitting, imperfectly paired training and testing sets usually leads to inferior performance.
Known as domain adaptation, the effort to bridge the gap between training and testing data distributions has been discussed several times under the context of deep learning (Tzeng et al., 2014; Long et al., 2015; Tzeng et al., 2015; Ganin & Lempitsky, 2015). To make the connection between the domain of training and the domain of testing, most of these methods require additional optimization steps and extra parameters. Such additional computational burden could greatly complicate the training of a DNN which is already intimidating enough for most people.
In this paper, we propose a simple yet effective approach called AdaBN for batch normalized DNN domain adaptation. We hypothesize that the label related knowledge is stored in the weight matrix of each layer, whereas domain related knowledge is represented by the statistics of the Batch Normalization (BN) (Ioffe & Szegedy, 2015) layer. Therefore, we can easily transfer the trained model to a new domain by modulating the statistics in the BN layer. This approach is straightforward to implement, has zero parameter to tune, and requires minimal computational resources. Moreover, our AdaBN is ready to be extended to more sophisticated scenarios such as multi-source domain adaptation and semi-supervised settings. Fig. 1 illustrates the flowchart of AdaBN. To summarize, our contributions are as follows:
 Figure 1: Illustration of the proposed method. For each convolutional or fully connected layer, we use different bias/variance terms to perform batch normalization for the training domain and the test domain. The domain specific normalization mitigates the domain shift issue.
1. We propose a novel domain adaptation technique called Adaptive Batch Normalization (AdaBN). We show that AdaBN can naturally dissociate bias and variance of a dataset, which is ideal for domain adaptation tasks. 2. We validate the effectiveness of our approach on standard benchmarks for both single source and multi-source domain adaptation. Our method outperforms the state-of-the-art methods. 3. We conduct experiments on the cloud detection for remote sensing images to further demonstrate the effectiveness of our approach in practical use.
# 2 RELATED WORK
Domain transfer in visual recognition tasks has gained increasing attention in recent literature (Beijbom, 2012; Patel et al., 2015). Often referred to as covariate shift (Shimodaira, 2000) or dataset bias (Torralba & Efros, 2011), this problem poses a great challenge to the generalization ability of a learned model. One key component of domain transfer is to model the difference between source and target distributions. In Khosla et al. (2012), the authors assign each dataset with an explicit bias vector, and train one discriminative model to handle multiple classification problems with different bias terms. A more explicit way to compute dataset difference is based on Maximum Mean Discrepancy (MMD) (Gretton et al., 2012). This approach projects each data sample into a Reproducing Kernel Hilbert Space, and then computes the difference of sample means. To reduce dataset discrepancies, many methods are proposed, including sample selections (Huang et al., 2006; Gong et al., 2013), explicit projection learning (Pan et al., 2011; Gopalan et al., 2011; Baktashmotlagh et al., 2013) and principal axes alignment (Fernando et al., 2013; Gong et al., 2012; Aljundi et al., 2015).
All of these methods face the same challenge of constructing the domain transfer function – a highdimensional non-linear function. Due to computational constraints, most of the proposed transfer functions are in the category of simple shallow projections, which are typically composed of kernel transformations and linear mapping functions.
In the field of deep learning, feature transferability across different domains is a tantalizing yet generally unsolved topic (Yosinski et al., 2014; Tommasi et al., 2015). To transfer the learned representations to a new dataset, pre-training plus fine-tuning (Donahue et al., 2014) have become de facto procedures. However, adaptation by fine-tuning is far from perfect. It requires a considerable amount of labeled data from the target domain, and non-negligible computational resources to retrain the whole network.
A series of progress has been made in DNN to facilitate domain transfer. Early works of domain adaptation either focus on reordering fine-tuning samples (Chopra et al., 2013), or regularizing MMD (Gretton et al., 2012) in a shallow network (Ghifary et al., 2014). It is only until recently that the problem is directly attacked under the setting of classification of unlabeled target domain using modern convolutional neural network (CNN) architecture. DDC (Tzeng et al., 2014) used the classical MMD loss to regularize the representation in the last layer of CNN. DAN (Long et al., 2015) further extended the method to multiple kernel MMD and multiple layer adaptation. Besides adapting features using MMD, RTN (Long et al., 2016) also added a gated residual layer for classifier adaptation. RevGrad (Ganin & Lempitsky, 2015) devised a gradient reversal layer to compensate the back-propagated gradients that are domain specific. Recently, by explicitly modeling both private and shared components of the domain representations in the network, Bousmalis et al. (2016) proposed a Domain Separation Network to extract better domain-invariant features.
Another related work is CORAL (Sun et al., 2016). This model focuses on the last layer of CNN. CORAL whitens the data in source domain, and then re-correlates the source domain features to target domain. This operation aligns the second order statistics of source domain and target domain distributions. Surprisingly, such simple approach yields state-of-the-arts results in various text classification and visual recognition tasks. Recently, Deep CORAL (Sun & Saenko, 2016) also extends the method into DNN by incorporating a CORAL loss.
# 2.1 BATCH NORMALIZATION
In this section, we briefly review Batch Normalization (BN) (Ioffe & Szegedy, 2015) which is closely related to our AdaBN. The BN layer is originally designed to alleviate the issue of internal covariate shifting – a common problem while training a very deep neural network. It first standardizes each feature in a mini-batch, and then learns a common slope and bias for each mini-batch. Formally, given the input to a BN layer $\mathbf { X } \in \mathbb { R } ^ { n \times p }$ , where $n$ denotes the batch size, and $p$ is the feature dimension, BN layer transforms a feature $j \in \{ 1 \ldots p \}$ into:
$$\begin{array} { r l } & { \hat { x } _ { j } = \frac { x _ { j } - \mathbb { E } \left[ \mathbf { X } _ { \cdot j } \right] } { \sqrt { \operatorname { V a r } [ \mathbf { X } _ { \cdot j } ] } } , } \\ & { y _ { j } = \gamma _ { j } \hat { x } _ { j } + \beta _ { j } , } \end{array}$$
where $x _ { j }$ and $y _ { j }$ are the input/output scalars of one neuron response in one data sample; $\mathbf { X } _ { \cdot j }$ denotes the $j ^ { t h }$ column of the input data; and $\gamma _ { j }$ and $\beta _ { j }$ are parameters to be learned. This transformation guarantees that the input distribution of each layer remains unchanged across different mini-batches. For Stochastic Gradient Descent (SGD) optimization, a stable input distribution could greatly facilitate model convergence, leading to much faster training speed for CNN. Moreover, if training data are shuffled at each epoch, the same training sample will be applied with different transformations, or in other words, more comprehensively augmented throughout the training. During the testing phase, the global statistics of all training samples is used to normalize every mini-batch of test data.
Extensive experiments have shown that Batch Normalization significantly reduces the number of iteration to converge, and improves the final performance at the same time. BN layer has become a standard component in recent top-performing CNN architectures, such as deep residual network (He et al., 2016), and Inception V3 (Szegedy et al., 2015).
# 3 THE MODEL
In Sec. 3.1, we first analyze the domain shift in deep neural network, and reveal two key observations. Then in Sec. 3.2, we introduce our Adaptive Batch Normalization (AdaBN) method based on these observations.
# 3.1 A PILOT EXPERIMENT
The Batch Normalization (BN) technique is originally proposed to help SGD optimization by aligning the distribution of training data. From this perspective, it is interesting to examine the BN parameters (batch-wise mean and variance) over different dataset at different layers of the network.
In this pilot experiment, we use MXNet implementation (Chen et al., 2016b) of the Inception-BN model (Ioffe & Szegedy, 2015) pre-trained on ImageNet classification task (Russakovsky et al., 2015) as our baseline DNN model. Our image data are drawn from (Bergamo & Torresani, 2010), which contains the same classes of images from both Caltech-256 dataset (Griffin et al., 2007) and Bing image search results. For each mini-batch sampled from one dataset, we concatenate the mean and variance of all neurons from one layer to form a feature vector. Using linear SVM, we can almost perfectly classify whether the mini-batch feature vector is from Caltech-256 or Bing dataset. Fig. 2 visualizes the distributions of mini-batch feature vectors from two datasets in 2D. It is clear that BN statistics from different domains are separated into clusters.
 (a) Shallow layer distributions
 (b) Deep layer distributions Figure 2: t-SNE (Van der Maaten & Hinton, 2008) visualization of the mini-batch BN feature vector distributions in both shallow and deep layers, across different datasets. Each point represents the BN statistics in one mini-batch. Red dots come from Bing domain, while the blue ones are from Caltech-256 domain. The size of each mini-batch is 64.
This pilot experiment suggests:
1. Both shallow layers and deep layers of the DNN are influenced by domain shift. Domain adaptation by manipulating the output layer alone is not enough. 2. The statistics of BN layer contain the traits of the data domain.
Both observations motivate us to adapt the representation across different domains by BN layer.
# 3.2 ADAPTIVE BATCH NORMALIZATION
Given the pre-trained DNN model and a target domain, our Adaptive Batch Normalization algorithm is as follows1:
<table><tr><td>Algorithm1 Adaptive Batch Normalization (AdaBN)</td></tr><tr><td>for neuron jinDNN do Concatenate neuron responses on all images of tar-</td></tr><tr><td>get domain t: xj =[...,xj(m),...] Compute the mean and variance of the target do-</td></tr><tr><td>main: μ =E(x),=√Var(x).</td></tr><tr><td>end for</td></tr><tr><td>for neuron j in DNN, testing image m in target domain do</td></tr><tr><td>(aj(m)-μ) Compute BN output yj(m) := γj +βj</td></tr><tr><td>g end for</td></tr></table>
The intuition behind our method is straightforward: The standardization of each layer by domain ensures that each layer receives data from a similar distribution, no matter it comes from the source domain or the target domain. Although modulating statistics in one BN layer by AdaBN is a simple translation and scaling operation, such linear transformation in one layer can achieve a highly nonlinear transformation through the whole deep CNN architecture. Thus, we believe this AdaBN process could approximate the intrinsically non-linear domain transfer function.
For $K$ domain adaptation where $K > 2$ , we standardize each sample by the statistics in its own domain. During training, the statistics are calculated for every mini-batch, the only thing that we need to make sure is that the samples in every mini-batch are from the same domain. For (semi)supervised domain adaptation, we may use the labeled data to fine-tune the weights as well. As a result, our method could fit in all different settings of domain adaptation with minimal effort.
Compared with CORAL (Sun et al., 2016), one natural question is why we transform the neuron responses independently, not decorrelate and then re-correlate the responses together as suggested in Sun et al. (2016). Under certain conditions, decorrelation could improve the performance. However, in CNN, the mini-batch size is usually smaller than the feature dimension, leading to singular covariance matrices that is hard to be inversed. As a result, the covariance matrix is always singular. In addition, decorrelation requires to compute the inverse of the covariance matrix which is computationally intensive, especially if we plan to apply AdaBN to all layers of the network.
# 4 EXPERIMENTS
In this section, we demonstrate the effectiveness of AdaBN on standard domain adaptation datasets, and empirically analyze our AdaBN model. We also evaluation our method on a practical application with remote sensing images.
# 4.1 EXPERIMENTAL SETTINGS
We first introduce our experiments on two standard datasets: Office (Saenko et al., 2010) and Caltech-Bing (Bergamo & Torresani, 2010).
Office (Saenko et al., 2010) is a standard benchmark for domain adaptation, which is a collection of 4652 images in 31 classes from three different domains: Amazon $\mathbf { \Pi } ^ { ( \mathbf { A } ) }$ , $D S R L ( \mathbf { D } )$ and Webcam(W). Similar to (Tzeng et al., 2014; Sun et al., 2016; Long et al., 2015), we evaluate the pairwise domain adaption performance of AdaBN on all six pairs of domains. For the multi-source setting, we evaluate our method on three transfer tasks $\{ \mathbf { A } , \bar { \mathbf { W } } \} \to \mathbf { D }$ , $\{ \mathbf { A } , \mathbf { D } \} \to \mathbf { W }$ , $\{ \mathbf { D } , \mathbf { W } \} \mathbf { A }$ .
Caltech-Bing (Bergamo & Torresani, 2010) is a much larger domain adaptation dataset, which contains 30,607 and 121,730 images in 256 categories from two domains Caltech-256(C) and Bing(B). The images in the Bing set are collected from Bing image search engine by keyword search. Apparently Bing data contains noise, and its data distribution is dramatically different from that of Caltech-256.
We compare our approach with a variety of methods, including four shallow methods: SA (Fernando et al., 2013), LSSA (Aljundi et al., 2015), GFK (Gong et al., 2012), CORAL (Sun et al., 2016), and four deep methods: DDC (Tzeng et al., 2014), DAN (Long et al., 2015), RevGrad (Ganin & Lempitsky, 2015), Deep CORAL (Sun & Saenko, 2016). Specifically, GFK models domain shift by integrating an infinite number of subspaces that characterize changes in statistical properties from the source to the target domain. SA, LSSA and CORAL align the source and target subspaces by explicit feature space transformations that would map source distribution into the target one. DDC and DAN are deep learning based methods which maximize domain invariance by adding to AlexNet one or several adaptation layers using MMD. RevGrad incorporates a gradient reversal layer in the deep model to encourage learning domain-invariant features. Deep CORAL extends CORAL to perform end-to-end adaptation in DNN. It should be noted that these deep learning methods have the adaptation layers on top of the output layers of DNNs, which is a sharp contrast to our method that delves into early convolution layers as well with the help of BN layers.
We follow the full protocol (Donahue et al., 2014) for the single source setting; while for multiple sources setting, we use all the samples in the source domains as training data, and use all the samples in the target domain as testing data. We fine-tune the Inception-BN (Ioffe & Szegedy, 2015) model on source domain in each task for 100 epochs. The learning rate is set to 0.01 initially, and then is dropped by a factor 0.1 every 40 epochs. Since the office dataset is quite small, following the best practice in Long et al. (2015), we freeze the first three groups of Inception modules, and set the learning rate of fourth and fifth group one tenth of the base learning rate to avoid overfitting. For Caltech-Bing dataset, we fine-tune the whole model with the same base learning rate.
Table 1: Single source domain adaptation results on Office-31 (Saenko et al., 2010) dataset with standard unsupervised adaptation protocol.
<table><tr><td colspan="7">Method A→W D→W W→D A→D D→A W→A Avg</td></tr><tr><td>AlexNet (Krizhevsky et al.,2012)</td><td>61.6</td><td>95.4</td><td>99.0</td><td>63.8</td><td>51.1</td><td>49.8 70.1</td></tr><tr><td>DDC (Tzeng et al., 2014)</td><td>61.8</td><td>95.0</td><td>98.5</td><td>64.4 52.1</td><td>52.2</td><td>70.6</td></tr><tr><td>DAN (Long et al., 2015)</td><td>68.5</td><td>96.0</td><td>99.0</td><td>67.0 54.0</td><td>53.1</td><td>72.9</td></tr><tr><td>Deep CORAL (Sun & Saenko, 2016)</td><td>66.4</td><td>95.7</td><td>99.2</td><td>66.8</td><td>52.8 51.5</td><td>72.1</td></tr><tr><td>RevGrad (Ganin & Lempitsky,2015)</td><td>73.0</td><td>96.4</td><td>99.2</td><td>1 1</td><td>1</td><td>1</td></tr><tr><td>Inception BN (Ioffe & Szegedy, 2015)</td><td>70.3</td><td>94.3</td><td>100</td><td>70.5</td><td>60.1 57.9</td><td>75.5</td></tr><tr><td>SA (Fernando et al., 2013)</td><td>69.8</td><td>95.5</td><td>99.0</td><td>71.3</td><td>59.4 56.9</td><td>75.3</td></tr><tr><td>GFK (Gong et al., 2012)</td><td>66.7</td><td>97.0</td><td>99.4</td><td>70.1</td><td>58.0 56.9</td><td>74.7</td></tr><tr><td>LSSA (Aljundi et al., 2015)</td><td>67.7</td><td>96.1</td><td>98.4</td><td>71.3</td><td>57.8 57.8</td><td>74.9</td></tr><tr><td>CORAL (Sun et al., 2016)</td><td>70.9</td><td>95.7</td><td>99.8</td><td>71.9</td><td>59.0 60.2</td><td>76.3</td></tr><tr><td>AdaBN</td><td>74.2</td><td>95.7</td><td>99.8</td><td>73.1</td><td>59.8 57.4</td><td>76.7</td></tr><tr><td> AdaBN + CORAL</td><td>75.4</td><td>96.2</td><td>99.6</td><td>72.7</td><td>59.0 60.5</td><td>77.2</td></tr></table>
# 4.2 RESULTS
# 4.2.1 OFFICE DATASET
Our results on Office dataset is reported in Table 1 and Table 2 for single/multi source(s), respectively. Note that the first 5 models of the Table 1 are pre-trained on AlexNet (Krizhevsky et al., 2012) instead of the Inception-BN (Ioffe & Szegedy, 2015) model, due to the lack of publicly available pre-trained Inception BN model in Caffe (Jia et al., 2014). Thus, the relative improvements over the baseline (AlexNet/Inception BN) make more sense than the absolute numbers of each algorithm.
From Table 1, we first notice that the Inception-BN indeed improves over the AlexNet on average, which means that the CNN pre-trained on ImageNet has learned general features, the improvements on ImageNet can be transferred to new tasks. Among the methods based on Inception-BN features, our method improves the most over the baseline. Moreover, since our method is complementary to other methods, we can simply apply CORAL on the top of AdaBN. Not surprisingly, this simple combination exhibits $0 . 5 \%$ increase in performance. This preliminary test reveals further potential of AdaBN if combined with other advanced domain adaptation methods. Finally, we could improve $1 . 7 \%$ over the baseline, and advance the state-of-the-art results for this dataset.
None of the compared methods has reported their performance on multi-source domain adaptation. To demonstrate the capacity of AdaBN under multi-domain settings, we compare it against CORAL, which is the best performing algorithm in the single source setting. The result is reported in Table 2. We find that simply combining two domains does not lead to better performance. The result is generally worse compared to the best performing single domain between the two. This phenomenon suggests that if we cannot properly cope with domain bias, the increase of training samples may be reversely affect to the testing performance. This result confirms the necessity of domain adaptation. In this more challenging setting, AdaBN still outperforms the baseline and CORAL on average. Again, when combined with CORAL, our method demonstrates further improvements. At last, our method archives $2 . 3 \%$ gain over the baseline.
<table><tr><td>Method</td><td>A,D→WA,W→D D,W→A</td><td></td><td></td><td>Avg</td></tr><tr><td>Inception BN (Ioffe & Szegedy,2015)</td><td>90.8</td><td>95.4</td><td>60.2</td><td>82.1</td></tr><tr><td>CORAL (Sun et al., 2016)</td><td>92.1</td><td>96.4</td><td>61.4</td><td>83.3</td></tr><tr><td>AdaBN</td><td>94.2</td><td>97.2</td><td>59.3</td><td>83.6</td></tr><tr><td>AdaBN + CORAL</td><td>95.0</td><td>97.8</td><td>60.5</td><td>84.4</td></tr></table>
Table 2: Multi-source domain adaptation results on Office-31 (Saenko et al., 2010) dataset with standard unsupervised adaptation protocol.
# 4.2.2 CALTECH-BING DATASET
To further evaluate our method on the large-scale dataset, we show our results on Caltech-Bing Dataset in Table 3. Compared with CORAL, AdaBN achieves better performance, which improves $1 . 8 \%$ over the baseline. Note that all the domain adaptation methods show minor improvements over the baseline in the task $\mathbf { C } \mathbf { B }$ . One of the hypotheses to this relatively small improvement is that the images in Bing dataset are collected from Internet, which are more diverse and noisier (Bergamo & Torresani, 2010). Thus, it is not easy to adapt on the Bing dataset from the relatively clean dataset Caltech-256. Combining CORAL with our method does not offer further improvements. This might be explained by the noise of the Bing dataset and the imbalance of the number of images in the two domains.
Table 3: Single source domain adaptation results on Caltech-Bing (Bergamo & Torresani, 2010) dataset.
<table><tr><td>Method</td><td>C→B B→C Avg</td><td></td><td></td></tr><tr><td>Inception BN (Ioffe& Szegedy,2015)35.1</td><td></td><td>64.6</td><td>49.9</td></tr><tr><td>CORAL (Sun et al., 2016)</td><td>35.3</td><td>67.2 </td><td> 51.3</td></tr><tr><td>AdaBN</td><td>35.2</td><td>68.1</td><td>51.7</td></tr><tr><td> AdaBN + CORAL</td><td>35.0</td><td>67.551.2</td><td></td></tr></table>
# 4.3 EMPIRICAL ANALYSIS
In this section, we investigate the influence of the number of samples in target domain to the performance and empirically analyze the adaptation effect of different BN layers.
# 4.3.1 SENSITIVITY TO TARGET DOMAIN SIZE.
Since the key of our method is to calculate the mean and variance of the target domain on different BN layers, it is very natural to ask how many target images is necessary to obtain stable statistics. In this experiment, we randomly select a subset of images in target domain to calculate the statistics and then evaluate the performance on the whole target set. Fig. 3 illustrates the effect of using different number of batches. The results demonstrate that our method can obtain good results when using only a small part of the target examples. It should also be noted that in the extremal case of one batch of target images, our method still achieves better results than the baseline. This is valuable in practical use since a large number of target images are often not available.
 Figure 3: Accuracy when varying the number of mini-batches used for calculating the statistics of BN layers in $\mathbf A \to \mathbf W$ and $\mathbf { B } \mathbf { C }$ , respectively. For $\mathbf B \to \mathbf C$ , we only show the results of using less than 100 batches, since the results are very stable when adding more examples. The batch size is 64 in this experiment. For even smaller number of examples, the performance may be not consistent and drop behind the baseline (e.g. 0.652 with 16 samples, 0.661 with 32 samples).
 Figure 4: Accuracy when adapting with different BN blocks in $\mathbf B \to \mathbf C$ . $x = 0$ corresponds to the result with non-adapt method, and 1, 2, 3a, $_ { 3 b }$ , 4a, $4 b$ , 4c, 5a, $5 b$ correspond to the nine different blocks in Inception-BN network..
# 4.3.2 ADAPTATION EFFECT FOR DIFFERENT BN LAYERS.
In this experiment, we analyze the effect of adapting on different BN layers with our AdaBN method. According to the structure of Inception-BN network Ioffe & Szegedy (2015), we categorize the BN layers into 9 blocks: 1, 2, 3a, 3b, 4a, 4b, 4c, 5a, 5b. Since the back BN layers are influenced by the outputs of previous BN layers, when adapting a specific block we adapted all the blocks before it. Fig. 4 illustrates the adaptation effect for different BN layers. It shows that adapting BN layers consistently improves the results over the baseline method in most cases. Specifically, when incorporating more BN layers in the adaptation, we could achiever better transfer results.
# 4.4 PRACTICAL APPLICATION FOR CLOUD DETECTION IN REMOTE SENSING IMAGES
In this section, we further demonstrate the effectiveness of AdaBN on a practical problem: Cloud Detection in Remote Sensing Images. Since remote sensing images are taken by different satellites with different sensors and resolutions, the captured images are visually different in texture, color, and value range distributions, as shown in Fig. 5. How to adapt a model trained on one satellite to another satellite images is naturally a domain adaptation problem.
Our task here is to identify cloud from the remote sensing images, which can be regarded as a semantic segmentation task. The experiment is taken under a self-collected dataset, which includes three image sets, from GF2, GF1 and Tianhui satellites. Each image set contains 635, 324 and 113 images with resolution over $6 0 0 0 { \times } 6 0 0 0$ pixels respectively. We name the three different datasets following the satellite names. GF2 dataset is used as the training dataset while GF1 and Tianhui datasets are for testing. We use a state-of-art semantic segmentation method (Chen et al., 2016a) as our baseline model.
<table><tr><td>Method</td><td>GF1</td><td>Tianhui</td></tr><tr><td>Baseline</td><td>38.95%</td><td>14.54%</td></tr><tr><td> AdaBN</td><td>64.50%</td><td>29.66%</td></tr></table>
Table 4: Domain adaptation results (mIOU) on GF1 and Tianhui datasets training on GF2 datasets.
The results on GF1 and Tianhui datasets are shown in Table 4. The relatively low results of the baseline method indicate that there exists large distribution disparity among images from different satellites. Thus, the significant improvement after applying AdaBN reveals the effectiveness of our method. Some of the visual results are shown in Fig. 6. Since other domain adaptation methods require either additional optimization steps and extra components (e.g. MMD) or post-processing distribution alignment (like CORAL), it is very hard to apply these methods from image classification to this large-size $( 6 0 0 0 \times 6 0 0 0 )$ segmentation problem. Comparatively, besides the effective performance, our method needs no extra parameters and very few computations over the whole adaptation process.
 Figure 5: Remote sensing images in different domains.
 Figure 6: Visual cloud detection results on GF1 dataset. White pixels in (b) and (c) represent the detected cloud regions.
# 5 CONCLUSION AND FUTURE WORKS
In this paper, we have introduced a simple yet effective approach for domain adaptation on batch normalized neural networks. Besides its original uses, we have exploited another functionality of Batch Normalization (BN) layer: domain adaptation. The main idea is to replace the statistics of each BN layer in source domain with those in target domain. The proposed method is easy to implement and parameter-free, and it takes almost no effort to extend to multiple source domains and semi-supervised settings. Our method established new state-of-the-art results on both single and multiple source(s) domain adaptation settings on standard benchmarks. At last, the experiments on cloud detection for large-size remote sensing images further demonstrate the effectiveness of our method in practical use. We believe our method opens up a new direction for domain adaptation.
In contrary to other methods that use Maximum Mean Discrepancy (MMD) or domain confusion loss to update the weights in CNN for domain adaptation, our method only modifies the statistics of BN layer. Therefore, our method is fully complementary to other existing deep learning based methods. It is interesting to see how these different methods can be unified under one framework.
# REFERENCES
Rahaf Aljundi, Remi Emonet, Damien Muselet, and Marc Sebban. Landmarks-based kernelized ´ subspace alignment for unsupervised domain adaptation. In CVPR, 2015. Mahsa Baktashmotlagh, Mehrtash Harandi, Brian Lovell, and Mathieu Salzmann. Unsupervised domain adaptation by domain invariant projection. In ICCV, pp. 769–776, 2013. Oscar Beijbom. Domain adaptations for computer vision applications. arXiv preprint arXiv:1211.4860, 2012. Alessandro Bergamo and Lorenzo Torresani. Exploiting weakly-labeled web images to improve object classification: a domain adaptation approach. In NIPS, pp. 181–189, 2010. Konstantinos Bousmalis, George Trigeorgis, Nathan Silberman, Dilip Krishnan, and Dumitru Erhan. Domain separation networks. NIPS, 2016. Liang-Chieh Chen, George Papandreou, Iasonas Kokkinos, Kevin Murphy, and Alan L Yuille. Deeplab: Semantic image segmentation with deep convolutional nets, atrous convolution, and fully connected crfs. arXiv preprint arXiv:1606.00915, 2016a. Tianqi Chen, Mu Li, Yutian Li, Min Lin, Naiyan Wang, Minjie Wang, Tianjun Xiao, Bing Xu, Chiyuan Zhang, and Zheng Zhang. MXNet: A flexible and efficient machine learning library for heterogeneous distributed systems. NIPS Workshop on Machine Learning Systems, 2016b. Sumit Chopra, Suhrid Balakrishnan, and Raghuraman Gopalan. DLID: Deep learning for domain adaptation by interpolating between domains. In ICML Workshop on Challenges in Representation Learning, volume 2, 2013. Jeff Donahue, Yangqing Jia, Oriol Vinyals, Judy Hoffman, Ning Zhang, Eric Tzeng, and Trevor Darrell. DeCAF: A deep convolutional activation feature for generic visual recognition. In ICML, pp. 647–655, 2014. E Knuth Donald. The art of computer programming. Sorting and searching, 3:426–458, 1999. Basura Fernando, Amaury Habrard, Marc Sebban, and Tinne Tuytelaars. Unsupervised visual domain adaptation using subspace alignment. In ICCV, pp. 2960–2967, 2013. Yaroslav Ganin and Victor Lempitsky. Unsupervised domain adaptation by backpropagation. In ICML, pp. 1180–1189, 2015. Muhammad Ghifary, W Bastiaan Kleijn, and Mengjie Zhang. Domain adaptive neural networks for object recognition. In PRICAI: Trends in Artificial Intelligence, pp. 898–904. 2014. Boqing Gong, Yuan Shi, Fei Sha, and Kristen Grauman. Geodesic flow kernel for unsupervised domain adaptation. In CVPR, pp. 2066–2073, 2012.
Boqing Gong, Kristen Grauman, and Fei Sha. Connecting the dots with landmarks: Discriminatively learning domain-invariant features for unsupervised domain adaptation. In ICML, pp. 222–230, 2013.
Raghuraman Gopalan, Ruonan Li, and Rama Chellappa. Domain adaptation for object recognition: An unsupervised approach. In ICCV, pp. 999–1006, 2011.
Arthur Gretton, Karsten M Borgwardt, Malte J Rasch, Bernhard Scholkopf, and Alexander Smola. ¨ A kernel two-sample test. The Journal of Machine Learning Research, 13(1):723–773, 2012.
Gregory Griffin, Alex Holub, and Pietro Perona. Caltech-256 object category dataset. 2007.
Kaiming He, Xiangyu Zhang, Shaoqing Ren, and Jian Sun. Deep residual learning for image recognition. CVPR, 2016.
Jiayuan Huang, Arthur Gretton, Karsten M Borgwardt, Bernhard Scholkopf, and Alex J Smola. ¨ Correcting sample selection bias by unlabeled data. In NIPS, pp. 601–608, 2006.
Sergey Ioffe and Christian Szegedy. Batch normalization: Accelerating deep network training by reducing internal covariate shift. In ICML, pp. 448–456, 2015.
Yangqing Jia, Evan Shelhamer, Jeff Donahue, Sergey Karayev, Jonathan Long, Ross Girshick, Sergio Guadarrama, and Trevor Darrell. Caffe: Convolutional architecture for fast feature embedding. In ACM MM, pp. 675–678, 2014.
Aditya Khosla, Tinghui Zhou, Tomasz Malisiewicz, Alexei A Efros, and Antonio Torralba. Undoing the damage of dataset bias. In ECCV, pp. 158–171. 2012.
Alex Krizhevsky, Ilya Sutskever, and Geoffrey E Hinton. Imagenet classification with deep convolutional neural networks. In NIPS, pp. 1097–1105, 2012.
Mingsheng Long, Yue Cao, Jianmin Wang, and Michael Jordan. Learning transferable features with deep adaptation networks. In ICML, pp. 97–105, 2015.
Mingsheng Long, Jianmin Wang, and Michael I Jordan. Unsupervised domain adaptation with residual transfer networks. In NIPS, 2016.
Sinno Jialin Pan, Ivor W Tsang, James T Kwok, and Qiang Yang. Domain adaptation via transfer component analysis. IEEE Transactions on Neural Networks, 22(2):199–210, 2011.
Vishal M Patel, Raghuraman Gopalan, Ruonan Li, and Rama Chellappa. Visual domain adaptation: A survey of recent advances. IEEE Signal Processing Magazine, 32(3):53–69, 2015.
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.
Kate Saenko, Brian Kulis, Mario Fritz, and Trevor Darrell. Adapting visual category models to new domains. In ECCV, pp. 213–226. 2010.
Hidetoshi Shimodaira. Improving predictive inference under covariate shift by weighting the loglikelihood function. Journal of statistical planning and inference, 90(2):227–244, 2000.
Baochen Sun and Kate Saenko. Deep coral: Correlation alignment for deep domain adaptation. arXiv preprint arXiv:1607.01719, 2016.
Baochen Sun, Jiashi Feng, and Kate Saenko. Return of frustratingly easy domain adaptation. AAAI, 2016.
Christian Szegedy, Vincent Vanhoucke, Sergey Ioffe, Jonathon Shlens, and Zbigniew Wojna. Rethinking the inception architecture for computer vision. arXiv preprint arXiv:1512.00567, 2015.
Tatiana Tommasi, Novi Patricia, Barbara Caputo, and Tinne Tuytelaars. A deeper look at dataset bias. German Conference on Pattern Recognition, 2015.
Antonio Torralba and Alexei A Efros. Unbiased look at dataset bias. In CVPR, pp. 1521–1528, 2011.
Eric Tzeng, Judy Hoffman, Ning Zhang, Kate Saenko, and Trevor Darrell. Deep domain confusion: Maximizing for domain invariance. arXiv preprint arXiv:1412.3474, 2014.
Eric Tzeng, Judy Hoffman, Trevor Darrell, and Kate Saenko. Simultaneous deep transfer across domains and tasks. In ICCV, pp. 4068–4076, 2015.
Laurens Van der Maaten and Geoffrey Hinton. Visualizing data using t-sne. Journal of Machine Learning Research, 9(2579-2605):85, 2008.
Jason Yosinski, Jeff Clune, Yoshua Bengio, and Hod Lipson. How transferable are features in deep neural networks? In NIPS, pp. 3320–3328, 2014.123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390# UNDERSTANDING ARCHITECTURES LEARNT BY CELL-BASED NEURAL ARCHITECTURE SEARCH
Yao Shu, Wei Wang & Shaofeng Cai
School of Computing National University of Singapore {shuyao,wangwei,shaofeng}@comp.nus.edu.sg
# ABSTRACT
Neural architecture search (NAS) searches architectures automatically for given tasks, e.g., image classification and language modeling. Improving the search efficiency and effectiveness has attracted increasing attention in recent years. However, few efforts have been devoted to understanding the generated architectures. In this paper, we first reveal that existing NAS algorithms (e.g., DARTS, ENAS) tend to favor architectures with wide and shallow cell structures. These favorable architectures consistently achieve fast convergence and are consequently selected by NAS algorithms. Our empirical and theoretical study further confirms that their fast convergence derives from their smooth loss landscape and accurate gradient information. Nonetheless, these architectures may not necessarily lead to better generalization performance compared with other candidate architectures in the same search space, and therefore further improvement is possible by revising existing NAS algorithms.
# 1 INTRODUCTION
Various neural network architectures (Krizhevsky et al., 2012; Simonyan & Zisserman, 2015; He et al., 2016; Huang et al., 2017) have been devised over the past decades, achieving superhuman performance for a wide range of tasks. Designing these neural networks typically takes substantial efforts from domain experts by trial and error. Recently, there is a growing interest in neural architecture search (NAS), which automatically searches for high-performance architectures for the given task. The searched NAS architectures (Zoph et al., 2018; Real et al., 2019; Pham et al., 2018; Liu et al., 2019; Xie et al., 2019b; Luo et al., 2018; Cai et al., 2019; Akimoto et al., 2019; Nayman et al., 2019) have outperformed best expert-designed architectures on many computer vision and natural language processing tasks.
Mainstream NAS algorithms typically search for the connection topology and transforming operation accompanying each connection from a predefined search space. Tremendous efforts have been exerted to develop efficient and effective NAS algorithms (Liu et al., 2019; Xie et al., 2019b; Luo et al., 2018; Akimoto et al., 2019; Nayman et al., 2019). However, less attention has been paid to these searched architectures for further insight. To our best knowledge, there is no related work in the literature examining whether these NAS architectures share any pattern, and how the pattern may impact the architecture search if there exists the pattern. These questions are fundamental to understand and improve existing NAS algorithms. In this paper, we endeavour to address these questions by examining the popular NAS architectures1.
The recent work (Xie et al., 2019a) shows that the architectures with random connection topologies can achieve competitive performance on various tasks compared with expert-designed architectures. Inspired by this result, we examine the connection topologies of the architectures generated by popular NAS algorithms. In particular, we find a connection pattern of the popular NAS architectures. These architectures tend to favor wide and shallow cells, where the majority of intermediate nodes are directly connected to the input nodes.
To appreciate this particular connection pattern, we first visualize the training process of the popular NAS architectures and their randomly connected variants. Fast and stable convergence is observed for the architectures with wide and shallow cells. We further empirically and theoretically show that the architectures with wider and shallower cells consistently enjoy a smoother loss landscape and smaller gradient variance than their random variants, which helps explain their better convergence and consequently the selection of these NAS architectures during the architecture search.
We finally evaluate the generalization performance of the popular NAS architectures and their randomly connected variants. We find that the architectures with wide and shallow cells may not generalize better than other candidate architectures despite their faster convergence. We therefore believe that rethinking NAS from the perspective of the true generalization performance rather than the convergence of candidate architectures should potentially help generate better architectures.
# 2 RELATED WORKS
Neural Architecture Search Neural architecture search (NAS) searches for best-performing architectures automatically for a given task. It has received increasing attention in recent years due to its outstanding performance and the demand for automated machine learning (AutoML). There are three major components in NAS as summarized by Elsken et al. (2019), namely search space, search policy (or strategy, algorithm), and performance evaluation (or estimation). To define the search space, the prior knowledge extracted from expert-designed architectures is typically exploited. As for the search policy, different algorithms are proposed to improve the effectiveness (Zoph et al., 2018; Real et al., 2019; Tan et al., 2019; Cai et al., 2019) and the efficiency (Pham et al., 2018; Liu et al., 2019; Xie et al., 2019b; Luo et al., 2018; Nayman et al., 2019; Akimoto et al., 2019) of the architecture search. However, no effort has been devoted to understanding the best architectures generated by various NAS approaches. Detailed analysis of these architectures may give insights about the further improvement of existing NAS algorithms.
Evaluation of NAS algorithms Recent works evaluate NAS algorithms by comparing them with random search. Li & Talwalkar (2019) and Sciuto et al. (2019) compare the generalization performance of architectures generated from random search and existing NAS algorithms. Interestingly, the random search can find architectures with comparable or even better generalization performance. Particularly, Sciuto et al. (2019) show empirically that the ineffectiveness of some NAS algorithms (Pham et al., 2018) could be the consequence of the weight sharing mechanism during the architecture search. While these evaluations help understand the general disadvantages of NAS algorithms, what kind of architectures the NAS algorithms are learning and why they learn these specific architectures are still not well understood.
# 3 THE CONNECTION PATTERN OF POPULAR NAS CELLS
Mainstream NAS algorithms (Zoph et al., 2018; Real et al., 2019; Pham et al., 2018; Liu et al., 2019; Xie et al., 2019b; Luo et al., 2018) typically search for the cell structure, including the connection topology and the corresponding operation (transformation) coupling each connection. The generated cell is then replicated to construct the entire neural network. We therefore mainly investigate these cell-based NAS architectures. In this section, we first introduce the commonly adopted cell representation, which is useful to understand the connection and computation in a cell space. We then sketch the connection topologies of popular cell-based NAS architectures to investigate their connection patterns. By comparison, we show that there is a common connection pattern among the cells learned by different NAS algorithms; particularly, these cells tend to be wide and shallow.
# 3.1 CELL REPRESENTATION
Following DARTS (Liu et al., 2019), we represent the cell topology as a directed acyclic graph (DAG) consisting of $N$ nodes, including $M$ input nodes, one output node and $( N - M - 1 )$ intermediate nodes. Each node forms a latent representation of the input instance. The input nodes consist of the outputs from $M$ preceding cells. And the output node aggregates (e.g., concatenate) the representations from all intermediate nodes. Each intermediate node is connected to $M$ proceeding nodes in the same cell. Each connection transforms the representation from one node via an operation from a predefined operation set, e.g., $3 \times 3$ convolution, $3 \times 3$ max pooling, etc. The target of NAS algorithm is to search for the best $M$ source nodes for each intermediate node and the best operation for each of the connections between nodes. In the literature, the searched cell is then replicated by $L$ times to build the entire neural network architecture2.
 Figure 1: Cell topologies of popular NAS architectures. Each sub-figure has three sets of nodes from left to right, i.e., the input nodes, intermediate nodes, and output node. The arrows (i.e., operations of the cell) represent the direction of information flow. The caption of each sub-figure reports the name of the architecture, width and depth of a cell following our definition. The width of a cell is computed with the assumption that all intermediate nodes share the same width $c$ .
 Figure 2: Topologies of DARTS (Liu et al., 2019) cell (leftmost) and its variants with random connections. The cell depth is increasing and width decreasing from left to right. In particular, the original DARTS cell $C ^ { d \bar { a } r t s }$ is widest and shallowest among these cells.
We abuse the notation $C$ to denote a cell and also the architecture built with the specific cell in the following sections. Besides, we shall use $C ^ { A }$ to denote the best architecture (or cell) searched with the NAS algorithm $A$ (e.g., DARTS (Liu et al., 2019), ENAS (Pham et al., 2018)). Details on how to build the architecture with given cells are provided in Appendix A.3.
# 3.2 THE COMMON CONNECTION PATTERN
Recently, Xie et al. (2019a) shows that neural networks constructed by cells with random connection patterns can achieve compelling performance on multiple tasks. Taking this a step further, we wonder whether cells generated from popular NAS algorithms share any connection patterns, which may explain why these cells are chosen during the architecture search. To investigate the connection patterns, we sketch the topologies of the popular NAS cells with detailed operations omitted.
Figure 1 illustrates topologies of 5 popular NAS cells3. To examine the connection pattern formally, we introduce the concept of ‘depth’ and ‘width’ for a cell. The depth of a cell is defined as the number of connections along the longest path from input nodes to the output node. The width of a cell is defined as the total width of the intermediate nodes that are connected to the input nodes. In particular, if some intermediate nodes are only partially connected to input nodes (i.e., have connections to other intermediate nodes), their width is reduced by the percentage of the number of connections to intermediate nodes over all connections. The width of a node is the number of channels for convolution operations; and the width is the dimension of the features for linear operations. Supposing that the width of each intermediate node is $c$ , as shown in Figure 1, the width and depth of the DARTS (Liu et al., 2019) cell are $3 . 5 c$ and 3 respectively, and the width and depth of the AmoebaNet (Real et al., 2019) cell are $_ { 4 c }$ and 4 correspondingly.
Following the above definitions, the smallest depth and largest width for a cell with $N = 7$ and $M = 2$ are 2 and $_ { 4 c }$ respectively. Similarly, for a cell with $N = 8$ and $M = 2$ , the smallest depth and largest width are 2 and $5 c$ respectively. In Figure 1, we can observe that cells from popular NAS architectures tend to be the widest and shallowest ones (with width close to $4 c / 5 c$ and depth close to 2) among all candidate cells in the same search space. Regarding this as the common connection pattern, we have the following observation:
Observation 3.1 (The Common Connection Pattern) NAS architectures generated by popular NAS algorithms tend to have the widest and shallowest cells among all candidate cells in the same search space.
# 4 THE IMPACTS OF CELL WIDTH AND DEPTH ON OPTIMIZATION
Given that popular NAS cells share the common connection pattern, we then explore the impact of this common connection pattern from the optimization perspective to answer the question: why the wide and shallow cells are selected during the architecture search? We sample and train variants of popular NAS architectures with random connections. Comparing randomly connected variants with the popular NAS architectures, we find that architectures with wider and shallower cells indeed converge faster so that they are selected by NAS algorithms (Section 4.1). To understand why the wider and shallower cell contributes to faster convergence, we further investigate the loss landscape and gradient variance of popular NAS architectures and their variants via both empirical experiments (Section 4.2) and theoretical analysis (Section 4.3).
# 4.1 CONVERGENCE
Popular NAS algorithms typically evaluate the performance of a candidate architecture prematurely before the convergence of its model parameters during the search process. For instance, DARTS (Liu et al., 2019), SNAS (Xie et al., 2019b) and ENAS (Pham et al., 2018) optimize hyper-parameters of architectures and model parameters concurrently. The amortized training time of each candidate architecture is insufficient and therefore far from the requirement for the full convergence. Likewise, AmoebaNet (Real et al., 2019) evaluates the performance of candidate architectures with the training of only a few epochs. In other words, these candidate architectures are not evaluated based on their generalization performance at convergence. As a result, architectures with faster convergence rates are more likely to be selected by existing NAS algorithms because they can obtain better evaluation performance given the same training budget. We therefore hypothesize that the popular NAS architectures may converge faster than other candidate architectures, which largely contributes to the selection of these architectures during the search.
To support the hypothesis above, we compare the convergence of original NAS architectures and their variants with random connections via empirical studies. We first sample variants of popular NAS cells following the sampling method in Appendix A.2. Then, we train both original NAS architectures and their random variants on CIFAR-10 and CIFAR-100 following the training details in Appendix A.3. During training, we evaluate the testing loss and accuracy of these architectures. Since the convergence is dependent on optimization settings, we also evaluate the convergence performance under different learning rates.
Take DARTS (Liu et al., 2019) for example, Figure 2 shows the connection topology of the original DARTS cell and its random variants. Figure 3 reports the test loss and accuracy curves of these architectures during training. As illustrated in Figure 3, the original cell $C ^ { d a r t s }$ , known as the widest and shallowest cell, has the fastest and most stable convergence compared with its variants. Further, as the width of a cell increases and the depth decreases (i.e., from $C _ { 4 }$ to $C _ { 1 }$ ), the convergence becomes faster. The results of other popular NAS architectures and their randomly connected variants are reported in Appendix B.2.
 Figure 3: Test loss and test accuracy $( \% )$ curves of DARTS and its randomly connected variants on CIFAR-10 and CIFAR-100 during training. The default learning rate is 0.025.
 Figure 4: Test accuracy $( \% )$ curves of DARTS and its randomly connected variants on CIFAR-10 and CIFAR-100 during training under different learning rates (0.0025 and 0.25). We only evaluate $C ^ { d a r t s }$ , $C _ { 1 } ^ { d a r t s }$ and $C _ { 3 } ^ { \breve { d } a r t s }$ for illustration. The caption of each sub-figure reports the dataset and the learning rate.
Figure 4 further validates the difference of convergence under different learning rates. The original cell $C ^ { d a r t s }$ enjoys the fastest and the most stable convergence among these cells under various learning rates. The difference in terms of convergence rate and stability is more obvious between $C ^ { d a r t s }$ and its variants with a larger learning rate as shown in Figure 4. Interestingly, $C _ { 3 } ^ { d a r t s }$ completely fails to converge on both CIFAR-10 and CIFAR-100 with a larger learning rate of 0.25. While there is a minor difference among these cells with a lower learning rate of 0.0025, we still find that there is a decreasing performance of convergence (i.e., convergence rate and stability) from $C ^ { d a r t s }$ , $C _ { 1 } ^ { d a r t s }$ $C _ { 3 } ^ { d a r t s }$ . Overall, the observations are consistent with the results in Figure 3.
We have also compared the convergence of popular NAS architectures and their random variants of different operations. Similarly, we sample and train the random variants of operations for popular NAS architectures following the details in Appendix A.2 and Appendix A.3. Figure 5 illustrates the convergence of these architectures. Surprisingly, with the same connection topologies as the popular NAS cells but different operations, all random variants achieve nearly the same convergence as these popular NAS architectures. Consistent results can be found in Figure 12 of Appendix B.2. We therefore believe that the types of operations have limited impacts on the convergence of NAS architectures and the connection topologies affect the convergence more significantly.
With these observations, we conclude that the popular NAS architectures with wider and shallower cells indeed converge faster and more stably, which explains why these popular NAS cells are selected during the architecture search. The next question is then why the wider and shallower cell leads to a faster and more stable convergence?
# 4.2 EMPIRICAL STUDY OF FACTORS AFFECTING CONVERGENCE
Since the wide and shallow cell is related to fast convergence, we further conduct the theoretical convergence analysis to investigate the cause of fast convergence. In this section, we first introduce the convergence analysis (i.e., Theorem 4.1) of non-convex optimization with the randomized stochastic gradient method (Ghadimi & Lan, 2013). Based on the analysis, we introduce the possible factors related to the common connection pattern that may affect the convergence. We then examine these factors empirically in the following subsections.
 Figure 5: Test accuracy $( \% )$ curves of DARTS, ENAS, AmoebaNet, NASNet and their random variants of operations on CIFAR-10 during training. The parameter size is attached in Table 3 of Appendix B.2.
Theorem 4.1 (Ghadimi & Lan, 2013) Let $f$ be a $L$ -smooth non-convex function, and let $f ^ { * }$ be the minimal. Given repeated, independent accesses to stochastic gradients with variance bound $\sigma ^ { 2 }$ for $f ( w )$ , SGD with initial ${ \pmb w } _ { 0 }$ , total iterations $N > 0$ and learning rate $\begin{array} { r } { \gamma _ { k } \ < \ \frac { 1 } { L } } \end{array}$ achieves the following convergence by randomly choosing ${ \pmb w } _ { k }$ as the final output ${ \pmb w } _ { R }$ with probability $\frac { \gamma _ { k } } { H }$ where $\begin{array} { r } { H = \sum _ { k = 1 } ^ { N } \gamma _ { k } } \end{array}$ :
$$\mathbb { E } [ \nabla f ( { \pmb w } _ { R } ) ^ { 2 } ] \le \frac { 2 ( f ( { \pmb w } _ { 0 } ) - f ^ { * } ) } { H } + \frac { L \sigma ^ { 2 } } { H } \sum _ { k = 1 } ^ { N } \gamma _ { k } ^ { 2 }$$
In this paper, $f$ and $\pmb { w }$ denote the objective (loss) function and model parameters respectively. Based on the above theorem, Lipschitz smoothness $L$ and gradient variance $\bar { \sigma } ^ { 2 }$ significantly affect the convergence, including the rate and the stability of convergence. Particularly, given a specific number of iterations $N$ , a smaller Lipschitz constant $L$ or smaller gradient variance $\bar { \sigma } ^ { 2 }$ would lead to a smaller convergence error and less damped oscillations, which indicates a faster and more stable convergence. Since the Lipschitz constant $L$ and gradient variance $\sigma ^ { 2 }$ are highly related to the objective function, different NAS architectures result in different $L$ and $\sigma ^ { 2 }$ . In the following subsections, we therefore conduct empirical analysis for the impacts of the cell with and depth on the Lipschitz smoothness and gradient variance.
# 4.2.1 LOSS LANDSCAPE
The constant $L$ of Lipschitz smoothness is closely correlated with the Hessian matrix of the objective function as shown by Nesterov (2004), which requires substantial computation and can only represent the global smoothness. The loss contour, which has been widely adopted to visualize the loss landscape of neural networks by Goodfellow & Vinyals (2015); Li et al. (2018), is instead computationally efficient and is able to report the local smoothness of the objective function. To explore the loss landscape of different architectures, we adopt the method in Li et al. (2018) to plot the loss contour $s ( \alpha , \beta ) \ = \mathbb { E } _ { i \sim P } \big [ f _ { i } ( \pmb { w } ^ { * } + \alpha \pmb { w } _ { 1 } + \beta \pmb { w } _ { 2 } ) \big ]$ . The notation $f _ { i } ( \cdot )$ denotes the loss evaluated at $i _ { t h }$ instance in the dataset and $P$ denotes the distribution of dataset. The notation $\pmb { w } ^ { * }$ , ${ \pmb w } _ { 1 }$ and ${ \pmb w } _ { 2 }$ denote the (local) optimal and two direction vectors randomly sampled from Gaussian distribution respectively. And $\alpha$ , $\beta$ , which are the $x$ and $y$ axis of the plots, denote the step sizes to perturb $\boldsymbol { w } ^ { * }$ . The loss contour plotted here is therefore a two-dimensional approximation of the truly highdimensional loss contour. However, as shown in Li et al. (2018), the approximation is valid and effective to characterize the property of the true loss contour.
To study the impact of the cell width and depth on Lipschitz smoothness, we compare the loss landscape between popular NAS architectures and their randomly connected variants trained in Section 4.1 on CIFAR-10 and CIFAR-100. Due to the space limitation, we only plot the loss landscape of DARTS (Liu et al., 2019) and its randomly connected variants in Figure 6. We observe that the connection topology has a significant influence on the smoothness of the loss landscape. With the widest and shallowest cell, $\bar { C } ^ { d a r t s }$ has a fairly benign and smooth landscape along with the widest near-convex region around the optimal. With a deeper and narrower cell, $\dot { C } _ { 1 } ^ { d a r t s }$ and $C _ { 2 } ^ { d a r t s }$ have a more agitated loss landscape compared with $C ^ { d \bar { a } r t s }$ . Further, $C _ { 3 } ^ { d a r t s }$ , with the smallest width and largest depth among these cells, has the most complicated loss landscape and the narrowest and steepest near-convex region around the optimum. The largest eigenvalue of the Hessian matrix, which indicates the maximum curvature of the objective function, is positively correlated with Lipschitz constant as shown by Nesterov (2004). A smoother loss landscape therefore corresponds to a smaller Lipschitz constant $L$ . $C ^ { d a r t s }$ is likely to achieve the smallest Lipschitz constant among these cells.
 Figure 6: Loss contours of DARTS and its variants with random connections on the test dataset of CIFAR-10. The lighter color of the contour lines indicates a larger loss. Notably, the loss of the blank area, around the corners of each plot, is extremely large. Besides, the area with denser contour lines indicates a steeper loss surface.
 Figure 7: Heat maps of the gradient variance from DARTS and its randomly connected variants around the optimal on the test dataset of CIFAR-10. The lighter color indicates a larger gradient variance. Notably, the gradient variance of the yellow area, around the corners of each plot, is extremely large. Obviously, the region with relatively small gradient variance becomes smaller from left to right.
Consistent results can be found in Appendix B.3 for the loss landscape of other popular NAS cells and their variants. Based on these results, we conclude that increasing the width and decreasing the depth of a cell widens the near-convex region around the optimal and smooths the loss landscape. The constant $L$ of Lipschitz smoothness therefore becomes smaller locally and globally. Following Theorem 4.1, architectures with wider and shallower cells shall converge faster and more stably.
# 4.2.2 GRADIENT VARIANCE
The gradient variance indicates the noise level of gradient by randomly selecting training instances in stochastic gradient descent (SGD) method. Large gradient variance indicates large noise in the gradient, which typically results in unstable updating of model parameters. Following Ghadimi $\&$ Lan (2013), gradient variance is defined as $\mathbf { \bar { V } a r } ( \bar { \nabla } f _ { i } ( \pmb { w } ) )$ . Similar to the visualization of loss landscape in Section 4.2.1, we visualize the gradient variance by $g ( \alpha , \beta ) = \mathrm { V a r } ( \nabla f _ { i } ( { \pmb w } ^ { * } + \alpha { \pmb w } _ { 1 } +$ $\beta \pmb { w } _ { 2 } )$ ). All other notations follow Section 4.2.1.
To study the impact of the width and depth of a cell on the gradient variance, we compare the gradient variance between popular NAS architectures and their randomly connected variants trained in Section 4.1 on CIFAR-10 and CIFAR-100. We visualize the gradient variance of DARTS (Liu et al., 2019) and its randomly connected variants in Figure 7 and Figure 8. For better visualization, we plot the figures using the standard deviation (i.e., $\sqrt { g ( \alpha , \beta ) } )$ to avoid extremely large values in the visualization of DARTS. Obviously, as the cell width decreases and the cell depth increases (i.e., from $C ^ { d a r t s }$ to $C _ { 4 } ^ { d a r t s }$ ), the region with relatively small gradient variance becomes smaller as shown in Figure 7. Consistently, the gradient variance generally shows an increasing trend from $C ^ { d a r t s }$ to
 Figure 8: 3D surfaces of the gradient variance from DARTS and its randomly connected variants around the optimal on the test dataset of CIFAR-100. The height of the surface indicates the value of gradient variance. Notably, the height of the gradient variance surface is gradually increasing from left to right. Especially, $C ^ { d a r t s }$ has the smoothest and lowest surface of gradient variance among these architectures.
$C _ { 4 } ^ { d a r t s }$ in Figure 8. Consequently, the gradient becomes noisier in the neighborhood of the optimal, which typically makes the optimization harder and unstable.
Similar results from other popular NAS architectures and their random variants are provided in Appendix B.4. Based on these results, we conclude that the increase in width and the decrease in depth of a cell result in a smaller gradient variance, which makes the optimization process less noisy and more efficient. The convergence of wide and shallow cells therefore shall be fast and stable following Theorem 4.1.
# 4.3 THEORETICAL ANALYSIS OF FACTORS AFFECTING CONVERGENCE
Our empirical study so far suggests that larger cell width and smaller cell depth smooth the loss landscape and decrease the gradient variance. Consequently, popular NAS architectures with wide and shallow cells converge fast. In this section, we investigate the impacts of the cell width and depth on Lipschitz smoothness and gradient variance from a theoretical perspective.
# 4.3.1 SETUP
We analyze the impact of the cell width and depth by comparing architectures with the widest cell and the narrowest cell as shown in Figure 26 of Appendix C. To simplify the analysis, the cells we investigate contain only one input node $_ { \textbf { \em x } }$ and one output node. The input node may be training instances or output node from any proceeding cell. All operations in the cell are linear operations without any non-linearity. Suppose there are $n$ intermediate nodes in a cell, the $i _ { t h }$ intermediate node and its associated weight matrix are denoted as $\mathbf { \boldsymbol { y } } ^ { ( i ) }$ and $W ^ { ( i ) } ( i = 1 , \cdots , n )$ respectively. The output node $_ z$ denotes the concatenation of all intermediate nodes. Both cells have the same arbitrary objective function $f$ following the output node, which shall consist of the arbitrary number of activation functions and cells. For clarity, we refer to the objective function, intermediate nodes and output node of the architecture with the narrowest cell as $\hat { \widehat { f } } , \widehat { \pmb { y } } ^ { ( i ) }$ and $\widehat { z }$ respectively. As shown in Figure 26, the intermediate node $\mathbf { \boldsymbol { y } } ^ { ( i ) }$ and $\widehat { \pmb y } ^ { ( i ) }$ bcan be computed by $\mathbf { \boldsymbol { y } } ^ { ( i ) } \equiv W ^ { ( i ) } \dot { \mathbf { \boldsymbol { x } } }$ and $\begin{array} { r } { \widehat { \pmb y } ^ { ( i ) } = \prod _ { k = 1 } ^ { i } W ^ { ( k ) } \pmb x } \end{array}$ b respectively. Particularly, we set $\begin{array} { r } { \prod _ { k = 1 } ^ { i } W ^ { ( k ) } = W ^ { ( i ) } W ^ { ( i - 1 ) } \cdot \cdot \cdot W ^ { ( 1 ) } } \end{array}$ . And ball the related proofs of following theorems can be found in Appendix C.
# 4.3.2 THEORETICAL RESULTS
Due to the complexity of the standard Lipschitz smoothness, we instead investigate the block-wise Lipschitz smoothness (Beck & Tetruashvili, 2013) of the two cases shown in Figure 26. In Theo$\mathrm { r e m } 4 . 2$ , we show that the block-wise Lipschitz constant of the narrowest cell is scaled by the largest eigenvalues of the model parameters (i.e., $W ^ { ( i ) } ( i = 1 , \cdots , n ) )$ . Notably, the Lipschitz constant of the narrowest cell can be significantly larger than the one of the widest cell while most of the largest eigenvalues are larger than 1, which slows down the convergence substantially. The empirical study in Section 4.2.1 has validated the results.
Theorem 4.2 (The impact of cell width and depth on block-wise Lipschitz smoothness ) Let $\lambda ^ { ( i ) }$ be the largest eigenvalue of $W ^ { ( i ) }$ . Given the widest cell with objective function $f$ and the narrowest cell with objective function ${ \widehat { f } } ,$ , by assuming the block-wise Lipschitz smoothness of the widest cell as $\begin{array} { r l r } { \left\| \frac { \partial f } { \partial W _ { 1 } ^ { ( i ) } } - \frac { \partial f } { \partial W _ { 2 } ^ { ( i ) } } \right\| } & { { } \le L ^ { ( i ) } \left\| W _ { 1 } ^ { ( i ) } - W _ { 2 } ^ { ( i ) } \right\| } & { } \end{array}$ for any $W _ { 1 } ^ { ( i ) }$ and $W _ { 2 } ^ { ( i ) }$ , the block-wise Lipschitz smoothness of the narrowest cell then can be represented as
 Figure 9: Comparison of the test accuracy at the convergence between popular NAS architectures and their randomly connected variants on CIFAR-10. Each popular NAS architecture (index 0 on the $x$ -axis) is followed by 13 randomly connected variants (from index 1 to index 13 on the $x$ -axis), corresponding to $C _ { 1 }$ to $C _ { 1 3 }$ respectively. The width and depth of these random variants are shown in Table 2 in Appendix B.2. The dashed lines report the accuracy of the popular NAS architectures.
$$\left\| \frac { \partial \widehat { f } } { \partial W _ { 1 } ^ { ( i ) } } - \frac { \partial \widehat { f } } { \partial W _ { 2 } ^ { ( i ) } } \right\| \leq ( \prod _ { j = 1 } ^ { i - 1 } \lambda ^ { ( j ) } ) L ^ { ( i ) } \left\| W _ { 1 } ^ { ( i ) } - W _ { 2 } ^ { ( i ) } \right\|$$
We then compare the gradient variance of the two cases shown in Figure 26. Interestingly, gradient variance suggests a similar but more significant difference between the two cases compared with their difference in Lipschitz smoothness. As shown in Theorem 4.3, the gradient variance of the narrowest cell is not only scaled by the square of the largest eigenvalue of the weight matrix but also is scaled by the number of intermediate nodes (i.e., $n$ ). Moreover, the upper bound of its gradient variance has numbers of additional terms, leading to a significantly larger gradient variance. The empirical study in Section 4.2.2 has confirmed the results.
Theorem 4.3 (The impact of cell width and depth on gradient variance ) Let $\lambda ^ { ( i ) }$ be the largest eigenvalue of $\dot { W } ^ { ( i ) }$ . Given the widest cell with objective function $f$ and the narrowest cell with objective function $\widehat { f } _ { \mathrm { i } }$ , by assuming the gradient variance of the widest cell as $\begin{array} { r } { \mathbb { E } \left\| \frac { \partial f } { \partial W ^ { ( i ) } } - \mathbb { E } \frac { \partial f } { \partial W ^ { ( i ) } } \right\| ^ { 2 } \leq } \end{array}$ $( \sigma ^ { ( i ) } ) ^ { 2 }$ for any $W ^ { ( i ) }$ , the gradient variance of the narrowest cell is then bounded by
$$\mathbb { E } \left\| \frac { \partial \widehat { f } } { \partial W ^ { ( i ) } } - \mathbb { E } \frac { \partial \widehat { f } } { \partial W ^ { ( i ) } } \right\| ^ { 2 } \leq n \sum _ { k = i } ^ { n } ( \frac { \sigma ^ { ( k ) } } { \lambda ^ { ( i ) } } \prod _ { j = 1 } ^ { k } \lambda ^ { ( j ) } ) ^ { 2 }$$
# 5 GENERALIZATION BEYOND THE COMMON CONNECTIONS
Our empirical and theoretical results so far have demonstrated that the common connection pattern helps to smooth the loss landscape and make the gradient more accurate. Popular NAS architectures with wider and shallower cells therefore converge faster, which explains why popular NAS architectures are selected by the NAS algorithms. Nonetheless, we have ignored the generalization performance obtained by popular NAS architectures and their random variants. We therefore wonder whether popular NAS architectures with wide and shallow cells generalize better.
In Figure 9, we visualize the test accuracy of popular NAS architectures and their randomly connected variants trained in Section 4.1. Notably, the popular NAS architectures can achieve competitive accuracy compared with most of the random variants. However, there are some random variants, which achieve higher accuracy than the popular architectures. Interestingly, there seems to be an optimal choice of depth and width for a cell to achieve higher test accuracy (i.e., $C _ { 7 }$ for DARTS and $C _ { 4 }$ for ENAS). Popular NAS architectures with wide and shallow cells therefore are not guaranteed to generalize better, although they typically converge faster than other random variants.
We also adapt the connections of popular NAS architectures to obtain their widest and shallowest variants. The adaption is possible due to the fact that the cells (including normal and reduction cell)
Table 1: Comparison of the test error at the convergence between the original and the adapted NAS architectures on CIFAR-10/100 and Tiny-ImageNet-200. The entire networks are constructed and trained following the experimental settings reported in Appendix A.3, which may slightly deviate from the original ones. The test errors (or the parameter sizes) of original and adapted architectures are reported on the left and right hand-side of slash respectively.
<table><tr><td rowspan="2">Architecture</td><td colspan="2">CIFAR-10</td><td colspan="2">CIFAR-100</td><td colspan="2">Tiny-ImageNet-200</td></tr><tr><td>Error(%)</td><td>Params(M)</td><td>Error(%)</td><td>Params(M)</td><td>Error(%)</td><td>Params(M)</td></tr><tr><td>NASNet (Zoph et al., 2018)</td><td>2.65/2.80</td><td>4.29/4.32</td><td>17.06/16.86</td><td>4.42/4.45</td><td>31.88/32.05</td><td>4.57/4.60</td></tr><tr><td>AmoebaNet (Real etal.,2019)</td><td>2.76/2.91</td><td>3.60/3.60</td><td>17.55/17.28</td><td>3.71/3.71</td><td>32.22/33.16</td><td>3.83/3.83</td></tr><tr><td>ENAS (Pham et al., 2018)</td><td>2.64/2.76</td><td>4.32/4.32</td><td>16.67/16.04</td><td>4.45/4.45</td><td>30.68/31.36</td><td>4.60/4.60</td></tr><tr><td>DARTS (Liu et al., 2019)</td><td>2.67/2.73</td><td>3.83/3.90</td><td>16.41/16.15</td><td>3.95/4.03</td><td>30.58/31.33</td><td>4.08/4.16</td></tr><tr><td>SNAS (Xie et al., 2019b)</td><td>2.88/2.69</td><td>3.14/3.19</td><td>17.78/17.20</td><td>3.26/3.31</td><td>32.40/32.61</td><td>3.39/3.45</td></tr></table>
of popular NAS architectures are generally not widest and narrowest as shown in Figure 1. While there are various widest and shallowest cells following our definition of cell width and depth, we apply the connection pattern of SNAS cell shown in Figure 1(e) to obtain the widest and shallowest cells. The adapted topologies are shown in Figure 25 of Appendix B.5.
Table 1 illustrates the comparison of the test accuracy between our adapted NAS architectures and the original ones. As shown in Table 1, the adapted architectures achieve smaller test error on CIFAR-100. Nevertheless, most of the adapted architectures, obtain larger test error than the original NAS architectures on both CIFAR-10 and Tiny-ImageNet- $2 0 0 ^ { 4 }$ . The results again suggest that the widest and shallowest cells may not help architectures generalize better, while these architectures typically achieve compelling generalization performance.
The results above have revealed that the architectures with wide and shallow cells may not generalize better despite their fast convergence. To improve current NAS algorithms, we therefore need to rethink the evaluation of the performance of candidate architectures during architecture search since the current NAS algorithms are not based on the generalization performance at convergence as mentioned in Section 4.1. Nonetheless, architectures with the wide and shallow cells usually guarantee a stable and fast convergence along with competitive generalization performance, which should be good prior knowledge for designing architectures and NAS algorithms.
# 6 CONCLUSION AND DISCUSSION
Recent works have been focusing on the design and evaluation of NAS algorithms. We instead endeavour to examine the architectures selected by the various popular NAS algorithms. Our study is the first to explore the common structural patterns selected by existing algorithms, why these architectures are selected, and why these algorithms may be flawed. In particular, we reveal that popular NAS algorithms tend to favor architectures with wide and shallow cells, which typically converge fast and consequently are likely be selected during the search process. However, these architectures may not generalize better than other candidates of narrow and deep cells.
To further improve the performance of the selected NAS architectures, one promising direction for the current NAS research is to evaluate the generalization performance of candidate architectures more accurately and effectively. While popular NAS architectures appreciate fast and stable convergence along with competitive generalization performance, we believe that the wide and shallow cells are still useful prior knowledge for the design of the search space. We hope this work can attract more attention to the interpretation and understanding of existing popular NAS algorithms.
# ACKNOWLEDGEMENT
This research is supported by the National Research Foundation Singapore under its AI Singapore Programme [Award No. AISG-GC-2019-002] and Singapore Ministry of Education Academic Research Fund Tier 3 under MOEs official grant number MOE2017-T3-1-007.
# REFERENCES
Youhei Akimoto, Shinichi Shirakawa, Nozomu Yoshinari, Kento Uchida, Shota Saito, and Kouhei Nishida. Adaptive stochastic natural gradient method for one-shot neural architecture search. In ICML, volume 97 of Proceedings of Machine Learning Research, pp. 171–180. PMLR, 2019.
Amir Beck and Luba Tetruashvili. On the convergence of block coordinate descent type methods. SIAM Journal on Optimization, 23(4):2037–2060, 2013.
Han Cai, Ligeng Zhu, and Song Han. Proxylessnas: Direct neural architecture search on target task and hardware. In ICLR (Poster). OpenReview.net, 2019.
Terrance Devries and Graham W. Taylor. Improved regularization of convolutional neural networks with cutout. CoRR, abs/1708.04552, 2017.
Thomas Elsken, Jan Hendrik Metzen, and Frank Hutter. Neural architecture search: A survey. Journal of Machine Learning Research, 20(55):1–21, 2019.
Saeed Ghadimi and Guanghui Lan. Stochastic first- and zeroth-order methods for nonconvex stochastic programming. SIAM Journal on Optimization, 23(4):2341–2368, 2013.
Ian J. Goodfellow and Oriol Vinyals. Qualitatively characterizing neural network optimization problems. In ICLR, 2015.
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.
Gao Huang, Zhuang Liu, Laurens van der Maaten, and Kilian Q. Weinberger. Densely connected convolutional networks. In CVPR, pp. 2261–2269. IEEE Computer Society, 2017.
Alex Krizhevsky, Geoffrey Hinton, et al. Learning multiple layers of features from tiny images. Technical report, Citeseer, 2009.
Alex Krizhevsky, Ilya Sutskever, and Geoffrey E. Hinton. Imagenet classification with deep convolutional neural networks. In NIPS, pp. 1106–1114, 2012.
Gustav Larsson, Michael Maire, and Gregory Shakhnarovich. Fractalnet: Ultra-deep neural networks without residuals. In ICLR (Poster). OpenReview.net, 2017.
Hao Li, Zheng Xu, Gavin Taylor, Christoph Studer, and Tom Goldstein. Visualizing the loss landscape of neural nets. In NeurIPS, pp. 6391–6401, 2018.
Liam Li and Ameet Talwalkar. Random search and reproducibility for neural architecture search. In UAI, pp. 129. AUAI Press, 2019.
Hanxiao Liu, Karen Simonyan, and Yiming Yang. DARTS: differentiable architecture search. In ICLR (Poster). OpenReview.net, 2019.
Renqian Luo, Fei Tian, Tao Qin, Enhong Chen, and Tie-Yan Liu. Neural architecture optimization. In NeurIPS, pp. 7827–7838, 2018.
Niv Nayman, Asaf Noy, Tal Ridnik, Itamar Friedman, Rong Jin, and Lihi Zelnik-Manor. XNAS: neural architecture search with expert advice. CoRR, abs/1906.08031, 2019.
Yurii Nesterov. Introductory Lectures on Convex Optimization - A Basic Course, volume 87 of Applied Optimization. Springer, 2004.
Hieu Pham, Melody Y. Guan, Barret Zoph, Quoc V. Le, and Jeff Dean. Efficient neural architecture search via parameter sharing. In ICML, volume 80 of Proceedings of Machine Learning Research, pp. 4092–4101. PMLR, 2018.
Esteban Real, Alok Aggarwal, Yanping Huang, and Quoc V. Le. Regularized evolution for image classifier architecture search. In AAAI, pp. 4780–4789. AAAI Press, 2019.
Christian Sciuto, Kaicheng Yu, Martin Jaggi, Claudiu Musat, and Mathieu Salzmann. Evaluating the search phase of neural architecture search. arXiv preprint arXiv:1902.08142, 2019. Karen Simonyan and Andrew Zisserman. Very deep convolutional networks for large-scale image recognition. In ICLR, 2015. Christian Szegedy, Wei Liu, Yangqing Jia, Pierre Sermanet, Scott E. Reed, Dragomir Anguelov, Dumitru Erhan, Vincent Vanhoucke, and Andrew Rabinovich. Going deeper with convolutions. In CVPR, pp. 1–9. IEEE Computer Society, 2015. Mingxing Tan, Bo Chen, Ruoming Pang, Vijay Vasudevan, Mark Sandler, Andrew Howard, and Quoc V. Le. Mnasnet: Platform-aware neural architecture search for mobile. In CVPR, pp. 2820– 2828. Computer Vision Foundation / IEEE, 2019. Saining Xie, Alexander Kirillov, Ross Girshick, and Kaiming He. Exploring randomly wired neural networks for image recognition. arXiv preprint arXiv:1904.01569, 2019a. Sirui Xie, Hehui Zheng, Chunxiao Liu, and Liang Lin. SNAS: stochastic neural architecture search. In ICLR (Poster). OpenReview.net, 2019b. Zirui Zhou, Qi Zhang, and Anthony Man-Cho So. 1,p-norm regularization: Error bounds and convergence rate analysis of first-order methods. In ICML, pp. 1501–1510, 2015. Barret Zoph, Vijay Vasudevan, Jonathon Shlens, and Quoc V. Le. Learning transferable architectures for scalable image recognition. In CVPR, pp. 8697–8710. IEEE Computer Society, 2018.
# APPENDIX A EXPERIMENTAL SETUP
# A.1 DATA PRE-PROCESSING AND AUGMENTATION
Our experiments are conducted on CIFAR-10/100 (Krizhevsky et al., 2009) and Tiny-ImageNet200. CIFAR-10/100 contains 50,000 training images and 10,000 test images of $3 2 \times 3 2$ pixels in 10 and 100 classes respectively. Tiny-ImageNet-200 consists of 100,000 training images, 10,000 validation images and 10,000 test images5 in 200 classes. We adopt the same data pre-processing and argumentation as described in DARTS (Liu et al., 2019): zero padding the training images with 4 pixels on each side and then randomly cropping them back to $3 2 \times 3 2$ on CIFAR-10/100 and $6 4 \times 6 4$ on Tiny-ImageNet-200; randomly flipping training images horizontally; normalizing training images with the means and standard deviations along the channel dimension.
# A.2 SAMPLING OF RANDOM VARIANTS
For a $N$ -node NAS cell, there are $\frac { ( N - 2 ) ! } { ( M - 1 ) ! }$ possible connections with $M$ input nodes and one output node. There are therefore hundreds to thousands of possible randomly connected variants for each popular NAS cell. The random variants of operations consist of a similar or even higher amount of architectures. Due to the prohibitive cost of comparing popular NAS cells with all variants, we randomly sample some variants to understand why the popular NAS cells are selected.
Given a NAS cell $C$ , we fix the partial order of intermediate nodes and their accompanying operations. We then replace the source node of their associated operations by uniformly randomly sampling a node from their proceeding nodes in the same cell to get their randomly connected variants. Similarly, given a NAS cell $C$ , we fix the partial order of intermediate nodes and their connection topologies. We then replace the operations couping each connection by uniformly randomly sampling from candidate operations to get their random variants of operations.
# A.3 ARCHITECTURES AND TRAINING DETAILS
For experiments on CIFAR-10/100 and Tiny-ImageNet-200, the neural network architectures are constructed by stacking $L = 2 0$ cells. Feature maps are down-sampled at the $L / 3$ -th and $2 L / 3$ -th cell of the entire architecture with stride 2. For Tiny-ImageNet-200, the stride of the first convolutional layer is adapted to 2 to reduce the input resolution from $6 4 \times 6 4$ to $3 2 \times 3 2$ . A more detailed building scheme can be found in DARTS (Liu et al., 2019).
In the default training setting, we apply stochastic gradient descent (SGD) with learning rate 0.025, momentum 0.9, weight decay $3 \times \bar { 1 0 ^ { - 4 } }$ and batch size 80 to train the models for 600 epochs on CIFAR10/100 and 300 epochs on Tiny-ImageNet-200 to ensure the convergence. The learning rate is gradually annealed to zero following the standard cosine annealing schedule. To compare the convergence under different learning rates in Section 4.1, we change the initial learning rate from 0.025 to 0.25 and 0.0025 respectively.
# A.4 REGULARIZATION
Since regularization mechanisms shall affect the convergence (Zhou et al., 2015), architectures are trained without regularization for a neat empirical study in Section 4. The regularization mechanisms are only used in Section 5 to get the converged generalization performance of the original and adapted NAS architectures on CIFAR-10/100 and Tiny-ImageNet-200 as shown in Table 1.
There are three adopted regularization mechanisms on CIFAR-10/100 and Tiny-ImageNet-200 in this paper: cutout (Devries & Taylor, 2017), auxiliary tower (Szegedy et al., 2015) and drop path (Larsson et al., 2017). We apply standard cutout regularization with cutout length 16. Moreover, the auxiliary tower is located at $2 L / 3$ -th cell of the entire architecture with weight 0.4. We apply the same linearly-increased drop path schedule as in NASNet (Zoph et al., 2018) with the maximum probability of 0.2.
# APPENDIX B MORE RESULTS
# B.1 NAS ARCHITECTURES AND THEIR VARIANTS
We compare the width and depth of popular NAS architectures and their variants of random connections in Table 2. The random variants are sampled following the method in Appendix A.2. We further show the connection topologies of popular NAS and their partial random variants of connections in Figure 10 and Figure 11.
Table 2: Comparison of the width and depth of popular NAS cells and their randomly variants of connections. The name of the popular NAS cell is followed by its width and depth, which is separated by a comma. The width of a cell is conventionally computed by assuming that each intermediate node shares the same width $c$ . Notably, the width and depth of random variants are in ascending and descending order respectively from $C _ { 1 }$ to $C _ { 1 3 }$ . Moreover, the popular NAS architectures achieve the largest width and nearly the smallest depth among all the variants.
<table><tr><td>Base Cell</td><td>C</td><td>C</td><td>C3</td><td>C4</td><td>C5</td><td>C6</td><td>C7</td><td>C8</td><td>Cg</td><td>C10</td><td>C11</td><td>C12</td><td>C13</td></tr><tr><td>DARTS (3.5c,3)</td><td>2c,4</td><td>2c,4</td><td>2c,4</td><td>2.5c,4</td><td>2.5c,4</td><td>2.5c,3</td><td>2.5c,3</td><td>2.5c,3</td><td>3c,3</td><td>3c,3</td><td>3c,3</td><td>3.5c,3</td><td>3.5c,3</td></tr><tr><td>ENAS (5c,2)</td><td>1.5c,6</td><td>1.5c,5</td><td>2c,6</td><td>2c,6</td><td>2.5c,5</td><td>2.5c,5</td><td>3c,4</td><td>3c,3</td><td>3.5c,5</td><td>3.5c,4</td><td>3.5c,4</td><td>3.5c,3</td><td>3.5c,3</td></tr><tr><td>AmoebaNet (4c,4)</td><td>1.5c,6</td><td>1.5c,5</td><td>1.5c,5</td><td>1.5c,3</td><td>2c,6</td><td>2c,6</td><td>2c,4</td><td>2.5c,5</td><td>2.5c,3</td><td>2.5c,3</td><td>3c,3</td><td>3.5c,4</td><td>3.5c,3</td></tr><tr><td>NASNet (5c,2)</td><td>1.5c,6</td><td>1.5c,5</td><td>2c,6</td><td>2c,6</td><td>2.5c,5</td><td>2.5c,5</td><td>3c,4</td><td>3c,3</td><td>3.5c,5</td><td>3.5c,4</td><td>3.5c,4</td><td>3.5c,3</td><td>3.5c,3</td></tr></table>
 Figure 10: Connection topology of AmoebaNet cell (Real et al., 2019) and its part of randomly connected variants. Each sub-figure reports the width and depth of a cell separated by a comma. The leftmost one is the original connection from AmoebaNet normal cell and others are the ones randomly sampled. The width of a cell is also computed by assuming that each intermediate node shares the same width $c$ . Notably, the original AmoebaNet cell has the largest width and almost the smallest depth among these cells.
 Figure 11: Connection topology of SNAS cell under mild constraint (Xie et al., 2019b) and its part of randomly connected variants. The width and depth of a cell are reported in the title of each plot. The leftmost one is the original connection from SNAS normal cell and others are the ones randomly sampled. The width of a cell is conventionally computed by assuming that each intermediate node shares the same width $c$ . Notably, the original SNAS cell has the largest width and the smallest depth among these cells.
 Figure 12: More test accuracy $( \% )$ curves of DARTS, ENAS, AmoebaNet, NASNet and their random variants of operations on CIFAR-10 during training.
Table 3: Comparison of the parameter size (MB) of popular NAS cells and their randomly variants of operations. $C _ { 0 }$ denotes the original NAS cell and $C _ { 1 }$ to $C _ { 1 0 }$ denote the random variants. Notably, there is a gap of $\sim 3 0 \%$ between the parameter size of the smallest architecture and one of the largest architecture.
<table><tr><td>Base cell</td><td>C</td><td>C1</td><td>C</td><td>C3</td><td>C4</td><td>C5</td><td>C6</td><td>C7</td><td>C8</td><td>C</td><td>C10</td></tr><tr><td>DARTS</td><td>3.35</td><td>3.37</td><td>2.84</td><td>2.70</td><td>2.98</td><td>3.19</td><td>2.43</td><td>3.49</td><td>2.88</td><td>3.31</td><td>2.81</td></tr><tr><td>ENAS</td><td>3.86</td><td>3.45</td><td>3.19</td><td>2.98</td><td>2.70</td><td>3.67</td><td>3.03</td><td>3.85</td><td>3.26</td><td>3.81</td><td>3.29</td></tr><tr><td>AmoebaNet</td><td>3.15</td><td>2.86</td><td>2.62</td><td>2.41</td><td>2.10</td><td>3.10</td><td>2.46</td><td>3.28</td><td>2.69</td><td>3.42</td><td>2.75</td></tr><tr><td>NASNet</td><td>3.83</td><td>3.45</td><td>3.19</td><td>2.98</td><td>2.70</td><td>3.67</td><td>3.03</td><td>3.85</td><td>3.26</td><td>3.81</td><td>3.29</td></tr></table>
# B.2 CONVERGENCE
In this section, we plot more test loss curves on CIFAR-10 (Krizhevsky et al., 2009) for original popular NAS architectures and their (12) randomly connected variants, as shown in Figure 13, Figure 14 and Figure 16. The depth and width of these 12 randomly connected variants can be found in Table 2. Notably, the width and depth of random variants (from $C _ { 1 }$ to $C _ { 1 2 }$ ) are in ascending and descending order respectively. Moreover, the popular NAS architectures achieve the largest width and nearly the smallest depth among all the variants. As shown in the following figures, the popular NAS cells, with larger width and smaller depth, typically achieve faster and more stable convergence than the random variants. Furthermore, with the increasing width and the decreasing depth, the convergence of random variants approaches to the original NAS architecture.
 Figure 13: Test loss curves of DARTS and its variants on CIFAR-10 during training.
 Figure 14: Test loss curves of AmoebaNet and its variants on CIFAR-10 during training.
 Figure 15: Test loss curves of ENAS and its variants on CIFAR-10 suring training.
 Figure 16: Test loss curves of NASNet and its variants on CIFAR-10 suring training.
# B.3 LOSS LANDSCAPE
In this section, we visualize loss landscapes for popular NAS architectures and their randomly connected variants. The depth and width of a cell are highly correlated. For example, the depth and width cannot reach their maximum simultaneously. With the increasing width, the average depth of cells grouped by the same width is decreasing as shown in Table 2. We therefore only group the results (including the ones from original NAS architectures) with various width levels of a cell for a better comparison. Notably, the architectures with wider and shallower cells have a smoother and benigner loss landscape, as shown in Figure 17, Figure 18, Figure 19 and Figure 20, which further supports the results in Section 4.2.1.
 Figure 17: Loss contours of DARTS and its variants with random connections on the test dataset of CIFAR-10.
 Figure 18: Loss contours of AmoebaNet and its randomly connected variants on the test dataset of CIFAR-10.
(a) 1.5c (b) 2c (c) 2.5c (d) 3c (e) 3.5c (a) 1.5c (b) 2c (c) 2.5c (d) 3c (e) 3.5c (a) 1.5c (b) 2c (c) 2.5c (d) 3c (e) 3.5c
 Figure 19: Loss contours of ENAS and its randomly connected variants on the test dataset of CIFAR10.
 Figure 20: Loss contours of NASNet and its randomly connected variants on the test dataset of CIFAR-10.
# B.4 GRADIENT VARIANCE
In this section, we visualize the gradient variance (i.e., $g ( \alpha , \beta )$ as defined in Section 4.2.2) for the popular NAS architectures as well as their variants with random connection, such as AmoebaNet in Figure 21, DARTS in Figure 22, ENAS in Figure 23 and NASNet in Figure 23. The $z$ -axis has been scaled by $1 0 ^ { - 5 }$ for a better visualization. Similarly, we group the results based on the width of cells. Notably, architectures with wider and shallower cells achieve relatively smaller gradient variance, which further confirms the results in Section 4.2.2.
 Figure 21: 3D surfaces of the gradient variance from AmoebaNet and its randomly connected variants on the test dataset of CIFAR-10.
 Figure 22: 3D surfaces of the gradient variance from DARTS and its randomly connected variants on the test dataset of CIFAR-10.
 Figure 23: 3D surfaces of the gradient variance from ENAS and its randomly connected variants on the test dataset of CIFAR-10.
 Figure 24: 3D surfaces of the gradient variance from NASNet and its randomly connected variants on the test dataset of CIFAR-10.
# B.5 ADAPTED TOPOLOGIES
In this section, we visualize the adapted architectures (in Figure 25) we investigate on in Section 5. Notably, The adapted connection topologies are not only applied in the normal cell but also the reduction cell. The adapted architectures are compared with popular NAS architectures to examine the impacts of the common connection pattern on generalization.
 Figure 25: Adapted topologies of cells from popular NAS architectures. The title of each sub-figure includes the name of the architecture, width and depth of the cell following our definition. Notably, these cells achieve the largest width and smallest depth in their original search space.
# APPENDIX C THEORETICAL ANALYSIS
# C.1 SETUP
 Figure 26: Two architectures to compare in the theoretical analysis: (a) architecture with widest cell; (b) architecture with narrowest cell. The notation $l$ and $\widehat { l }$ denote the values of objective function $f$ and $\widehat { f }$ evaluated at input $_ { \textbf { \em x } }$ respectively.
# C.2 BASICS
We firstly compare the gradient of case I and case $\mathrm { I I }$ shown in Figure 26. For case I, since $\begin{array} { r l } { \mathbf { \boldsymbol { y } } ^ { ( i ) } = } & { { } } \end{array}$ $W ^ { ( i ) } { \pmb x }$ , the gradient to each weight matrix $W ^ { ( i ) }$ is denoted by
$$\frac { \partial f } { \partial W ^ { ( i ) } } = \frac { \partial f } { \partial \pmb { y } ^ { ( i ) } } \pmb { x } ^ { T }$$
Similarly, since $\begin{array} { r } { \widehat { \pmb { y } } ^ { ( i ) } = \prod _ { k = 1 } ^ { i } W ^ { ( k ) } \pmb { x } } \end{array}$ for the case II, the gradient to each weight matrix $W ^ { ( i ) }$ is denoted by
$$\begin{array} { l } { \displaystyle \frac { \partial \widehat { f } } { \partial W ^ { ( i ) } } = \sum _ { k = i } ^ { n } ( \prod _ { j = i + 1 } ^ { k } W ^ { ( j ) } ) ^ { T } \displaystyle \frac { \partial \widehat { f } } { \partial \widehat { y } ^ { ( k ) } } ( \prod _ { j = 1 } ^ { i - 1 } W ^ { ( j ) } { \pmb x } ) ^ { T } } \\ { = \sum _ { k = i } ^ { n } ( \prod _ { j = i + 1 } ^ { k } W ^ { ( j ) } ) ^ { T } \displaystyle \frac { \partial \widehat { f } } { \partial \widehat { y } ^ { ( k ) } } { \pmb x } ^ { T } ( \prod _ { j = 1 } ^ { i - 1 } W ^ { ( j ) } ) ^ { T } } \\ { = \displaystyle \sum _ { k = i } ^ { n } ( \prod _ { j = i + 1 } ^ { k } W ^ { ( j ) } ) ^ { T } \displaystyle \frac { \partial { f } } { \partial W ^ { ( k ) } } ( \prod _ { j = 1 } ^ { i - 1 } W ^ { ( j ) } ) ^ { T } } \end{array}$$
Exploring the fact that $\begin{array} { r } { \frac { \partial \widehat { f } } { \partial \widehat { \pmb { y } } ^ { ( i ) } } = \frac { \partial f } { \partial \pmb { y } ^ { ( i ) } } } \end{array}$ ∂f∂y(i) , we get (4) by inserting (1) into (3).
# C.3 PROOF OF THEOREM 4.2
Due to the complexity of comparing the standard Lipschitz constant of the smoothness for these two cases, we instead investigate the block-wise Lipschitz constant (Beck & Tetruashvili, 2013). In other words, we evaluate the Lipschitz constant for each weight matrix $W ^ { ( i ) }$ while fixing all other matrices. Formally, we assume the block-wise Lipschitz smoothness of case I as
$$\left\| \frac { \partial f } { \partial W _ { 1 } ^ { ( i ) } } - \frac { \partial f } { \partial W _ { 2 } ^ { ( i ) } } \right\| \leq L ^ { ( i ) } \left\| W _ { 1 } ^ { ( i ) } - W _ { 2 } ^ { ( i ) } \right\| \quad \forall W _ { 1 } ^ { ( i ) } , W _ { 2 } ^ { ( i ) }$$
The default matrix norm we adopted is 2-norm. And $W _ { 1 } ^ { ( i ) } , W _ { 2 } ^ { ( i ) }$ denote possible assignments for $W ^ { ( i ) }$ .
Denoting that $\lambda ^ { ( i ) } = \left\| W ^ { ( i ) } \right\|$ , which is the largest eigenvalue of matrix $W ^ { ( i ) }$ , we can get the smoothness of case $\mathrm { I I }$ as
$$\begin{array} { r l } { \left| \frac { \partial \hat { f } } { \partial W _ { 1 } ^ { ( i ) } } - \frac { \partial \hat { f } } { \partial W _ { 2 } ^ { ( i ) } } \right| \Bigg | = \left| \displaystyle \sum _ { k = i } ^ { n } ( \displaystyle \prod _ { j = i + 1 } ^ { k } W ^ { ( j ) } ) ^ { T } \big ( \frac { \partial f } { \partial W _ { 1 } ^ { ( k ) } } - \frac { \partial f } { \partial W _ { 2 } ^ { ( k ) } } ) ( \displaystyle \prod _ { j = 1 } ^ { i - 1 } W ^ { ( j ) } ) ^ { T } \right| } & { } \\ { \displaystyle } & { \leq \displaystyle \sum _ { k = i } ^ { n } \left\| \big ( \displaystyle \prod _ { j = i + 1 } ^ { k } W ^ { ( j ) } \big ) ^ { T } \big ( \frac { \partial f } { \partial W _ { 1 } ^ { ( k ) } } - \frac { \partial f } { \partial W _ { 2 } ^ { ( k ) } } \big ) ( \displaystyle \prod _ { j = 1 } ^ { i - 1 } W ^ { ( j ) } ) ^ { T } \right| } \\ & { \displaystyle \leq \displaystyle \sum _ { k = i } ^ { n } ( \displaystyle \frac { 1 } { \lambda ^ { ( i ) } } \displaystyle \prod _ { j = 1 } ^ { k } \lambda ^ { ( j ) } ) L ^ { ( k ) } \left\| W _ { 1 } ^ { ( k ) } - W _ { 2 } ^ { ( k ) } \right\| } \\ & { \displaystyle \leq ( \displaystyle \prod _ { j = 1 } ^ { i - 1 } \lambda ^ { ( j ) } ) L ^ { ( i ) } \left\| W _ { 1 } ^ { ( i ) } - W _ { 2 } ^ { ( k ) } \right\| } \end{array}$$
We get the equality in (6) since $j > i$ and $W ^ { ( j ) }$ keeps the same for the computation of block-wise Lipschitz constant of $W ^ { ( i ) }$ . Based on the triangle inequality of norm, we get (7) from (6). We get (8) from (7) based on the inequality $\lVert W V \rVert \leq \lVert W \rVert \lVert V \rVert$ and the assumption of the smoothness for case I in (5). Finally, since we are evaluating the block-wise Lipschitz constant for $W ^ { ( i ) }$ , $W _ { 1 } ^ { ( k ) } = W _ { 2 } ^ { ( k ) }$ while $k \neq i$ , which leads to the final inequality (9).
# C.4 PROOF OF THEOREM 4.3
Similarly, we assume the gradient variance of case I is bounded as
$$\mathbb { E } \left\| \frac { \partial f } { \partial W ^ { ( i ) } } - \mathbb { E } \frac { \partial f } { \partial W ^ { ( i ) } } \right\| ^ { 2 } \leq ( \sigma ^ { ( i ) } ) ^ { 2 }$$
The gradient variance of case $\mathrm { I I }$ is then bounded by
$$\begin{array} { r l } { \mathbb { E } \left\| \displaystyle \frac { \partial \hat { f } } { \partial W ^ { ( i ) } } - \mathbb { E } \frac { \partial \hat { f } } { \partial W ^ { ( i ) } } \right\| ^ { 2 } = \mathbb { E } \left\| \displaystyle \sum _ { k = i } ^ { n } ( \displaystyle \prod _ { j = i + 1 } ^ { k } W ^ { ( j ) } ) ^ { T } ( \displaystyle \frac { \partial f } { \partial W ^ { ( k ) } } - \mathbb { E } \frac { \partial f } { \partial W ^ { ( k ) } } ) ( \displaystyle \prod _ { j = 1 } ^ { i - 1 } W ^ { ( j ) } ) ^ { T } \right\| ^ { 2 } } & { } \\ { \leq n \mathbb { E } \displaystyle \sum _ { k = i } ^ { n } \left\| ( \displaystyle \prod _ { j = i + 1 } ^ { k } W ^ { ( j ) } ) ^ { T } ( \displaystyle \frac { \partial f } { \partial W ^ { ( k ) } } - \mathbb { E } \frac { \partial f } { \partial W ^ { ( k ) } } ) ( \displaystyle \prod _ { j = 1 } ^ { i - 1 } W ^ { ( j ) } ) ^ { T } \right\| ^ { 2 } } & { } \\ { \leq n \displaystyle \sum _ { k = i } ^ { n } ( \displaystyle \frac { \sigma ^ { ( k ) } } { \lambda ^ { ( i ) } } \displaystyle \prod _ { j = 1 } ^ { k } \lambda ^ { ( j ) } ) ^ { 2 } } & { } \end{array}$$
We get (12) from (11) based on Cauchy-Schwarz inequality. Based on the inequality $\| W V \| \leq$ $\| W \| \| V \|$ and the assumption of bounded gradient variance for case I in (10), we get the final inequality.123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417# ATTENTIVE WEIGHTS GENERATION FOR FEW SHOTLEARNING VIA INFORMATION MAXIMIZATION
Anonymous authors Paper under double-blind review
# ABSTRACT
Few shot image classification aims at learning a classifier from limited labeled data. Generating the classification weights has been applied in many metalearning approaches for few shot image classification due to its simplicity and effectiveness. However, we argue that it is difficult to generate the exact and universal classification weights for all the diverse query samples from very few training samples. In this work, we introduce Attentive Weights Generation for few shot learning via Information Maximization (AWGIM), which addresses current issues by two novel contributions. i) AWGIM generates different classification weights for different query samples by letting each of query samples attends to the whole support set. ii) To guarantee the generated weights adaptive to different query sample, we re-formulate the problem to maximize the lower bound of mutual information between generated weights and query as well as support data. As far as we can see, this is the first attempt to unify information maximization into few shot learning. Both two contributions are proved to be effective in the extensive experiments and we show that AWGIM is able to achieve state-of-the-art performance on benchmark datasets.
# 1 INTRODUCTION
While deep learning methods achieve great success in domains such as computer vision (He et al., 2016), natural language processing (Devlin et al., 2018), reinforcement learning (Silver et al., 2018), their hunger for large amount of labeled data limits the application scenarios where only a few data are available for training. Humans, in contrast, are able to learn from limited data, which is desirable for deep learning methods. Few shot learning is thus proposed to enable deep models to learn from very few samples (Fei-Fei et al., 2006).
Meta learning is by far the most popular and promising approach for few shot problems (Vinyals et al., 2016; Finn et al., 2017; Snell et al., 2017; Ravi & Larochelle, 2016; Rusu et al., 2019). In meta learning approaches, the model extracts high level knowledge across different tasks so that it can adapt itself quickly to a new-coming task (Schmidhuber, 1987; Andrychowicz et al., 2016). There are several kinds of meta learning methods for few shot learning, such as gradient-based (Finn et al., 2017; Ravi & Larochelle, 2016) and metric-based (Snell et al., 2017; Sung et al., 2018). Weights generation, among these different methods, has shown effectiveness with simple formulation (Qi et al., 2018; Qiao et al., 2018; Gidaris & Komodakis, 2018; 2019). In general, weights generation methods learn to generate the classification weights for different tasks conditioned on the limited labeled data. However, fixed classification weights for different query samples within one task might be sub-optimal, due to the few shot challenge.
We introduce Attentive Weights Generation for few shot learning via Information Maximization (AWGIM) in this work to address these limitations. In AWGIM, the classification weights are generated for each query sample specifically. This is done by two encoding paths where the query sample attends to the task context. However, we show in experiments that simple cross attention between query samples and support set fails to guarantee classification weights fitted to diverse query data since the query-specific information is lost during weights generation. Therefore, we propose to maximize the lower bound of mutual information between generated weights and query, support data. As far as we know, AWGIM is the first work introducing Variational Information Maximization in few shot learning. The induced computational overhead is minimal due to the nature of few shot problems. Furthermore, by maximizing the lower bound of mutual information, AWGIM gets rid of inner update without compromising performance.
AWGIM is evaluated on two benchmark datasets and shows state-of-the-art performance. We also conducted detailed analysis to validate the contribution of each component in AWGIM.
# 2 RELATED WORKS
# 2.1 FEW SHOT LEARNING
Learning from few labeled training data has received growing attentions recently. Most successful existing methods apply meta learning to solve this problem and can be divided into several categories. In the gradient-based approaches, an optimal initialization for all tasks is learned (Finn et al., 2017). Ravi & Larochelle (2016) learned a meta-learner LSTM directly to optimize the given fewshot classification task. Sun et al. (2019) learned the transformation for activations of each layer by gradients to better suit the current task.
In the metric-based methods, a similarity metric between query and support samples is learned. (Koch et al., 2015; Vinyals et al., 2016; Snell et al., 2017; Sung et al., 2018; Li et al., 2019a). Spatial information or local image descriptors are also considered in some works to compute richer similarities (Lifchitz et al., 2019; Li et al., 2019b; Wertheimer & Hariharan, 2019).
Generating the classification weights directly has been explored by some works. Gidaris & Komodakis (2018) generated classification weights as linear combinations of weights for base and novel classes. Similarly, Qiao et al. (2018) and Qi et al. (2018) both generated the classification weights from activations of a trained feature extractor. Graph neural network denoising autoencoders are used in (Gidaris & Komodakis, 2019). Munkhdalai & Yu (2017) proposed to generate “fast weights” from the loss gradient for each task. All these methods do not consider generating different weights for different query examples, nor maximizing the mutual information.
There are some other methods for few-shot classification. Generative models are used to generate or hallucinate more data in (Zhang et al., 2018; Wang et al., 2018; Chen et al., 2019). Bertinetto et al. (2019) and Lee et al. (2019) used the closed-form solutions directly for few shot classification. Liu et al. (2019) integrated label propagation on a transductive graph to predict the query class label.
# 2.2 ATTENTION
Attention mechanism shows great success in computer vision (Xu et al., 2015; Parmar et al., 2018) and natural language processing (Bahdanau et al., 2015; Vaswani et al., 2017). It is effective in modeling the interaction between queries and key-value pairs from certain context. Based on the fact that keys and queries point to the same entities or not, people refer to attention as self attention or cross attention. In this work, we use both types of attention to encode the task and query-task information. The work most similar to ours is Attentive Neural Processes (Kim et al., 2019), which also employs self and cross attention. However, we are using attention for few-shot image classification via maximizing the mutual information. In stark contrast, Kim et al. (2019) worked on regression from the perspective of a stochastic process and the variational objective is optimized.
# 2.3 MUTUAL INFORMATION
Given two random variables $\mathbf { X }$ and $\mathsf { y }$ , mutual information $I ( { \bf x } ; { \bf y } )$ measures the decrease of uncertainty in one random variable when another is known. It is defined as the Kullback-Leibler divergence between joint distribution $p ( \mathbf { x } , \mathbf { y } )$ and product of marginal distributions $p ( \mathbf { x } ) \otimes p ( \mathbf { y } )$ ,
$$I ( \mathbf { x } ; \mathbf { y } ) = D _ { \mathrm { K L } } ( p ( \mathbf { x } , \mathbf { y } ) \| p ( \mathbf { x } ) \otimes p ( \mathbf { y } ) ) .$$
When x and y are independent, $p ( \mathbf { x } , \mathbf { y } ) = p ( \mathbf { x } ) \otimes p ( \mathbf { y } )$ so that $I ( { \bf x } , { \bf y } ) = 0$ , indicating that knowing $\mathbf { X }$ does not reveal any information about y. When y is a deterministic function of $\mathbf { X }$ , $I ( \mathbf { x } , \mathbf { y } )$ achieves its maximum value. Mutual information has been widely applied in applications such as Generative Adversarial Networks(Chen et al., 2016), self-supervised learning(Hjelm et al., 2019), visual question generation Krishna et al. (2019) and so on.
 Figure 1: The overview of our proposed AWGIM. The input task is 5-way 1-shot with $\mathbf { X }$ as support set and $\hat { \bf x }$ as one query example. Different colors of the data in support set indicate different categories. The encoding process in contextual path produces context-aware support representations $\mathbf { X } ^ { c p }$ . Similarly, the attentive path enables the query sample $\hat { \bf x }$ to be equipped with task knowledge. Both paths are achieved by attention mechanism. $\hat { \mathbf { x } } ^ { a p }$ is repeated to concatenate with $\mathbf { X } ^ { c p }$ . The weight generator $g$ takes these concatenated representations as input to generate classification weights W specific for $\hat { \bf x }$ , denoted by the colorful matrix with slash. It can be used to predict the class label for $\hat { \bf x }$ and X. W is also used to reconstruct the inputs of the generator $g$ by two networks $r _ { 1 }$ and $r _ { 2 }$ . In this way, the lower bound of mutual information is maximized and $g$ is forced to generate classification weights sensitive to different query samples.
# 3 PROPOSED METHOD
In this section, we provide the problem formulation first. Then the proposed model is described in Sec. 3.3. The objective function, which maximizes the mutual information between certain variables, and theoretical analysis are provided in Sec. 3.4.
# 3.1 PROBLEM FORMULATION
Following many popular meta-learning methods for few shot classification, we formulate the problem under episodic training paradigm (Vinyals et al., 2016; Finn et al., 2017). One $N$ -way $K$ -shot task sampled from an unknown task distribution $P ( \tau )$ includes support set and query set:
$${ \mathcal { T } } = ( { \mathcal { S } } , { \mathcal { Q } } ) ,$$
where $\mathcal { S } = \{ ( \mathbf { x } ^ { c _ { n } ; k } , \mathbf { y } ^ { c _ { n } ; k } ) | k = 1 , . . . , K ; n = 1 , . . . , N \}$ , $\mathcal { Q } = \{ ( \hat { \mathbf { x } } _ { 1 } , . . . , \hat { \mathbf { x } } _ { | \mathcal { Q } | } ) \}$ . Support set $s$ contains $N K$ labeled samples. Query set $\mathcal { Q }$ includes $\hat { \bf x }$ and we need to predict label $\hat { \mathbf { y } }$ for $\hat { \bf x }$ based on $s$ . During meta-training, the meta-loss is estimated on $\mathcal { Q }$ to optimize the model. During metatesting, the performance of meta-learning method is evaluated on $\mathcal { Q }$ , provided the labeled $s$ . The classes used in meta-training and meta-testing are disjoint so that the meta-learned model needs to learn the knowledge transferable across tasks and adapt itself quickly to novel tasks.
Our proposed approach follows the general framework to generate the classification weights (Qi et al., 2018; Qiao et al., 2018; Rusu et al., 2019; Gidaris & Komodakis, 2018; 2019). In this framework, there is a feature extractor to output image feature embeddings. The meta-learner needs to generate the classification weights for different tasks.
# 3.2 LATENT EMBEDDING OPTIMIZATION
Latent Embedding Optimization (LEO) (Rusu et al., 2019) is one of the weights generation methods that is most related to our work. In LEO, the latent code $_ z$ is generated by $h$ conditioned on support set $s$ , described as $z = h ( S )$ . $h$ is instantiated as relation networks (Santoro et al., 2017). Classification weights $\pmb { w }$ can be decoded from $_ { z }$ with $l$ , $w = l ( z )$ . In the inner loop, we use $\pmb { w }$ to compute the loss (usually cross entropy) on the support set and then update $_ z$ :
$$\begin{array} { r } { z ^ { \prime } = z - \eta \nabla _ { z } \mathcal { L } _ { \mathcal { S } } ( \pmb { w } ) , } \end{array}$$
where $\mathcal { L } _ { S }$ indicates that the loss is evaluated on $s$ only. The updated latent code $z ^ { \prime }$ is used to decode new classification weights $\mathbf { \Delta } \mathbf { w ^ { \prime } }$ with generating function $l$ . $\mathbf { \Delta } _ { \mathbf { \ b { w } } ^ { \prime } }$ is adopted in the outer loop for query set $\mathcal { Q }$ and the objective function of LEO then can be written as
$$\operatorname* { m i n } _ { \theta } \mathcal { L } _ { \mathcal { Q } } ( w ^ { \prime } ) .$$
Here $\theta$ stands for the parameters of $h$ and $l$ and we omit the regularization terms for clarity. LEO avoids updating high-dimensional $\textbf { \em w }$ in the inner loop by learning a lower-dimensional latent space, from which sampled $_ z$ can be used to generate $\pmb { w }$ . The most significant difference between LEO and AWGIM is that we do not need inner updates to adapt the model. Instead, AWGIM is a feedforward network trained to maximize the mutual information so that it fits to different tasks well. On the other hand, AWGIM learns to generate optimal classification weights for each query sample while LEO generates fixed weights conditioned on the support set within one task. In Section 3.4 we will show LEO can be casted as a special case of AWGIM under certain conditions.
# 3.3 ATTENTIVE WEIGHTS GENERATION
The framework of our proposed method is shown in Figure 1. Assume that we have a feature extractor, which can be a simple 4-layer Convnet or a deeper Resnet. All the images included in the sampled task $\tau$ are processed by this feature extractor and represented as $d$ -dimensional vectors afterwards, i.e., $\mathbf { x } ^ { c _ { n } ; k } , \hat { \mathbf { x } } \in \mathbb { R } ^ { d }$ . There are two paths to encode the task context and the individual query sample respectively, which are called contextual path and attentive path. The outputs of both paths are concatenated together as input to the generator for classification weights. Generated classification weights are used to not only predict the label of $\hat { \bf x }$ , but also maximize the lower bound of mutual information between itself and other variables, which will be discussed in the following section 3.4.
# 3.3.1 CONTEXTUAL AND ATTENTIVE PATHS
The encoding process includes two paths, namely the contextual path and attentive path. The contextual path aims at learning representations for only the support set with a multi-head self-attention network $f _ { s a } ^ { c p }$ (Vaswani et al., 2017). The outputs of contextual path ${ \bf X } ^ { c p } \in \mathbb { R } ^ { N K \times d _ { h } }$ 1 thus contain richer information about the task and can be used later for weights generation.
Existing weights generation methods generate the classification weights conditioned on the support set only, which is equivalent to using contextual path. However, the classification weights generated in this way might be sub-optimal. This is because estimating the exact and universal classification weights from very few labeled data in the support set is difficult and sometimes impossible. The generated weights are usually in lack of adaptation to different query samples. We address this issue by introducing attentive path, where the individual query example attends to the task context and then is used to generate the classification weights. Therefore, the classification weights are adaptive to different query samples and aware of the task context as well.
In the attentive path, a new multi-head self-attention network $f _ { s a } ^ { a p }$ on the support set is employed to encode the global task information. $f _ { s a } ^ { a p }$ is different from $f _ { s a } ^ { c p }$ in contextual path because the selfattention network in contextual path emphasizes on generating the classification weights. On the contrary, outputs of self-attention here plays the role of providing the V alue context for different query samples to attend in the following cross attention. Sharing the same self-attention networks might limit the expressiveness of learned representations in both paths. The cross attention network $f _ { c a } ^ { a p }$ applied on each query sample and task-aware support set is followed to produce $\hat { \bf X } ^ { a p } \in \mathbb { R } ^ { | \mathcal { Q } | \times d _ { h } }$ .
We use multi-head attention with $h$ heads in both paths. In one attention block, we produce $h$ different sets of queries, keys and values. Multi-head attention is claimed to be able to learn more comprehensive and expressive representations from $h$ different subspaces (Vaswani et al., 2017; Voita et al., 2019). More details of these two paths can be found in A.2.
# 3.3.2 WEIGHTS GENERATOR
We replicate them afterwa ${ \bf X } ^ { c p } \in \mathbb { R } ^ { N K \times d _ { h } }$ anve $\hat { \bf X } ^ { a p } \in \mathbb { R } ^ { | \mathcal { Q } | \times d _ { h } }$ r $| \mathcal { Q } |$ $N K$ ectively and reshape. These two tensors $\pmb { \chi } ^ { c p } \in \mathbb { R } ^ { | \mathcal { Q } | \times N K \times d _ { h } }$ $\hat { \pmb { \mathsf { X } } } ^ { a p } \in \mathbb { R } ^ { | \mathcal { Q } | \times N K \times d _ { h } }$
$d _ { h } < d$ is the hidden dimension. We use matrix form here to be consistent with the description in 3.3.2.
are concatenated to become $\pmb { \chi } ^ { c p \oplus a p } \in \mathbb { R } ^ { | \mathcal { Q } | \times N K \times 2 d _ { h } }$ . $\mathbf { \pmb { \chi } } ^ { c p \oplus a p }$ can be interpreted that each query sample has its own latent representations for support set to generate specific classification weights, which are both aware of the task-context and adaptive to individual query sample.
$\mathbf { X } ^ { c p \oplus a p }$ is decoded by the weights generator $g : \mathbb { R } ^ { 2 d _ { h } } \mathbb { R } ^ { 2 d }$ . We assume that the classification weights follow Gaussian distribution with diagonal covariance. $g$ outputs the distribution parameters and we sample the weights from learned distribution during meta-training. The sampled classification weights are represented as $\pmb { \mathsf { W } } \in \mathbb { R } ^ { | \mathcal { Q } | \times N K \times d }$ . To reduce complexity, we compute the mean value on $K$ classification weights for each class to have ${ \pmb W } ^ { f i n a l } \in \mathbb { R } ^ { | \mathcal { Q } | \times N \times d }$ . Therefore, ith query sample has its specifican be computed by c classifica Wf inali,:,: tion weight matrix . The support data $\pmb { \mathsf { W } } _ { i , : , : } ^ { f i n a l } \in \mathbb { R } ^ { N \times d }$ . Th for rediction for query datatimes and reshaped as $\hat { \mathbf { X } } \mathbf { W } ^ { f i n a l \mathbf { T } }$ $\mathbf { X }$ $| \mathcal { Q } |$ $\pmb { \chi } _ { s } \in \mathbb { R } ^ { | \mathcal { Q } | \times N K \times d }$ . So the prediction for support data can also be computed as ${ \pmb x } _ { s } { \pmb w } ^ { f i n a l { \bf T } }$ .
Besides the weights generator $g$ , we have another two decoders $r _ { 1 } : \mathbb { R } ^ { d } \mathbb { R } ^ { d _ { h } }$ and $r _ { 2 } : \mathbb { R } ^ { d } $ $\mathbb { R } ^ { d _ { h } }$ . They both take the generated weights $\boldsymbol { \mathsf { W } }$ as inputs and learn to reconstruct $\mathbf { X } ^ { c p }$ and ${ \hat { \mathbf { X } } } ^ { a p }$ respectively. The outputs of $r _ { 1 }$ and $r _ { 2 }$ are denoted as $\bar { \pmb { \chi } } _ { r e } ^ { c p } , \hat { \pmb { \chi } } _ { r e } ^ { a p } \in \mathbb { R } ^ { | \mathcal { Q } | \times N K \times d _ { h } }$ . The reason we are using reconstruction as auxiliary tasks will be discussed in following Sec. 3.4.
# 3.4 INFORMATION MAXIMIZATION
In this section, we perform the analysis for one query sample without loss of generality. The subscripts for classification weights are omitted for clarity. In general, we use $\displaystyle ( \mathbf { x } , \mathbf { y } )$ and $( \hat { \mathbf { x } } , \hat { \mathbf { y } } )$ to represent support and query samples respectively.
Since the classification weights w generated from $g$ are encoded with attentive path and contextual path, it is expected that we can directly have the query-specific weights. However, we show in the experiments that simply doing this does not outperform a weight generator conditioned only on the $s$ significantly, which implies that the generated classification weights from two paths are not sensitive to different query samples. In other words, the information from attentive path is not kept well during the weights generation.
To address this limitation, we propose to maximize the mutual information between generated weights w and support as well as query data. The objective function can be described as
$$\operatorname* { m a x } I ( ( \hat { \mathbf { x } } , \hat { \mathbf { y } } ) ; \mathbf { w } ) + \sum _ { ( \mathbf { x } , \mathbf { y } ) \in S } I ( ( \mathbf { x } , \mathbf { y } ) ; \mathbf { w } )$$
According to the chain rule of mutual information, we have
$$I ( ( \hat { \mathbf { x } } , \hat { \mathbf { y } } ) ; \mathbf { w } ) = I ( \hat { \mathbf { x } } ; \mathbf { w } ) + I ( \hat { \mathbf { y } } ; \mathbf { w } | \hat { \mathbf { x } } ) .$$
Equation 6 stands for both terms in 5. So the objective function can be written as
$$\operatorname* { m a x } I ( \hat { \mathbf { x } } ; \mathbf { w } ) + I ( \hat { \mathbf { y } } ; \mathbf { w } | \hat { \mathbf { x } } ) + \sum _ { ( \mathbf { x } , \mathbf { y } ) \in \mathcal { S } } [ I ( \mathbf { x } ; \mathbf { w } ) + I ( \mathbf { y } ; \mathbf { w } | \mathbf { x } ) ] .$$
Directly computing the mutual information in Equation 7 is intractable since the true posteriori distributions like $p ( \hat { \mathbf { y } } | \hat { \mathbf { x } } , \mathbf { w } )$ , $p ( \hat { \mathbf { x } } | \mathbf { w } )$ are still unknown. Therefore, we use Variational Information Maximization (Barber & Agakov, 2003; Chen et al., 2016) to compute the lower bound of Equation 5. We use $p _ { \theta } ( \hat { \mathbf { x } } | \mathbf { w } )$ to approximate the true posteriori distribution, where $\theta$ represents the model parameters. As a result, we have
$$\begin{array} { r c l } { I ( \hat { \mathbf { x } } ; \mathbf { w } ) } & { = } & { H ( \hat { \mathbf { x } } ) - H ( \hat { \mathbf { x } } | \mathbf { w } ) } \\ & { = } & { H ( \hat { \mathbf { x } } ) + \mathbb { E } _ { \mathbf { w } \sim p ( \mathbf { w } | \hat { \mathbf { x } } , S ) } [ \mathbb { E } _ { \hat { \mathbf { x } } \sim p ( \hat { \mathbf { x } } | \mathbf { w } ) } [ \log p ( \hat { \mathbf { x } } | \mathbf { w } ) ] ] } \\ & { = } & { H ( \hat { \mathbf { x } } ) + \mathbb { E } _ { \mathbf { w } \sim p ( \mathbf { w } | \hat { \mathbf { x } } , S ) } [ D _ { \mathrm { K L } } ( p ( \hat { \mathbf { x } } | \mathbf { w } ) | | p \theta ( \hat { \mathbf { x } } | \mathbf { w } ) ) + \mathbb { E } _ { \hat { \mathbf { x } } \sim p ( \hat { \mathbf { x } } | \mathbf { w } ) } [ \log p _ { \theta } ( \hat { \mathbf { x } } | \mathbf { w } ) ] ] } \\ & { \geq } & { H ( \hat { \mathbf { x } } ) + \mathbb { E } _ { \mathbf { w } \sim p ( \mathbf { w } | \hat { \mathbf { x } } , S ) } [ \mathbb { E } _ { \hat { \mathbf { x } } \sim p ( \hat { \mathbf { x } } | \mathbf { w } ) } [ \log p \theta ( \hat { \mathbf { x } } | \mathbf { w } ) ] ] } \end{array}$$
$H ( \cdot )$ is the entropy of a random variable. $H ( { \hat { \mathbf { x } } } )$ is a constant value for given data. We can maximize this lower bound as the proxy for the true mutual information.
Similar to $I ( \hat { \mathbf { x } } ; \mathbf { w } )$
$$I ( \hat { \mathbf { y } } ; \mathbf { w } | \hat { \mathbf { x } } ) \geq H ( \hat { \mathbf { y } } | \hat { \mathbf { x } } ) + \mathbb { E } _ { \mathbf { w } \sim p ( \mathbf { w } | \hat { \mathbf { x } } , S ) } [ \mathbb { E } _ { \hat { \mathbf { y } } \sim p ( \hat { \mathbf { y } } | \hat { \mathbf { x } } , \mathbf { w } ) } [ \log p _ { \theta } ( \hat { \mathbf { y } } | \hat { \mathbf { x } } , \mathbf { w } ) ] ] ,$$
$$\begin{array} { r } { \displaystyle \sum _ { \mathbf { x } , \mathbf { y } ) \in S } I ( ( \mathbf { x } , \mathbf { y } ) ; \mathbf { w } ) \geq \displaystyle \sum _ { ( \mathbf { x } , \mathbf { y } ) \in S } H ( ( \mathbf { x } , \mathbf { y } ) ) + \mathbb { E } _ { \mathbf { w } \sim p ( \mathbf { w } | \hat { \mathbf { x } } , S ) } [ \mathbb { E } _ { ( \mathbf { x } , \mathbf { y } ) \sim p ( ( \mathbf { x } , \mathbf { y } ) | \mathbf { w } ) } [ \log p _ { \theta } ( \mathbf { x } | \mathbf { w } ) + \log p _ { \theta } ( \mathbf { y } | \mathbf { x } , \mathbf { w } ) ] , } \end{array}$$
$p _ { \theta } ( \hat { \mathbf { x } } | \mathbf { w } ) , p _ { \theta } ( \mathbf { x } , \mathbf { y } | \mathbf { w } )$ are used to approximate the true posteriori distribution $p ( \hat { \mathbf { x } } | \mathbf { w } )$ and $p ( \mathbf { x } , \mathbf { y } | \mathbf { w } )$ .
Put the lower bounds back into Equation 7. Omit the constant entropy terms and the expectation subscripts for clarity, we have the new objective function as
$$\operatorname* { m a x } _ { \theta } \mathbb { E } [ \log p _ { \theta } ( \hat { \mathbf { y } } | \hat { \mathbf { x } } , \mathbf { w } ) + \log p _ { \theta } ( \mathbf { y } | \mathbf { x } , \mathbf { w } ) + \log p _ { \theta } ( \mathbf { x } | \mathbf { w } ) + \log p _ { \theta } ( \hat { \mathbf { x } } | \mathbf { w } ) ] .$$
The first two terms are maximizing the log likelihood of label for both support and query data with respective to the network parameters, given the generated classification weights. This is equivalent to minimizing the cross entropy between prediction and ground-truth. We assume that $p _ { \theta } ( \hat { \mathbf { x } } | \mathbf { w } )$ and $p _ { \theta } ( \mathbf { x } | \mathbf { w } )$ are Gaussian distributions. $r _ { 1 }$ and $r _ { 2 }$ are used to approximate the mean of these two Gaussian distributions. Therefore maximizing the log likelihood is equivalent to reconstruct $\mathbf { x } ^ { c p }$ and $\hat { \mathbf { x } } ^ { a p }$ with $L 2$ loss. Thus the loss function to train the network can be written as
$$L = \mathrm { C E } ( \hat { \bf y } _ { p r e d } , \hat { \bf y } ) + \lambda _ { 1 } \sum _ { { \bf y } \in \mathcal { S } } \mathrm { C E } ( { \bf y } _ { p r e d } , { \bf y } ) + \lambda _ { 2 } \sum _ { { \bf x } ^ { c p } \in \mathcal { S } } | | { \bf x } ^ { c p } - { \bf x } _ { r e } ^ { c p } | | _ { 2 } + \lambda _ { 3 } | | \hat { \bf x } ^ { a p } - \hat { \bf x } _ { r e } ^ { a p } | | _ { 2 } .$$
CE here stands for cross entropy. $\mathbf { x } ^ { c p }$ and $\hat { \mathbf { x } } ^ { a p }$ are the inputs to weights generator $g$ . $\mathbf { x } _ { r e } ^ { c p } \sim p _ { \theta } ( \mathbf { x } | \mathbf { w } )$ and $\hat { \mathbf { x } } _ { r e } ^ { a p } \sim p _ { \theta } ( \hat { \mathbf { x } } | \mathbf { w } )$ are the reconstruction of $\mathbf { x } ^ { c p }$ and $\hat { \mathbf { x } } ^ { a p }$ . Since we convert the log likelihood in Equation 14 to mean square error or cross entropy in Equation 15 to optimize, the value of each term in Equation 15 is not equal to real log likelihood and we have to decide the weightage for each one. $\lambda _ { 1 } , \lambda _ { 2 } , \lambda _ { 3 }$ are thus hyper-parameters for trade-off of different terms. With the help of last three terms, the generated classification weights are forced to carry information about the support data and the specific query sample.
In LEO (Rusu et al., 2019), the inner update loss is computed as cross entropy on support data. If we merge the inner update into outer loop, then the loss becomes the summation of first two terms in Equation 15. However, the weight generation in LEO does not involve specific query samples, thus making reconstructing $\hat { \mathbf { x } } ^ { a p }$ impossible. In this sense, LEO can be regarded as a special case of our proposed method, where (1) only contextual path exits and (2) $\lambda _ { 2 } = \lambda _ { 3 } = 0$ .
# 3.5 COMPLEXITY ANALYSIS
The encoding process in contextual path results in computational complexity $O ( ( N K ) ^ { 2 } )$ due to self-attention. Similarly, the computational complexity of attentive path is $O ( ( N K ) ^ { 2 } + | \mathcal { Q } | ( N K ) )$ . In total, the complexity is ${ \cal O } ( ( \bar { N } K ) ^ { 2 } + | \mathcal { Q } | ( \bar { N ^ { } } K ) )$ . However, because of the nature of few-shot learning problem, the value of $( N K ) ^ { 2 }$ is usually negligible. The value of $| \mathcal { Q } |$ depends on the setting and the cross attention can be implemented parallelly via matrix multiplication. Therefore, the induced computational overhead will be negligible. AWGIM avoids the inner update without compromising the performance, which furthers reduces both training and inference time significantly. The empirical evaluation is presented in A.3.4.
# 4 EXPERIMENTS
# 4.1 DATASETS AND PROTOCOLS
We conduct experiments on miniImageNet (Vinyals et al., 2016) and tieredImageNet (Ren et al., 2018), two commonly used benchmark datasets, to compare with other methods and analyze our model. Both datasets are subsets of ILSVRC-12 dataset (Russakovsky et al., 2015). miniImageNet contains 100 randomly sampled classes with 600 images per class. We follow the train/test split in (Ravi & Larochelle, 2016), where 64 classes are used for meta-training, 16 for meta-validation and 20 for meta-testing. tieredImageNet is a larger dataset compared to miniImageNet. There are 608 classes and 779,165 images in total. They are selected from 34 higher level nodes in ImageNet (Deng et al., 2009) hierarchy. 351 classes from 20 high level nodes are used for meta-training, 97 from 6 nodes for meta-validation and 160 from 8 nodes for meta-testing.
We use the image features in LEO (Rusu et al., 2019) provided by the authors 2. They trained a 28-layer Wide Residual Network (Zagoruyko & Komodakis, 2016) on the meta-training set. Each image then is represented by a 640 dimensional vector, which is used as the input to our model.
For $N$ -way $K$ -shot experiments, we randomly sample $N$ classes from meta-training set and each of them contains $K$ samples as the support set and 15 as query set. Similar to other works, we train 5-way 1-shot and 5-shot models on two dataset. During meta-testing, 600 $N$ -way $K$ -shot tasks are sampled from meta-testing set and the average accuracy for query set is reported with $9 5 \%$ confidence interval, as done in recent works (Finn et al., 2017; Snell et al., 2017; Rusu et al., 2019).
# 4.2 IMPLEMENTATION DETAILS
We use TensorFlow (Abadi et al., 2016) to implement our method and the code will be made available. $d = 6 4 0$ is the dimension of feature embeddings. $d _ { h }$ is set to be 128. The number of heads $h$ in attention module is set to be 4. $g , r _ { 1 }$ and $r _ { 2 }$ are 2-layer MLPs with 256 hidden units. We decide $\lambda _ { 1 } = 1$ , $\lambda _ { 2 } = \lambda _ { 3 } = 0 . 0 0 1$ by meta-validation performance.
Table 1: Accuracy comparison with other approaches on miniImageNet. The results are averaged on 600 tasks from meta-testing set with $9 5 \%$ confidence interval. Best results are highlighted.
<table><tr><td>Model</td><td>Feature Extractor</td><td>5-way 1-shot</td><td>5-way 5-shot</td></tr><tr><td>Matching Networks (Vinyals et al., 2016)</td><td>Conv-4</td><td>46.60</td><td>60.00</td></tr><tr><td>MAML(Finn et al.,2017)</td><td>Conv-4</td><td>48.70 ± 1.84%</td><td>63.11 ± 0.92%</td></tr><tr><td>Meta LSTM (Ravi & Larochelle, 2016)</td><td>Conv-4</td><td>43.44 ± 0.77%</td><td>60.60 ± 0.71%</td></tr><tr><td>Prototypical Nets (Snell et al.,2017)</td><td>Conv-4</td><td>49.42 ± 0.78%</td><td>68.20 ± 0.66%</td></tr><tr><td>Relation Nets (Sung et al.,2018)</td><td>Conv-4</td><td>50.44 ± 0.82%</td><td>65.32 ± 0.70%</td></tr><tr><td>SNAIL (Mishra et al., 2018)</td><td>Resnets-12</td><td>55.71 ± 0.99%</td><td>68.88 ± 0.92%</td></tr><tr><td>TPN (Liu et al., 2019)</td><td>Resnets-12</td><td>59.46</td><td>75.65</td></tr><tr><td>MTL (Sun et al., 2019)</td><td>Resnets-12</td><td>61.20 ± 1.80%</td><td>75.50 ± 0.80</td></tr><tr><td>Dynamic (Gidaris & Komodakis,2018)</td><td>WRN-28-10</td><td>60.06 ± 0.14%</td><td>76.39 ± 0.11%</td></tr><tr><td>Prediction (Qiao et al., 2018)</td><td>WRN-28-10</td><td>59.60 ± 0.41%</td><td>73.74 ± 0.19%</td></tr><tr><td>DAE-GNN (Gidaris & Komodakis,2019)</td><td>WRN-28-10</td><td>62.96 ± 0.15%</td><td>78.85 ± 0.10%</td></tr><tr><td>LEO (Rusu et al., 2019)</td><td>WRN-28-10</td><td>61.76 ± 0.08%</td><td>77.59 ± 0.12%</td></tr><tr><td>AWGIM (ours)</td><td>WRN-28-10</td><td>63.12 ± 0.08%</td><td>78.40 ± 0.11%</td></tr></table>
Table 2: Accuracy comparison with other approaches on tieredImageNet. The results are averaged on 600 tasks from meta-testing set with $9 5 \%$ confidence interval. Best results are highlighted.
<table><tr><td>Model</td><td>Feature Extractor</td><td>5-way 1-shot</td><td>5-way 5-shot</td></tr><tr><td>MAML (Finn et al., 2017)</td><td>Conv-4</td><td>51.67 ± 1.81%</td><td>70.30 ± 1.75%</td></tr><tr><td>Prototypical Nets (Snell et al., 2017)</td><td>Conv-4</td><td>53.31± 0.89%</td><td>72.69 ± 0.74%</td></tr><tr><td>Relation Nets (Sung et al., 2018)</td><td>Conv-4</td><td>54.48 ± 0.93%</td><td>71.32 ± 0.78%</td></tr><tr><td>TPN (Liu et al., 2019)</td><td>Conv-4</td><td>59.91 ± 0.96%</td><td>72.85 ± 0.74%</td></tr><tr><td>MetaOptNet (Lee et al., 2019)</td><td>Resnets-12</td><td>65.81 ± 0.74%</td><td>81.75 ± 0.53%</td></tr><tr><td>LEO (Rusu et al., 2019)</td><td>WRN-28-10</td><td>66.33 ± 0.05%</td><td>81.44 ± 0.09%</td></tr><tr><td>AWGIM (ours)</td><td>WRN-28-10</td><td>67.69 ± 0.11%</td><td>82.82 ± 0.13%</td></tr></table>
ADAMW Loshchilov & Hutter (2017) is used to optimize the network with weight decay $1 \times 1 0 ^ { - 6 }$ . The initial learning rate is set to 0.0002 for 5-way 1-shot and 0.001 for 5-way 5-shot, which is decayed by 0.2 for every 15,000 iterations. We train the model for 50,000 iterations. Batch size is 64 for 5-way 1-shot and 32 for 5-way 5-shot. Similar to LEO (Rusu et al., 2019), we first train the model on meta-training set and choose the optimal hyper-parameters by validation results. Then we train the model on meta-training and meta-validation sets together using fixed hyper-parameters.
# 4.3 COMPARISON WITH OTHER METHODS
We compare the performance of our approach AWGIM on two datasets with several state-of-theart methods proposed in recent years. The results of MAML, Prototypical Nets, Relation Nets on tieredImageNet are evaluated by Liu et al. (2019). The results of Dynamic on miniImageNet with WRN-28-10 as the feature extractor is reported in (Gidaris & Komodakis, 2019). The other results are reported in the corresponding original papers. We also include the backbone network structure of the used feature extractor for reference. The results on miniImageNet and tieredImageNet are shown in Table 1 and 2 respectively.
The top half parts of Table 1 and 2 display the methods belonging with different meta learning categories, such as metric-based(Matching Networks, Prototypical Nets), gradient-based (MAML, MTL), graph-based (TPN). The bottom part shows the classification weights generation approaches including Dynamic, Prediction, DAE-GNN, LEO and our proposed AWGIM.
AWGIM can outperform all the methods in top parts of two table. Comparing with other classification weights generation methods in the bottom part, AWGIM still shows very competitive performance, namely the best on tieredImageNet and close to the state-of-the-art on miniImageNet. We note that all the classification weights generation methods are using WRN-28-10 as backbone network, which makes the comparison fair. In particular, AWGIM can outperform LEO in all settings.
# 4.4 ANALYSIS
Table 3: Analysis of our proposed AWGIM. In the top half, the attentive path is removed to compare with LEO. In the bottom part, ablation analysis with respective to different components is provided. We also shuffle the generated classification weights randomly to show that they are indeed optimal for different query samples.
<table><tr><td rowspan="2">Model</td><td colspan="2">miniImageNet</td><td colspan="2">tieredImageNet</td></tr><tr><td>5-way 1-shot</td><td>5-way 5-shot</td><td> 5-way 1-shot</td><td>5-way 5-shot</td></tr><tr><td>LEO</td><td>61.76 %</td><td>77.59 %</td><td>66.33%</td><td>81.44 %</td></tr><tr><td>Generator in LEO</td><td>60.33 %</td><td>74.53 %</td><td>65.17%</td><td>78.77 %</td></tr><tr><td>Generator conditioned on S only</td><td>61.02%</td><td>74.33%</td><td>66.22%</td><td>79.66%</td></tr><tr><td>Generator conditioned on S with IM</td><td>62.04%</td><td>77.54%</td><td>66.43%</td><td>81.73%</td></tr><tr><td>MLP encoding,入1 = 入2= 入3=0</td><td>58.95%</td><td>71.68%</td><td>63.92%</td><td>75.80%</td></tr><tr><td>MLP encoding</td><td>62.26%</td><td>76.91%</td><td>65.84%</td><td>79.24%</td></tr><tr><td>入1=λ2=λ3=0</td><td>61.61%</td><td>74.14%</td><td>65.65%</td><td>79.93%</td></tr><tr><td>入1=入2=0</td><td>62.06%</td><td>74.18%</td><td>65.85%</td><td>80.42%</td></tr><tr><td>入3=0</td><td>62.91%</td><td>77.88%</td><td>67.27%</td><td>81.67%</td></tr><tr><td>入1=0</td><td>62.19%</td><td>74.21%</td><td>66.82%</td><td>80.61%</td></tr><tr><td>2=入g=0</td><td>62.12%</td><td>77.65%</td><td>66.86%</td><td>81.03%</td></tr><tr><td>random shuffle in class</td><td>62.87%</td><td>77.48%</td><td>67.52%</td><td>82.55%</td></tr><tr><td>random shuffle between classes</td><td>61.20%</td><td>77.48%</td><td>66.55%</td><td>82.53%</td></tr><tr><td>AWGIM (ours)</td><td>63.12%</td><td>78.40%</td><td>67.69 %</td><td>82.82%</td></tr></table>
We perform detailed analysis on AWGIM, shown in Table 3. We include the results of LEO Rusu et al. (2019) for reference. “Generator in LEO” means that there is no inner update in LEO. In the upper part of the table, we first studied the effect of attentive path. We implemented two generators including only the contextual path during encoding. “Generator conditioned on $s$ with IM” indicates that we add the cross entropy loss and reconstruction loss for support set. It can be observed that “Generator conditioned on $s$ only” is trained with cross entropy on query set, which is similar to “Generator in LEO” without inner update. It is able to achieve similar or slightly better results than “Generator in LEO”, which implies that self-attention is no worse than relation networks used in LEO to model task-context. With information maximization, our generator is able to obtain slightly better performance than LEO.
The effect of attention is investigated by replacing the attention modules with 2-layer MLPs, which is shown as “MLP encoding”. More specifically, one MLP in contextual path is used for support set and another MLP in attentive path for query samples. We can see that even without attention to encode the task-contextual information, “MLP encoding” can achieve accuracy close to LEO, for the sake of information maximization. However, if we let $\lambda _ { 1 } = \lambda _ { 2 } = \lambda _ { 3 } = 0$ for MLP encoding, the performance drops significantly, which demonstrates the importance of maximizing the information.
We conducted ablation analysis with respective to $\lambda _ { 1 } , \lambda _ { 2 }$ and $\lambda _ { 3 }$ to investigate the effect of information maximization. First, $\lambda _ { 1 }$ , $\lambda _ { 2 }$ and $\lambda _ { 3 }$ are all set to be 0. In this case, the accuracy is similar to “generator conditioned on $s$ only”, showing that the generated classification weights are not fitted for different query samples, even with the attentive path. It can also be observed that maximizing the mutual information between weights and support is more crucial since $\lambda _ { 1 } = \lambda _ { 2 } = 0$ degrades accuracy significantly, comparing with $\lambda _ { 3 } = 0$ . We further investigate the relative importance of the classification on support as well as reconstruction. $\lambda _ { 1 } = 0$ affects the performance noticeably. We conjecture that the support label prediction is more critical for information maximization.
The classification weights are generated specifically for each query sample in AWGIM. To this point, we shuffle the classification weights between query samples within the same classes and between different classes as well to study whether the classification weights are adapted for different query samples. Assume there are T query samples per class in one task. Wf inal ∈ R|Q|×N×d can be reshaped into Wf inal $\mathbf { W } ^ { f i n a l } \in \mathbb { R } ^ { N \times T \times N \times \bar { d } }$ . Then we shuffle this weight tensor along the first and second axis randomly. The results are shown as “random shuffle between classes” and “random shuffle in class” in Table 3. For 5-way 1-shot experiments, the random shuffle between classes degrades the accuracy noticeably while the random shuffle in class dose not affect too much. This indicates that when the support data are very limited, the generated weights for query samples from the same class are very similar to each other while distinct for different classes. When there are more labeled data in support set, two kinds of random shuffle show very close or even the same results in 5-way 5-shot experiments, which are both worse than the original ones. This implies that the generated classification weights are more diverse and specific for each query sample in 5-way 5-shot setting. The possible reason is that larger support set provides more knowledge to estimate the optimal classification weights for each query example.
More analysis is provided in Appendix A.3.
# 5 CONCLUSION
In this work, we introduce Attentive Weights Generation via Information Maximization (AWGIM) for few shot image classification. AWGIM learns to generate optimal classification weights for each query sample within the task by two encoding paths. To guarantee this, the lower bound of mutual information between generated weights and query, support data is maximized. As far as we know, AWGIM is the first work utilizing mutual information techniques for few shot learning. The effectiveness of AWGIM is demonstrated by state-of-the-art performance on two benchmark datasets and extensive analysis.
# REFERENCES
Mart´ın Abadi, Ashish Agarwal, Paul Barham, Eugene Brevdo, Zhifeng Chen, Craig Citro, Greg S Corrado, Andy Davis, Jeffrey Dean, Matthieu Devin, et al. Tensorflow: Large-scale machine learning on heterogeneous distributed systems. arXiv preprint arXiv:1603.04467, 2016. Marcin Andrychowicz, Misha Denil, Sergio Gomez, Matthew W Hoffman, David Pfau, Tom Schaul, Brendan Shillingford, and Nando De Freitas. Learning to learn by gradient descent by gradient descent. In NeurIPS, 2016. Dzmitry Bahdanau, Kyunghyun Cho, and Yoshua Bengio. Neural machine translation by jointly learning to align and translate. In ICLR, 2015. David Barber and Felix V Agakov. The im algorithm: a variational approach to information maximization. In NeurIPS, 2003. Luca Bertinetto, Joao F Henriques, Philip Torr, and Andrea Vedaldi. Meta-learning with differentiable closed-form solvers. In ICLR, 2019. Xi Chen, Yan Duan, Rein Houthooft, John Schulman, Ilya Sutskever, and Pieter Abbeel. Infogan: Interpretable representation learning by information maximizing generative adversarial nets. In NeurIPS, 2016. Zitian Chen, Yanwei Fu, Yu-Xiong , Lin Ma, Wei Liu, and Martial Hebert. Image deformation meta-networks for one-shot learning. In CVPR, 2019.
Jia Deng, Wei Dong, Richard Socher, Li-Jia Li, Kai Li, and Li Fei-Fei. Imagenet: A large-scale hierarchical image database. In CVPR, 2009.
Jacob Devlin, Ming-Wei Chang, Kenton Lee, and Kristina Toutanova. Bert: Pre-training of deep bidirectional transformers for language understanding. arXiv preprint arXiv:1810.04805, 2018.
Li Fei-Fei, Rob Fergus, and Pietro Perona. One-shot learning of object categories. TPAMI, 2006.
Chelsea Finn, Pieter Abbeel, and Sergey Levine. Model-agnostic meta-learning for fast adaptation of deep networks. In ICML, 2017.
Spyros Gidaris and Nikos Komodakis. Dynamic few-shot visual learning without forgetting. In CVPR, 2018.
Spyros Gidaris and Nikos Komodakis. Generating classification weights with gnn denoising autoencoders for few-shot learning. In CVPR, 2019.
Kaiming He, Xiangyu Zhang, Shaoqing Ren, and Jian Sun. Deep residual learning for image recognition. In CVPR, 2016.
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. ICLR, 2019.
Hyunjik Kim, Andriy Mnih, Jonathan Schwarz, Marta Garnelo, Ali Eslami, Dan Rosenbaum, Oriol Vinyals, and Yee Whye Teh. Attentive neural processes. In ICLR, 2019.
Gregory Koch, Richard Zemel, and Ruslan Salakhutdinov. Siamese neural networks for one-shot image recognition. In ICML Deep Learning Workshop, 2015.
Ranjay Krishna, Michael Bernstein, and Li Fei-Fei. Information maximizing visual question generation. In CVPR, 2019.
Kwonjoon Lee, Subhransu Maji, Avinash Ravichandran, and Stefano Soatto. Meta-learning with differentiable convex optimization. In CVPR, 2019.
Hongyang Li, David Eigen, Samuel Dodge, Matthew Zeiler, and Xiaogang Wang. Finding taskrelevant features for few-shot learning by category traversal. In CVPR, 2019a.
Wenbin Li, Lei Wang, Jinglin Xu, Jing Huo, Yang Gao, and Jiebo Luo. Revisiting local descriptor based image-to-class measure for few-shot learning. In CVPR, 2019b.
Yann Lifchitz, Yannis Avrithis, Sylvaine Picard, and Andrei Bursuc. Dense classification and implanting for few-shot learning. In CVPR, 2019.
Yanbin Liu, Juho Lee, Minseop Park, Saehoon Kim, Eunho Yang, Sung Ju Hwang, and Yi Yang. Learning to propagate labels: Transductive propagation network for few-shot learning. In ICLR, 2019.
Ilya Loshchilov and Frank Hutter. Fixing weight decay regularization in adam. arXiv preprint arXiv:1711.05101, 2017.
Laurens van der Maaten and Geoffrey Hinton. Visualizing data using t-sne. JMLR, 2008.
Nikhil Mishra, Mostafa Rohaninejad, Xi Chen, and Pieter Abbeel. A simple neural attentive metalearner. In ICLR, 2018.
Tsendsuren Munkhdalai and Hong Yu. Meta networks. In ICML, 2017.
Niki Parmar, Ashish Vaswani, Jakob Uszkoreit, Łukasz Kaiser, Noam Shazeer, Alexander Ku, and Dustin Tran. Image transformer. ICML, 2018.
Hang Qi, Matthew Brown, and David G Lowe. Low-shot learning with imprinted weights. In CVPR, 2018.
Siyuan Qiao, Chenxi Liu, Wei Shen, and Alan L Yuille. Few-shot image recognition by predicting parameters from activations. In CVPR, 2018.
Sachin Ravi and Hugo Larochelle. Optimization as a model for few-shot learning. In ICLR, 2016.
Mengye Ren, Eleni Triantafillou, Sachin Ravi, Jake Snell, Kevin Swersky, Joshua B Tenenbaum, Hugo Larochelle, and Richard S Zemel. Meta-learning for semi-supervised few-shot classification. In ICLR, 2018.
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. IJCV, 2015.
Andrei A Rusu, Dushyant Rao, Jakub Sygnowski, Oriol Vinyals, Razvan Pascanu, Simon Osindero, and Raia Hadsell. Meta-learning with latent embedding optimization. In ICLR, 2019.
Adam Santoro, David Raposo, David G Barrett, Mateusz Malinowski, Razvan Pascanu, Peter Battaglia, and Timothy Lillicrap. A simple neural network module for relational reasoning. In NeurIPS, 2017.
Jurgen Schmidhuber. Evolutionary principles in self-referential learning, or on learning how to¨ learn: the meta-meta-... hook. PhD thesis, 1987.
David Silver, Thomas Hubert, Julian Schrittwieser, Ioannis Antonoglou, Matthew Lai, Arthur Guez, Marc Lanctot, Laurent Sifre, Dharshan Kumaran, Thore Graepel, et al. A general reinforcement learning algorithm that masters chess, shogi, and go through self-play. Science, 362(6419):1140– 1144, 2018.
Jake Snell, Kevin Swersky, and Richard Zemel. Prototypical networks for few-shot learning. In NeurIPS, 2017.
Qianru Sun, Yaoyao Liu, Tat-Seng Chua, and Bernt Schiele. Meta-transfer learning for few-shot learning. In CVPR, 2019.
Flood Sung, Yongxin Yang, Li Zhang, Tao Xiang, Philip HS Torr, and Timothy M Hospedales. Learning to compare: Relation network for few-shot learning. In CVPR, 2018.
Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N Gomez, Łukasz Kaiser, and Illia Polosukhin. Attention is all you need. In NeurIPS, 2017.
Oriol Vinyals, Charles Blundell, Timothy Lillicrap, Daan Wierstra, et al. Matching networks for one shot learning. In NeurIPS, 2016.
Elena Voita, David Talbot, Fedor Moiseev, Rico Sennrich, and Ivan Titov. Analyzing multi-head self-attention: Specialized heads do the heavy lifting, the rest can be pruned. arXiv preprint arXiv:1905.09418, 2019.
Yu-Xiong Wang, Ross Girshick, Martial Hebert, and Bharath Hariharan. Low-shot learning from imaginary data. In CVPR, 2018.
Davis Wertheimer and Bharath Hariharan. Few-shot learning with localization in realistic settings. In CVPR, 2019.
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 ICML, 2015.
Sergey Zagoruyko and Nikos Komodakis. Wide residual networks. arXiv preprint arXiv:1605.07146, 2016.
Ruixiang Zhang, Tong Che, Zoubin Ghahramani, Yoshua Bengio, and Yangqiu Song. Metagan: An adversarial approach to few-shot learning. In NeurIPS, 2018.
# A APPENDIX
# A.1 MUTLI-HEAD ATTENTION IN AWGIM
The multi-head attention can be described as
$$M u l t i H e a d ( Q , K , V ) = C o n c a t ( h e a d _ { 1 } , . . . , h e a d _ { H } ) W ^ { O } ,$$
$$h e a d _ { i } ( Q ^ { i } , K ^ { i } , V ^ { i } ) = A t t e n t i o n ( Q ^ { i } , K ^ { i } , V ^ { i } ) ,$$
$$A t t e n t i o n ( Q , K , V ) = s o f t m a x ( \frac { Q K ^ { T } } { \sqrt { d _ { k } } } V ) ,$$
$$Q ^ { i } = Q W _ { Q } ^ { i } , K ^ { i } = K W _ { K } ^ { i } , V ^ { i } = V W _ { V } ^ { i } ,$$
Here $Q , K , V$ are query, key, value matrices. $W _ { Q } ^ { i } , W _ { K } ^ { i } , W _ { V } ^ { i }$ are the weight matrices for $i$ th head. $W ^ { O }$ is the weight matrix for output. $d _ { k }$ is the dimension of keys. Original $Q$ is added to the output of Equation 16 to stabilize the training as residual learning.
# A.2 MODEL DETAILS
# A.2.1 CONTEXTUAL PATH
The encoding process in contextual path is realized by a simple multi-head self-attention network on support data. First, ${ \bf x } ^ { c _ { n } ; k }$ are mapped to a lower dimensional hidden space by a MLP $f _ { 1 } : \mathbb { R } ^ { d } $ $\mathbb { R } ^ { d _ { h } }$ to reduce the computation complexity. Then the low-dimensional representations $\mathbf { x } _ { h 1 } ^ { c _ { n } ; k }$ are processed by the -head self-attention network $f _ { c p } ^ { s a } : \mathbb { R } ^ { d _ { h } } \mathbb { R } ^ { d _ { h } }$ ,
$${ \bf X } ^ { c p } = M u l t i H e a d A t t e n t i o n ( Q = { \bf X } _ { h 1 } , K = { \bf X } _ { h 1 } , V = { \bf X } _ { h 1 } ) .$$
$\mathbf { X } _ { h 1 } \in \mathbb { R } ^ { N K \times d _ { h } }$ is the matrix where each row stands for one support sample $\mathbf { x } _ { h 1 } ^ { c _ { n } ; k }$ . For one $N$ -way $K$ -shot task, the outputs of $f _ { c p } ^ { s a }$ .
# A.2.2 ATTENTIVE PATH
The attentive path is instantiated by attention, similar to contextual path. First, a MLP $f _ { 2 } : \mathbb { R } ^ { d } $ $\mathbb { R } ^ { d _ { h } }$ is used to map both ${ \bf x } ^ { c _ { n } ; k }$ and $\hat { \bf x }$ to $\mathbf { x } _ { h 2 } ^ { c _ { n } ; k }$ and $\hat { \mathbf { x } } _ { h 2 }$ . Then we employ another $H$ -head selfattention network $f _ { a p } ^ { s a } : \mathbb { R } ^ { d _ { h } } \mathbb { R } ^ { d _ { h } }$ on $\mathbf { x } _ { h 2 } ^ { c _ { n } ; k }$ to encode the global task information to each support sample,
$${ \bf X } ^ { a p } = M u l t i H e a d A t t e n t i o n ( Q = { \bf X } _ { h 2 } , K = { \bf X } _ { h 2 } , V = { \bf X } _ { h 2 } ) .$$
The cross attention between query and context-aware support samples are computed as
$${ \hat { \bf X } } ^ { a p } = M u l t i H e a d A t t e n t i o n ( Q = { \hat { \bf X } } _ { h 2 } , K = { \bf X } _ { h 2 } , V = { \bf X } ^ { a p } ) .$$
Here $\hat { \mathbf { X } } ^ { a p } \in \mathbb { R } ^ { | \mathcal { Q } | \times d _ { h } }$ is the matrix form of $\hat { \mathbf { x } } _ { q }$ , where each query sample is context-aware.
# A.2.3 WEIGHT GENERATOR
Assume $\mathbf { x } ^ { c p \oplus a p } = \mathbf { X } _ { i , j , : } ^ { c p \oplus a p } \in \mathbb { R } ^ { 2 d _ { h } }$ , where $i , j$ stands for $i$ th query sample and $j$ th support sample. $\mathbf { x } ^ { c p \oplus a p }$ is decoded by the weights generator $g : \mathbb { R } ^ { 2 d _ { h } } \mathbb { R } ^ { 2 d }$ . We assume that the classification weights follow Gaussian distribution with diagonal covariance and we sample the weights from this distribution during meta-training, shown in Equation 23 and 24.
$$\mu _ { \mathbf { w } } , \sigma _ { \mathbf { w } } = g ( \mathbf { z } )$$
$$\mathbf { w } \sim \mathcal { N } ( \mu _ { \mathbf { w } } , \pmb { \Sigma } _ { \mathbf { w } } )$$
# A.3 EXPERIMENTAL ANALYSIS
# A.3.1 FEW SHOT REGRESSION
AWGIM can be applied to few shot regression task by slight modification. During meta-training, we set the number of classes $N$ equal to 1 and adapt the cross entropy loss to mean square error. We use the data points $( x , y )$ as inputs to AWGIM and generate weight as well as bias parameters for a three layer MLP with hidden dimension 40. This is consistent with few shot regression experimental setting in LEO.
The few shot regression tasks are constructed as either sinusoidal or linear regression tasks. For sinusoidal regression tasks, the amplitude range is [0.1, 5], phase range $[ 0 , 2 \pi ]$ , frequency range [0.5, 2.0]. For linear regression tasks, the slope range is $[ - 1 , 1 ]$ , intercept range $[ - 5 , 5 ]$ . Input $x$ is randomly sample from $[ - 5 , 5 ]$ . Gaussian noise with standard deviation 0.3 is added to $y$ during meta-training. We show some qualitative results in Figure 2. (a) and (b) are examples that can be tackled easily. For some non-trivial cases such as (c) and (d), AWGIM produces predictions slightly mixing with another regression family, despite that overall results are still faithful.
 Figure 2: 5-shot regression results for a multi-modal task distribution. Regression targets are plotted in red and prediction in black. 5 training samples per task are plotted with blue solid circles.
# A.3.2 EFFECT OF MULTI-HEAD ATTENTION
We replace the multi-head attention in the two paths with single-head attention and conduct the 5- way 1-shot and 5-way 5-shot experiments on miniImageNet dataset. The results are shown in Table 4. We can see clearly that multi-head attention improve the performance. In particular, for 5-way 1-shot experiment, single head attention gives results close to MLP encoding, which indicates that single head attention struggles when data are extremely scarce.
Table 4: Accuracy results on miniImageNet with 4 heads or single head in attention networks.
<table><tr><td>Method</td><td>5-way 1 -shot</td><td> 5-way 5-shot</td></tr><tr><td>4 heads</td><td>63.12%</td><td>78.40%</td></tr><tr><td>single head</td><td>62.35%</td><td>77.75%</td></tr></table>
# A.3.3 CONVERGENCE
We compare AWGIM with LEO in terms of convergence speed. The batch size is set to be 16 for both methods. We use the hyper-parameters tuned by authors to train LEO. The accuracy of metavalidation set during meta-training on 5-way 1-shot miniImageNet is plotted, shown in Figure 3. we can see clearly that AWGIM converges faster than LEO and outperforms LEO except for the first few iterations.
 Figure 3: The meta-validation accuracy during meta-training.
# A.3.4 INFERENCE TIME
We measure the inference time of AWGIM to show that it induces minimal computational overhead. In comparison, we use “MLP encoding” in two paths, which has time complexity $O ( N K + | \mathcal { Q } | )$ . We use two set-ups on miniImageNet and the batch size is set to be 64. 100 batches are processed and we report the average consumed time for one batch. All these experiments on done with the same GPU and workstation. The results are shown in Table 5. It can be observed that the usage of self-attention and cross attention in AWGIM occurs negligible overhead, compared with MLP encoding. This is because the values of $N , K , | \mathcal { Q } |$ are all relatively small and matrix multiplication further can be processed very fast by GPU.
Table 5: The comparison of inference time between AWGIM and MLP encoding.
<table><tr><td>Method</td><td>5-way 1 -shot</td><td>5-way 5-shot</td></tr><tr><td>AWGIM</td><td>0.036s</td><td>0.093s</td></tr><tr><td>MLP encoding</td><td>0.033s</td><td>0.093s</td></tr></table>
# A.3.5 VISUALIZATION
We visualize the generated classification weights by t-SNE (Maaten & Hinton, 2008). First we sample 400 tasks from meta-validation set of 5-way 1-shot miniImageNet experiment. Each task contains 5 query samples from 5 different classes. Thus in total there are $4 0 0 \times 5 \times 5 = 1 0 , 0 0 0$ weight vectors to visualize. As comparison, inputs to the generator $g$ are also plotted. The visualization results are shown in Figure 4. The inputs to $g$ are displayed in (a, b) and the generated classification weights in (c, d). From the comparison between (a) and (c), we can see the decoded weights for each class in (c) are clustered closer than (a) in general. Red and blue dots in (b, d) denotes the classification weights for two query samples from two classes within one task. It can be observed that $g$ can generate adapted weights for different query samples. This is consistent with Table 3, where the results of “random shuffle between classes” suggest that query samples from different class have distinct classification weights.
 Figure 4: t-SNE visualization of the inputs to $g$ in (a, b) and the generated classification weights in (c, d). Blue and red dots in (b) and (d) are the classification weights for two query samples in the same task.123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466# DEEP K-NN FOR NOISY LABELS
Anonymous authors Paper under double-blind review
# ABSTRACT
Modern machine learning models are often trained on examples with noisy labels that hurt performance and are hard to identify. In this paper, we provide an empirical study showing that a simple $k$ -nearest neighbor-based filtering approach on the logit layer of a preliminary model can remove mislabeled training data and produce more accurate models than some recently proposed methods. We also provide new statistical guarantees into its efficacy.
# 1 INTRODUCTION
Machine learned models can only be as good as the data they were used to train on. With increasingly large modern datasets and automated and indirect labels like clicks, it is becoming ever more important to investigate and provide effective techniques to handle noisy labels.
We revisit the classical method of filtering out suspicious training examples using $k$ -nearest neighbors ( $k$ -NN) (Wilson, 1972). Like Papernot & McDaniel (2018), we apply $k$ -NN on the learned intermediate representation of a preliminary model, which adds robustness. In fact, the $k$ -nearest neighbor approach has recently been receiving attention for its robustness properties (Wang et al., 2018; Reeve & Kaban, 2019) and as an auxiliary strategy for modern machine learning (Jiang et al., 2018).
The main contributions of this paper are:
• Experimentally showing that identifying mislabeled examples by $k$ -NN executed on an intermediate layer of a preliminary deep model works well compared to state-of-art methods for handling noisy labels across noise levels, and is robust to the choice of $k$ . • Theoretically showing that $k$ -NN’s predictions will only identify a training example as clean if its label is the Bayes-optimal label. We also provide finite-sample analysis in terms of the margin and how spread out the corrupted labels are (Theorem 1), rates of convergence for the margin (Theorem 2) and rates under Tsybakov’s noise condition (Theorem 3) with all rates matching minimax-optimal rates in the noiseless setting.
Our work shows that even though the preliminary neural network is trained with corrupted labels, it still yields intermediate representations that are useful for $k$ -nearest neighbor filtering. Given labels which are in high disagreement, one can either automatically remove them and retrain on the remaining, or send to a human operator for further review. This strategy is also be useful in human-in-the-loop systems where one can warn the human annotator that a label is suspicious, and automatically propose new labels based on its nearest neighbors’ labels.
In addition to strong empirical performance, deep $k$ -NN filtering has a couple of advantages. Firstly, many methods require a clean set of samples whose labels can be trusted. Here we show that the $k$ -NN based method is robust and does not require such a clean set of samples. Second, while $k$ -NN does introduce the hyperparameter $k$ , we will show that deep $k$ -NN filtering is stable to the choice of $k$ : such robustness to hyperparameters is highly desirable as optimal tuning for this problem is often not available in practice (i.e. when no clean validation set is available).
# 2 RELATED WORK
We review relevant prior work in training on noisy labels and related $k$ -NN theory.
# 2.1 TRAINING WITH NOISY LABELS
Methods to handle label noise can be classified into two main strategies: (i) explicitly identify and remove the noisy examples, and (ii) indirectly handle the noise with robust training methods.
Data Cleaning This proposal fits into the broad family of data cleaning methods, in that our proposal detects and filters dirty data (see Chu et al. (2016) for a recent survey). The use of $k$ -NN to “edit” training data has been popular since Wilson (1972) used it to throw away training examples that were not consistent with their $k = 3$ nearest neighbors. The idea of using a preliminary model to help identify mislabeled examples dates to at least Guyon et al. (1994), who proposed using the model to compute an information gain for each example and then suspecting ones with high gain. Other early work used a cross-validation set-up to train a classifier on part of the data, then use it to make a prediction on held-out training examples, and remove any examples if the prediction disagrees with the label; ensembles of models can also be used for the predictions. (Brodley & Freidl, 1999).
Noise Corruption Estimation For multi-class problems, a popular approach is to account for noisy labels by applying a confusion matrix after the model’s softmax layer (Sukhbaatar et al., 2014). Such methods rely on a confusion matrix which is often unknown and must be estimated. Patrini et al. (2017) suggest deriving it from the softmax distribution of the model trained on noisy data while Goldberger & Ben-Reuven (2016); Jindal et al. (2016); Han et al. (2018) give alternatives. Accurate estimates are generally hard to attain when only untrusted data is available. Hendrycks et al. (2018) achieves more accurate estimates in the setting where some amount of known clean, trusted data is available. Xiao et al. (2015); Khetan et al. (2017); Vahdat (2017) use EM-type algorithms to estimate the clean label distribution.
Noise-Robust Training Natarajan et al. (2013) propose a method to make any surrogate loss function noise-robust given knowledge of the corruption rates. Ghosh et al. (2017) proves that losses like mean absolute error (MAE) are inherently robust under symmetric or uniform label noise while Zhang & Sabuncu (2018) shows that training with MAE results in poor convergence and accuracy. They propose a new loss function based on the negative Box-Cox transformation that trades off the noise-robustness of MAE with the training efficiency of cross-entropy. Lastly, the ramp, unhinged, and savage losses have been proposed and theoretically justified to be noise-robust for support vector machines (Brooks, 2011; Van Rooyen et al., 2015; Masnadi-Shirazi & Vasconcelos, 2009). Rolnick et al. (2017) empirically shows that deep learning models are robust to noise when there are enough correctly labeled examples and when the model capacity and training batch size are sufficiently large.
Auxiliary Models Veit et al. (2017) propose learning a label cleaning network on trusted data by predicting the differences between clean and noisy labels. Li et al. (2017) suggests training on a weighted average between noisy labels and distilled predictions of an auxiliary model trained on trusted data.
Example Weighting Here we make a hard decision about whether to keep a training example, but one can also adapt the weights on training examples based on the confidence in their labels. Liu & Tao (2015) provides an importance-weighting scheme for binary classification. Ren et al. (2018) suggests upweighting examples whose loss gradient is aligned with those of trusted examples at every step in training. Jiang et al. (2017) investigates a recurrent network that learns a sample weighting scheme to give to the base model.
# 2.2 $k$ -NEAREST NEIGHBOR THEORY
The theory of $k$ -nearest neighbor classification has a long history, for example: Fix & Hodges Jr (1951); Cover (1968); Stone (1977); Devroye et al. (1994); Chaudhuri & Dasgupta (2014). Much of the prior work focuses on $k$ -NN’s statistical consistency properties. However, with the growing interest in adversarial examples and learning with noisy labels, there have recently been analyses of $k$ -nearest neighbor methods in these settings. Wang et al. (2018) analyze the robustness of $k$ -NN classification and provide a robust variant of 1-NN classification where their notion of robustness is that predictions of nearby points should be similar. Gao et al. (2016) provides an analysis of the $k$ -NN classifier under noisy labels and like us, show that $k$ -NN can attain similar rates in the noisy setting as in the noiseless setting. Gao et al. (2016) assumes a noise model where labels are corrupted uniformly at random, while we assume an arbitrary corruption pattern and provide results based on a notion of how spread out the corrupted points are. Moreover, we provide finite-sample bounds borrowing recent advances in $k$ -NN convergence theory in the noiseless setting (Jiang, 2019) while the guarantees of Gao et al. (2016) are asymptotic. Reeve & Kaban (2019) provide stronger guarantees on a robust modification of $k$ -NN proposed by Gao et al. (2016). To the best of our knowledge, we provide the first finite-sample rates of consistency for the classical $k$ -NN method in the noisy setting with very little assumptions on the label noise.
# 3 ALGORITHM
We first define the $k$ -nearest neighbor classifier:
Definition 1 ( $k$ -NN). Let the $k$ -NN radius of $x \in \mathcal { X }$ be $r _ { k } ( x ) : = \operatorname* { i n f } \{ r : | B ( x , r ) \cap X | \geq k \}$ where $B ( x , r ) : = \{ x ^ { \prime } \in \mathcal { X } : | x - x ^ { \prime } | \leq r \}$ and the $k$ -NN set of $x \in \mathcal { X }$ be $N _ { k } ( x ) : = B ( x , r _ { k } ( x ) ) \cap X$ . Then for all $x \in \mathcal { X }$ , the $k$ -NN classifier function w.r.t. $X$ has discriminant function
$$\eta _ { k } ( y ; x ) : = \frac { 1 } { \vert N _ { k } ( x ) \vert } \sum _ { i = 1 } ^ { n } 1 \left[ y _ { i } = y , x _ { i } \in N _ { k } ( x ) \right] ,$$
with prediction $\eta _ { k } ( x ) : = \arg \operatorname* { m a x } _ { y } \eta _ { k } ( y ; x )$ .
Our method Algorithm 1 assumes a dataset $\mathcal { D } _ { \mathrm { n o i s y } }$ with potentially noisy labels, along with a dataset $\mathcal { D } _ { \mathrm { c l e a n } }$ consisting of clean or trusted labels. Note that we allow $\mathcal { D } _ { \mathrm { c l e a n } }$ to be empty (i.e. in instances where no such trusted data is available). We have found that having $\mathcal { D } _ { \mathrm { c l e a n } }$ becomes important when $\mathcal { D } _ { \mathrm { n o i s y } }$ has a high corruption rate; otherwise the representations learned by training on $\mathcal { D } _ { \mathrm { n o i s y } }$ alone are often reasonable enough. The procedure begins by training on either $\mathcal { D } _ { \mathrm { n o i s y } } \cup \mathcal { D } _ { \mathrm { c l e a n } }$ or $\mathcal { D } _ { \mathrm { c l e a n } }$ . For our experiments, we partition $\mathcal { D } _ { \mathrm { c l e a n } }$ into a training set $\mathcal { D } _ { c t }$ and validation set $\mathcal { D } _ { c v }$ and train models on $\mathcal { D } _ { c t }$ and $\mathcal { D } _ { \mathrm { n o i s y } } \cup \mathcal { D } _ { c t }$ and choose the one that performs better on $\mathcal { D } _ { c v }$ .
We then filter examples that disagree with the $k$ -NN classifier prediction, where the $k$ -NN is computed on the final logit layer of the trained model (i.e. the layer right before softmax).
# Algorithm 1 Filtering datapoints via deep $k$ -NN.
<table><tr><td>Inputs: Dnoisy, Dclean, k</td></tr><tr><td>Train model M on either Dnoisy U Dclean Or Dclean·</td></tr><tr><td>Let N be the activations of Dnoisy U Dclean on the logit layer of M.</td></tr><tr><td>Dfiltered := {(x,y) ∈ N : nk(x) = y},where nk is computed w.r.t. N. Train final model on Dfiltered UDc.</td></tr></table>
# 4 THEORETICAL ANALYSIS
For the theoretical analysis, we assume the binary classification problem with the features defined on compact set $\mathcal { X } \subseteq \mathbb { R } ^ { D }$ . We assume that points are drawn according to distribution $\mathcal { F }$ as follows: the features come from distribution $\mathbb { P } _ { \mathcal { X } }$ on $\mathcal { X }$ and the labels are distributed according to the measurable conditional probability function $\eta : \mathcal { X } [ 0 , 1 ]$ . That is, a sample $( X , Y )$ is drawn from $\mathcal { F }$ as follows: $X$ is drawn according to $\mathbb { P } _ { \mathcal { X } }$ and $Y$ is chosen according to $\mathbb { P } ( Y = 1 | X = x ) = \eta ( x )$ .
The goal will be to show that given corrupted examples, the $k$ -NN disagreement method is still able to identify the examples whose labels do not match that of the Bayes-optimal label.
We will make a few regularity assumptions for our analysis to hold. The first regularity assumption ensures that the support $\mathcal { X }$ does not become arbitrarily thin anywhere. This is a standard nonparametric assumption (e.g. Singh et al. (2009); Jiang (2019)).
Assumption 1 (Support Regularity). There exists $\omega > 0$ and $r _ { 0 } > 0$ such that ${ V o l } ( \mathcal { X } \cap B ( x , r ) ) \geq$ $\boldsymbol { \omega } \cdot V o l ( B ( x , r ) )$ for all $x \in \mathcal { X }$ and $0 < r < r _ { 0 }$ , where $B ( x , r ) : = \{ x ^ { \prime } \in \mathcal { X } : | x - x ^ { \prime } | \leq r \}$ .
Let $p _ { \mathcal { X } }$ be the density function corresponding to $\mathbb { P } _ { \mathcal { X } }$ . The next assumption ensures that with a sufficiently large sample, we will obtain a good covering of the input space.
Assumption 2 $\overset { \cdot } { p } _ { \mathcal { X } }$ bounded from below). $p _ { X , 0 } : = \operatorname* { i n f } _ { x \in \mathcal { X } } p _ { X } ( x ) > 0 .$ .
Finally, we make a smoothness assumption on $\eta$ , as done in other analyses of $k$ -NN classification (e.g. Chaudhuri & Dasgupta (2014); Reeve & Kaban (2019))
Assumption 3 $\overline { { \eta } }$ Holder continuous) ¨ . There exists $0 \textless \alpha \leq 1$ and $C _ { \alpha } \ > \ 0$ such that $| \eta ( x ) -$ $\eta ( x ^ { \prime } ) \vert \leq C _ { \alpha } \vert x - x ^ { \prime } \vert ^ { \alpha }$ for all $x , x ^ { \prime } \in { \mathcal { X } }$ .
We propose a notion of how spread out a set of points is based on the minimum pairwise distance between the points. This will be a quantity in the finite-sample bounds we will present. Intuitively, the more spread out a contaminated set of points is, the less clean samples we will be needed to overcome the contamination of that set.
Definition 2 (Minimum pairwise distance).
$$S _ { 2 } ( C ) : = \operatorname* { m i n } _ { \substack { x , x ^ { \prime } \in C , x \neq x ^ { \prime } } } | x - x ^ { \prime } | .$$
Also define the $\Delta$ -interior region of $\mathcal { X }$ where there is at least $\Delta$ margin in the probabilistic label:
Definition 3. Let $\Delta \geq 0$ . Define $\begin{array} { r } { \mathcal { X } ^ { \Delta } : = \{ x \in \mathcal { X } : \left| \frac { 1 } { 2 } - \eta ( x ) \right| \geq \Delta \} . } \end{array}$
We now state the result, which says that with high probability uniformly on $\chi ^ { \Delta }$ when $\Delta > 0$ is known, we have that the label disagrees with the $k$ -NN classifier if and only if the label is not the Bayes-optimal prediction. Due to space, all of the proofs have been deferred to the Appendix.
Theorem 1 (Fixed $\Delta$ ). Let $\Delta , \delta \ > \ 0$ and suppose Assumptions 1, 2, and $^ 3$ hold. There exists constants $K _ { l } , K _ { u } > 0$ depending only on $\mathcal { F }$ such that the following holds with probability at least $1 - \delta$ . Let $X _ { [ n ] }$ be $n$ (uncorrupted) examples drawn from the $\mathcal { F }$ and $C$ be a set of points with corrupted labels and denote our sample $X : = X _ { [ n ] } \cup C$ . Suppose $k$ lies in the following range
$$K _ { l } \cdot \frac { 1 } { \Delta ^ { 2 } } \cdot \log ^ { 2 } ( 1 / \delta ) \cdot \log n \leq k \leq K _ { u } \cdot \operatorname* { m i n } \{ S _ { 2 } ( C ) ^ { D } , \Delta ^ { D / \alpha } \} \cdot n ,$$
then the following holds uniformly over $x \in \mathcal { X } ^ { \Delta }$ : the $k$ -NN prediction computed w.r.t. $X$ agrees with the label if and only if the label is the Bayes-optimal label $\eta ^ { * } ( x ) : = 1 [ \eta ( x ) \geq \frac { 1 } { 2 } ]$ .
In the last result, we assumed that $\Delta$ was fixed. We next show how we can make a similar guarantee but show that we can take $\Delta 0$ as we choose $k , n \infty$ appropriately and provide rates of convergence.
Theorem 2 (Rates of convergence for $\Delta$ ). Let $\delta > 0$ and suppose Assumptions 1, 2, and 3 hold. There exist constants $K _ { l } , K _ { u } , K ~ > ~ 0$ depending only on $\mathcal { F }$ such that the following holds with probability at least $1 - \delta$ . Let $X _ { [ n ] }$ be $n$ (uncorrupted) examples drawn from $\mathcal { F }$ , and $C$ be a set of points with corrupted labels and denote our sample $X : = X _ { [ n ] } \cup C$ . Suppose $k$ lies in the following range
$$K _ { l } \cdot \log ^ { 2 } ( 1 / \delta ) \cdot n ^ { \frac { \alpha } { \alpha + D } } \leq k \leq K _ { u } \cdot S _ { 2 } ( C ) ^ { D } \cdot n ,$$
then the following holds uniformly over $x \in \mathcal { X } ^ { \Delta }$ : the $k$ -NN prediction computed w.r.t. $X$ agrees with the label if and only if the label is the Bayes-optimal label $\eta ^ { * } ( x ) : = 1 [ \eta ( x ) \geq \frac { 1 } { 2 } ]$ where
$$\Delta = K \cdot \left( \sqrt { \frac { \log n + \log ( 1 / \delta ) } { k } } + \left( \frac { k } { n } \right) ^ { \alpha / D } \right) .$$
Remark 1. Choosing $k = { \cal { O } } ( n ^ { 2 \alpha / ( 2 \alpha + D ) } )$ in the above result gives us $\Delta = \widetilde { \cal O } ( n ^ { - \alpha / ( 2 \alpha + D ) } )$ . This rate for $\Delta$ is the minimax-optimal rate for $k$ -nearest neighbor classification on $\chi ^ { \Delta }$ given a sample of size $n$ (Chaudhuri $\&$ Dasgupta, 2014) in the uncorrupted setting. Thus, our analysis is tight up to logarithmic factors.
We next give results with an additional margin assumption, also known as Tsybakov’s noise condition (Mammen et al., 1999; Tsybakov et al., 2004):
Assumption 4 (Tsybakov Noise Condition). The following holds for some $C _ { \beta }$ and $\beta$ and all $\Delta > 0$
$$\mathbb { P } _ { \mathcal { X } } ( x \notin \mathcal { X } ^ { \Delta } ) \le C _ { \beta } \cdot \Delta ^ { \beta } .$$
 Figure 1: Left: training samples. We observe that test accuracy improves as $S _ { 2 } ( C )$ increases (middle) and that fewer clean training samples are needed to achieve an accuracy of $90 \%$ (right).
Theorem 3 (Rates under Tsybakov Noise Condition). Let $\delta > 0$ and suppose Assumptions 1, 2, 3 and 4 hold. There exists constants $K _ { l } , K _ { u } , K , K ^ { \prime } > 0$ depending only on $\mathcal { F }$ such that the following holds with probability at least $1 - \delta$ . Let $X _ { [ n ] }$ be $n$ (uncorrupted) examples drawn from the $\mathcal { F }$ and $C$ be a set of points with corrupted labels and denote our sample $X : = X _ { [ n ] } \cup C$ . Suppose $k$ lies in the following range
$$K _ { l } \cdot \log ^ { 2 } ( 1 / \delta ) \cdot n ^ { \frac { \alpha } { \alpha + D } } \leq k \leq K _ { u } \cdot S _ { 2 } ( C ) ^ { D } \cdot n ,$$
and define $\eta _ { k } ( x ) : = \arg \operatorname* { m a x } _ { y } \eta _ { k } ( y ; x )$ . Then,
$$\begin{array} { r } { \mathbb { P } \left( \eta _ { k } ( x ) \neq \eta ^ { * } ( x ) \right) \leq K \cdot \left( \sqrt { \frac { \log n + \log ( 1 / \delta ) } { k } } + \left( \frac { k } { n } \right) ^ { \alpha / D } \right) ^ { \beta } , } \\ { \quad R _ { X } - R ^ { * } \leq K ^ { \prime } \cdot \left( \sqrt { \frac { \log n + \log ( 1 / \delta ) } { k } } + \left( \frac { k } { n } \right) ^ { \alpha / D } \right) ^ { \beta + 1 } } \end{array}$$
where $R _ { X } : = \mathbb { E } _ { \mathcal { F } } [ g _ { k } ( x ) \neq y ]$ and $R ^ { * } : = \mathbb { E } _ { \mathcal { F } } [ g ^ { * } ( x ) \neq y ]$ denote the risk of the $k$ -NN method and Bayes optimal classifier, respectively.
Remark 2. Choosing $k = { \cal { O } } ( n ^ { 2 \alpha / ( 2 \alpha + D ) } )$ in the above gives us a rate of $\widetilde { O } ( n ^ { - \alpha ( \beta + 1 ) / ( 2 \alpha + D ) } ) f o r$ the excess risk. This matches the lower bounds of Audibert et al. (2007) up to logarithmic factors.
# 4.1 IMPACT OF MINIMUM PAIRWISE DISTANCE
The minimum pairwise distance across corrupted samples, $S _ { 2 } ( C )$ , is a key quantity in the theory presented in the previous section. We now empirically study its significance in a simulated binary classification task in 2 dimensions. Clean samples with label $L$ are generated by sampling i.i.d from $\mathcal { N } ( \mu _ { L } , I _ { 2 \times 2 } )$ , where $\mu _ { 0 } = ( 0 , - 2 )$ and $\mu _ { 1 } = ( 0 , 2 )$ . The decision boundary is the line $y = 0$ . We take 100 samples uniformly spaced on a square grid centered about $( 0 , 0 )$ and corrupt them by flipping their true label. With this construction, $S _ { 2 } ( C )$ is precisely the grid width, which we let vary. The training set is a union of 100 clean samples and the 100 corrupted samples. Using 1000 clean samples as a test set we study the classification performance of a majority vote $k$ -NN classifier, where $k = 1 0$ . Results are shown in Figure 1. As expected, we see that as $S _ { 2 } ( C )$ decreases, so does test accuracy and we need more clean training samples to compensate.
# 5 EXPERIMENTS
We evaluate the effectiveness of our algorithm as follows. We split each dataset’s training set into two parts, $\mathcal { D } _ { \mathrm { c l e a n } }$ and $\mathcal { D } _ { \mathrm { n o i s y } }$ . We then corrupt the labels of some fraction of examples in $\mathcal { D } _ { \mathrm { n o i s y } }$ by applying a corruption matrix prescribed by one of the following methods.
• Uniform: The label is flipped to any one of the labels (including itself) with equal probability. • Flip: The label is flipped to any other label with equal probability. • Hard Flip: With probability $\begin{array} { l } { { \frac { 1 } { 2 } } } \end{array}$ , we flip the label $m$ to $\pi ( m )$ where $\pi$ is some predefined permutation of the labels.
 Figure 2: UCI Results. Error plots against amount of noise applied to the labels of $\mathcal { D } _ { \mathrm { n o i s y } }$ . $\mathcal { D } _ { \mathrm { c l e a n } }$ contains $5 \%$ of the data. Each column is a different corruption and each row is for a different dataset. We see that the $k$ -NN method consistently chooses the best datapoints to filter leading to lower error. More results are in the Appendix.
We compare against the following baselines:
• Gold Loss Correction (GLC) (Hendrycks et al., 2018) estimates the corruption matrix by averaging the softmax outputs of the clean examples on a model trained on noisy data. • Distill (Li et al., 2017) assigns each example in the combined dataset a “soft” label that is a convex combination of its label and its softmax output from a model trained solely on clean data. • Forward (Patrini et al., 2017), similar in spirit to GLC, estimates the corruption matrix by training a model on noisy data and using the softmax output for prototype examples for each class. It does not require a clean dataset like other methods. • Clean. We define this as training on the clean data only. • Full. We define this as training on the full (clean and noisy) data. • $k$ -NN Classify is like “Full” except we use $k$ -NN majority voting on the logits layer for classification at test time.
We report test errors and show the average across multiple runs with standard error bands shaded. Errors are computed on 11 uniformly distributed noise rates between 0 and 1 inclusive. For the results shown in the main text, we have that $\mathcal { D } _ { \mathrm { c l e a n } }$ is randomly selected and is $5 \%$ of the data. In the Appendix, we show results over different sizes of $\mathcal { D } _ { \mathrm { c l e a n } }$ . We implement all methods using the Tensorflow 2.0 Keras API and Scikit-Learn. We use the Adam optimizer with default learning rate 0.001 and a batch size of 128 across all experiments. For the UCI datasets, we set $k = 5 0$ and set $k = 5 0 0$ for all other datasets. We chose $k = 5 0$ for the UCI datasets because some of the datasets were of small size. However, we found that the $k$ -NN method’s performance was quite stable to the choice of $k$ , which we show in Section 5.4. We describe the permutations used for hard flipping in the Appendix.
# 5.1 UCI AND MNIST RESULTS
We show the results for one of the UCI datasets in Figure 2 and Fashion MNIST in Figure 3. Due to space, results for MNIST and the remaining UCI datasets are in the Appendix. For UCI, we use a fully-connected neural network with a single hidden layer of dimension 100 with ReLU activations and train for 100 epochs. For both MNIST datasets, we use is a two hidden-layer fully-connected neural network where each layer has 256 hidden units with ReLU activations. We train the model for 20 epochs. We see that the $k$ -NN approach attains models with a low error rate across noise rates and either outperforms or is competitive with the next best method, GLC.
# 5.2 CIFAR RESULTS
For CIFAR10/100 we use ResNet-20, which we train from scratch on single NVIDIA P100 GPUs. We train CIFAR10 for 100 epochs and CIFAR100 for 150 epochs. We show results for CIFAR10 in Figure 4 and results for CIFAR100 in the Appendix, due to space. We see that the $k$ -NN method performs competitively. It generally outperforms on the uniform and flip noise types but performs worse for the hard flip noise type. It is not too surprising that $k$ -NN would be weaker in the presence of hard flip noise (i.e. where labels are mapped based on a pre-determined mapping between labels) as the noise is much more structured in that case making it more difficult to be filtered out by majority vote among the neighbors. In other words, unlike the uniform and flip noise types, we are no longer dealing with white label noise in the hard flip noise type.
 Figure 3: Fashion MNIST. Each column is a different corruption method. We see that the $k$ -NN approach performs competitively. More results are in the Appendix.
 Figure 4: CIFAR10. Each column is a different corruption method. We see that our $k$ -NN method performs competitively or outperforms on the uniform and flip noise types but performs worse for the hard flip noise type. More results are in the Appendix.
# 5.3 SVHN RESULTS
We show the results in Figure 5. We train ResNet-20 from scratch on NVIDIA P100 GPUs for 100 epochs. As in the CIFAR experiments, we see that the $k$ -NN method tends to be competitive in the uniform and flip noise types but does slightly worse in the hard flip.
# 5.4 ROBUSTNESS TO $k$
In this section, we show that our procedure is stable in its hyperparameter $k$ . The theoretical results suggest that a wide range of $k$ can give us statistical consistency guarantees and we show that in practice a wide range of $k$ gives us similar results for Algorithm 1 (Figure 6). Such robustness in
 Figure 5: SVHN. We see that the $k$ -NN method performs competitively on the uniform and flip noise types but performs worse for the hard flip noise type. More results in the Appendix.
<table><tr><td rowspan=1 colspan=1>Letters</td><td rowspan=1 colspan=1>1020</td><td rowspan=1 colspan=1>4.554.283.77</td><td rowspan=1 colspan=1>22.06</td><td rowspan=1 colspan=1>2.482.051.76</td><td rowspan=1 colspan=1>2.331.911.57</td><td rowspan=1 colspan=1>2.051.781.56</td><td rowspan=1 colspan=1>2.191.791.34</td><td rowspan=1 colspan=1>21.85</td><td rowspan=1 colspan=1>4.834.453.85</td><td rowspan=1 colspan=1>3.162.522.07</td><td rowspan=1 colspan=1>2.962.121.78</td><td rowspan=1 colspan=1>2.351.921.56</td><td rowspan=1 colspan=1>2.11.81.58</td><td rowspan=1 colspan=1>2.522.061.42</td><td rowspan=1 colspan=1>21.93</td><td rowspan=1 colspan=1>3.63.35</td><td rowspan=1 colspan=1>3.172.522.05</td><td rowspan=1 colspan=1>2.11.851.62</td><td rowspan=1 colspan=1>1.831.61.38</td><td rowspan=1 colspan=1>1.821.61.41</td><td rowspan=1 colspan=1>1.821.641.42</td><td rowspan=1 colspan=1>2.522.362.04</td></tr><tr><td rowspan=1 colspan=1>Phonemes</td><td rowspan=1 colspan=1>51020</td><td rowspan=1 colspan=1>7.897.867.72</td><td rowspan=1 colspan=1>1.911.541.34</td><td rowspan=1 colspan=1>1.791.531.33</td><td rowspan=1 colspan=1>2.121.671.35</td><td rowspan=1 colspan=1>1.261.161.13</td><td rowspan=1 colspan=1>2.582.281.76</td><td rowspan=1 colspan=1>32.852.24</td><td rowspan=1 colspan=1>7.917.957.89</td><td rowspan=1 colspan=1>1.931.541.34</td><td rowspan=1 colspan=1>3.212.751.97</td><td rowspan=1 colspan=1>2.161.691.35</td><td rowspan=1 colspan=1>1.341.221.16</td><td rowspan=1 colspan=1>3.973.642.87</td><td rowspan=1 colspan=1>4.313.963.28</td><td rowspan=1 colspan=1>6.66.736.36</td><td rowspan=1 colspan=1>1.921.551.33</td><td rowspan=1 colspan=1>1.771.611.45</td><td rowspan=1 colspan=1>1.961.61.3</td><td rowspan=1 colspan=1>1.21.151.14</td><td rowspan=1 colspan=1>1.781.621.38</td><td rowspan=1 colspan=1>2.72.582.28</td></tr><tr><td rowspan=1 colspan=1>Wilt</td><td rowspan=1 colspan=1>1020</td><td rowspan=1 colspan=1>5.184.684.31</td><td rowspan=1 colspan=1>0.560.430.36</td><td rowspan=1 colspan=1>0.850.750.86</td><td rowspan=1 colspan=1>0.540.450.35</td><td rowspan=1 colspan=1>0.390.320.32</td><td rowspan=1 colspan=1>0.930.770.57</td><td rowspan=1 colspan=1>1.861.771.5</td><td rowspan=1 colspan=1>5.275.635.18</td><td rowspan=1 colspan=1>0.560.440.34</td><td rowspan=1 colspan=1>3.893.142.67</td><td rowspan=1 colspan=1>0.530.430.35</td><td rowspan=1 colspan=1>0.520.410.34</td><td rowspan=1 colspan=1>5.154.864.23</td><td rowspan=1 colspan=1>4.954.844.32</td><td rowspan=1 colspan=1>4.64.785.63</td><td rowspan=1 colspan=1>0.550.430.34</td><td rowspan=1 colspan=1>0.730.660.61</td><td rowspan=1 colspan=1>0.580.430.36</td><td rowspan=1 colspan=1>0.390.310.3</td><td rowspan=1 colspan=1>0.980.780.57</td><td rowspan=1 colspan=1>1.91.811.49</td></tr><tr><td rowspan=1 colspan=1>Seeds</td><td rowspan=1 colspan=1>1020</td><td rowspan=1 colspan=1>3.293.432.99</td><td rowspan=1 colspan=1>4.223.042.69</td><td rowspan=1 colspan=1>3.712.842.27</td><td rowspan=1 colspan=1>4.22.992.74</td><td rowspan=1 colspan=1>3.082.141.72</td><td rowspan=1 colspan=1>2.872.742.44</td><td rowspan=1 colspan=1>新2.2</td><td rowspan=1 colspan=1>5.135.024.41</td><td rowspan=1 colspan=1>4.333.382.56</td><td rowspan=1 colspan=1>5.564.583.57</td><td rowspan=1 colspan=1>4.393.192.65</td><td rowspan=1 colspan=1>3.642.652.09</td><td rowspan=1 colspan=1>5.114.94.23</td><td rowspan=1 colspan=1>4.884.733.86</td><td rowspan=1 colspan=1>2.942.752.85</td><td rowspan=1 colspan=1>4.063.422.53</td><td rowspan=1 colspan=1>3.632.962.25</td><td rowspan=1 colspan=1>3.913.142.57</td><td rowspan=1 colspan=1>2.992.251.62</td><td rowspan=1 colspan=1>2.842.692.43</td><td rowspan=1 colspan=1>3.012.862.49</td></tr><tr><td rowspan=1 colspan=1>Iris</td><td rowspan=1 colspan=1>1020</td><td rowspan=1 colspan=1>292.46</td><td rowspan=1 colspan=1>3.232.481.85</td><td rowspan=1 colspan=1>3.482.591.97</td><td rowspan=1 colspan=1>3.972.251.52</td><td rowspan=1 colspan=1>2.461.320.6</td><td rowspan=1 colspan=1>1.721.260.96</td><td rowspan=1 colspan=1>2.051.551.32</td><td rowspan=1 colspan=1>5.255.064.46</td><td rowspan=1 colspan=1>3.382.531.51</td><td rowspan=1 colspan=1>5.154.583.45</td><td rowspan=1 colspan=1>4.032.241.38</td><td rowspan=1 colspan=1>3.022.171.46</td><td rowspan=1 colspan=1>4.323.983.36</td><td rowspan=1 colspan=1>4.434.083.53</td><td rowspan=1 colspan=1>2.92.62.51</td><td rowspan=1 colspan=1>3.292.341.84</td><td rowspan=1 colspan=1>3.132.021.48</td><td rowspan=1 colspan=1>4.11.861.34</td><td rowspan=1 colspan=1>2.321.150.58</td><td rowspan=1 colspan=1>1.140.910.65</td><td rowspan=1 colspan=1>1.351.161</td></tr><tr><td rowspan=1 colspan=1>Parkinsons</td><td rowspan=1 colspan=1>51020</td><td rowspan=1 colspan=1>55.354.88</td><td rowspan=1 colspan=1>3.463.263.01</td><td rowspan=1 colspan=1>3.263.223.08</td><td rowspan=1 colspan=1>4.223.453.1</td><td rowspan=1 colspan=1>3.43.212.98</td><td rowspan=1 colspan=1>3.263.222.97</td><td rowspan=1 colspan=1>3.763.823.52</td><td rowspan=1 colspan=1>5.175.435.19</td><td rowspan=1 colspan=1>3.553.383.02</td><td rowspan=1 colspan=1>4.494.253.94</td><td rowspan=1 colspan=1>4.13.443.05</td><td rowspan=1 colspan=1>3.363.322.95</td><td rowspan=1 colspan=1>5.345.274.99</td><td rowspan=1 colspan=1>5.355.135.06</td><td rowspan=1 colspan=1>4.985.245.1</td><td rowspan=1 colspan=1>362.98</td><td rowspan=1 colspan=1>3.563.13.01</td><td rowspan=1 colspan=1>4.593.372.98</td><td rowspan=1 colspan=1>3.683.112.96</td><td rowspan=1 colspan=1>3.283.122.91</td><td rowspan=1 colspan=1>3.633.823.47</td></tr><tr><td rowspan=1 colspan=1>MNIST</td><td rowspan=1 colspan=1>51020</td><td rowspan=1 colspan=1>22.07</td><td rowspan=1 colspan=1>0.690.50.35</td><td rowspan=1 colspan=1>1.030.850.69</td><td rowspan=1 colspan=1>0.50.410.34</td><td rowspan=1 colspan=1>0.40.330.27</td><td rowspan=1 colspan=1>2.722.421.97</td><td rowspan=1 colspan=1>2.752.452.03</td><td rowspan=1 colspan=1>32.48</td><td rowspan=1 colspan=1>0.690.50.35</td><td rowspan=1 colspan=1>1.911.50.86</td><td rowspan=1 colspan=1>0.50.420.34</td><td rowspan=1 colspan=1>0.440.350.27</td><td rowspan=1 colspan=1>3.463.12.36</td><td rowspan=1 colspan=1>3.493.142.41</td><td rowspan=1 colspan=1>2.031.861.54</td><td rowspan=1 colspan=1>0.690.50.35</td><td rowspan=1 colspan=1>0.780.670.53</td><td rowspan=1 colspan=1>0.220.210.2</td><td rowspan=1 colspan=1>0.290.260.22</td><td rowspan=1 colspan=1>0.650.480.36</td><td rowspan=1 colspan=1>2.141.981.67</td></tr><tr><td rowspan=1 colspan=1>Fashion MNIST</td><td rowspan=1 colspan=1>51020</td><td rowspan=1 colspan=1>22.07</td><td rowspan=1 colspan=1>1.881.711.56</td><td rowspan=1 colspan=1>1.731.61.48</td><td rowspan=1 colspan=1>1.591.521.45</td><td rowspan=1 colspan=1>1.561.521.44</td><td rowspan=1 colspan=1>2.532.211.95</td><td rowspan=1 colspan=1>2.542.32.05</td><td rowspan=1 colspan=1>3.553.142.38</td><td rowspan=1 colspan=1>1.871.711.56</td><td rowspan=1 colspan=1>2.552.131.54</td><td rowspan=1 colspan=1>1.591.531.46</td><td rowspan=1 colspan=1>1.61.541.46</td><td rowspan=1 colspan=1>3.32.922.17</td><td rowspan=1 colspan=1>3.312.992.27</td><td rowspan=1 colspan=1>21.92</td><td rowspan=1 colspan=1>1.871.711.56</td><td rowspan=1 colspan=1>1.621.521.43</td><td rowspan=1 colspan=1>1.441.411.38</td><td rowspan=1 colspan=1>1.481.461.41</td><td rowspan=1 colspan=1>2.312.192.04</td><td rowspan=1 colspan=1>2.42.221.97</td></tr><tr><td rowspan=1 colspan=1>CIFAR10</td><td rowspan=1 colspan=1>5200</td><td rowspan=1 colspan=1>6.746.586.4</td><td rowspan=1 colspan=1>76.585.52</td><td rowspan=1 colspan=1>6.866.325.66</td><td rowspan=1 colspan=1>5.435.395.11</td><td rowspan=1 colspan=1>5.035.274.57</td><td rowspan=1 colspan=1>6.346.115.93</td><td rowspan=1 colspan=1>6.746.556.36</td><td rowspan=1 colspan=1>7.146.826.62</td><td rowspan=1 colspan=1>7.26.565.59</td><td rowspan=1 colspan=1>7.126.725.9</td><td rowspan=1 colspan=1>5.525.625.16</td><td rowspan=1 colspan=1>5.355.324.85</td><td rowspan=1 colspan=1>6.716.486.1</td><td rowspan=1 colspan=1>7.126.836.56</td><td rowspan=1 colspan=1>5.084.894.77</td><td rowspan=1 colspan=1>7.136.535.45</td><td rowspan=1 colspan=1>5.855.34.68</td><td rowspan=1 colspan=1>3.763.913.51</td><td rowspan=1 colspan=1>4.274.43.82</td><td rowspan=1 colspan=1>4.334.214.03</td><td rowspan=1 colspan=1>4.964.894.75</td></tr><tr><td rowspan=1 colspan=1>CIFAR100</td><td rowspan=1 colspan=1>1</td><td rowspan=1 colspan=1>10.810.7910.78</td><td rowspan=1 colspan=1>10.229.949.38</td><td rowspan=1 colspan=1>9.989.79.15</td><td rowspan=1 colspan=1>9.599.42</td><td rowspan=1 colspan=1>9.579.63</td><td rowspan=1 colspan=1>9.179.098.92</td><td rowspan=1 colspan=1>9.299.259.07</td><td rowspan=1 colspan=1>10.7910.8110.8</td><td rowspan=1 colspan=1>10.249.899.44</td><td rowspan=1 colspan=1>10.039.689.13</td><td rowspan=1 colspan=1>9.649.468.97</td><td rowspan=1 colspan=1>9.669.639.17</td><td rowspan=1 colspan=1>9.29.18.92</td><td rowspan=1 colspan=1>9.299.259.09</td><td rowspan=1 colspan=1>10.6410.6510.66</td><td rowspan=1 colspan=1>10.239.899.41</td><td rowspan=1 colspan=1>9.889.388.65</td><td rowspan=1 colspan=1>8.588.568.07</td><td rowspan=1 colspan=1>8.989.198.81</td><td rowspan=1 colspan=1>7.487.447.33</td><td rowspan=1 colspan=1>8.047.997.9</td></tr><tr><td rowspan=1 colspan=1>SVHN</td><td rowspan=1 colspan=1>1020</td><td rowspan=1 colspan=1>5.044.984.32</td><td rowspan=1 colspan=1>3.522.21.83</td><td rowspan=1 colspan=1>3.563.22.67</td><td rowspan=1 colspan=1>1.992.272.14</td><td rowspan=1 colspan=1>1.621.341.2</td><td rowspan=1 colspan=1>4.644.513.96</td><td rowspan=1 colspan=1>4.954.824.41</td><td rowspan=1 colspan=1>34.85</td><td rowspan=1 colspan=1>281.83</td><td rowspan=1 colspan=1>4.093.723.09</td><td rowspan=1 colspan=1>2.172.291.9</td><td rowspan=1 colspan=1>2.051.481.19</td><td rowspan=1 colspan=1>5.234.964.34</td><td rowspan=1 colspan=1>5.525.294.82</td><td rowspan=1 colspan=1>82.7</td><td rowspan=1 colspan=1>4.172.411.85</td><td rowspan=1 colspan=1>2.162.011.54</td><td rowspan=1 colspan=1>0.890.880.98</td><td rowspan=1 colspan=1>1.351.040.98</td><td rowspan=1 colspan=1>2.322.161.83</td><td rowspan=1 colspan=1>3.042.982.74</td></tr></table>
hyperparameter is highly desirable because optimal tuning is often not available, especially when no sufficient clean validation set is available.
 Table 1: Area under the test error vs noise rate curve. Each row corresponds to a dataset and size of clean dataset $\mathcal { D } _ { \mathrm { c l e a n } }$ pair, where the size is a percentage of the total training set $5 \%$ , $10 \%$ , $20 \%$ ). Each column shows the area under the error curve across noise rates for a particular method and noise type (Uniform, Flip, Hard Flip). We see that the $k$ -NN method consistently outperforms the other methods for Uniform and Flip and outperforms the other methods on Hard Flip on the smaller datasets. Figure 6: Performance across different values of $k$ . Here we show that on a UCI dataset, the performance of Algorithm 1 is stable when varying its hyperparameter $k$ . Note that the $y$ -axis has been zoomed in to better see the differences between the curves.
# 5.5 AREA UNDER ERROR VS NOISE LEVEL CURVE ACROSS DATASETS
In the figures shown so far, it may be difficult to compare the curves in some cases so we report an area under the curve metric in Table 1.
Conclusions and Open Questions We conclude from our experiments and theory that the $k$ -NN based method (Algorithm 1) is a relatively safe method to remove problematic training examples before training. While $k$ -NN methods can be sensitive to the choice of $k$ when used with small datasets (Garcia et al., 2009), we hypothesize that with today’s large datasets one can blithely set $k$ to a fixed practically medium-sized value (e.g. $k = 5 0 0$ ) as done here and expect reasonable performance. Theoretically we provided some new results for how well $k$ -NN can identify clean versus corrupted labels. Open theoretical questions are whether there are alternate notions of how to characterize the difficulty of a particular configuration of corrupted examples and whether we can provide both upper and lower learning bounds under these noise conditions.
# REFERENCES
Jean-Yves Audibert, Alexandre B Tsybakov, et al. Fast learning rates for plug-in classifiers. The Annals of Statistics, 35(2):608–633, 2007.
Carla E. Brodley and Mark A. Freidl. Identifying mislabeled training data. Journal Artificial Intelligence Research, 1999.
J Paul Brooks. Support vector machines with the ramp loss and the hard margin loss. Operations Research, 59(2):467–479, 2011.
Kamalika Chaudhuri and Sanjoy Dasgupta. Rates of convergence for nearest neighbor classification. In Advances in Neural Information Processing Systems, pp. 3437–3445, 2014.
Xu Chu, Ilhab F. Ilyas, Sanjay Krishnan, and Jiannan Wan. Data cleaning: Overview and emerging challenges. In SIGMOD, 2016.
Thomas M Cover. Rates of convergence for nearest neighbor procedures. In Proceedings of the Hawaii International Conference on Systems Sciences, pp. 413–415, 1968.
Luc Devroye, Laszlo Gyorfi, Adam Krzyzak, Gabor Lugosi, et al. On the strong universal consis- ´ tency of nearest neighbor regression function estimates. The Annals of Statistics, 22(3):1371– 1385, 1994.
Evelyn Fix and Joseph L Hodges Jr. Discriminatory analysis-nonparametric discrimination: consistency properties. Technical report, California Univ Berkeley, 1951.
Wei Gao, Xin-Yi Niu, and Zhi-Hua Zhou. On the consistency of exact and approximate nearest neighbor with noisy data. arXiv preprint arXiv:1607.07526, 2016.
E. K. Garcia, S. Feldman, M. R. Gupta, and S. Srivastava. Completely lazy learning. IEEE Trans. on Knowledge and DataEngineering, 2009.
Aritra Ghosh, Himanshu Kumar, and PS Sastry. Robust loss functions under label noise for deep neural networks. In Thirty-First AAAI Conference on Artificial Intelligence, 2017.
Jacob Goldberger and Ehud Ben-Reuven. Training deep neural-networks using a noise adaptation layer. 2016.
I. Guyon, N. Matic, and V. Vapnik. Discovering informative patterns and data cleaning. In AAAI Workshop on Knowledge Discovery in Databases, 1994.
Bo Han, Jiangchao Yao, Gang Niu, Mingyuan Zhou, Ivor Tsang, Ya Zhang, and Masashi Sugiyama. Masking: A new perspective of noisy supervision. In Advances in Neural Information Processing Systems, pp. 5836–5846, 2018.
Dan Hendrycks, Mantas Mazeika, Duncan Wilson, and Kevin Gimpel. Using trusted data to train deep networks on labels corrupted by severe noise. In Advances in neural information processing systems, pp. 10456–10465, 2018.
H. Jiang, B. Kim, M. Y. Guan, and M. R. Gupta. To trust or not to trust a classifier. In Advances in Neural Information Processing Systems (NeurIPS), 2018.
Heinrich Jiang. Non-asymptotic uniform rates of consistency for k-nn regression. In Proceedings of the AAAI Conference on Artificial Intelligence, volume 33, pp. 3999–4006, 2019.
Lu Jiang, Zhengyuan Zhou, Thomas Leung, Li-Jia Li, and Li Fei-Fei. Mentornet: Regularizing very deep neural networks on corrupted labels. arXiv preprint arXiv:1712.05055, 4, 2017.
Ishan Jindal, Matthew Nokleby, and Xuewen Chen. Learning deep networks from noisy labels with dropout regularization. In 2016 IEEE 16th International Conference on Data Mining (ICDM), pp. 967–972. IEEE, 2016.
Ashish Khetan, Zachary C Lipton, and Anima Anandkumar. Learning from noisy singly-labeled data. arXiv preprint arXiv:1712.04577, 2017.
Yuncheng Li, Jianchao Yang, Yale Song, Liangliang Cao, Jiebo Luo, and Li-Jia Li. Learning from noisy labels with distillation. In Proceedings of the IEEE International Conference on Computer Vision, pp. 1910–1918, 2017. Tongliang Liu and Dacheng Tao. Classification with noisy labels by importance reweighting. IEEE Transactions on Pattern Analysis and Machine Intelligence, 38(3):447–461, 2015. Enno Mammen, Alexandre B Tsybakov, et al. Smooth discrimination analysis. The Annals of Statistics, 27(6):1808–1829, 1999. Hamed Masnadi-Shirazi and Nuno Vasconcelos. On the design of loss functions for classification: theory, robustness to outliers, and savageboost. In Advances in Neural Information Processing Systems, pp. 1049–1056, 2009. Nagarajan Natarajan, Inderjit S Dhillon, Pradeep K Ravikumar, and Ambuj Tewari. Learning with noisy labels. In Advances in Neural Information Processing Systems, pp. 1196–1204, 2013. Nicolas Papernot and Patrick McDaniel. Deep k-nearest neighbors: Towards confident, interpretable and robust deep learning. arXiv preprint arXiv:1803.04765, 2018. Giorgio Patrini, Alessandro Rozza, Aditya Krishna Menon, Richard Nock, and Lizhen Qu. Making deep neural networks robust to label noise: A loss correction approach. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pp. 1944–1952, 2017. Henry WJ Reeve and Ata Kaban. Fast rates for a kNN classifier robust to unknown asymmetric label noise. arXiv preprint arXiv:1906.04542, 2019. Mengye Ren, Wenyuan Zeng, Bin Yang, and Raquel Urtasun. Learning to reweight examples for robust deep learning. arXiv preprint arXiv:1803.09050, 2018. David Rolnick, Andreas Veit, Serge Belongie, and Nir Shavit. Deep learning is robust to massive label noise. arXiv preprint arXiv:1705.10694, 2017. Aarti Singh, Clayton Scott, Robert Nowak, et al. Adaptive Hausdorff estimation of density level sets. The Annals of Statistics, 37(5B):2760–2782, 2009. Charles J Stone. Consistent nonparametric regression. The Annals of Statistics, pp. 595–620, 1977. Sainbayar Sukhbaatar, Joan Bruna, Manohar Paluri, Lubomir Bourdev, and Rob Fergus. Training convolutional networks with noisy labels. arXiv preprint arXiv:1406.2080, 2014. Alexander B Tsybakov et al. Optimal aggregation of classifiers in statistical learning. The Annals of Statistics, 32(1):135–166, 2004. Arash Vahdat. Toward robustness against label noise in training deep discriminative neural networks. In Advances in Neural Information Processing Systems, pp. 5596–5605, 2017. Brendan Van Rooyen, Aditya Menon, and Robert C Williamson. Learning with symmetric label noise: The importance of being unhinged. In Advances in Neural Information Processing Systems, pp. 10–18, 2015. Andreas Veit, Neil Alldrin, Gal Chechik, Ivan Krasin, Abhinav Gupta, and Serge Belongie. Learning from noisy large-scale datasets with minimal supervision. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pp. 839–847, 2017. Yizhen Wang, Somesh Jha, and Kamalika Chaudhuri. Analyzing the robustness of nearest neighbors to adversarial examples. In International Conference on Machine Learning, pp. 5120–5129, 2018. D. Wilson. Asymptotic properties of nearest neighbor rules using edited data. IEEE Trans. on Systems, Man and Cybernetics, 1972. Tong Xiao, Tian Xia, Yi Yang, Chang Huang, and Xiaogang Wang. Learning from massive noisy labeled data for image classification. In Proceedings of the IEEE conference on computer vision and pattern recognition, pp. 2691–2699, 2015. Zhilu Zhang and Mert Sabuncu. Generalized cross entropy loss for training deep neural networks with noisy labels. In Advances in Neural Information Processing Systems, pp. 8778–8788, 2018.
# A PROOFS
A.1 SUPPORTING THEORETICAL RESULTS
The following bounds $r _ { k } ( x )$ uniformly in $x \in \mathcal { X }$ . Lemma 1 (Lemma 2 of Jiang (2019)). The following holds with probability at least $1 - \delta / 2$ . If
$$2 ^ { 8 } \cdot D \log ^ { 2 } ( 4 / \delta ) \cdot \log n \leq k \leq { \frac { 1 } { 2 } } \cdot \omega \cdot p _ { X , 0 } \cdot v _ { D } \cdot r _ { 0 } ^ { D } \cdot n ,$$
then $\begin{array} { r } { \operatorname* { s u p } _ { x \in \mathcal { X } } r _ { k } ( x ) \leq \left( \frac { 2 k } { \omega \cdot v _ { D } \cdot n \cdot p _ { X , 0 } } \right) ^ { 1 / D } } \end{array}$ , where $v _ { D }$ is the volume of the unit ball in $\mathbb { R } ^ { D }$ .
The next result bounds the number of distinct $k$ -NN sets over $\mathcal { X }$ .
Lemma 2 (Lemma 3 of Jiang (2019)). Let $M$ be the number of distinct $k$ -NN sets over $\mathcal { X }$ , that is, $M : = | \{ N _ { k } ( x ) : x \in \mathcal { X } \} |$ . Then $M \leq D \cdot n ^ { D }$ .
# A.2 MINIMUM $k$ -NN SPREAD
We propose a more notion of how spread out a set of points is than $S _ { 2 }$ which will be used in the theoretical analysis. This will allow us to more precisely characterize how difficult a configuration of incorrectly labeled examples will be to work with in the $k$ -NN context. For example, if such examples are spread out far apart, then there will be many correctly labeled examples nearby for the $k$ -NN approach to identify the incorrectly labeled examples. On the other hand, if the corrupted examples are all close together, then it will be more difficult to identify them without many uncorrected examples in that region. To this end, we define the minimum $k$ -NN spread:
Definition 4 (minimum $k$ -NN spread).
$$S _ { k } ( C ) : = \operatorname* { m i n } _ { x \in C } r _ { k } ( x , C ) ,$$
where $r _ { k } ( x , C )$ denotes the distance from $x$ to the $k$ -th closest neighbor in $C$ .
Note that this definition is consistent with the earlier definition of $S _ { 2 }$ .
# A.3 PROOF OF THEOREM 1
Proof of Theorem $^ { l }$ . Let $\tau , \gamma , \epsilon > 0$ be quantities that will be determined later. Suppose that for some $\dot { x } \in \mathcal { X } ^ { \Delta }$ , we have $r _ { k } ( x ) \ \leq \ \tau$ and $S _ { \mathrm { \lfloor ( \frac { 1 } { 2 } - \gamma ) \cdot k \rfloor } } ( C ) \geq \tau$ . Then, at least $\textstyle { \frac { 1 } { 2 } } + \gamma$ fraction of the points within $x$ ’s $k$ -nearest neighbors are not in the corrupted set $C$ . Let $A _ { x } : = N _ { k } ( x ) \backslash C$ , that is, the $k$ -nearest neighbors of $x$ that are not in $C$ . Then it is clear that $A _ { x }$ is a $k _ { 0 }$ -nearest neighbor set of $x$ relative to $X \backslash C$ for some $k _ { 0 } \geq \lceil ( \frac { 1 } { 2 } + \gamma ) \cdot k \rceil$ . We have that $A _ { x } \subseteq \mathcal { X } ^ { \Delta } \oplus \tau$ where $\begin{array} { r } { A _ { \mathbf { \lambda } } \oplus { } r : = \{ x \in \mathcal { X } : \operatorname* { i n f } _ { a \in A } | x - a | \leq r \} . } \end{array}$ . Let us consider without loss of generality that $\eta ( x ) \ge \frac { 1 } { 2 } + \Delta$ (call this set $\chi \Delta , +$ ). The case $\begin{array} { r } { \mathring { \mathcal { X } } ^ { \Delta , - } : = \{ { x } \in \mathcal { X } ^ { \Delta } : \eta ( { x } ) \leq \frac { 1 } { 2 } - \breve { \Delta } \} } \end{array}$ follows by symmetry. Thus, we have $\eta ( x ^ { \prime } ) \geq \frac { 1 } { 2 } + \Delta - C _ { \alpha } \tau ^ { \alpha }$ for all $x ^ { \prime } \in A _ { x }$ . By Hoeffing’s inequality, we have
$$\mathbb { P } \left( \frac { 1 } { \lvert A _ { x } \rvert } \sum _ { x ^ { \prime } \in A _ { x } } y ( x ^ { \prime } ) < \frac { 1 } { 2 } + \Delta - C _ { \alpha } \tau ^ { \alpha } - \epsilon \right) \le \exp ( - 2 \epsilon ^ { 2 } \cdot k _ { 0 } ) ,$$
where $y ( x )$ is the label corresponding to sample $x$ . By Lemma 2, we have that there are at most $\boldsymbol { D } \cdot \boldsymbol { n } ^ { D }$ such $k _ { 0 }$ -nearest neighbor sets across all $k _ { 0 }$ in $X \backslash C$ . That is, this is also a bound on the number of distinct $A _ { x }$ for $x \in \mathcal { X }$ . Therefore, if we set
$$\epsilon = \sqrt { \frac { D \log n + \log ( 4 D / \delta ) } { ( 1 + 2 \gamma ) \cdot k } } ,$$
then by union bound, we have that
$$\mathbb { P } \left( \operatorname* { i n f } _ { x \in \mathcal { X } ^ { \Delta , + } } \frac { 1 } { \left| A _ { x } \right| } \sum _ { x ^ { \prime } \in A _ { x } } y ( x ^ { \prime } ) < \frac { 1 } { 2 } + \Delta - C _ { \alpha } \tau ^ { \alpha } - \epsilon \right) \leq \frac { \delta } { 4 } .$$
and thus, with probability at least $1 - \delta / 4$ , we have that $\begin{array} { r } { \frac { 1 } { | A _ { x } | } \sum _ { x ^ { \prime } \in A _ { x } } y ( x ^ { \prime } ) \ \geq \ \frac { 1 } { 2 } + \Delta - } \end{array}$ $C _ { \alpha } \tau ^ { \alpha } - \epsilon$ uniformly over $x \in \mathcal { X } ^ { \Delta , + }$ . Similarly, with probability at least $1 - \delta / 4$ we have that 1|A | Px0∈A y(x0) ≤ 12 − ∆ + Cατ α + uniformly over x ∈ X ∆,−.
Hence, in order for $k$ -nearest neighbor prediction to predict the Bayes-optimal label on $\chi ^ { \Delta }$ , it suffices that
$$k _ { 0 } \left( \frac { 1 } { 2 } + \Delta - C _ { \alpha } { \tau } ^ { \alpha } - \epsilon \right) \geq \frac { k } { 2 } .$$
Since $k _ { 0 } \geq ( \frac { 1 } { 2 } + \gamma ) \cdot k$ , we have that the above holds if
$$\Delta \ge C _ { \alpha } \tau ^ { \alpha } + \epsilon + \frac { 1 - 2 \gamma } { 2 ( 1 + 2 \gamma ) } .$$
We now choose the values of $\tau , \gamma , \epsilon$ to upper bound each of the terms on the R.H.S. by $\Delta / 3$ so that the above holds.
We can bound the last term by $\Delta / 3$ by setting:
$$\gamma = \frac { 1 } { 2 } \cdot \frac { 3 - 2 \Delta } { 3 + 2 \Delta } .$$
Next, taking
$$\displaystyle { k \geq \frac { 3 ( 3 + 2 \Delta ) } { 2 \Delta ^ { 2 } } \left( D \log n + \log ( 4 D / \delta ) \right) , }$$
we have that $\epsilon \leq \Delta / 3$ . Now, by Lemma 1, we have that setting
$$\tau = \left( \frac { 2 k } { \omega \cdot v _ { D } \cdot n \cdot p _ { X , 0 } } \right) ^ { 1 / D }$$
gives us that $r _ { k } ( x ) \leq \tau$ for all $x \in \mathcal { X }$ with probability at least $1 - \delta / 2$ . It thus suffices to take
$$k \leq { \frac { 1 } { 2 } } \left( { \frac { \Delta } { 3 \cdot C _ { \alpha } } } \right) ^ { D / \alpha } \cdot \omega \cdot v _ { D } \cdot p _ { X , 0 } \cdot n$$
so that $C _ { \alpha } \tau ^ { \alpha } \leq \Delta / 3$ . Now in order for $S _ { \left\lfloor \left( { \frac { 1 } { 2 } } - \gamma \right) \cdot k \right\rfloor } ( C ) \geq \tau$ , it suffices to have $S _ { 2 } ( C ) \geq \tau$ . This can be accomplished by having the following hold:
$$k \leq \frac 1 2 \cdot S _ { 2 } ( C ) ^ { D } \cdot \omega \cdot v _ { D } \cdot p _ { X , 0 } \cdot n .$$
Thus, there exists positive constants $K _ { l }$ and $K _ { u }$ depending only on $\mathcal { F }$ such that if
$$K _ { u } \cdot \frac { 1 } { \Delta ^ { 2 } } \cdot ( \log ^ { 2 } ( 1 / \delta ) \cdot \log n ) \le k \le K _ { u } \cdot \operatorname* { m i n } \{ S _ { 2 } ( C ) ^ { D } , \Delta ^ { D / \alpha } \} \cdot n ,$$
then the desired conditions hold.
# A.4 PROOF OF THEOREM 2
Proof of Theorem 2. The proof begins in the same way as the proof of Theorem 1. As before, let $\tau , \gamma , \epsilon > 0$ be quantities that will be determined later. Like before, we are reduced to showing
$$\Delta \ge C _ { \alpha } \tau ^ { \alpha } + \epsilon + \frac { 1 - 2 \gamma } { 2 ( 1 + 2 \gamma ) } ,$$
as long as the conditions for Lemma 1 and 2 hold and $S _ { 2 } ( x ) \geq \tau$ and $r _ { k } ( x ) \leq \tau$ where we choose
$$\epsilon = \sqrt { \frac { D \log n + \log ( 4 D / \delta ) } { ( 1 + 2 \gamma ) \cdot k } } , \quad \gamma = \frac { 1 } { 2 } \cdot \frac { 3 - 2 \Delta } { 3 + 2 \Delta } , \quad \tau = \left( \frac { 2 k } { \omega \cdot v _ { D } \cdot n \cdot p _ { X , 0 } } \right) ^ { 1 / D } .$$
These conditions hold for some $K _ { u }$ and $K _ { l }$ depending on $\mathcal { F }$ . Then we are reduced to having
$$\frac 2 3 \Delta \geq \sqrt { \frac { D \log n + \log ( 4 D / \delta ) } { ( 1 + 2 \gamma ) \cdot k } } + C _ { \alpha } \left( \frac { 2 k } { \omega \cdot v _ { D } \cdot n \cdot p _ { X , 0 } } \right) ^ { \alpha / D } .$$
Since $\gamma \geq 0$ , it suffices to have
$$\frac 2 3 \Delta \geq \sqrt { \frac { D \log n + \log ( 4 D / \delta ) } { k } } + C _ { \alpha } \left( \frac { 2 k } { \omega \cdot v _ { D } \cdot n \cdot p _ { X , 0 } } \right) ^ { \alpha / D } .$$
The desired form for $\Delta$ clearly follows for some choice of $K$ depending only on $D , \omega , p _ { X , 0 } , C _ { \alpha }$ , all of which depend only on $\mathcal { F }$ .
Finally, we must ensure that $\begin{array} { r } { \lfloor \left( \frac { 1 } { 2 } - \gamma \right) \cdot k \rfloor \ge 2 } \end{array}$ so that $S _ { \lfloor ( \frac { 1 } { 2 } - \gamma ) \cdot k \rfloor } ( C ) \geq S _ { 2 } ( x )$ . Given the expression for $\gamma$ , it is equivalent to have $\begin{array} { r } { \lfloor \left( \frac { 2 \Delta } { 3 + 2 \Delta } \right) \cdot k \rfloor \ge 2 } \end{array}$ . It suffices to show that $k \geq \frac { 3 ( 3 + 2 \Delta ) } { 2 \Delta }$ . Given the form of $\Delta$ in terms of $n$ and $k$ , we see that it suffices to have that
$$k \geq \frac { 9 } { 2 } \cdot K \cdot \left( \left( \sqrt { \frac { \log n + \log ( 1 / \delta ) } { k } } + \left( \frac { k } { n } \right) ^ { \alpha / D } \right) \right) ^ { - 1 } + 3 ,$$
which holds when $k \geq K _ { 0 } \cdot n ^ { 2 \alpha / ( 2 \alpha + D ) }$ for some $K _ { 0 }$ depending only on $\mathcal { F }$ , as desired.
# A.5 PROOF OF THEOREM 3
Proof of Theorem 3. The first part follows from Theorem 2. For the second part, we have by Theorem 2 that if $x \in \mathcal { X } ^ { \Delta }$ , then the $k$ -NN classifier and the Bayes-optimal classifier match with probability $1 - \delta$ uniformly. Thus, we have
$$\begin{array} { r l } & { { R _ { X } } - { R ^ { * } } \leq \mathbb { P } ( x \notin \mathcal { X } ^ { \Delta } ) \left( \mathbb { E } _ { \mathcal { F } } [ g _ { k } ( x ) \neq y | x \notin \mathcal { X } ^ { \Delta } ] - \mathbb { E } _ { \mathcal { F } } [ g ^ { * } ( x ) \neq y | x \notin \mathcal { X } ^ { \Delta } ] \right) } \\ & { \qquad \leq { C _ { \beta } } \cdot \Delta ^ { \beta } \cdot \left( \mathbb { E } _ { \mathcal { F } } [ g _ { k } ( x ) \neq y | x \notin \mathcal { X } ^ { \Delta } ] - \mathbb { E } _ { \mathcal { F } } [ g ^ { * } ( x ) \neq y | x \notin \mathcal { X } ^ { \Delta } ] \right) \leq { C _ { \beta } } \cdot \Delta ^ { \beta } \cdot 2 \Delta . } \end{array}$$
The result follows immediately from Theorem 2.
# B HARD FLIP PERMUTATIONS
For Fashion MNIST we hard flip by swapping the following classes: TSHIRT $\mathbf { \Gamma } \mathbf { S } \mathbf { H }$ IRT, TROUSER DRESS, PULLOVER $ { \mathrm { C O A T } }$ , SANDAL BAG, SNEAKER ANKLEBOOT. For CIFAR10 we swap the pairs: TRUCK AUTOMOBILE, BIRD AIRPLANE, DEER HORSE, $\mathrm { \Delta ^ { \circ } A T D O G , F R O G S H I P } .$ For CIFAR100, we hard flip circularly (i.e. $\pi ( i ) = ( i + 1 )$ mod $K$ ) within each of the 20 superclasses. For all other datasets, we hard flip circularly.
# C ADDITIONAL PLOTS
We provide the plots that were ommitted from the main text due to space constraints.
 Figure 7: Plots for UCI Phonemes dataset at 10, $20 \%$ clean data and all corruption types.
 Figure 8: Plots for UCI Letters dataset at 5, 10, $20 \%$ clean data and all corruption types.
 Figure 9: Plots for UCI Wilt dataset at 5, 10, $20 \%$ clean data and all corruption types.
 Figure 10: Plots for UCI Parkinsons dataset at 5, 10, $20 \%$ clean data and all corruption types.
 Figure 11: Plots for UCI Seeds dataset at 5, 10, $20 \%$ clean data and all corruption types.
 Figure 12: Plots for UCI Iris dataset at 5, 10, $20 \%$ clean data and all corruption types.
 Figure 13: Plots for MNIST at 5, 10, $20 \%$ clean data and all corruption types.
 Figure 14: Plots for Fashion MNIST at 10, $20 \%$ clean data and all corruption types.
 Figure 15: Plots for CIFAR10 at 10, $20 \%$ clean data and all corruption types.
 Figure 16: Plots for CIFAR100 at 5, 10, $20 \%$ clean data and all corruption types.
 Figure 17: Plots for SVHN at 10, $20 \%$ clean data and all corruption types.123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313# DEEP LEARNING FOR PHYSICAL PROCESSES: INCORPORATING PRIOR SCIENTIFIC KNOWLEDGE
Emmanuel de Bezenac ´ ∗, Arthur Pajot ∗, Patrick Gallinari emmanuel.de-bezenac, arthur.pajot, patrick.gallinari @lip6.fr Sorbonne Universites, UMR 7606, LIP6, F-75005 Paris, France ´
# ABSTRACT
We consider the use of Deep Learning methods for modeling complex phenomena like those occurring in natural physical processes. With the large amount of data gathered on these phenomena the data intensive paradigm could begin to challenge more traditional approaches elaborated over the years in fields like maths or physics. However, despite considerable successes in a variety of application domains, the machine learning field is not yet ready to handle the level of complexity required by such problems. Using an example application, namely Sea Surface Temperature Prediction, we show how general background knowledge gained from the physics could be used as a guideline for designing efficient Deep Learning models. In order to motivate the approach and to assess its generality we demonstrate a formal link between the solution of a class of differential equations underlying a large family of physical phenomena and the proposed model. Experiments and comparison with series of baselines including a state of the art numerical approach is then provided.
# 1 INTRODUCTION
A physical process is a sustained phenomenon marked by gradual changes through a series of states occurring in the physical world. Physicists and environmental scientists attempt to model these processes in a principled way through analytic descriptions of the scientist’s prior knowledge of the underlying processes. Conservation laws, physical principles or phenomenological behaviors are generally formalized using differential equations. This physical paradigm has been, and still is the main framework for modeling complex natural phenomena like e.g. those involved in climate. With the availability of very large datasets captured via different types of sensors, this physical modeling paradigm is being challenged by the statistical Machine Learning (ML) paradigm, which offers a prior-agnostic approach. However, despite impressive successes in a variety of domains as demonstrated by the deployment of Deep Learning methods in fields such as vision, language, speech, etc, the statistical approach is not yet ready to challenge the physical paradigm for modeling complex natural phenomena, or at least it has not demonstrated how to. This is a new challenge for this field and an emerging research direction in the ML community. We believe that knowledge and techniques accumulated for modeling physical processes in well developed fields such as maths or physics could be useful as a guideline to design efficient learning systems and conversely, that the ML paradigm could open new directions for modeling such complex phenomena. In this paper we then raise two issues: 1) are modern ML techniques ready to be used to model complex physical phenomena, and 2) how general knowledge gained from the physical modeling paradigm could help designing efficient ML models.
In this work, we tackle these questions by considering a specific physical modeling problem: forecasting sea surface temperature (SST). SST plays a significant role in analyzing and assessing the dynamics of weather and other biological systems. Accurately modeling and predicting such dynamics is critical in various applications such as weather forecasting, or planning of coastal activities. Since 1982, weather satellites have made huge quantities of very high resolution SST data available Bernstein (1982). Standard physical methods for forecasting SST use coupled ocean-atmosphere prediction systems, based on the Navier Stokes equations. These models rely on multiple physical hypotheses and do not optimally exploit the information available in the data. On the other hand, despite the availability of large amounts of data, direct applications of ML methods do not lead to competitive state of the art results, as will be seen in section 4.
We use SST as a typical and representative problem of intermediate complexity. Our goal is not to offer one more solution to this problem, but to use it as an illustration for advancing on the challenges mentioned above. The way we handle this problem is general enough to be transfered to a more general class of transport problems.
We propose a Deep Neural Network (NN) model, inspired from general physical motivations which offers a new approach for solving this family of problems. We first motivate our approach by introducing in section 2 the solution of a general class of partial differential equations (PDE) which is a core component of a large family of transport and propagation phenomena in physics. This general solution is used as a guideline for introducing a Deep Learning architecture for SST prediction which is described in section 3. Experiments and comparison with a series of baselines is introduced in section 4. A review of related work is finally presented in section 5.
The main contributions of this work are: 1) an example showing how to incorporate general physical background for designing a NN aimed at modeling a relatively complex prediction task. We believe the approach to be general enough to be used for a family of transport problems obeying general advection-diffusion principles. 2) formal links between our model’s prediction and the solution of a general advection diffusion PDE 3) an unsupervised model for estimating motion fields, given a sequence of images. 4) a proof, on a relatively complex physical modeling problem, that full data intensive approaches based on deep architectures can be competitive with state of the art dedicated numerical methods.
# 2 PHYSICAL MOTIVATION
Forecasting consists in predicting future temperature maps using past records. Temperatures are acquired via satellite imagery. If we focus on a specific area, we can formulate the problem as prediction of future temperature images of this area using past images. The classical approach to forecasting SST consists in using numerical models representing prior knowledge on the conservation laws and physical principles, which take the form of PDEs. These models are then coupled with SST data using assimilation techniques in order to adjust to initial conditions. It is then integrated forward in time to predict SST evolution. For the sea surface, temperature variation is related to a fluid transport problem. In fluids, transport occurs through the combination of two principles: advection and diffusion. During advection, a fluid transports some conserved quantity $I$ (the temperature for SST) or material via bulk motion, i.e.for small variations $\Delta x , \Delta t$ , conservation is expressed as:
$$I ( x , t ) = I ( x + \Delta x , t + \Delta t )$$
applying a first order approximation of the right hand side and moving the resulting terms to the left hand side of equation 1, we obtain the advection equation, known also as the Brightness Constancy Constraint Equation (BCCE):
$$\frac { \partial I } { \partial t } + ( w . \nabla ) I = 0$$
where $\nabla$ denotes the gradient operator, and $w$ the motion vector $\textstyle { \frac { \Delta x } { \Delta t } }$ . This equation describes the temporal evolution of quantity $I$ for displacement $w$ . Note that this equation is also the basis for many variational methods for Optical Flow. To retrieve the motion, numerical schemes are applied, and the resulting system of equations, along with a an additional constraint on $w$ is solved for $w$ . This motion can then be used to forecast the future value of $I$ .
$$\frac { \partial I } { \partial t } + ( w . \nabla ) I = D \nabla ^ { 2 } I$$
$\nabla ^ { 2 }$ denotes the Laplacian operator and $D$ the diffusion coefficient. Note that when $D \to 0$ , we recover the advection equation 2.
This equation describes a large family of physical processes (e.g. fluid dynamics, heat conduction, wind dynamics, etc). Let us now state a result, characterizing the general solutions of equation 3.
Theorem 1. 1 For any initial condition $I _ { 0 } \in L ^ { 1 } ( \mathbb { R } ^ { 2 } )$ with $I _ { 0 } ( \pm \infty ) = 0$ , there exists a unique global solution $I ( x , t )$ to the advection-diffusion equation 3:
$$I ( x , t ) = \int _ { \mathbb { R } ^ { 2 } } k ( x - w , y ) I _ { 0 } ( y ) d y$$
where $\begin{array} { r } { k ( u , v ) = \frac { 1 } { 4 \pi D t } e ^ { - \frac { 1 } { 4 D t } \left. u - v \right. ^ { 2 } } } \end{array}$ is a radial basis function kernel, or alternatively, a 2 dimensional Gaussian probability density with mean $u$ and variance $2 D t$ .
Equation 4 provides a principled way to calculate $I ( x , t )$ for any time $t$ using the initial condition $I _ { 0 }$ , provided the motion $w$ and the diffusion coefficient $D$ are known. It states that quantity $I ( x , t )$ can be computed from the initial condition $I _ { 0 }$ via a convolution with a Gaussian probability density function. In other words, if $I$ was used as a model for the evolution of the SST and the surface’s underlying advecting mechanisms were known, future surface temperatures could be predicted from previous ones. Unfortunately neither the initial conditions, the motion vector nor the diffusion coefficient are known. They have to be estimated from the data. Inspired from the general form of solution 4, we propose a ML method, expressed as a Deep Learning architecture for predicting SST. This model will learn to predict a motion field analog to the $w$ in equation 4, which will be used to predict future images.
# 3 MODEL
 Figure 1: Motion is estimated from the input images $( I _ { t - k - 1 : t } )$ with a convolutional neural network (top left CDNN component). A warping scheme then displaces the last input image along this motion estimate to produce the future image. The error signal is calculated using the target future image $I _ { t + 1 }$ , and is backprogated through the warping scheme to correct the CDNN. To produce multiple time-step forecasts, the predicted image is fed back in the CDNN in an autoregressive manner.
The model consists of two main components, as illustrated in Figure 1. One predicts the motion field from a sequence of past input images, this is convolutional-deconvolutional (CDNN) module on the top of figure 1, and the other warps the last input image using the motion field from the first component, in order to produce an image forecast. The entire system is trained in an end-to-end fashion, using only the supervision from the target SST image. By doing so, we are able to produce an interpretable latent state which corresponds in our problem to the velocity field advecting the temperatures.
Let us first introduce some notations. Each SST image $I _ { t }$ is acquired on a bounded rectangle of $\mathbb { R } ^ { 2 }$ , named $\Omega$ . We denote $I _ { t } ( x )$ and $w _ { t } ( x )$ the sea surface temperature and the two-dimensional motion vector at time $t \in \mathbb { R }$ at position $x \in \Omega$ . $I _ { t } : \Omega \to \mathbb { R }$ and $\dot { w } _ { t } : \Omega \to \mathbb { R } ^ { 2 }$ represent the temperatures and the motion vector field at time $t$ defined on $\Omega$ . When time $t$ and position $x$ are available from the context, we will drop the subscript $t$ from $w _ { t } ( x )$ and $I _ { t } ( x )$ , along with $x$ for clarity. Given a sequence of $k$ consecutive SST images $\{ I _ { t - k - 1 } , . . . , I _ { t } \}$ (also denoted as $I _ { t - k - 1 : t } )$ , our goal is to predict the next image $I _ { t + 1 }$ .
 Figure 2: Architecture of the CDNN motion estimation component. For the estimated motion flow $\hat { w } _ { t }$ , colours correspond to the flow orientation and colour intensity to the flow intensity
As indicated in section 2, provided the underlying motion field is known, one can compute SST forecasts. Let us introduce how the motion field is estimated in our architecture. We are looking for a vector field $w$ which when applied to the geometric space $\Omega$ renders $I _ { t }$ close to $I _ { t + 1 }$ , i.e. $I _ { t + 1 } ( \bar { x } ) \simeq$ $I _ { t } ( x + w ( x ) )$ , $\forall x \in \Omega$ . If $I _ { t + 1 }$ were known, we could estimate $w$ , but $I _ { t + 1 }$ is precisely what we are looking for. Instead, we choose to use a convolutional-deconvolutional architecture to predict a motion vector for each pixel. As shown in figure 2, this network makes use of skip connections He et al. (2015), allowing fine grained information from the first layers to flow through in a more direct manner. We use a Batch Normalization layer between each convolution, and Leaky $R e L U$ (with parameter value set to 0.1) non-linearities between convolutions and transposed-convolutions. We used $k = 4$ concatenated images $I _ { t - k - 1 : t }$ as input for training. We have selected this architecture experimentally, testing different state-of-the-art convolution-deconvolution network architectures. Let $\hat { w } \in \mathbb { R } ^ { 2 \times \mathbf { \bar { W } } \times H }$ be the output of the network, where $W$ and $H$ are respectively the width and height of the images, and $\mathit { \Omega } ^ { , }$ corresponds to the two components of the flow at each point of the motion field.
Generally, and this is the case for our problem, we do not have a direct supervision on the motion vector field, since the target motion is usually not available. Using the warping scheme introduced below, we will nonetheless be able to (weakly) supervise $w$ , based on the discrepancy of the warped version of the $I _ { t }$ image and the target image $I _ { t + 1 }$ .
# 3.2 WARPING SCHEME
 Figure 3: Warping scheme. To calculate the pixel value for time $t + 1$ at position $x$ , we first compute its previous position at time $t$ , i.e. $x - w$ . We then center a Gaussian in that position in order to obtain a weight value for each pixel in $I _ { t }$ based on its distance with $x - w$ , and compute a weighted average of the pixel values of $I _ { t }$ . This weighted average will correspond to the new pixel value at $x$ in $I _ { t + 1 }$ .
Discretizing the solution of the advection-diffusion equation in section 2 by replacing the integral with a sum, and setting image $I _ { t }$ as the initial condition, we obtain a method to calculate the future image, based on the motion field estimate $\hat { w }$ . The latter is used as a warping scheme:
$$\hat { I } _ { t + 1 } ( x ) = \sum _ { y \in \Omega } k ( x - \hat { w } ( x ) , y ) I _ { t } ( y )$$
where $\begin{array} { r } { k ( x - \underset { . } { \hat { w } } , y ) = \underset { . } { \frac { 1 } { 4 \pi D \Delta t } } e ^ { - \frac { 1 } { 4 D \Delta t } \| x - \hat { w } - y \| ^ { 2 } } } \end{array}$ is a radial basis function kernel, as in equation 4, parameterized by the diffusion coefficient $D$ and the time step value $\Delta t$ between $t$ and $t + 1$ and $\hat { w }$ is the estimated value of the vector flow $w$ . To calculate the temperature for time $t + 1$ at position $x$ , we compute the scalar product between $k ( x - { \hat { w } } , . )$ , a Gaussian centered in $x - \hat { w }$ , and the previous image $I _ { t }$ . Simply put, it is a weighted average of the temperatures $I _ { t }$ , where the weight values are larger when the pixel’s positions that are closer to $x - \hat { w }$ . Informally, $x - \hat { w }$ corresponds to the pixel’s previous position at time $t$ . See figure 3.
As seen by the relation with the solution of the advection-diffusion equation, the proposed warping mechanism is then clearly adapted to the modeling of phenomena governed by the advectiondiffusion equation. SST forecasting is a particular case, but the proposed scheme can be used for any problems in which advection and diffusion are occurring. Moreover, this warping scheme is entirely differentiable, allowing backpropagation of the error signal to the motion fireld estimating module.
This warping mechanism has been inspired by the Spatial Transformer Network (STN) Jaderberg et al. (2015), originally designed to be incorporated as a layer in a convolutional neural network architecture in order to gain invariance under geometric transformations. Using the notations in Jaderberg et al. (2015), when the inverse geometric transformation $\mathcal { T } _ { \theta }$ of the grid generator step is set to $\mathcal { T } _ { \theta } ( x ) = x - \hat { w } ( x )$ , and the kernels $k ( . ; \Phi _ { x } )$ and $k ( . ; \Phi _ { y } )$ in the sampling step are radial basis function kernels, we recover our warping scheme. The latter can be seen as a specific case of the STN, without the localization step. This result theoretically grounds the use of the STN for Optical Flow in many recent articles Zhu et al. (2017), Yu et al. (2016), Patraucean et al. (2015), Finn et al. (2016): in equation 3, when $D \to 0$ , we recover the brightness constancy constraint equation, used in the latter.
For training, supervision is provided at the output of the warping module. It consists in minimizing the discrepancy between the warped image $\hat { I } _ { t + 1 }$ and the target image $I _ { t + 1 }$ . The loss is measured via a differentiable function and the gradient is back propagated through the warping function in order to adjust the parameters of the convolutional-deconvolutional module generating the vector field. This is detailed in the next section.
# 3.3 LOSS FUNCTION
At each iteration, the model aims at forecasting the next observation, given the previous ones. We evaluate the discrepancy between the warped image $\hat { I } _ { t + 1 }$ and the target image $I _ { t + 1 }$ using the Charbonnier penalty function $\rho ( x ) = ( x + \epsilon ) ^ { \frac { 1 } { \alpha } }$ , where $\epsilon$ and $\alpha$ are parameters to be set. Note that with $\epsilon = 0$ and $\alpha \stackrel { \cdot } { = } \frac { 1 } { 2 }$ , we recover the $\ell _ { 2 }$ loss. The Charbonnier penalty function is known to reduce the influence of outliers compared to an $l _ { 2 }$ norm. We have also tested the Laplacian pyramid loss Ling & Okada (2006), where we enforce convolutions of all deconvolutional layers to be close to down-sampled versions of the target image in the Charbonnier penalty sense, but we have observed an overall decrease in generalization performance.
The proposed NN model has been designed according to the intuition gained from general background knowledge of a physical phenomenon, here advection-diffusion equations. Additional prior knowledge – expressed as partial differential equations, or through constraints – can be easily incorporated in our model, by adding penalty terms in the loss function. As the displacement $w$ is explicitly part of our model, one strength of our model is its capacity to apply some regularization term directly on the motion field. In our experiments, we tested the influence of different terms: divergence $\nabla . w _ { t } ( x ) ^ { 2 }$ , magnitude $\| w _ { t } ( x ) \| ^ { 2 }$ and smoothness $\Vert \nabla w _ { t } ( x ) \Vert ^ { 2 }$ .
$$L _ { t } = \sum _ { x \in \Omega } \rho ( \hat { I } _ { t + 1 } ( x ) - I _ { t + 1 } ( x ) ) + \lambda _ { \mathrm { d i v } } ( \nabla . w _ { t } ( x ) ) ^ { 2 } + \lambda _ { \mathrm { m a g n } } \left\| w _ { t } ( x ) \right\| ^ { 2 } + \lambda _ { \mathrm { g r a d } } \left\| \nabla w _ { t } ( x ) \right\| ^ { 2 }$$
# 4 EXPERIMENTS
# 4.1 DATASET DESCRIPTION
Since 1982, high resolution SST data has been made available by the NOAA6 weather satellite, Bernstein (1982). Dealing directly with these data requires a lot of preprocessing (e.g. some regions are not available due to clouds, hindering temperature acquisition). In order to avoid such complications which are beyond the scope of this work, we used synthetic but realistic SST data of the Atlantic ocean generated by a sophisticated simulation engine: NEMO (Nucleus for European Modeling of the Ocean) engine 2, Madec (2008). NEMO is a state-of-the-art modelling framework of ocean related engines. It is a primitive equation model adapted to the regional and global ocean circulation problems. Historical data is accumulated in the model to generate a synthesized estimate of the states of the system using data analysis, a specific data assimilation scheme, which means that the data does follow the true temperatures. The resulting dataset is constituted of daily temperature acquisitions of 481 by 781 pixels, from 2006-12-28 to 2017-04-05 (3734 acquisitions).
We extract 64 by 64 pixel sized sub-regions as indicated in figure 4.1. We use data from years 2006 to 2015 for training and validation (94743 training examples), and years 2016 to 2017 for testing. We withhold $20 \%$ of the training data for validation, selected uniformly at random at the beginning of each experiment. For the tests we used sub-regions enumerated 17 to 20 in figure 4.1, where the interactions between hot and cold waters make the dynamics interesting to study. All the regions numbered in figure 4.1, from 2006 to 2015 where used for training 3. Each sequence of images used for training or for evaluation corresponds to a specific numbered sub-region. We make the simplifying hypothesis that the data in a single sub-region contains enough information to forecast the future of the sub-region. As the forecast is for a small temporal horizon we can assume that the influence from outside the region is small enough.
 Figure 4: Sub regions extracted for the dataset. Test regions are regions 17 to 20.
We normalize the daily SST acquisitions of each sub region using the mean and the standard deviation of all the SST data of the sub-region acquired on the same day of the year for all the years in the training set, i.e. the SST acquisition of sub-region 2 on date September 8th 2017 is standardized using the data of all the September 8th available in the dataset. This removes the seasonal component from SST data.
# 4.2 BASELINE COMPARISON
We compare our model with several baselines. Each model is evaluated with a mean square error metric, forecasting images on a horizon of 6 (we forecast from $I _ { t + 1 }$ to $I _ { t + 6 }$ and then average the MSE). The hyperparameters are tuned using the validation set. Neural network based models are run on a Titan $\mathrm { X p }$ GPU, and runtime is given for comparison purpose.
Concerning the constraints on the vector field $w$ (equation 6. the regularization coefficients selected via validation are $\lambda _ { \mathrm { d i v } } = 1$ , $\lambda _ { \mathrm { { m a g n } } } = - 0 . 0 3$ and $\lambda _ { \mathrm { g r a d } } = 0 . 4$ . The coefficient diffusion $D$ was set to 0.45 by cross validation. We also compare the results with the model without any regularization.
Our reference model for forecasting is Ber´ eziat & Herlin (2015), a numerical assimilation model ´ which relies on data assimilation. In Ber´ eziat & Herlin (2015), the ocean’s dynamics are modeled ´ using shallow water equations Vallis (2017) and the initial conditions, along with other terms, are estimated using assimilation techniques Tremolet (2006). This is a state of the art assimilation model ´ for predicting ocean dynamics, here SST.
The other baselines are 1) an autoregressive convolutional-deconvolutional NN (ACNN), with an architecture similar to our CDNN module, but trained to predict the future image directly, without explicitly representing the motion vector field. Each past observation is used as an input channel (the 4 input images used in the experiments are concatenated), and the output is used as new input for multi step forecasting, 2) a ConvLSTM model Shi et al. (2015), which uses convolutional transitions in the inner LSTM module, and 3) the model in Mathieu et al. (2015) which is a multi-scale ACNN trained as a Generative Adversial Network (GAN). We have used a non-official code for Mathieu et al. (2015), which is made available at https://github.com/dyelax/Adversarial_ Video_Generation. For Ber´ eziat & Herlin (2015), the code has been provided by the authors ´ of the paper. We have implemented the ACNN and ConvLSTM models ourselves. The code for our models, along with these baselines will be made available.
# 4.3 QUANTITATIVE RESULTS
<table><tr><td>Model</td><td>Average Score (MSE)</td><td>Average Time</td></tr><tr><td>Numerical model Béréziat & Herlin (2015)</td><td>1.99</td><td>4.8 s</td></tr><tr><td>ConvLSTM Shi et al. (2015)</td><td>5.76</td><td>0.018 s</td></tr><tr><td>ACNN</td><td>15.84</td><td>0.54 s</td></tr><tr><td>GAN Video Generation (Mathieu et al. (2015))</td><td>4.73</td><td>0.096 s</td></tr><tr><td>Proposed model with regularization</td><td>1.42</td><td>0.040 s</td></tr><tr><td>Proposed model without regularization</td><td>2.01</td><td>0.040 s</td></tr></table>
Table 1: Average score and average time on test data. Average score is calculated using the mean square error metric (MSE), time is in seconds. The regularization coefficients for our model have been set using a validation set with $\lambda _ { \mathrm { d i v } } = 1$ , $\lambda _ { \mathrm { { m a g n } } } = - 0 . 0 3$ and $\lambda _ { \mathrm { g r a d } } = 0 . 4$ .
Quantitatively, our model performs well. The MSE score is better than any of the baselines. The closest NN baseline is Mathieu et al. (2015) which regularizes a regression convolutiondeconvolution model with a GAN. The performance is however clearly below the proposed model and it does not allow to easily incorporate prior constraints inspired from the physics of the phenomenon. ACNN is a direct predictor of the image sequence, implemented via a CDNN module identical to the one used in our model. Its performance is poor. Clearly, a straightforward use of prediction models is not adapted to the complexity of the phenomenon. ConvLSTM performs better: as opposed to the ACNN, it seems to be able to capture a dynamic, although not very accurately. Overall, direct prediction models are not able to capture the complex underlying dynamics and they produce blurry sequences of images. The GAN explicitly forces the network output to eliminate the blurring effect and then makes it able to capture short term dynamics. The state of the art numerical model Ber´ eziat & Herlin (2015), performs well but has a slighthly lower performance than our reg- ´ ularized model, although it incorporates more prior constraints. This shows that pure ML models, when conceived adequately and when trained with enough data, can be competitive with state of the art dedicated models. Regularizing the motion vector $w$ notably increases the performance w.r.t. to the unregularized model. The choice of the constraints (divergence, magnitude and smoothness) inspired here by physical background correspond to relevant priors on the dynamics of the model.
 Figure 5: From top to bottom: target, our model prediction, our model flow, numerical assimilation model , ACNN, ConvLSTM. Data correspond to daily temperatures from January 17 to January 23, 2017
As for the running time, the proposed model is extremely fast, being just above the ConvLSTM model of Shi et al. (2015). The running time of Ber´ eziat & Herlin (2015)’s model is not comparable ´ to the others. It was run on a CPU (no GPU code) when all the others were run on Titan $\mathrm { X p }$ GPU. However, an optimization procedure is required to estimate the motion field, and it is clearly slower than the straightforward NN predictions. Moreover, in order to prevent the numerical scheme from diverging, multiple intermediate forecasts are required.
Besides MSE, we need to analyze the prediction samples qualitatively. Figure 4.3 shows the predictions obtained by the different models. On the top row, the ground truth for a sequence of 4 temperature images corresponding to time $t .$ , $t + 1$ , $t + 3$ and $t + 6$ . The second row corresponds to our regularized model prediction at times $t + 1 , t + 3$ and $t + 6$ (time $t$ corresponds to the last input image, it is repeated on each row). The model seems to conserve temperatures. The prediction is close to the target for $t + 1 , t + 3$ and starts to move away at time $t + 6$ . The third row shows the motion flow estimated by the model. Each color in the flow images corresponds to a motion vector. There is clearly a strong evolving dynamic captured for this sequence. Row 4 is the numerical assimilation model of Ber´ eziat & Herlin (2015). It also clearly captures some dynamics and shows ´ interesting patterns, but it tends to diverge when the prediction horizon increases. The ACNN model (row 5) rapidly produces blurry images; it does not preserve the temperatures and does not seem to capture any dynamics. On row 6 are plotted the predictions of the ConvLSTM model. Temperature is not preserved and although a dynamic is captured, it does not correspond to the target. Overall, the proposed model seems to forecast SST quite accurately, while retrieving a coherent motion vector field.
# 5 RELATED WORK
ML for Physical modeling Close to this work is the field of spatio-temporal statistics. In their reference book Cressie & Wikle (2015) also advocate the use of physical background knowledge to build statistical models. They show how the design of statistical models can be inspired from partial differential equations linked to an observed physical phenomenon. They mainly consider auto-regressive models within a hierarchical Bayesian framework. In Raissi et al. (2017), Archambeau et al. (2007) and Alvarez et al. (2011) the author use PDE-inspired gaussian process to model physical process. Even if the methods and the application are different, the motivation and arguments are similar to the ones developed here.
Another interesting research direction is the use of NNs for reducing the complexity of numerical simulation for physical processes. Generally, in these approaches statistical models are used in place of a computational demanding component of the numerical simulation process. For example in the domain of fluid dynamics, Tompson et al. (2017) and Ladicky et al. (2015) propose to use regressors ´ for simulating fluid and smoke animation. Ladicky et al. (2015) use a random forest to compute ´ particle location and Tompson et al. (2017) use a CNN to approximate part of a numerical PDE scheme. In these approaches, ML is only a component of a numerical simulation scheme whereas we aim at modeling the whole physical process via a Deep Learning approach. Farther to our objective, Rudy et al. (2017) make use of a sparse regression method for discovering the governing partial differential equation(s) of a given system by time series measurements in the spatial domain. Other works have suggested using neural networks for physical process forecast, such as Brajard et al. (2017).
Our work is also related to recent developments in computer vision, in the related but distinct fields of video prediction and motion estimation in videos. Our goal and the domain of application are clearly different from video modeling, but since our solution involves predicting a motion field and the next SST image, the solutions share some similarities. Motion estimation and video predictions by deep architectures have motivated a series of work over the last two years. We briefly review them below and outline the differences.
Optical Flow Optical flow consists in retrieving the apparent motion of objects, surfaces, or particles between two consecutive frames of a video. The extracted motion can be used in many areas such as object detection, object tracking, movement detection, robot navigation and visual odometry. In the vision community, this is considered as a problem by itself and several papers are dedicated to this topic. Classical methods rely on the brightness constancy constrain equation (BCCE) (equation 2), derived from the observation that surfaces usually persist over time and hence the intensity value of a small region remains the same despite its position change Sun et al. (2008). Since using BCCE directly leads to complicated optimizing issues, classic approaches – namely differential methods – approximate BCCE using a first order Taylor expansion and develop variational methods.
As an alternative to these methods, Deep Learning models have been recently proposed for estimating the optical flow between 2 images. Fischer et al. (2015) formulate optical flow as a supervised regression problem, using a CNN to predict motion. Ilg et al. (2016) build on this approach and propose to use an ensemble of these CNN architectures. They assess results on par with state of the art methods for optical flow, while maintaining a small computational overhead. The difficulty here is that these methods require a notable quantity of target data, i.e. optical flow images, while because of the complexity of manually annotating flow images, there are only a few small annotated collections available. Fischer et al. (2015) and Ilg et al. (2016) chose to pretrain their model on a synthetic dataset made of computer animations and their associated motion and show that this information transfers well to real videos. Yu et al. (2016) demonstrate that it is possible to predict the optical flow between two input images in an unsupervised way using a CNN and a Spatial Transformer Network. This is however not extensible for prediction as is done in our setting since this requires the two images $I _ { t }$ and $I _ { t + 1 }$ as input while $I _ { t + 1 }$ is not available at inference time for prediction.
# Video prediction
It is only very recently that video prediction emerged as a task in the Deep Learning community. For this task, people are generally interested at predicting accurately the displacement/ emergence/ disappearing of objects in the video. In our application, the goal is clearly different since we are interested into modeling the whole dynamics behind image changes and not at following moving objects. Let us first introduce some methods that perform prediction by computing optical flow or a similar transformation. Both Patraucean et al. (2015) and Finn et al. (2016) use some form of motion flow estimation. For next frame prediction Patraucean et al. (2015) introduce a STN module at the hidden layer of a LSTM in order do estimate a motion field in this latent space. The resulting image is then decoded in the original image space for prediction. This approach clearly does not allow introducing prior knowledge on the field vector as this has been done in our work. Finn et al. (2016) learn affine transformations on image parts in order to predict object displacement and Van Amersfoort et al. (2017) proposed a similar model.
Let us now consider models that directly attempt to predict the next frame without estimating a motion field. As shown in the experimental section, plain application of autoregressive models produces blurred images. Mathieu et al. (2015), one of our baseline proposed to use different loss functions and a GAN regularization of a CDNN predictor which led to sharper and higher quality predictions. Significant improvements have been obtained with the Video Pixel Network of Kalchbrenner et al. (2016), which is a sophisticated architecture composed of resolution preserving CNN encoders, LSTM and PixelCNN decoders which form a conditional Spatio-temporal video autoencoder with differentiable memory. This model is probably state of the art today for video prediction, They reach a high accuracy on moving MNIST and good performance on a robot video dataset. A drawback is the complexity of the model and the number of parameters: they are using respectively $2 0 \bf { M }$ and $1 \textbf { M }$ frames on these two datasets. We did not test this model since up to our knowledge no code was available.
# 6 CONCLUSION AND FUTURE WORK
The evolution in time of the proposed model is deterministic. Predicting future observations should also deal with the inherent ambiguity and lack of information for the prediction task. A natural future direction would be to incorporate uncertainty in the model’s evolution in the proposed framework. We can extend the proposed model by incorporating a stochastic latent variable in the flow field generation process. A promising direction is the development of generative models which has become popular in Deep Learning, leading to different families of innovative models. For example, the Stochastic Gradient Variational Bayes algorithm (SGVB) Kingma & Welling (2014) provides a framework for learning stochastic latent variables with deep neural networks, and has recently been used by some authors to model time series Karl et al. (2016); Chung et al. (2015); Krishnan et al. (2015). A recent work where both spatial and temporal information are considered is Walker et al. (2016) who model pixel trajectories in a video. As a follow up of our work, we plan to consider such extensions in the future.
The data intensive paradigm offers alternative directions to the classical physical approaches for modeling complex natural processes. Our belief is that cross fertilization of both paradigms is essential for pushing further the frontier of complex data modeling. By using as an example application a relatively complex problem concerning ocean dynamics, we proposed a principled way to design Deep Learning models using inspiration from the physics. The proposed approach can be easily generalized to a class of problems for which the underlying dynamics follow advection-diffusion principles. We have compared the proposed approach to a series of baselines. It is able to reach performance comparable to a state of the art numerical model and clearly outperform alternative NN models used as baselines.
# ACKNOWLEDGMENTS
This work was partially funded by ANR project LOCUST - ANR-15-CE23-0027 and by CLEAR - Center for LEArning & data Retrieval - joint lab. With Thales (www.thalesgroup.com).
# REFERENCES
Mauricio A Alvarez, David Luengo, and Neil D Lawrence. Linear latent force models using gaussian processes. 2011.
Cedric Archambeau, Dan Cornford, Manfred Opper, and John Shawe-Taylor. Gaussian process approximations of stochastic differential equations. In Gaussian Processes in Practice, pp. 1–16, 2007.
Dominique Ber´ eziat and Isabelle Herlin. ´ Coupling Dynamic Equations and Satellite Images for Modelling Ocean Surface Circulation, pp. 191–205. Springer International Publishing, Cham, 2015. ISBN 978-3-319-25117-2. doi: 10.1007/978-3-319-25117-2 12. URL https://doi. org/10.1007/978-3-319-25117-2_12.
R. L. Bernstein. Sea surface temperature estimation using the noaa 6 satellite advanced very high resolution radiometer. Journal of Geophysical Research: Oceans, 87(C12):9455–9465, 1982. ISSN 2156-2202. doi: 10.1029/JC087iC12p09455. URL http://dx.doi.org/10.1029/ JC087iC12p09455.
Julien Brajard, Anastase Alexandre Charantonis, and F Jourdin. Predicting ocean dynamics through machine learning: Application on sea-surface suspended particulate mater. In American Meteorological Society Annual Meeting 2017, 2017.
Junyoung Chung, Kyle Kastner, Laurent Dinh, Kratarth Goel, Aaron C Courville, and Yoshua Bengio. A recurrent latent variable model for sequential data. In C. Cortes, N. D. Lawrence, D. D. Lee, M. Sugiyama, and R. Garnett (eds.), Advances in Neural Information Processing Systems 28, pp. 29802988. Curran Associates, Inc., 2015. URL http://papers.nips.cc/paper/ 5653-a-recurrent-latent-variable-model-for-sequential-data.pdf.
N. Cressie and C.K. Wikle. Statistics for Spatio-Temporal Data. Wiley, 2015. ISBN 9781119243045. URL https://books.google.fr/books?id $\underline { { \underline { { \mathbf { \Pi } } } } } =$ 4L_dCgAAQBAJ.
Chelsea Finn, Ian J. Goodfellow, and Sergey Levine. Unsupervised learning for physical interaction through video prediction. CoRR, abs/1605.07157, 2016. URL http://arxiv.org/abs/ 1605.07157.
Philipp Fischer, Alexey Dosovitskiy, Eddy Ilg, Philip Hausser, Caner Hazirbas, Vladimir Golkov, ¨ Patrick van der Smagt, Daniel Cremers, and Thomas Brox. Flownet: Learning optical flow with convolutional networks. CoRR, abs/1504.06852, 2015. URL http://arxiv.org/abs/ 1504.06852.
Kaiming He, Xiangyu Zhang, Shaoqing Ren, and Jian Sun. Deep residual learning for image recognition. CoRR, abs/1512.03385, 2015. URL http://arxiv.org/abs/1512.03385.
Eddy Ilg, Nikolaus Mayer, Tonmoy Saikia, Margret Keuper, Alexey Dosovitskiy, and Thomas Brox. Flownet 2.0: Evolution of optical flow estimation with deep networks. CoRR, abs/1612.01925, 2016. URL http://arxiv.org/abs/1612.01925.
Max Jaderberg, Karen Simonyan, Andrew Zisserman, and Koray Kavukcuoglu. Spatial transformer networks. CoRR, abs/1506.02025, 2015. URL http://arxiv.org/abs/1506.02025.
Nal Kalchbrenner, Aaron van den Oord, Karen Simonyan, Ivo Danihelka, Oriol Vinyals, Alex ¨ Graves, and Koray Kavukcuoglu. Video pixel networks. CoRR, abs/1610.00527, 2016. URL http://arxiv.org/abs/1610.00527.
Maximilian Karl, Maximilian Soelch, Justin Bayer, and Patrick van der Smagt. Deep variational bayes filters: Unsupervised learning of state space models from raw data. ICLR 2017, 2016.
Diederik P Kingma and Max Welling. Auto-encoding variational bayes. ICLR 2014, 2014.
Rahul G Krishnan, Uri Shalit, and David Sontag. Deep kalman filters. arXiv preprint arXiv:1511.05121, 2015.
L’ubor Ladicky, SoHyeon Jeong, Barbara Solenthaler, Marc Pollefeys, and Markus Gross. Data- ´ driven fluid simulations using regression forests. ACM Trans. Graph., 34(6):199:1–199:9, October 2015. ISSN 0730-0301. doi: 10.1145/2816795.2818129. URL http://doi.acm.org/ 10.1145/2816795.2818129.
Haibin Ling and K. Okada. Diffusion distance for histogram comparison. In 2006 IEEE Computer Society Conference on Computer Vision and Pattern Recognition (CVPR’06), volume 1, pp. 246– 253, June 2006. doi: 10.1109/CVPR.2006.99.
G. Madec. NEMO ocean engine. Note du Pole de mod ˆ elisation, Institut Pierre-Simon Laplace ´ (IPSL), France, No 27, ISSN No 1288-1619, 2008.
Michael Mathieu, Camille Couprie, and Yann LeCun. Deep multi-scale video prediction beyond ¨ mean square error. CoRR, abs/1511.05440, 2015. URL http://arxiv.org/abs/1511. 05440.
Viorica Patraucean, Ankur Handa, and Roberto Cipolla. Spatio-temporal video autoencoder with differentiable memory. CoRR, abs/1511.06309, 2015. URL http://arxiv.org/abs/ 1511.06309.
Maziar Raissi, Paris Perdikaris, and George Em Karniadakis. Numerical gaussian processes for time-dependent and non-linear partial differential equations. arXiv preprint arXiv:1703.10230, 2017.
Samuel H. Rudy, Steven L. Brunton, Joshua L. Proctor, and J. Nathan Kutz. Data-driven discovery of partial differential equations. SCIENCE ADVANCES —, 3(April), 2017. URL http://arxiv. org/abs/1607.01067.
Xingjian Shi, Zhourong Chen, Hao Wang, Dit-Yan Yeung, Wai-Kin Wong, and Wang-chun Woo. Convolutional LSTM network: A machine learning approach for precipitation nowcasting. CoRR, abs/1506.04214, 2015. URL http://arxiv.org/abs/1506.04214.
Deqing Sun, Stefan Roth, J. P. Lewis, and Michael J. Black. Learning Optical Flow, pp. 83–97. Springer Berlin Heidelberg, Berlin, Heidelberg, 2008. ISBN 978-3-540-88690-7. doi: 10.1007/ 978-3-540-88690-7 7. URL https://doi.org/10.1007/978-3-540-88690-7_7.
Jonathan Tompson, Kristofer Schlachter, Pablo Sprechmann, and Ken Perlin. Accelerating Eulerian fluid simulation with convolutional networks. In Doina Precup and Yee Whye Teh (eds.), Proceedings of the 34th International Conference on Machine Learning, volume 70 of Proceedings of Machine Learning Research, pp. 3424–3433, International Convention Centre, Sydney, Australia, 06–11 Aug 2017. PMLR. URL http://proceedings.mlr.press/v70/ tompson17a.html.
Yannick Tremolet. Accounting for an imperfect model in 4d-var. ´ Quarterly Journal of the Royal Meteorological Society, 132(621):2483–2504, 2006.
Geoffrey K Vallis. Atmospheric and oceanic fluid dynamics. Cambridge University Press, 2017.
Joost Van Amersfoort, Anitha Kannan, Marc’Aurelio Ranzato, Arthur Szlam, Du Tran, and Soumith Chintala. Transformation-Based Models of Video Sequences. In CoRR abs/1701.08435 (2017), pp. 1–11, 2017. URL http://arxiv.org/abs/1701.08435.
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, 2016.
Jason J. Yu, Adam W. Harley, and Konstantinos G. Derpanis. Back to Basics: Unsupervised Learning of Optical Flow via Brightness Constancy and Motion Smoothness, pp. 3–10. Springer International Publishing, Cham, 2016. ISBN 978-3-319-49409-8. doi: 10.1007/978-3-319-49409-8 1. URL https://doi.org/10.1007/978-3-319-49409-8_1.
Yi Zhu, Zhen-Zhong Lan, Shawn D. Newsam, and Alexander G. Hauptmann. Guided optical flow learning. CoRR, abs/1702.02295, 2017. URL http://arxiv.org/abs/1702.02295.
# A PROOF OF THE THEOREM IN SECTION 2 1
Proof. In the following, bold $\mathbf { x }$ and $\mathbf { y }$ will denote vectors of $\mathbb { R } ^ { 2 }$ , while $x$ and $y$ will correspond to the first and second components of $\mathbf { x }$ , respectively. Analogously, $u$ and $v$ will correspond to the components of $w$ . The 2D Fourier Transformation $\mathcal { F }$ of $f : \bar { \mathbb { R } } ^ { 2 } \bar { \mathbb { R } }$ is defined as
$$\begin{array} { l } { \displaystyle \mathcal { F } ( f ) = \int _ { \mathbb { R } ^ { 2 } } f ( \mathbf { x } ) e ^ { - i < \xi , \mathbf { x } > } d \mathbf { x } } \\ { \displaystyle \ = \int _ { \mathbb { R } } \int _ { \mathbb { R } } f ( x , y ) e ^ { - i x \xi _ { 1 } - i y \xi _ { 2 } } d x d y } \end{array}$$
We apply the Fourier Transform $\mathcal { F }$ to both sides of 3. As consequence of the linearity of the Fourier transform, we can calculate decompose the Fourier transform of the left hand side in the sum of the transforms of each term. We have three terms: $\begin{array} { r } { \frac { \partial I } { \partial t } , ( w . \nabla ) I } \end{array}$ and $- D \nabla ^ { 2 } I$ .
$$\begin{array} { l } { \displaystyle \mathcal { F } ( \frac { \partial I } { \partial t } ) = \int _ { \mathbb { R } ^ { 2 } } \frac { \partial I } { \partial t } e ^ { - i < \mathbf { x } , \xi > } d \mathbf { x } } \\ { \displaystyle \ = \int _ { \mathbb { R } ^ { 2 } } \frac { \partial } { \partial t } ( I e ^ { - i < \mathbf { x } , \xi > } ) d \mathbf { x } } \\ { \displaystyle \ = \frac { \partial } { \partial t } \int _ { \mathbb { R } ^ { 2 } } I e ^ { - i < \mathbf { x } , \xi > } d \mathbf { x } } \\ { \displaystyle \ = \frac { \partial \mathcal { F } ( I ) } { \partial t } } \end{array}$$
$$\begin{array} { r l } { F ( ( w , \nabla ) I ) = \displaystyle \int _ { \mathbb { R } ^ { 2 } } ( w , \nabla ) I e ^ { - i \omega \cdot \xi } d x } \\ { = \displaystyle \int _ { \mathbb { R } } \int _ { \mathbb { R } } ( w \frac { \partial I } { \partial x } + v \frac { \partial I } { \partial y } ) e ^ { - i x \xi _ { 1 } - \mathrm { i } y \xi _ { 2 } } d x d y } \\ { = \displaystyle \mu \int _ { \mathbb { R } } e ^ { - i \psi \cdot \xi } \int _ { \mathbb { R } } \frac { \partial I } { \partial x } e ^ { - i \xi _ { 1 } } d x d y + v \displaystyle \int _ { \mathbb { R } } e ^ { - i \psi \xi _ { 1 } } \int _ { \mathbb { R } } \frac { \partial I } { \partial y } e ^ { - i y \xi _ { 2 } } d y d x } \\ { = \displaystyle i \xi _ { 1 } w \int _ { \mathbb { R } } e ^ { - i \psi \xi _ { 2 } } \int _ { x } [ e ^ { - i \psi \xi _ { 1 } } d x d y + i \xi _ { 2 } v \int _ { \mathbb { R } } e ^ { - i \psi \xi _ { 1 } } \int _ { \mathbb { R } } \frac { \partial I } { \partial y } e ^ { - i y \xi _ { 2 } } d y d x } \\ { = \displaystyle \tilde { U } _ { \mathbb { R } } \int _ { \mathbb { R } } \int _ { \mathbb { R } } e ^ { - i \psi \xi _ { 1 } - \mathrm { i } \psi _ { \xi } } d x d y + v \xi _ { 2 } v \int _ { \mathbb { R } } \int _ { \mathbb { R } } I _ { \mathbb { R } } e ^ { - i \omega \xi _ { 1 } - y \psi } d x d y } \\ { = ( \xi _ { 1 } w + i \xi _ { 2 } v ) \int _ { \mathbb { R } } \int _ { \mathbb { R } } \int _ { \mathbb { R } } \int _ { \mathbb { R } } - i \omega \xi _ { 1 } - i \psi \xi _ { 2 } d x d y } \\ { = i \ < \xi , w > F ( I ) } \end{array}$$
$$\begin{array} { r l } { \mathcal { F } ( - D \nabla ^ { 2 } I ) = - \int _ { \mathbb { R } ^ { 2 } } D \nabla ^ { 2 } I c ^ { - i \nu \xi } s c ^ { - \alpha } k s ^ { \zeta } d x } \\ { = - \int _ { \mathbb { R } ^ { 2 } } \int _ { \mathbb { R } ^ { 0 } } D \big ( \hat { \partial } \hat { \partial } ^ { 2 } I + \hat { \partial } \hat { \partial } ^ { 2 } I \big ) e ^ { - i \alpha \zeta _ { 1 } - i \psi \xi } d x d y } \\ { } & { = - D \int _ { \mathbb { R } ^ { 2 } } e ^ { - i \nu \xi } \int _ { \mathbb { R } ^ { 2 } } \frac { \partial ^ { 2 } I } { \partial x ^ { 2 } } e ^ { - i \alpha \zeta _ { 1 } } d x d y - D \int _ { \mathbb { R } ^ { \epsilon } } e ^ { - i \alpha \zeta _ { 1 } } \int _ { \mathbb { R } } \frac { \partial ^ { 2 } I } { \partial y ^ { 2 } } e ^ { - i \nu \xi \epsilon } d y d x } \\ { } & { = - ( \delta _ { 1 } ) ^ { 2 } D \int _ { \mathbb { R } ^ { 2 } } e ^ { - i \nu \zeta _ { 1 } } \int _ { \mathbb { R } } { F } ^ { - i \nu \zeta _ { 1 } } d x d y d y - ( \delta _ { 2 } ) ^ { 2 } D \int _ { \mathbb { R } ^ { \epsilon } } e ^ { - i \alpha \zeta _ { 1 } } \int _ { \mathbb { R } } { F } ^ { - i \nu \zeta _ { 2 } } d y d x } \\ { } & { = D \mathfrak { L } _ { 1 } ^ { 2 } \int _ { \mathbb { R } ^ { \epsilon } } e ^ { - i \alpha \zeta _ { 2 } } \int _ { \mathbb { R } } { F } ^ { - i \nu \zeta _ { 2 } } d x d y + D \mathfrak { L } _ { 2 } ^ { 2 } \int _ { \mathbb { R } ^ { \epsilon } } e ^ { - i \kappa \zeta _ { 1 } } \int _ { \mathbb { R } } { F } ^ { i \nu \zeta - i \psi \zeta _ { 2 } } d y d x } \\ { } & { = D \mathfrak { L } _ { 2 } ^ { 3 } \int _ { \mathbb { R } ^ { 2 } } \int _ { \mathbb { R } } { F } ^ { - i \nu \zeta _ { 2 } } d x d y + D \mathfrak { L } _ { 2 } ^ { 2 } \int _ { \mathbb { R } } { F } ^ { - i \nu \zeta _ { 1 } } d x d y d x } \\ { } & = D \mathfrak { L } _ { 1 } ^ { 3 } \int _ \mathbb \end{array}$$
Regrouping all three previously calculated terms, we obtain
$$\frac { \partial \mathcal { F } ( I ) } { \partial t } + ( i < \xi , w > + D \left\| \xi \right\| ^ { 2 } ) \mathcal { F } ( I ) = 0$$
This is a first order ordinary differential equation of the form $f ^ { \prime } ( t ) + a f ( t ) = 0$ , which admits a known solution $f ( t ) = f ( 0 ) { e ^ { - a t } }$ . Thus, the solution of 11 is
$$\begin{array} { r } { \mathcal { F } ( I ) = \mathcal { F } ( I ) _ { 0 } e ^ { - ( i < \xi , w > + D \| \xi \| ^ { 2 } ) t } } \\ { = \mathcal { F } ( I ) _ { 0 } e ^ { - i < \xi , w > t } e ^ { - D t \| \xi \| ^ { 2 } } } \end{array}$$
where $\mathcal { F } ( I ) _ { 0 }$ denotes the initial condition of the advection diffusion equation in the frequency domain. In order to obtain a solution of 3 in the spatial domain, we calculate the inverse Fourier Transform ${ \mathcal { F } } ^ { - 1 }$ of 12. The multiplication of two functions in the frequency domain is equivalent to their convolution in the spatial domain, i.e. ${ \mathcal { F } } ( f * g ) = { \mathcal { F } } ( f ) { \mathcal { F } } ( g )$ . Hence, the inverse of both terms $\mathcal { F } ( I ) _ { 0 } e ^ { - i < \xi , w > t }$ and $e ^ { - D t \| \boldsymbol { \xi } \| ^ { 2 } }$ can be calculated separately:
Multiplication by a complex exponential in the frequency domain is equivalent to a shift in the spatial domain : $\bar { e } ^ { - i < \xi , w \bar { > } } \mathcal { F } ( f ( \bar { \mathbf { x } } ) ) = \mathcal { F } ( f ( \mathbf { x } - w ) )$ , for $\boldsymbol { v } \in \mathbb { R } ^ { 2 }$ . Thus, for the first term,
$$\mathcal { F } ^ { - 1 } ( \mathcal { F } ( I ) _ { 0 } e ^ { - ( i < \xi , w > ) t } ) = I _ { 0 } ( \mathbf { x } - w )$$
For the second term, we use the fact that the Fourier Transform of a Gaussian function also is a Gaussian function, i.e. $\begin{array} { r } { \mathcal { F } \big ( \frac { 1 } { 2 \pi \sigma ^ { 2 } } e ^ { - \frac { 1 } { 2 \sigma ^ { 2 } } \| \mathbf { x } \| ^ { 2 } } \big ) = e ^ { - \frac { 1 } { 2 } \sigma ^ { 2 } \| \boldsymbol { \xi } \| ^ { 2 } } } \end{array}$ . Identifying $\sigma ^ { 2 }$ with $2 D t$ , we have:
$$\mathcal { F } ^ { - 1 } ( e ^ { - D t \| \boldsymbol { \xi } \| ^ { 2 } } ) = \frac { 1 } { 4 \pi D t } e ^ { - \frac { 1 } { 4 D t } \| \mathbf { x } \| ^ { 2 } }$$
As has been stated above, the solution is a convolution of both previously calculated terms:
$$\begin{array} { r } { I ( \mathbf { x } , t ) = \displaystyle \int _ { \mathbb { R } ^ { 2 } } \frac { 1 } { 4 \pi D t } e ^ { - \frac { 1 } { 4 D t } \| \mathbf { y } \| ^ { 2 } } I _ { 0 } ( \mathbf { x } - w - \mathbf { y } ) d y } \\ { = \displaystyle \int _ { \mathbb { R } ^ { 2 } } \frac { 1 } { 4 \pi D t } e ^ { - \frac { 1 } { 4 D t } \| \mathbf { x } - w - \mathbf { y } \| ^ { 2 } } I _ { 0 } ( \mathbf { y } ) d \mathbf { y } } \end{array}$$
# B ON THE GENERALIZATION IN SPACE AND TIME
The ability of the model to adapt to other conditions should be evaluated on other regions. This, however, requires a complete study by itself and is beyond the scope of this paper. We, however, present below complementary experiments aimed at assessing the potential of the proposed model for forecasting SST on sequences distant in time and space from the ones used for training.
# B.1 TEMPORAL DIMENSION
In section 4, training has been performed on data from 2006 - 2015 and testing on the period 2016- 2017. In order to provide some indication of the model behavior on more distant time intervals between train and test data, we have performed experiments using the same regions (17 to 20) as in section 4, but using the period 2011 to 2017 for training and period 2006 to 2010 for testing. Figure B.1 shows the MSE curve on this test set, each point corresponding to the mean MSE on predictions performed on 6 days ahead the current date. The most important conclusion is probably that the MSE error remains in the same range for all these years. All the yearly error curve show a clear seasonal phenomenon with a higher prediction error during summer. A similar behavior has been observed when exchanging train and test data.
 Figure 6: Evaluation of our model’s accuracy in time on data from 2006 to 2010 using data from 2011 to 2017 for training. Regions 17 to 20 were used for both periods. Each day, we produce daily forecasts for 6 days ahead and calculate the associated mean square error.
# B.2 SPATIAL DIMENSION
In the experiments, the models have been trained and evaluated on selected regions (numbered 17 to 20 in Figure 4.1), considered as the most interesting for the observed dynamics.
<table><tr><td rowspan=1 colspan=1></td><td rowspan=1 colspan=1>Test Regions 17&18</td><td rowspan=1 colspan=1>Test Regions 8&9</td></tr><tr><td rowspan=1 colspan=1>Model trained on Regions 17 & 18</td><td rowspan=1 colspan=1>1.43</td><td rowspan=1 colspan=1>1.22</td></tr><tr><td rowspan=1 colspan=1>Model trained on Regions 8&9</td><td rowspan=1 colspan=1>1.90</td><td rowspan=1 colspan=1>1.19</td></tr></table>
Table 2: Evaluation of our model’s spatial generalization ability. We train our model on two distinct regions and calculate the MSE on both regions for each trained model.
We describe below some results providing indications on how the model performs on regions different from the training ones. For these experiments, the model has been trained on regions 17 and 18 in Figure 4.1 and tested on two other regions (regions 8 and 9), and vice versa (trained on 8 and 9 and tested on 17 and 18). The two couples of regions have been selected so as to have different latitude and longitude. The underlying physical processes generating the data are known to be different in these regions: the overall motion in regions 17 and 18 is greater, and the difference between extreme temperature is larger, compared to regions 8 and 9. Experimental conditions are similar to the one described in section 4, i.e. 2006-2015 have been used for training and 2016-1017 for testing.
Results in Table B.2 show that the model generalizes reasonably well to unseen data from distant spatial regions, with a slight decrease in performance when training and test regions do not correspond. The performance loss is 0.47 for regions (17, 18) which show a strong dynamics, whereas it is only 0.03 for regions (8, 9) for which the dynamics are more stable. Most notably, MSE performance depends more on the region itself than on the train/ test conditions. Error is always higher in regions with strong dynamics (17, 18) than on more stable regions (8, 9) whatever the train/ test conditions are. Note that to further improve the results on distant data, it is possible to fine-tune the model using data from the studied regions.
 Figure 7: Output for the 6 of May to the 9 of May 2016, Output , From top to bottom: target, our model prediction, our model flow
 Figure 8: Output for the 6 of January to the 9 of January 2016. From top to bottom: target, our model prediction, our model flow123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288# DATA AUGMENTATION INSTEAD OFEXPLICIT REGULARIZATION
Anonymous authors Paper under double-blind review
# ABSTRACT
Modern deep artificial neural networks have achieved impressive results through models with very large capacity—compared to the number of training examples— that control overfitting with the help of different forms of regularization. Regularization can be implicit, as is the case of stochastic gradient descent or parameter sharing in convolutional layers, or explicit. Most common explicit regularization techniques, such as dropout and weight decay, reduce the effective capacity of the model and typically require the use of deeper and wider architectures to compensate for the reduced capacity. Although these techniques have been proven successful in terms of results, they seem to waste capacity. In contrast, data augmentation techniques reduce the generalization error by increasing the number of training examples and without reducing the effective capacity. In this paper we systematically analyze the effect of data augmentation on some popular architectures and conclude that data augmentation alone—without any other explicit regularization techniques—can achieve the same performance or higher as regularized models, especially when training with fewer examples.
# 1 INTRODUCTION
Regularization plays a central role in machine learning. Loosely defined, regularization is any modification applied to a learning algorithm that helps prevent overfitting and improve generalization. Whereas in simple machine learning algorithms the sources of regularization can be easily identified as explicit terms in the objective function, in modern deep neural networks the sources of regularization are multiple and some of them are not explicit, but implicit.
Although the terms explicit and implicit regularization have been used recently in the literature (Neyshabur et al., 2014; Zhang et al., 2017), their distinction is rather subjective. We propose the following definitions:
• Explicit regularization techniques are those specifically and solely designed to constrain the effective capacity of a given model in order to reduce overfitting. Furthermore, explicit regularizers are not a structural or essential part of the network architecture, the data or the learning algorithm and can typically be added or removed easily. Implicit regularization is the reduction of the generalization error or overfitting provided by characteristics of the network architecture, the training data or the learning algorithm, which are not specifically designed to constrain the effective capacity of the given model.
Examples of explicit regularizers are weight decay (Hanson & Pratt, 1989), which penalizes large parameters; dropout (Srivastava et al., 2014), which randomly removes a fraction of the neural connections during training; or stochastic depth (Huang et al., 2016), which drops whole layers instead. Implicit regularization effects are provided by the popular stochastic gradient descent (SGD) algorithm, which tends to converge to solutions with small norm (Zhang et al., 2017); convolutional layers, which impose parameter sharing based on prior knowledge about the data; batch normalization (Ioffe & Szegedy, 2015), whose main goal is reducing the the internal covariate shift, but also implicitly regularizes the model due to the noise in the batch estimates for mean and variance.
Driven by the efficient use and development of GPUs, much research efforts have been devoted to finding ways of training deeper and wider networks of larger capacity (Simonyan & Zisserman,
2014; He et al., 2016; Zagoruyko & Komodakis, 2016), Ironically, their effective capacity is eventually reduced in practice by the use of weight decay and dropout, among other explicit regularizers. It is known, for instance, that the gain in generalization provided by dropout comes at the cost of using larger models and training for longer (Goodfellow et al., 2016). Hence, it seems that with such an approach deep networks are wasting capacity (Dauphin & Bengio, 2013). As a matter of fact, unlike traditional machine learning models, deep neural networks seem not to need explicit regularizers to generalize well, as recently suggested by Zhang et al. (2017).
One popular technique that also improves generalization is data augmentation. Importantly, it differs from explicit regularizers mainly in that it does not reduce the effective capacity of the model. Data augmentation is a very old practice in machine learning (Simard et al., 1992) and it has been identified as a critical component of many models (Ciresan et al., 2010; Krizhevsky et al., 2012; LeCun et al., 2015). However, although some authors have reported the impact of data augmentation on the performance of their models and, in some cases, a comparison of different amount of augmentation (Graham, 2014) the literature lacks, to our knowledge, a systematic analysis of the impact of data augmentation on deep neural networks compared to the most popular regularization techniques.
# 1.1 OUR CONTRIBUTIONS
In this paper, we systematically analyze the role of data augmentation in deep neural networks for object recognition, compare it to some popular explicit regularization techniques, discuss its relationship with model capacity and test its potential to enhance learning from less training data and adapt to different architectures.
# 1.1.1 DATA AUGMENTATION AND EXPLICIT REGULARIZATION
Zhang et al. (2017) recently raised the thought-provoking idea that explicit regularization may improve generalization performance, but is neither necessary nor by itself sufficient for controlling generalization error. The authors came to this conclusion from the observation that turning off the explicit regularizers of a model does not prevent the model from generalizing—although the performance does become degraded. This contrasts with traditional machine learning involving convex optimization, where regularization is necessary to avoid overfitting and generalize.
However, Zhang et al. (2017) consider data augmentation an explicit form of regularization comparable to weight decay and dropout. We argue instead that data augmentation deserves a different classification due to some fundamental properties: Notably, data augmentation does not reduce the effective capacity of the model. Explicit regularizers are often used to counteract overfitting, but as a side effect the architecture needs to be larger and the training longer (Krizhevsky et al., 2012; Goodfellow et al., 2016). In contrast, data augmentation increases the number of training examples— although not in an independently distributed way—and the robustness against input variability. This has the welcome side-effect of implicitly regularizing the model and improving generalization.
Here, we build upon some of the ideas and procedures from Zhang et al. (2017) and perform some experiments to assess the role of data augmentation in deep neural networks and in particular in contrast to explicit regularizers (weight decay and dropout). In our experiments, we consider two levels of augmentation, light and heavier, as well as no augmentation at all. Then, we test them on two popular successful network architectures: the relatively shallow all convolutional network net (Springenberg et al., 2014) and the deeper wide residual network (Zagoruyko & Komodakis, 2016), trained on CIFAR-10 and CIFAR-100 (Krizhevsky & Hinton, 2009), with and and without explicit regularization. Our central conclusion can be summarized as:
In a deep convolutional neural network trained with sufficient level of data augmentation, optimized by SGD, explicit regularizers (weight decay and dropout) might not provide any additional generalization improvement.
# 1.1.2 DATA AUGMENTATION AND TRAINING WITH FEWER EXAMPLES
Augmented data might be regarded as artificial and very similar to the source examples, therefore with limited contribution for making a network learn more useful representations. However, it has proven to be very useful in extreme cases such as one-shot learning, where only one or few training examples are available (Vinyals et al., 2016).
In order to provide a better insight of the usefulness of data augmentation, we train the networks with only $80 \%$ , $50 \%$ , $10 \%$ and $1 \%$ of the available training data and test the effect of data augmentation, again in contrast to explicit regularizers. The summary of our findings in this regard can be summarized as:
When a deep neural network is trained with a subset of the training data, heavier data augmentation achieves a smaller gap with respect to the baseline model, especially if no explicit regularization is used. Thus, data augmentation seems to serve as true data to a great extent.
# 1.1.3 DATA AUGMENTATION AND ADAPTABILITY
One of the disadvantages of explicit regularization is that the parameters highly depend on the network architecture, the amount of training data and other factors. Therefore, if the architecture or other factors change, one has to tune the regularization hyperparameters to achieve comparable results. In order to analyze how data augmentation adapts to different architectures, we test several augmentation schemes on shallower and deeper versions of the network, with and without explicit regularization. Our finding is the following:
Data augmentation easily adapts to different depths without tuning its parameters. If no explicit regularization is used, we observe that a shallower network achieves slightly worse results and a deeper architecture achieves better results.
# 1.2 RELATED WORK
Regularization is a central research topic in machine learning as it is a key component for ensuring good generalization (Girosi et al., 1995; Muller, 2012). In the case of deep learning, where networks ¨ tend to have several orders of magnitude more parameters than training examples, statistical learning theory (Vapnik & Chervonenkis, 1971) indicates that regularization becomes even more crucial. Accordingly, a myriad of tools and techniques have been proposed as regularizers: early stopping (Plaut et al., 1986), weight decay (Hanson & Pratt, 1989) and other $L ^ { p }$ penalties, dropout (Srivastava et al., 2014) and stochastic depth (Huang et al., 2016), to name a few examples. Besides, other successful techniques have been studied for their regularization effect, despite not being explicitly intended as such. That is the case of unsupervised pre-training (Erhan et al., 2010), multi-task learning (Caruana, 1998), convolutional layers (LeCun et al., 1990), batch normalization (Ioffe & Szegedy, 2015) or adversarial training (Szegedy et al., 2013).
Data augmentation is another almost ubiquitous technique in deep learning, especially for computer vision tasks, which can be regarded as an implicit regularizer because it improves regularization. It was already used in the late 80’s and early 90’s for handwritten digit recognition (Simard et al., 1992) and it has been identified as a very important element of many modern successful models, like AlexNet (Krizhevsky et al., 2012), All-CNN (Springenberg et al., 2014) or ResNet (He et al., 2016), for instance. In some cases, data augmentation has been applied heavily with successful results (Wu et al., 2015). In domains other than computer vision, data augmentation has also been proven effective, for example in speech recognition (Jaitly & Hinton, 2013), music source separation (Uhlich et al., 2017) or text categorization (Lu et al., 2006).
Bengio et al. (2011) focused on the importance of data augmentation for recognizing handwritten digits (MNIST) through greedy layer-wise unsupervised pre-training (Bengio et al., 2007). The main conclusion of that work was that deeper architectures benefit more from data augmentation than shallow networks. Zhang et al. (2017) included data augmentation in their analysis of the role of regularization in the generalization of deep networks, although it was considered an explicit regularizer similar to weight decay and dropout. A few works have reported the performance of their models when trained with different types of data augmentation levels, as is the case of Graham (2014). Recently, the deep learning community seems to have become more aware of the importance of data augmentation and new techniques, such as cutout (DeVries & Taylor, 2017a) or augmentation in the feature space (DeVries & Taylor, 2017b), have been proposed. Very interestingly, models that automatically learn useful data transformations have also been published recently (Hauberg et al., 2016; Lemley et al., 2017; Ratner et al., 2017).
# 2 EXPERIMENTS AND RESULTS
This section describes the experimental setup for systematically analyzing the role of data augmentation in modern deep neural networks and presents the most relevant and interesting results.
# 2.1 SETUP
All the experiments are performed on the neural networks API Keras (Chollet et al., 2015) on top of TensorFlow (Abadi et al., 2015) and on a single GPU NVIDIA GeForce GTX 1080 Ti.
# 2.1.1 NETWORK ACRCHITECTURES
We perform our experiments on two popular architectures that have achieved successful results in object recognition tasks: the all convolutional network, All-CNN (Springenberg et al., 2014) and the wide residual network, WRN (Zagoruyko & Komodakis, 2016). We choose these networks not only because of their effectiveness, but also because they have simple architectures, which is convenient for drawing clearer conclusions. All-CNN has a relatively small number of layers and parameters, whereas WRN is rather deep and has many more parameters.
All convolutional net. All-CNN consists of only convolutional layers with ReLU activations (Glorot et al., 2011), it is relatively shallow (12 layers) and has about $1 . 3 { \bf M }$ parameters. The architecture can be described as follows:
where $K C D ( S )$ is a $D \times D$ convolutional layer with $K$ channels and stride $S$ , followed by batch normalization and a ReLU non-linearity. $N . C l .$ is the number of classes and Gl.Avg. refers to global average pooling. The network is identical to the All-CNN-C architecture in the original paper, except for the introduction of the batch normalization layers. We set the same training parameters as in the original paper in the cases they are reported. Specifically, in all experiments the All-CNN networks are trained using stochastic gradient descent with batch size of 128, during 350 epochs, with fixed momentum 0.9 and learning rate of 0.01 multiplied by 0.1 at epochs 200, 250 and 300. The kernel parameters are initialized according to the Xavier uniform initialization (Glorot & Bengio, 2010).
Wide Residual Network. WRN is a modification of ResNet (He et al., 2016) that achieves better performance with fewer layers, but more units per layer. Although in the original paper several combinations of depth and width are tested, here we choose for our experiments the WRN-28-10 version (28 layers and about $3 6 . 5 \mathrm { ~ M ~ }$ parameters), which is reported to achieve the best results on CIFAR. It has the following architecture:
# 16C3(1)–4×160R–4×320R–4×640R–BN–ReLU–Avg.(8)–FC–Softmax
where $K \mathbf { R }$ is a residual block with residual function BN–ReLU–KC3(1)–BN–ReLU–KC3(1). BN is batch normalization, Avg.(8) is spatial average pooling of size 8 and FC is a fully connected layer. The stride of the first convolution within the residual blocks is 1 except in the first block of the series of 4, where it is 2 to subsample the feature maps. As before, we try to replicate the training parameters of the original paper: we use SGD with batch size of 128, during 200 epochs, with fixed Nesterov momentum 0.9 and learning rate of 0.1 multiplied by 0.2 at epochs 60, 120 and 160. The kernel parameters are initialized according to the He normal initialization (He et al., 2015).
# 2.1.2 DATA
We perform the experiments on the two highly benchmarked data sets CIFAR-10 and CIFAR-100 (Krizhevsky & Hinton, 2009), which are labeled according to 10 and 100 object classes respectively. Both data sets consist of $6 0 , 0 0 0 \ 3 2 \mathrm { ~ x ~ } \ 3 2$ color images split into 50,000 for training and 10,000 for testing. In all our experiments, the input images are fed into the network with pixel values normalized to the range $[ 0 , 1 ]$ and with floating precision of 32 bits. So as to analyze the role of data augmentation, we test the network architectures presented above with two different augmentation schemes as well as with no data augmentation at all:
 Figure 1: Random images from CIFAR10 transformed according to the augmentation schemes used in our experiments, choosing extreme values from the augmentation parameters. Note that these images are very unlikely to be used during training.
Table 1: Description and range of possible values of the parameters used for the heavier augmentation. $B ( p )$ denotes a Bernouilli distribution and $\textstyle { \mathcal { U } } ( a , b )$ a uniform distribution.
<table><tr><td>Parameter</td><td>Description</td><td>Range</td></tr><tr><td></td><td>Horizontal flip</td><td>1-2B(0.5)</td></tr><tr><td>fh t</td><td>Horizontal translation</td><td>u(-0.1,0.1)</td></tr><tr><td>ty</td><td>Vertical translation</td><td>u(-0.1,0.1)</td></tr><tr><td></td><td>Horizontal scale</td><td>u(0.85,1.15)</td></tr><tr><td>2x</td><td>Vertical scale</td><td>u(0.85,1.15)</td></tr><tr><td>福</td><td>Rotation angle</td><td></td></tr><tr><td>?</td><td>Shear angle</td><td>(22.5,22.5)</td></tr><tr><td>?</td><td>Contrast</td><td>u(-0.15,0.15)</td></tr><tr><td>8</td><td></td><td>u(0.5,1.5)</td></tr><tr><td></td><td>Brightness</td><td>U(-0.25,0.25)</td></tr></table>
Light augmentation. This scheme is adopted from the literature, for example (Goodfellow et al., 2013; Springenberg et al., 2014), and performs only horizontal flips and horizontal and vertical translations of $10 \%$ of the image size.
Heavier augmentation. This scheme performs a larger range of affine transformations, as well as contrast and brightness adjustment:
• Affine transformatio $\operatorname { n s : } \left[ { y ^ { \prime } } \right] = { \left[ \begin{array} { l l l } { f _ { h } z _ { x } \cos ( \theta ) } & { - z _ { y } \sin ( \theta + \phi ) } & { t _ { x } } \\ { z _ { x } \sin ( \theta ) } & { \ : z _ { y } \cos ( \theta + \phi ) } & { t _ { y } } \\ { 0 } & { 0 } & { 1 } \end{array} \right] } { \left[ \begin{array} { l } { x } \\ { y } \\ { 1 } \end{array} \right] }$ • Contrast adjustment: $x ^ { \prime } = \gamma ( x - { \overline { { x } } } ) + { \overline { { x } } }$ • Brightness adjustment: $x ^ { \prime } = x + \delta$
The description and range of values of the parameters are specified in Table 1 and some examples of transformed images with extreme values of the parameters are provided in Figure 1. The choice of the parameters is arbitrary and the only criterion was that the objects are still recognizable, by visually inspecting a few images. We deliberately avoid designing a particularly successful scheme.
# 2.2 A SUBSTITUTE FOR EXPLICIT REGULARIZATION
 Figure 2: Test accuracy of the networks All-CNN and WRN on CIFAR-10 and CIFAR-100, trained without any explicit regularization (upper groups of bars) and with both dropout and weight decay (lower groups), as in the original papers. The different bars represent different models (original, deeper and shallower) and different percentage of training images (100, 50 and $10 \%$ ). The different shades within each bar show the result of training with each data augmentation scheme (none, light and heavier). In most cases, the models trained without regularization achieve the same performance as the explicitly regularized models, or even significantly higher accuracy, as is the case of the shallower and deeper models and when training with fewer examples.
In order to analyze the role of data augmentation and test the hypothesis that it might serve as a substitute for explicit regularization techniques, we first try to replicate the results of All-CNN and WRN provided in the original papers, achieved with both weight decay and dropout. Then, we train the models without weight decay and finally without neither weight decay nor dropout. We test all these different models with the three data augmentation schemes: light, heavier and no augmentation. Additionally, we test the effect of removing the batch normalization (see Appendix A).
As reported by previous works (Krizhevsky et al., 2012; Simonyan & Zisserman, 2014), when the models are trained with data augmentation, at test time slightly better results are obtained by augmenting the test set as well. Therefore, the test accuracy reported here comes from averaging the softmax posteriors over 10 random light augmentations.
The main results of the different experiments are shown in Figure 2 (blue bars) and the full report of all experiments can be found in Table 2 of the Appendix A. As expected, both explicit regularization —weight decay and dropout—and data augmentation are successful in reducing the generalization error. However, some relevant observations can be made. Most notably, it seems that data augmentation alone is able to regularize the model as much as in combination with weight decay and dropout and in some cases it clearly achieves better performance, as in the case of All-CNN. Another observation is that without explicit regularization, heavier augmentation always provides better results than light augmentation, whereas with regularization this effect is counterintuitively not consistent.
# 2.3 FEWER AVAILABLE TRAINING EXAMPLES
We extend the analysis of the data augmentation role by training the same networks with fewer training examples. Similarly, we also analyze the combination of data augmentation and explicit regularization in this case. All models are trained with the same random subset of data and tested in the same test set as the previous experiments in order to enable fairer comparisons. Figure 2 (green and red bars) shows the main results with $50 \%$ and $10 \%$ of the available data and the full report, as well as additional experiments with $80 \%$ and $1 \%$ of the data, is given in Table 3 of the Appendix A.
As expected, the performance decays with the number of available training examples. However, as the level of data augmentation increases, the difference with respect to the baseline performance (by training with all examples) significantly decreases. This indicates that data augmentation serves, to a great extent, as true data. Therefore, this confirms the effectiveness of this technique when not many training examples are available.
Furthermore, in all the experiments with a reduced set of the available data, the observations presented above become even clearer. It seems that if explicit regularization is removed, data augmentation alone better resists the lack of data. This can probably be explained by the fact that explicit regularization reduces the effective capacity, preventing the model from taking advantage of the augmented data.
# 2.4 SHALLOWER AND DEEPER ARCHITECTURES
Finally, we perform the same experiments on shallower and deeper versions of All-CNN, so as to analyze how data augmentation and regularization are handled by architectures of different depth. We test a shallower network with 9 layers instead of 12 and $3 7 4 \mathrm { K }$ parameters instead of $1 . 3 { \bf M }$ :
and a deeper network with 15 layers and $2 . 4 \mathbf { M }$ parameters:
2×96C3(1)–96C3(2)–2×192C3(1)–192C3(2)–2×192C3(1)–192C3(2)–192C3(1)–192C1(1) –N.Cl.C1(1)–Gl.Avg.–Softmax
The results in Figure 2 (purple and brown bars) together with the detailed report of results in Table 4 of the Appendix A show that if the explicit regularization is removed and data augmentation applied, the shallower network achieves slightly worse results and the deeper network slightly better results than the original network. This behavior can be explained by the reduced or increased depth and number of parameters. However, with the explicit regularization active, the results dramatically decrease in both cases. The most probable explanation is that the regularization parameters are not adjusted to the architecture, whereas in the original models the parameters where finely tuned by the authors to obtain state of the art results. This highlights another important advantage of data augmentation: the adjustment of its parameters depends mostly on the training data, rather than on the particular architecture, which offers much more flexibility compared to using explicit regularization. In Appendix B we provide ananalysis of the norm of the weight matrices that helps shed some more light on how the different levels of regularization and data augmentation affect the learned models.
# 3 DISCUSSION AND CONCLUSION
In this work, we have presented a systematic analysis of the role of data augmentation in deep neural networks for object recognition, focusing on the comparison with popular techniques of explicit regularization. We have built upon the work by Zhang et al. (2017), where the authors concluded that explicit regularization is not necessary, although it improves generalization performance. Here, we have shown that it is not only unnecessary, but also that the generalization gain provided by explicit regularization can be achieved by data augmentation alone.
The importance of these results lies in the fact that explicit regularization is the standard tool to enable the generalization of most machine learning methods. However, according to Zhang et al. (2017), explicit regularization plays a different role in deep learning, not explained by statistical learning theory (Vapnik & Chervonenkis, 1971). We argue instead that the theory still holds in deep learning, but one has to properly consider the crucial role of implicit regularization. Explicit regularization is no longer necessary because its contribution is already provided by the many elements that implicitly regularize the models: SGD, convolutional layers or data augmentation, among others.
Whereas explicit regularizers, such as weight decay and dropout, succeed in mitigating overfitting by blindly reducing the effective capacity of a model, implicit regularization operates more effectively at capturing important characteristics of the data (Neyshabur et al., 2014). For instance, convolutional layers successfully reduce the capacity of a model by imposing a parameter sharing strategy that incorporates some essential prior domain knowledge, as well as data augmentation by transforming the training examples in a meaningful and plausible way.
In this regard it is worth highlighting some of the advantages of data augmentation: Not only does it not reduce the effective capacity of the model, but it increases the number of training examples, which, according to statistical learning theories, reduces the generalization error. Furthermore, if the transformations are such that they reflect plausible variations of the real objects, it increases the robustness of the model and it can be regarded as a data-dependent prior, similarly to unsupervised pre-training (Erhan et al., 2010). Besides, unlike explicit regularization techniques, data augmentation does not increase the computational complexity because it can be performed in parallel to the gradient updates on the CPU, making it a computationally free operation. Finally, in Section 2.4 we have shown how data augmentation transparently adapts to architectures of different depth, whereas explicitly regularized models need manual adjustment of the regularization parameters.
Deep neural networks can especially benefit from data augmentation because they do not rely on precomputed features and because the large number of parameters allows them to shatter the augmented training set. Actually, if data augmentation is included for training, we might have to reconsider whether deep learning operates in an overparameterization regime, since the model capacity should take into account the amount of training data, which is exponentially increased by augmentation.
Some argue that despite these advantages, data augmentation is a highly limited approach because it depends on some prior expert knowledge and it cannot be applied to all domains. However, we argue instead that expert knowledge should not be disregarded but exploited. A single data augmentation scheme can be designed for a broad family of data, e.g. natural images, and effectively applied to a broad set of tasks, e.g. object recognition, segmentation, localization, etc. Besides, some recent works show that it is possible to learn the data augmentation strategies (Lemley et al., 2017; Ratner et al., 2017) and future research will probably yield even better results in different domains.
Finally, it is important to note that, due to computational limitations, we have performed a systematic analysis only on CIFAR-10 and CIFAR-100, which consist of very small images. These data sets do not allow performing more agressive data augmentation since the low resolution images can easily show distortions that hinder the recognition of the object. However, some previous works (Graham, 2014; Springenberg et al., 2014) have shown impressive results by performing heavier data augmentation on higher resolution versions on CIFAR-10. We plan to extend this analysis to higher resolution data sets such as ImageNet and one could expect even more benefits from data augmentation compared to explicit regularization techniques.
# ACKNOWLEDGMENTS
This project has received funding from the European Union’s Horizon 2020 research and innovation programme under the Marie Sklodowska-Curie grant agreement No 641805.
# 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 http://tensorflow.org/. Software available from tensorflow.org.
Yoshua Bengio, Pascal Lamblin, Dan Popovici, and Hugo Larochelle. Greedy layer-wise training of deep networks. In Advances in neural information processing systems, pp. 153–160, 2007.
Yoshua Bengio, Arnaud Bergeron, Nicolas Boulanger-Lewandowski, Thomas Breuel, Youssouf Chherawala, Moustapha Cisse, Dumitru Erhan, Jeremy Eustache, Xavier Glorot, Xavier Muller, et al. Deep learners benefit more from out-of-distribution examples. In Proceedings of the Fourteenth International Conference on Artificial Intelligence and Statistics, pp. 164–172, 2011.
Rich Caruana. Multitask learning. In Learning to learn, pp. 95–133. Springer, 1998.
Franc¸ois Chollet et al. Keras. https://github.com/fchollet/keras, 2015.
Dan Claudiu Ciresan, Ueli Meier, Luca Maria Gambardella, and Jurgen Schmidhuber. Deep big¨ simple neural nets excel on handwritten digit recognition. arXiv preprint arXiv:1003.0358, 2010.
Yann N Dauphin and Yoshua Bengio. Big neural networks waste capacity. In International Conference on Learning Representations, ICLR, arXiv: 1301.3583, 2013.
Terrance DeVries and Graham W Taylor. Improved regularization of convolutional neural networks with cutout. arXiv preprint arXiv:1708.04552, 2017a.
Terrance DeVries and Graham W Taylor. Dataset augmentation in feature space. In International Conference on Learning Representations, ICLR, arXiv:1702.05538, 2017b.
Dumitru Erhan, Yoshua Bengio, Aaron Courville, Pierre-Antoine Manzagol, Pascal Vincent, and Samy Bengio. Why does unsupervised pre-training help deep learning? Journal of Machine Learning Research, 11(Feb):625–660, 2010.
Federico Girosi, Michael Jones, and Tomaso Poggio. Regularization theory and neural networks architectures. Neural computation, 7(2):219–269, 1995.
Xavier Glorot and Yoshua Bengio. Understanding the difficulty of training deep feedforward neural networks. In JMLR W&CP: Proceedings of the Thirteenth International Conference on Artificial Intelligence and Statistics (AISTATS 2010), volume 9, pp. 249–256, may 2010.
Xavier Glorot, Antoine Bordes, and Yoshua Bengio. Deep sparse rectifier neural networks. In Proceedings of the Fourteenth International Conference on Artificial Intelligence and Statistics, pp. 315–323, 2011.
Ian Goodfellow, Yoshua Bengio, and Aaron Courville. Deep learning. MIT press, 2016.
Ian J. Goodfellow, David Warde-Farley, Mehdi Mirza, Aaron C. Courville, and Yoshua Bengio. Maxout networks. In Proceedings of the 30th International Conference on Machine Learning, ICML, pp. 1319–1327, 2013.
Benjamin Graham. Fractional max-pooling. arXiv preprint arXiv:1412.6071, 2014.
Stephen Jose Hanson and Lorien Y Pratt. Comparing biases for minimal network construction with´ back-propagation. In Advances in neural information processing systems, pp. 177–185, 1989.
Søren Hauberg, Oren Freifeld, Anders Boesen Lindbo Larsen, John Fisher, and Lars Hansen. Dreaming more data: Class-dependent distributions over diffeomorphisms for learned data augmentation. In Artificial Intelligence and Statistics, pp. 342–350, 2016.
Kaiming He, Xiangyu Zhang, Shaoqing Ren, and Jian Sun. Delving deep into rectifiers: Surpassing human-level performance on imagenet classification. In Proceedings of the IEEE international conference on computer vision, pp. 1026–1034, 2015.
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.
Gao Huang, Yu Sun, Zhuang Liu, Daniel Sedra, and Kilian Q Weinberger. Deep networks with stochastic depth. In European Conference on Computer Vision, pp. 646–661. Springer, 2016.
Sergey Ioffe and Christian Szegedy. Batch normalization: Accelerating deep network training by reducing internal covariate shift. In International Conference on Machine Learning, pp. 448–456, 2015.
Navdeep Jaitly and Geoffrey E Hinton. Vocal tract length perturbation (vtlp) improves speech recognition. In Proc. ICML Workshop on Deep Learning for Audio, Speech and Language, pp. 625– 660, 2013.
Alex Krizhevsky and Geoffrey Hinton. Learning multiple layers of features from tiny images. Technical report, University of Toronto, 2009.
Alex Krizhevsky, Ilya Sutskever, and Geoffrey E Hinton. Imagenet classification with deep convolutional neural networks. In Advances in neural information processing systems, pp. 1097–1105, 2012.
Yann LeCun, Bernhard E Boser, John S Denker, Donnie Henderson, Richard E Howard, Wayne E Hubbard, and Lawrence D Jackel. Handwritten digit recognition with a back-propagation network. In Advances in neural information processing systems, pp. 396–404, 1990.
Yann LeCun, Yoshua Bengio, and Geoffrey Hinton. Deep learning. Nature, 521(7553):436–444, 2015.
Joseph Lemley, Shabab Bazrafkan, and Peter Corcoran. Smart augmentation-learning an optimal data augmentation strategy. IEEE Access, 2017.
Xinghua Lu, Bin Zheng, Atulya Velivelli, and ChengXiang Zhai. Enhancing text categorization with semantic-enriched representation and training data augmentation. Journal of the American Medical Informatics Association, 13(5):526–535, 2006.
Klaus-Robert Muller. Regularization techniques to improve generalization. In ¨ Neural Networks: Tricks of the Trade, pp. 49–51. Springer, 2012.
Behnam Neyshabur, Ryota Tomioka, and Nathan Srebro. In search of the real inductive bias: On the role of implicit regularization in deep learning. In International Conference on Learning Representations, ICLR, arXiv: 1412.6614, 2014.
D. C. Plaut, S. J. Nowlan, and G. E Hinton. Experiments on learning by back propagation. ERIC, 1986.
Alexander J Ratner, Henry R Ehrenberg, Zeshan Hussain, Jared Dunnmon, and Christopher Re.´ Learning to compose domain-specific transformations for data augmentation. In Advances in Neural Information Processing Systems, pp. 3239–3249, 2017.
Patrice Simard, Bernard Victorri, Yann LeCun, and John Denker. Tangent prop-a formalism for specifying selected invariances in an adaptive network. In Advances in neural information processing systems, pp. 895–903, 1992.
Karen Simonyan and Andrew Zisserman. Very deep convolutional networks for large-scale image recognition. arXiv preprint arXiv:1409.1556, 2014.
Jost Tobias Springenberg, Alexey Dosovitskiy, Thomas Brox, and Martin Riedmiller. Striving for simplicity: The all convolutional net. In International Conference on Learning Representations, ICLR, arXiv:1412.6806, 2014.
Nitish Srivastava, Geoffrey E Hinton, Alex Krizhevsky, Ilya Sutskever, and Ruslan Salakhutdinov. Dropout: a simple way to prevent neural networks from overfitting. 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.
Stefan Uhlich, Marcello Porcu, Franck Giron, Michael Enenkl, Thomas Kemp, Naoya Takahashi, and Yuki Mitsufuji. Improving music source separation based on deep neural networks through data augmentation and network blending. Submitted to ICASSP, 2017.
V. N. Vapnik and A. Y. Chervonenkis. On the uniform convergence of relative frequencies of events to their probabilities. Theory of Probab. and its Applications, 16(2):264–280, 1971.
Oriol Vinyals, Charles Blundell, Tim Lillicrap, koray kavukcuoglu, and Daan Wierstra. Matching networks for one shot learning. In Advances in Neural Information Processing Systems 29, pp. 3630–3638, 2016.
Ren Wu, Shengen Yan, Yi Shan, Qingqing Dang, and Gang Sun. Deep image: Scaling up image recognition. arXiv preprint arXiv:1501.02876, 7(8), 2015.
Sergey Zagoruyko and Nikos Komodakis. Wide residual networks. In Proceedings of the British Machine Vision Conference, BMVC, pp. 87.1–87.12, 2016.
Chiyuan Zhang, Samy Bengio, Moritz Hardt, Benjamin Recht, and Oriol Vinyals. Understanding deep learning requires rethinking generalization. In International Conference on Learning Representations, ICLR, arXiv:1611.03530, 2017.
# A DETAILED AND EXTENDED EXPERIMENTAL RESULTS
This appendix details the results of the main experiments shown in Figure 2 and provides the results of many other experiments. For example, the results of the models trained with dropout, but without weight decay and the results of training with $80 \%$ and $1 \%$ of the data are not shown in Figure 2 in order not to clutter the visualization.
Additionally, for most experiments we train a version of the network without batch normalization. These results are provided within brackets in the tables. Note that the original All-CNN results published by Springenberg et al. (2014) did not include batch normalization. In the case of WRN, we remove all batch normalization layers except the top-most one, before the spatial average pooling, since otherwise many models would not converge.
Table 2: Test accuracy of the networks All-CNN and WRN on CIFAR-10 and CIFAR-100, comparing the performance with and without explicit regularizers and the different augmentation schemes. Results within brackets show the performance of the models without batch normalization
<table><tr><td>Network</td><td>WD</td><td>Dropout</td><td>Aug.scheme</td><td>Test CIFAR-10</td><td>Test CIFAR-100</td></tr><tr><td rowspan="9">All-CNN</td><td>yes</td><td>yes</td><td>no</td><td>90.04 (88.35)</td><td>66.50 (60.54)</td></tr><tr><td>yes</td><td>yes</td><td>light</td><td>93.26 (91.97)</td><td>70.85 (65.57)</td></tr><tr><td>yes</td><td>yes</td><td>heavier</td><td>93.08 (92.44)</td><td>70.59 (68.62)</td></tr><tr><td>no</td><td>yes</td><td>no</td><td>77.99 (87.59)</td><td>52.39 (60.96)</td></tr><tr><td>no</td><td>yes</td><td>light</td><td>77.20 (92.01)</td><td>69.71 (68.01)</td></tr><tr><td>no</td><td>yes</td><td>heavier</td><td>88.29 (92.18)</td><td>70.56 (68.40)</td></tr><tr><td>no</td><td>no</td><td>no</td><td>84.53 (71.98)</td><td>57.99 (39.03)</td></tr><tr><td>no</td><td>no</td><td>light</td><td>93.26 (90.10)</td><td>69.26 (63.00)</td></tr><tr><td>no</td><td>no</td><td>heavier</td><td>93.55 (91.48)</td><td>71.25 (71.46)</td></tr><tr><td rowspan="8">WRN</td><td>yes</td><td>yes</td><td>no</td><td>91.44 (89.30)</td><td>71.67 (67.42)</td></tr><tr><td>yes</td><td>yes</td><td>light</td><td>95.01 (93.48)</td><td>77.58 (74.23)</td></tr><tr><td>yes</td><td>yes</td><td>heavier</td><td>95.60 (94.38)</td><td>76.96 (74.79)</td></tr><tr><td>no</td><td>yes</td><td>no</td><td>91.47 (89.38)</td><td>71.31 (66.85)</td></tr><tr><td>no</td><td>yes</td><td>light</td><td>94.76 (93.52)</td><td>77.42 (74.62)</td></tr><tr><td>no</td><td>yes</td><td>heavier</td><td>95.58 (94.52)</td><td>77.47 (73.96)</td></tr><tr><td>no</td><td>no</td><td>no</td><td>89.56 (85.45)</td><td>68.16 (59.90)</td></tr><tr><td>no</td><td>no</td><td>light</td><td>94.71 (93.69)</td><td>77.08 (75.27)</td></tr><tr><td></td><td>no</td><td>no</td><td>heavier</td><td>95.47 (94.95)</td><td>77.30 (75.69)</td></tr></table>
An important observation from Table 2 is that the interaction of weight decay and dropout is not always consistent, since in some cases better results are obtained with both explicit regularizers active and in other cases, only dropout achieves better generalization. However, the effect of data augmentation seems to be clearer: just some light augmentation achieves much better results than training only with the original data set and performing heavier augmentation almost always further improves the test accuracy, without the need for explicit regularization.
Not surprisingly, batch normalization also contributes to improve the generalization of All-CNN and it seems to combine well with data augmentation. On the contrary, when combined with explicit regularization the results are interestingly not consistent in the case of All-CNN: it seems to improve the generalization of the model trained with both weight decay and dropout, but it drastically reduces the performance with only dropout, in the case of CIFAR-10 and CIFAR-100 without augmentation. A probable explanation is, again, that the regularization hyperparameteres would need to be readjusted with a change of the architecture.
Furthermore, it seems that the gap between the performance of the models trained with and without batch normalization is smaller when they are trained without explicit regularization and when they include heavier data augmentation. This can be observed in both Table 2 and Table 3, which contains the results of the models trained with fewer examples. It is important to note as well the benefits of batch normalization for obtaining better results when training with fewer examples. However, it is surprising that there is only a small drop in the performance of WRN— $9 5 . 4 7 \ \%$ to $9 4 . 9 5 ~ \%$ without regularization— from removing the batch normalization layers of the residual blocks, given
that they were identified as key components for training deep residual networks (He et al., 2016; Zagoruyko & Komodakis, 2016).
Table 3: Test accuracy when training with only $80 \%$ , $50 \%$ , $10 \%$ and $1 \%$ of the available training examples. Results within brackets show the performance of the models without batch normalization
<table><tr><td>Network</td><td>Pct. Data</td><td>Explicit Reg.</td><td>Aug. scheme</td><td>Test CIFAR-10 89.41 (86.61)</td><td>Test CIFAR-100</td></tr><tr><td rowspan="18"></td><td rowspan="4">80 %</td><td>yes yes</td><td>no light</td><td>92.20 (91.25)</td><td>63.93 (52.51) 67.63 (63.24)</td></tr><tr><td>yes</td><td>heavier</td><td>92.83 (91.42)</td><td>68.01 (65.89)</td></tr><tr><td>no</td><td>no</td><td>83.04 (75.00)</td><td>55.78 (35.95)</td></tr><tr><td>no</td><td>light</td><td>92.25 (88.75)</td><td>69.05 (56.81)</td></tr><tr><td rowspan="6"></td><td>no</td><td>heavier</td><td>92.80 (90.55)</td><td>69.40 (63.57)</td></tr><tr><td>yes</td><td>no</td><td>85.88 (82.33)</td><td>58.24 (44.94)</td></tr><tr><td>yes</td><td>light</td><td>90.30 (87.37)</td><td>61.03 (54.68)</td></tr><tr><td></td><td>heavier</td><td>90.09 (88.94)</td><td>63.25 (57.91)</td></tr><tr><td>yes no</td><td>no</td><td>78.61 (69.46)</td><td>48.62 (31.81)</td></tr><tr><td>no</td><td>light</td><td>90.21 (84.38)</td><td>62.83 (47.84)</td></tr><tr><td rowspan="6">All-CNN 10 %</td><td></td><td>heavier</td><td>90.76 (87.44)</td><td>64.41 (55.27)</td></tr><tr><td>no yes</td><td>no</td><td></td><td></td></tr><tr><td></td><td>light</td><td>67.19 (61.61)</td><td>33.77 (19.79) 38.51 (22.79)</td></tr><tr><td>yes</td><td>heavier</td><td>76.03 (69.18)</td><td>38.34 (26.29)</td></tr><tr><td>yes no</td><td></td><td>78.69 (64.14) 60.97 (41.07)</td><td>26.05 (17.55)</td></tr><tr><td>no</td><td>no light</td><td>78.29 (67.65)</td><td>37.84 (24.34)</td></tr><tr><td rowspan="6">1%</td><td>no</td><td>heavier</td><td>79.87 (70.64)</td><td>39.85 (26.31)</td></tr><tr><td>yes</td><td>no</td><td></td><td>9.16 (3.60)</td></tr><tr><td></td><td>light</td><td>27.53 (29.90) 37.18 (26.85)</td><td>9.64 (3.65)</td></tr><tr><td>yes yes</td><td>heavier</td><td>42.73 (26.87)</td><td>9.14 (2.52)</td></tr><tr><td>no</td><td>no</td><td>38.89 (35.68)</td><td>9.50 (5.51)</td></tr><tr><td>no</td><td>light</td><td>44.35 (29.29)</td><td>9.87 (5.36)</td></tr><tr><td rowspan="10">80% 50%</td><td></td><td>heavier</td><td>47.60 (33.72)</td><td>11.45 (3.57)</td></tr><tr><td>yes</td><td>no</td><td>90.27</td><td>70.41</td></tr><tr><td>yes</td><td>light</td><td>94.07</td><td>75.66</td></tr><tr><td>yes</td><td>heavier</td><td>94.57</td><td>75.51</td></tr><tr><td>no</td><td>no</td><td>88.98</td><td>66.10</td></tr><tr><td></td><td>no light</td><td>93.97</td><td>75.07</td></tr><tr><td></td><td>no heavier</td><td>94.84</td><td>75.38</td></tr><tr><td></td><td>yes no</td><td>86.96</td><td>63.60</td></tr><tr><td>yes</td><td>light</td><td>92.65</td><td>70.83</td></tr><tr><td>yes no</td><td>heavier</td><td>92.86</td><td>70.33</td></tr><tr><td rowspan="6">WRN</td><td></td><td>no</td><td>85.56</td><td>60.64</td></tr><tr><td>no</td><td></td><td></td><td>69.97</td></tr><tr><td>no</td><td>light</td><td>91.87</td><td>70.72</td></tr><tr><td></td><td>heavier</td><td>92.77</td><td></td></tr><tr><td>yes</td><td>no</td><td>70.73</td><td>34.11</td></tr><tr><td>yes</td><td>light</td><td>76.00</td><td>36.65</td></tr><tr><td rowspan="6">10 %</td><td>yes</td><td>heavier</td><td>78.10</td><td>38.93</td></tr><tr><td>no</td><td>no</td><td>60.39</td><td>23.65</td></tr><tr><td>no</td><td>light</td><td>79.19</td><td>39.24</td></tr><tr><td>no</td><td>heavier</td><td>80.29</td><td>41.44</td></tr><tr><td>yes</td><td></td><td>33.45</td><td>7.47</td></tr><tr><td></td><td>no</td><td>34.13</td><td>7.50</td></tr><tr><td rowspan="5">1%</td><td>yes</td><td>light</td><td></td><td></td></tr><tr><td>yes</td><td>heavier</td><td>41.02</td><td>8.37</td></tr><tr><td>no</td><td>no</td><td>38.63</td><td>9.47</td></tr><tr><td>no</td><td>light</td><td>43.84</td><td>9.91</td></tr><tr><td>no</td><td>heavier</td><td>47.14</td><td>11.03</td></tr></table>
The results in Table 3 clearly support the conclusion presented in Section 2.3: data augmentation alone resists better the lack of training data compared to explicit regularizers. Already with $80 \%$ and
Table 4: Test accuracy of the shallower and deeper versions of the All-CNN network on CIFAR-10 and CIFAR-100. Results in parentheses show the difference with respect to the original model.
<table><tr><td>Network</td><td>Explicit Reg.</td><td>Aug. scheme</td><td>Test CIFAR-10</td><td>Test CIFAR-100</td></tr><tr><td rowspan="5">All-CNN shallower</td><td>yes</td><td>no</td><td>76.45 (-13.59)</td><td>51.31 (-9.23)</td></tr><tr><td>yes</td><td>light</td><td>82.02 (-11.24)</td><td>56.81 (-8.76)</td></tr><tr><td>yes</td><td>heavier</td><td>86.66 (-6.42)</td><td>58.64 (-9.98)</td></tr><tr><td>no</td><td>no</td><td>85.22 (+0.69)</td><td>58.95 (+0.96)</td></tr><tr><td>no</td><td>light</td><td>90.02 (-3.24)</td><td>65.51 (-3.75)</td></tr><tr><td rowspan="6">All-CNN deeper</td><td>no</td><td>heavier</td><td>90.34 (-3.21)</td><td>65.87 (-5.38)</td></tr><tr><td>yes</td><td>no</td><td>86.26 (-3.78)</td><td>49.06 (-11.48)</td></tr><tr><td>yes</td><td>light</td><td>85.04 (-8.22)</td><td>52.03 (-13.54)</td></tr><tr><td>yes</td><td>heavier</td><td>88.46 (-4.62)</td><td>51.78 (-16.84)</td></tr><tr><td>no</td><td>no</td><td>83.30 (-1.23)</td><td>54.22 (-3.77)</td></tr><tr><td>no no</td><td>light heavier</td><td>93.46 (+0.20) 94.19 (+0.64)</td><td>72.16 (+2.90) 73.30 (+2.35)</td></tr></table>
$50 \%$ of the data better results are obtained in some cases, but the differences become much bigger when training with only $10 \%$ and $1 \%$ of the available data. It seems that explicit regularization prevents the model from both fitting the data and generalizing well, whereas data augmentation provides useful transformed examples. Interestingly, with only $1 \%$ of the data, even without data augmentation the models without explicit regularization perform better.
The same effect can be observed in Table 4, where both the shallower and deeper versions of AllCNN perform much worse when trained with explicit regularization, even when trained without data augmentation. This is another piece of evidence that explicit regularization needs to be used very carefully, it requires a proper tuning of the hyperparameters and is not always benefitial.
# B NORM OF THE WEIGHT MATRIX
Table 5: Frobenius norm of the weight matrices learned by the networks All-CNN and WRN on CIFAR-10 and CIFAR-100, trained with and without explicit regularizers and the different augmentation schemes. Norms within brackets correspond to the models without batch normalization
<table><tr><td>Network</td><td>WD</td><td>Dropout</td><td>Aug. scheme</td><td>Norm CIFAR-10</td><td>Norm( CIFAR-100</td></tr><tr><td rowspan="9">All-CNN</td><td>yes</td><td>yes</td><td>no</td><td>48.7 (64.9)</td><td>76.5 (97.9)</td></tr><tr><td>yes</td><td>yes</td><td>light</td><td>52.7 (63.2)</td><td>77.6 (86.8)</td></tr><tr><td>yes</td><td>yes</td><td>heavier</td><td>57.6 (62.8)</td><td>78.1 (83.1)</td></tr><tr><td>no</td><td>yes</td><td>no</td><td>52.4 (70.5)</td><td>79.7 (103.3)</td></tr><tr><td>no</td><td>yes</td><td>light</td><td>57.0 (67.9)</td><td>83.6 (93.0)</td></tr><tr><td>no</td><td>yes</td><td>heavier</td><td>62.8 (67.5)</td><td>84.0 (88.0)</td></tr><tr><td>no</td><td>no</td><td>no</td><td>37.3 (63.7)</td><td>47.6 (102.7)</td></tr><tr><td>no</td><td>no</td><td>light</td><td>47.0 (69.5)</td><td>80.0 (108.9)</td></tr><tr><td>no</td><td>no</td><td>heavier</td><td>62.0 (71.7)</td><td>91.7 (91.7)</td></tr><tr><td rowspan="8">WRN</td><td>yes</td><td>yes</td><td>no</td><td>101.4 (122.6)</td><td>134.8 (126.5)</td></tr><tr><td>yes</td><td>yes</td><td>light</td><td>106.1 (123.9)</td><td>140.8 (129.3)</td></tr><tr><td>yes</td><td>yes</td><td>heavier</td><td>119.3 (125.3)</td><td>164.2 (132.5)</td></tr><tr><td>no</td><td>yes</td><td>no</td><td>153.3 (122.5)</td><td>185.1 (126.5)</td></tr><tr><td>no</td><td>yes</td><td>light</td><td>160.6 (123.9)</td><td>199.0 (129.4)</td></tr><tr><td>no</td><td>yes</td><td>heavier</td><td>175.1 (125.2)</td><td>225.4 (132.5)</td></tr><tr><td>no</td><td>no</td><td>no</td><td>139.0 (120.4)</td><td>157.9 (122.0)</td></tr><tr><td>no</td><td>no</td><td>light</td><td>153.6 (123.2)</td><td>187.0 (127.2)</td></tr><tr><td></td><td>no</td><td>no</td><td>heavier</td><td>170.4 (125.4)</td><td>217.6 (132.9)</td></tr></table>
One of the simplest way of getting a rough idea of the complexity of the learned models is computing the norm of the weight matrix. Table 5 shows the Frobenius norm of the weight matrices of the models trained with different levels of explicit regularization and data augmentation. The clearest conclusion is that heavier data augmentation seems to yield solutions with larger norm. This is always true except in some All-CNN models trained without batch normalization. Another observation is that, as expected, weight decay constrains the norm of the learned function. Besides, the models trained without batch normalization exhibit smaller differences between different levels of regularization and augmentation and, in the case of All-CNN, less consistency.
Table 6: Frobenius norm of the weight matrices learned by the shallower and deeper versions of the All-CNN network on CIFAR-10 and CIFAR-100.
<table><tr><td>Network</td><td>Explicit Reg.</td><td>Aug.scheme</td><td>Norm CIFAR-10</td><td>Norm CIFAR-100</td></tr><tr><td rowspan="6">All-CNN shallower</td><td>yes</td><td>no</td><td>47.9</td><td>68.9</td></tr><tr><td>yes</td><td>light</td><td>49.7</td><td>67.1</td></tr><tr><td>yes</td><td>heavier</td><td>51.9</td><td>66.2</td></tr><tr><td>no</td><td>no</td><td>34.8</td><td>64.7</td></tr><tr><td>no</td><td>light</td><td>45.6</td><td>68.8</td></tr><tr><td>no</td><td>heavier</td><td>53.1</td><td>68.3</td></tr><tr><td rowspan="6">All-CNN deeper</td><td>yes</td><td>no</td><td>62.3</td><td>92.1</td></tr><tr><td>yes</td><td>light</td><td>66.5</td><td>95.7</td></tr><tr><td>yes</td><td>heavier</td><td>71.5</td><td>96.9</td></tr><tr><td>no</td><td>no</td><td>45.4</td><td>53.4</td></tr><tr><td>no</td><td>light</td><td>57.3</td><td>77.3</td></tr><tr><td>no</td><td>heavier</td><td>70.7</td><td>97.5</td></tr></table>
One of the relevant results presented in this paper is the poor performance of the regularized models on the shallower and deeper versions of All-CNN, compared to the models without explicit regularization (see Table 4). One hypothesis is that the amount of regularization is not properly adjusted through the hyperparameters. This could be reflected in the norm of the learned weights, shown in Table 6. However, the norm alone does not seem to fully explain the large performance differences between the different models. Finding the exact reasons why the regularized models not able to generalize well might require a much thourough analysis and we leave it as future work.123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515# RETHINKING SOFTMAX CROSS-ENTROPY LOSS FOR ADVERSARIAL ROBUSTNESS
Tianyu Pang, Kun Xu, Yinpeng Dong, Chao Du, Ning Chen, Jun Zhu∗ Dept. of Comp. Sci. & Tech., BNRist Center, Institute for AI, Tsinghua University; RealAI {pty17,xu-k16,dyp17,du-c14}@mails.tsinghua.edu.cn, {ningchen,dcszj}@tsinghua.edu.cn
# ABSTRACT
Previous work shows that adversarially robust generalization requires larger sample complexity, and the same dataset, e.g., CIFAR-10, which enables good standard accuracy may not suffice to train robust models. Since collecting new training data could be costly, we focus on better utilizing the given data by inducing the regions with high sample density in the feature space, which could lead to locally sufficient samples for robust learning. We first formally show that the softmax cross-entropy (SCE) loss and its variants convey inappropriate supervisory signals, which encourage the learned feature points to spread over the space sparsely in training. This inspires us to propose the Max-Mahalanobis center (MMC) loss to explicitly induce dense feature regions in order to benefit robustness. Namely, the MMC loss encourages the model to concentrate on learning ordered and compact representations, which gather around the preset optimal centers for different classes. We empirically demonstrate that applying the MMC loss can significantly improve robustness even under strong adaptive attacks, while keeping high accuracy on clean inputs comparable to the SCE loss with little extra computation.
# 1 INTRODUCTION
The deep neural networks (DNNs) trained by the softmax cross-entropy (SCE) loss have achieved state-of-the-art performance on various tasks (Goodfellow et al., 2016). However, in terms of robustness, the SCE loss is not sufficient to lead to satisfactory performance of the trained models. It has been widely recognized that the DNNs trained by the SCE loss are vulnerable to adversarial attacks (Carlini & Wagner, 2017a; Goodfellow et al., 2015; Kurakin et al., 2017; Moosavi-Dezfooli et al., 2016; Papernot et al., 2016), where human imperceptible perturbations can be crafted to fool a high-performance network. To improve adversarial robustness of classifiers, various kinds of defenses have been proposed, but many of them are quickly shown to be ineffective to the adaptive attacks, which are adapted to the specific details of the proposed defenses (Athalye et al., 2018).
Besides, the methods on verification and training provably robust networks have been proposed (Dvijotham et al., 2018a;b; Hein & Andriushchenko, 2017; Wong & Kolter, 2018). While these methods are exciting, the verification process is often slow and not scalable. Among the previously proposed defenses, the adversarial training (AT) methods can achieve state-of-the-art robustness under different adversarial settings (Madry et al., 2018; Zhang et al., 2019b). These methods either directly impose the AT mechanism on the SCE loss or add additional regularizers. Although the AT methods are relatively strong, they could sacrifice accuracy on clean inputs and are computationally expensive (Xie et al., 2019). Due to the computational obstruction, many recent efforts have been devoted to proposing faster verification methods (Wong et al., 2018; Xiao et al., 2019) and accelerating AT procedures (Shafahi et al., 2019; Zhang et al., 2019a). However, the problem still remains.
Schmidt et al. (2018) show that the sample complexity of robust learning can be significantly larger than that of standard learning. Given the difficulty of training robust classifiers in practice, they further postulate that the difficulty could stem from the insufficiency of training samples in the commonly used datasets, e.g., CIFAR-10 (Krizhevsky & Hinton, 2009). Recent work intends to solve this problem by utilizing extra unlabeled data (Carmon et al., 2019; Stanforth et al., 2019), while we focus on the complementary strategy to exploit the labeled data in hand more efficiently. Note that although the samples in the input space are unchangeable, we could instead manipulate the local sample distribution, i.e., sample density in the feature space via appropriate training objectives. Intuitively, by inducing high-density feature regions, there would be locally sufficient samples to train robust classifiers and return reliable predictions (Schmidt et al., 2018).
Similar to our attempt to induce high-density regions in the feature space, previous work has been proposed to improve intra-class compactness. Contrastive loss (Sun et al., 2014) and triplet loss (Schroff et al., 2015) are two classical objectives for this purpose, but the training iterations will dramatically grow to construct image pairs or triplets, which results in slow convergence and instability. The center loss (Wen et al., 2016) avoids the pair-wise or triplet-wise computation by minimizing the squared distance
 Figure 1: Intuitive illusion of how training data moves and how sample density varies in a two-dimensional feature space during the training procedure.
between the features and the corresponding class centers. However, since the class centers are updated w.r.t. the learned features during training, the center loss has to be jointly used with the SCE loss to seek for a trade-off between inter-class dispersion and intra-class compactness. Therefore, the center loss cannot concentrate on inducing strong intra-class compactness to construct high-density regions and consequently could not lead to reliable robustness, as shown in our experiments.
In this paper, we first formally analyze the sample density distribution induced by the SCE loss and its other variants (Pang et al., 2018; Wan et al., 2018) in Sec. 3.2, which demonstrates that these previously proposed objectives convey unexpected supervisory signals on the training points, which make the learned features tend to spread over the space sparsely. This undesirable behavior mainly roots from applying the softmax function in training, which makes the loss function only depend on the relative relation among logits and cannot directly supervise on the learned representations.
We further propose a novel training objective which can explicitly induce high-density regions in the feature space and learn more structured representations. To achieve this, we propose the MaxMahalanobis center (MMC) loss (detailed in Eq. (8)) as the substitute of the SCE loss. Specifically, in the MMC loss, we first preset untrainable class centers with optimal inter-class dispersion in the feature space according to Pang et al. (2018), then we encourage the features to gather around the centers by minimizing the squared distance similar with the center loss. The MMC loss can explicitly control the inter-class dispersion by a single hyperparameter, and further concentrate on improving intra-class compactness in the training procedure to induce high-density regions, as intuitively shown in Fig. 1. Behind the simple formula, the MMC loss elegantly combines the favorable merits of the previous methods, which leads to a considerable improvement on the adversarial robustness.
In experiments, we follow the suggestion by Carlini et al. (2019) that we test under different threat models and attacks, including the adaptive attacks (Athalye et al., 2018) on MNIST, CIFAR-10, and CIFAR-100 (Krizhevsky & Hinton, 2009; LeCun et al., 1998). The results demonstrate that our method can lead to reliable robustness of the trained models with little extra computation, while maintaining high clean accuracy with faster convergence rates compared to the SCE loss and its variants. When combined with the existing defense mechanisms, e.g., the AT methods (Madry et al., 2018), the trained models can be further enhanced under the attacks different from the one used to craft adversarial examples for training.
# 2 PRELIMINARIES
This section first provides the notations, then introduces the adversarial attacks and threat models.
# 2.1 NOTATIONS
In this paper, we use the lowercases to denote variables and the uppercases to denote mappings. Let $L$ be the number of classes, we define the softmax function softmax ${ \bf \Phi } : \mathbb { R } ^ { L } \to \dot { \mathbb { R } } ^ { L }$ as so $\mathrm { \ t m a x } ( h ) _ { i } = \exp ( h _ { i } ) / { \sum _ { l = 1 } ^ { L } \exp ( h _ { l } ) } , i \in [ L ]$ , where $[ L ] : = \{ 1 , \cdots , L \}$ and $h$ is termed as logit.
A deep neural network (DNN) learns a non-linear mapping from the input $x \in \mathbb { R } ^ { p }$ to the feature $z = \dot { Z ( x ) } \in \mathbb { R } ^ { d }$ . One common training objective for DNNs is the softmax cross-entropy (SCE) loss:
$$\mathcal { L } _ { \mathrm { S C E } } ( Z ( x ) , y ) = - 1 _ { y } ^ { \top } \log { [ \mathrm { s o f t m a x } ( W z + b ) ] } ,$$
for a single input-label pair $( x , y )$ , where $1 _ { y }$ is the one-hot encoding of $y$ and the logarithm is defined as element-wise. Here $W$ and $b$ are the weight matrix and bias vector of the SCE loss, respectively.
# 2.2 ADVERSARIAL ATTACKS AND THREAT MODELS
Previous work has shown that adversarial examples can be easily crafted to fool DNNs (Biggio et al., 2013; Nguyen et al., 2015; Szegedy et al., 2014). A large amount of attacking methods on generating adversarial examples have been introduced in recent years (Carlini & Wagner, 2017a; Chen et al., 2017; Dong et al., 2018; Goodfellow et al., 2015; Ilyas et al., 2018; Kurakin et al., 2017; Madry et al., 2018; Moosavi-Dezfooli et al., 2016; Papernot et al., 2016; Uesato et al., 2018). Given the space limit, we try to perform a comprehensive evaluation by considering five different threat models and choosing representative attacks for each threat model following Carlini et al. (2019):
White-box $l _ { \infty }$ distortion attack: We apply the projected gradient descent (PGD) (Madry et al., 2018) method, which is efficient and widely studied in previous work (Pang et al., 2019).
White-box $l _ { 2 }$ distortion attack: We apply the C&W (Carlini & Wagner, 2017a) method, which has a binary search mechanism on its parameters to find the minimal $l _ { 2 }$ distortion for a successful attack.
Black-box transfer-based attack: We use the momentum iterative method (MIM) (Dong et al., 2018) that is effective on boosting adversarial transferability (Kurakin et al., 2018).
Black-box gradient-free attack: We choose SPSA (Uesato et al., 2018) since it has broken many previously proposed defenses. It can still perform well even when the loss is difficult to optimize.
General-purpose attack: We also evaluate the general robustness of models when adding Gaussian noise (Gilmer et al., 2019) or random rotation (Engstrom et al., 2019) on the input images.
Furthermore, to exclude the false robustness caused by, e.g., gradient mask (Athalye et al., 2018), we modify the above attacking methods to be adaptive attacks (Carlini & Wagner, 2017b; Carlini et al., 2019; Herley & Van Oorschot, 2017) when evaluating on the robustness of our method. The adaptive attacks are much more powerful than the non-adaptive ones, as detailed in Sec. 4.2.
# 3 METHODOLOGY
Various theoretical explanations have been developed for adversarial examples (Fawzi et al., 2016; 2018; Ilyas et al., 2019; Papernot et al., 2018). In particular, Schmidt et al. (2018) show that training robust classifiers requires significantly larger sample complexity compared to that of training standard ones, and they further postulate that the difficulty of training robust classifiers stems from, at least partly, the insufficiency of training samples in the common datasets. Recent efforts propose alternatives to benefit training with extra unlabeled data (Carmon et al., 2019; Stanforth et al., 2019), while we explore the complementary way to better use the labeled training samples for robust learning.
Although a given sample is fixed in the input space, we can instead manipulate the local sample distribution, i.e., sample density in the feature space, via designing appropriate training objectives. Intuitively, by inducing high-density regions in the feature space, it can be expected to have locally sufficient samples to train robust models that are able to return reliable predictions. In this section, we first formally define the notion of sample density in the feature space. Then we provide theoretical analyses of the sample density induced by the SCE loss and its variants. Finally, we propose our new Max-Mahalanobis center (MMC) loss and demonstrate its superiority compared to previous losses.
# 3.1 SAMPLE DENSITY IN THE FEATURE SPACE
Given a training dataset $\mathcal { D }$ with $N$ input-label pairs, and the feature mapping $Z$ trained by the objective $\bar { \mathcal { L } } ( Z ( \bar { x } ) , y )$ on this dataset, we define the sample density nearby the feature point $z = Z ( x )$
following the similar definition in physics (Jackson, 1999) as
$$\mathbb { S D } ( z ) = \frac { \Delta N } { \mathrm { V o l } ( \Delta B ) } .$$
Here $\operatorname { v o l } ( \cdot )$ denotes the volume of the input set, $\Delta B$ is a small neighbourhood containing the feature point $z$ , and $\Delta N = | Z ( \mathcal { D } ) \cap \Delta B |$ is the number of training points in $\Delta B$ , where $Z ( \mathcal { D } )$ is the set of all mapped features for the inputs in $\mathcal { D }$ . Note that the mapped feature $z$ is still of the label $y$ .
In the training procedure, the feature distribution is directly induced by the training loss $\mathcal { L }$ , where minimizing the loss value is the only supervisory signal for the feature points to move (Goodfellow et al., 2016). This means that the sample density varies mainly along the orthogonal direction w.r.t. the loss contours, while the density along a certain contour could be approximately considered as the same. For example, in the right panel of Fig. 1, the sample density induced by our MMC loss (detailed in Sec. 3.3) changes mainly along the radial direction, i.e., the directions of red arrows, where the loss contours are dashed concentric circles. Therefore, supposing $\mathcal { L } ( z , y ) = C$ , we choose $\Delta B = \{ \mathbf { z } \in \mathbb { R } ^ { d } | { \mathcal { L } } ( \mathbf { z } , y ) \in [ C , C + \Delta C ] \}$ , where $\Delta C > 0$ is a small value. Then $\mathrm { V o l } ( \Delta B )$ is the volume between the loss contours of $C$ and $C + \Delta C$ for label $y$ in the feature space.
# 3.2 THE SAMPLE DENSITY INDUCED BY THE GENERALIZED SCE LOSS
Generalized SCE loss. To better understand how the SCE loss and its variants (Pang et al., 2018; Wan et al., 2018) affect the sample density of features, we first generalize the definition in Eq. (1) as:
$$\mathcal { L } _ { \mathrm { g - S C E } } ( Z ( x ) , y ) = - 1 _ { y } ^ { \top } \log { [ \mathrm { s o f t m a x } ( h ) ] } ,$$
where the logit $h = H ( z ) \in \mathbb { R } ^ { L }$ is a general transformation of the feature $z$ , for example, $h = W z + b$ in the SCE loss. We call this family of losses as the generalized SCE $\scriptstyle ( { \bf g } - { \bf S } { \bf C } { \bf E } )$ loss. Wan et al. (2018) propose the large-margin Gaussian Mixture (L-GM) loss, where $h _ { i } = { \breve { - } } ( z - \mu _ { i } ) ^ { \top } \Sigma _ { i } ( z - \mu _ { i } ) - m \delta _ { i , y }$ under the assumption that the learned features $z$ distribute as a mixture of Gaussian. Here $\mu _ { i }$ and $\Sigma _ { i }$ are extra trainable means and covariance matrices respectively, $m$ is the margin, and $\delta _ { i , y }$ is the indicator function. Pang et al. (2018) propose the Max-Mahalanobis linear discriminant analysis (MMLDA) loss, where $h _ { i } = - \| z - \mu _ { i } ^ { * } \| _ { 2 } ^ { 2 }$ under the similar mixture of Gaussian assumption, but the main difference is that $\mu _ { i } ^ { * }$ are not trainable, but calculated before training with optimal inter-class dispersion. These two losses both fall into the family of the $\mathbf { g }$ -SCE loss with quadratic logits:
$$h _ { i } = - ( z - \mu _ { i } ) ^ { \top } \Sigma _ { i } ( z - \mu _ { i } ) + B _ { i } ,$$
where $B _ { i }$ are the bias variables. Besides, note that for the SCE loss, there is
$$\mathrm { s o f t m a x } ( W z + b ) _ { i } = \frac { \exp ( W _ { i } ^ { \top } z + b _ { i } ) } { \sum _ { l \in [ L ] } \exp ( W _ { l } ^ { \top } z + b _ { l } ) } = \frac { \exp ( - \| z - \frac { 1 } { 2 } W _ { i } \| _ { 2 } ^ { 2 } + b _ { i } + \frac { 1 } { 4 } \| W _ { i } \| _ { 2 } ^ { 2 } ) } { \sum _ { l \in [ L ] } \exp ( - \| z - \frac { 1 } { 2 } W _ { l } \| _ { 2 } ^ { 2 } + b _ { l } + \frac { 1 } { 4 } \| W _ { l } \| _ { 2 } ^ { 2 } ) } .$$
According to Eq. (4), the SCE loss can also be regraded as a special case of the $\mathrm { g - S C E }$ loss with quadratic logits, where $\begin{array} { r } { \mu _ { i } = \frac { 1 } { 2 } W _ { i } } \end{array}$ , $\begin{array} { r } { B _ { i } = b _ { i } + \frac 1 4 \| \dot { W _ { i } } \| _ { 2 } ^ { 2 } } \end{array}$ and $\Sigma _ { i } = I$ are identity matrices. Therefore, later when we refer to the g-SCE loss, we assume that the logits are quadratic as in Eq. (4) by default.
The contours of the g-SCE loss. To provide a formal representation of the sample density induced by the $\mathrm { g - S C E }$ loss, we first derive the formula of the contours, i.e., the closed-form solution of $\mathcal { L } _ { \mathrm { g - S C E } } ( Z ( x ) , y ) = C$ in the space of $z$ , where $C \in ( 0 , + \infty )$ is a given constant. Let $C _ { e } = \exp ( C ) \in$ $( 1 , + \infty )$ , from Eq. (3), we can represent the contours as the solution of
$$\log \left( 1 + \frac { \sum _ { l \neq y } \exp ( h _ { l } ) } { \exp ( h _ { y } ) } \right) = C \implies h _ { y } = \log \left[ \sum _ { l \neq y } \exp ( h _ { l } ) \right] - \log ( C _ { e } - 1 ) .$$
The function in Eq. (5) does not provide an intuitive closed-form solution for the contours, since the existence of the term $\begin{array} { r } { \log \left[ \sum _ { l \neq y } \exp ( h _ { l } ) \right] } \end{array}$ . However, note that this term belongs to the family of Log-Sum-Exp (LSE) function, which is a smooth approximation to the maximum function (Nesterov, 2005; Nielsen & Sun, 2016). Therefore, we can locally approximate the function in Eq. (5) with
$$h _ { y } - h _ { \tilde { y } } = - \log ( C _ { e } - 1 ) ,$$
 Figure 2: Intuitive illustration on the inherent limitations of the $\mathbf { g } { - } \mathbf { S } \mathbf { C } \mathbf { E }$ loss. Reasonably learned features for a classification task should distribute in clusters, so it is counter-intuitive that the feature points tend to move to infinity to pursue lower loss values when applying the $\mathbf { g }$ -SCE loss. In contrast, MMC induces models to learn more structured and orderly features.
where $\tilde { y } = \mathrm { a r g } \operatorname* { m a x } _ { l \neq y } h _ { l }$ . In the following text, we apply colored characters with tilde like $\tilde { y }$ to better visually distinguish them. According to Eq. (6), we can define $\mathcal { L } _ { y , \tilde { y } } ( z ) = \log [ \exp ( h _ { \tilde { y } } - h _ { y } ) + 1 ]$ as the local approximation of the $\mathrm { g - S C E }$ loss nearby the feature point $z$ , and substitute the neighborhood ∆B by ∆By,y˜ $\Delta \bar { B } _ { y , \mathrm { ~ \scriptsize ~ = ~ } } \{ \mathbf { z } \in \mathbb { R } ^ { d } | \mathcal { L } _ { y , \mathrm { ~ \scriptsize ~ ( ~ \mathbf { z } ) ~ \in ~ } [ C , C \dot { ~ } + \Delta C ] \} }$ . For simplicity, we assume scaled identity covariance matrix in Eq. (4), i.e., $\Sigma _ { i } = \sigma _ { i } I$ , where $\sigma _ { i } > 0$ are scalars. Through simple derivations (detailed in Appendix A.1), we show that if $\sigma _ { y } \neq \sigma$ , the solution of $\mathcal { L } _ { y , \textit { \textbf { ( z ) } } } = C$ is a $( d - 1 )$ - dimensional hypersphere with the center $\mathbf { M } _ { y , \mathbf { \Omega } } = ( \sigma _ { y } - \sigma \mathbf { \Omega } ) ^ { - 1 } ( \sigma _ { y } \mu _ { y } - \sigma \mathbf { \Omega } \mu \mathbf { \Sigma } )$ ; otherwise if $\sigma _ { y } = \sigma$ , the hypersphere-shape contour will degenerate to a hyperplane.
The induced sample density. Since the approximation in Eq. (6) depends on the specific $y$ and $\cdot$ , we define the training subset $\mathcal { D } _ { k , \tilde { k } } = \{ ( x , y ) \in \mathcal { D } | y = k$ , $\tilde { y } = \tilde { k } \}$ and $N _ { k , \tilde { k } } = | \mathcal { D } _ { k , \tilde { k } } |$ . Intuitively, Dk,k˜ includes the data with the true label of class $k$ , while the highest prediction returned by the classifier is class $\tilde { k }$ among other classes. Then we can derive the approximated sample density in the feature space induced by the $\mathbf { g }$ -SCE loss, as stated in the following theorem:
Theorem 1. (Proof in Appendix A.1) Given $( x , y ) \in \mathcal { D } _ { k , \tilde { k } }$ , $z = Z ( x )$ and $\mathcal { L } _ { g - S C E } ( z , y ) = C$ , if there are $\Sigma _ { k } = \sigma _ { k } I$ , $\Sigma _ { \tilde { k } } = \sigma _ { \tilde { k } } I$ , and $\sigma _ { k } \neq \sigma _ { \tilde { k } }$ , then the sample density nearby the feature point $z$ based on the approximation in Eq. (6) is
$$\begin{array} { r } { \mathbb { S } \mathbb { D } ( z ) \propto \frac { N _ { k , \tilde { k } } \cdot p _ { k , \tilde { k } } ( C ) } { \left[ \mathbf { B } _ { k , \tilde { k } } + \frac { \log ( C _ { e } - 1 ) } { \sigma _ { k } - \sigma _ { \tilde { k } } } \right] ^ { \frac { d - 1 } { 2 } } } , a n d \mathbf { B } _ { k , \tilde { k } } = \frac { \sigma _ { k } \sigma _ { \tilde { k } } \| \mu _ { k } - \mu _ { \tilde { k } } \| _ { 2 } ^ { 2 } } { ( \sigma _ { k } - \sigma _ { \tilde { k } } ) ^ { 2 } } + \frac { B _ { k } - B _ { \tilde { k } } } { \sigma _ { k } - \sigma _ { \tilde { k } } } , } \end{array}$$
where for the input-label pair in $\mathcal { D } _ { k , \tilde { k } }$ , there is $\mathcal { L } _ { g - S C E } \sim p _ { k , \tilde { k } } ( c )$ .
Limitations of the $\mathbf { g }$ -SCE loss. Based on Theorem 1 and the approximation in Eq. (6), let $C ^ { * } =$ $\mathrm { l o g } ( 1 + \exp ( \mathbf { B } _ { k , \tilde { k } } ( \sigma _ { \tilde { k } } - \sigma _ { k } ) ) )$ and $C _ { e } ^ { * } = \exp ( C ^ { * } )$ , such that $\begin{array} { r } { \bar { \mathbf { B } } _ { k , \tilde { k } } + \frac { \log ( C _ { e } ^ { * } - 1 ) } { \sigma _ { k } - \sigma _ { \tilde { k } } } \bar { = } \bar { 0 } } \end{array}$ = 0. According to Appendix A.1, if $\sigma _ { k } > \sigma _ { \tilde { k } }$ , then $C ^ { * }$ will act as a tight lower bound for $C$ , i.e., the solution set of $C < C ^ { * }$ is empty. This will make the training procedure tend to avoid this case since the loss $C$ cannot be further minimized to zero, which will introduce unnecessary biases on the returned predictions. On the other hand, if $\sigma _ { k } < \sigma _ { \tilde { k } }$ , $C$ could be minimized to zero. However, when $C 0$ , the sample density will also tend to zero since there is $\begin{array} { r } { \mathbf { B } _ { k , \tilde { k } } + \frac { \log ( C _ { e } - 1 ) } { \sigma _ { k } - \sigma _ { \tilde { k } } } \infty } \end{array}$ , which means the feature point will be encouraged to go further and further from the hypersphere center $\mathbf { M } _ { k , \tilde { k } }$ only to make the loss value $C$ be lower, as intuitively illustrated in Fig. 2(a).
This counter-intuitive behavior mainly roots from applying the softmax function in training. Namely, the softmax normalization makes the loss value only depend on the relative relation among logits. This causes indirect and unexpected supervisory signals on the learned features, such that the points with low loss values tend to spread over the space sparsely. Fortunately, in practice, the feature point will not really move to infinity, since the existence of batch normalization layers (Ioffe & Szegedy, 2015), and the squared radius from the center $\mathbf { M } _ { k , \tilde { k } }$ increases as $\mathcal { O } ( | \log C | )$ when minimizing the loss $C$ These theoretical conclusions are consistent with the empirical observations on the two-dimensional features in previous work (cf. Fig. 1 in Wan et al. (2018)).
Another limitation of the $\mathbf { g }$ -SCE loss is that the sample density is proportional to $N _ { k , \tilde { k } }$ , which is on average $N / L ^ { 2 }$ . For example, there are around 1.3 million training data in ImageNet (Deng et al., 2009), but with a large number of classes $L = 1 , 0 0 0$ , there are averagely less than two samples in each $\mathcal { D } _ { k , \tilde { k } }$ . These limitations inspire us to design the new training loss as in Sec 3.3.
Remark 1. If $\sigma _ { k } = \sigma _ { \tilde { k } }$ (e.g., as in the SCE loss), the features with loss values in $[ C , C + \Delta C ]$ will be encouraged to locate between two hyperplane contours without further supervision, and consequently there will not be explicit supervision on the sample density as shown in the left panel of Fig. 1.
Remark 2. Except for the $\mathbf { g }$ -SCE loss, Wen et al. (2016) propose the center loss in order to improve the intra-class compactness of learned features, formulated as $\begin{array} { r } { \mathcal { L } _ { \mathrm { C e n t e r } } ( Z ( x ) , y ) = \frac { 1 } { 2 } \| z - \mu _ { y } \| _ { 2 } ^ { 2 } } \end{array}$ . Here the center $\mu _ { y }$ is updated based on a mini-batch of learned features with label $y$ in each training iteration. The center loss has to be jointly used with the SCE loss as $\mathcal { L } _ { \mathrm { S C E } } + \lambda \mathcal { L } _ { \mathrm { C e n t e r } } ,$ , since simply supervise the DNNs with the center loss term will cause the learned features and centers to degrade to zeros (Wen et al., 2016). This makes it difficult to derive a closed-form formula for the induced sample density. Besides, the center loss method cannot concentrate on improving intra-class compactness, since it has to seek for a trade-off between inter-class dispersion and intra-class compactness.
# 3.3 MAX-MAHALANOBIS CENTER LOSS
Inspired by the above analyses, we propose the Max-Mahalanobis center (MMC) loss to explicitly learn more structured representations and induce high-density regions in the feature space. The MMC loss is defined in a regression form without the softmax function as
$$\mathcal { L } _ { \mathrm { M M C } } ( Z ( x ) , y ) = \frac { 1 } { 2 } \| z - \mu _ { y } ^ { * } \| _ { 2 } ^ { 2 } .$$
Here $\mu ^ { * } = \{ \mu _ { l } ^ { * } \} _ { l \in [ L ] }$ are the centers of the Max-Mahalanobis distribution (MMD) (Pang et al., 2018). The MMD is a mixture of Gaussian distribution with identity covariance matrix and preset centers $\mu ^ { * }$ , where $\| \mu _ { l } ^ { * } \| _ { 2 } = C _ { \mathrm { M M } }$ for any $l \in [ L ]$ , and $C _ { \mathrm { M M } }$ is a hyperparameter. These MMD centers are invariable during training, which are crafted according to the criterion: $\begin{array} { r } { \mu ^ { * } = \arg \operatorname* { m i n } _ { \mu } \operatorname* { m a x } _ { i \neq j } \langle \mu _ { i } , \mu _ { j } \rangle } \end{array}$ . Intuitively, this criterion is to maximize the minimal angle between any two centers, which can provide optimal inter-class dispersion as shown in Pang et al. (2018). In Appendix B.1, we provide the generation algorithm for $\mu ^ { * }$ in MMC. We derive the sample density induced by the MMC loss in the feature space, as stated in Theorem 2. Similar to the previously introduced notations, here we define the subset $\mathcal { D } _ { k } = \{ ( x , y ) \in \mathcal { D } | y = k \}$ and $N _ { k } = | \mathcal { D } _ { k } |$ .
Theorem 2. (Proof in Appendix A.2) Given $( x , y ) \in \mathcal { D } _ { k }$ , $z = Z ( x )$ and $\mathcal { L } _ { M M C } ( z , y ) = C$ , the sample density nearby the feature point $z$ is
$$\mathbb { S D } ( z ) \propto \frac { N _ { k } \cdot p _ { k } ( C ) } { C ^ { \frac { d - 1 } { 2 } } } ,$$
where for the input-label pair in $\mathcal { D } _ { k }$ , there is $\mathcal { L } _ { M M C } \sim p _ { k } ( c )$
According to Theorem 2, there are several attractive merits of the MMC loss, as described below.
Inducing higher sample density. Compared to Theorem 1, the sample density induced by MMC is proportional to $N _ { k }$ rather than $N _ { k , \tilde { k } }$ , where $N _ { k }$ is on average $N / L$ . It facilitates producing higher sample density. Furthermore, when the loss value $C$ is minimized to zero, the sample density will exponentially increase according to Eq. (9), as illustrated in Fig. 2(b). The right panel of Fig. 1 also provides an intuitive insight on this property of the MMC loss: since the loss value $C$ is proportional to the squared distance from the preset center $\mu _ { y } ^ { * }$ , the feature points with lower loss values are certain to locate in a smaller volume around the center. Consequently, the feature points of the same class are encouraged to gather around the corresponding center, such that for each sample, there will be locally enough data in its neighborhood for robust learning (Schmidt et al., 2018). The MMC loss value also becomes a reliable metric of the uncertainty on returned predictions.
Better exploiting model capacity. Behind the simple formula, the MMC loss can explicitly monitor inter-class dispersion by the hyperparameter $C _ { \mathrm { M M } }$ , while enabling the network to concentrate on minimizing intra-class compactness in training. Instead of repeatedly searching for an internal tradeoff in training as the center loss, the monotonicity of the supervisory signals induced by MMC can better exploit model capacity and also lead to faster convergence, as empirically shown in Fig. 3(a).
 Figure 3: (a) Test error rates on clean images w.r.t training time on CIFAR-10. Here AT refers to 10-steps targeted PGD adversarial training, i.e., $\mathsf { A T } _ { 1 0 } ^ { \mathsf { t a r } }$ . (b) Two-dimensional visualization of the attacks on trained MMC networks in the feature space of MNIST. For each attack there is $\epsilon = 0 . 3$ with step size of 0.01. The total number of iteration steps is 50, where Iter- indicates the perturbed features at -th iteration step.
Avoiding the degradation problem. The MMC loss can naturally avoid the degradation problem encountered in Wen et al. (2016) when the center loss is not jointly used with the SCE loss, since the preset centers $\mu ^ { * }$ for MMC are untrainable. In the test phase, the network trained by MMC can still return a normalized prediction with the softmax function. More details about the empirical superiorities of the MMC loss over other previous losses are demonstrated in Sec. 4.
Remark 3. In Appendix B.2, we discuss on why the squared-error form in Eq. (8) is preferred compared to, e.g., the absolute form or the Huber form in the adversarial setting. We further introduce flexible variants of the MMC loss in Appendix B.3, which can better adapt to various tasks.
Remark 4. Pang et al. (2018) propose a Max-Mahalanobis linear discriminant analysis (MMLDA) method, which assumes the features to distribute as an MMD. Due to the Gaussian mixture assumption, the training loss for the MMLDA method is obtained by the Bayes’ theorem as
$${ \mathcal { L } } _ { \mathrm { M M L D A } } ( Z ( x ) , y ) = - \log \left[ \frac { \exp ( - \frac { \| z - \mu _ { y } ^ { * } \| _ { 2 } ^ { 2 } } { 2 } ) } { \sum _ { l \in [ L ] } \exp ( - \frac { \| z - \mu _ { l } ^ { * } \| _ { 2 } ^ { 2 } } { 2 } ) } \right] = - \log \left[ \frac { \exp ( z ^ { \top } \mu _ { y } ^ { * } ) } { \sum _ { l \in [ L ] } \exp ( z ^ { \top } \mu _ { l } ^ { * } ) } \right] .$$
Note that there is $\Sigma _ { i } = { \textstyle { \frac { 1 } { 2 } } } I$ in Eq. (4) for the MMLDA loss, similar with the SCE loss. Thus the MMLDA method cannot explicitly supervise on the sample density and induce high-density regions in the feature space, as analyzed in Sec. 3.2. Compared to the MMLDA method, the MMC loss introduces extra supervision on intra-class compactness, which facilitates better robustness.
# 4 EXPERIMENTS
In this section, we empirically demonstrate several attractive merits of applying the MMC loss. We experiment on the widely used MNIST, CIFAR-10, and CIFAR-100 datasets (Krizhevsky & Hinton, 2009; LeCun et al., 1998). The main baselines for the MMC loss are SCE (He et al., 2016), Center loss (Wen et al., 2016), MMLDA (Pang et al., 2018), and L-GM (Wan et al., 2018). The codes are provided in https://github.com/P2333/Max-Mahalanobis-Training.
# 4.1 PERFORMANCE ON THE CLEAN INPUTS
The network architecture applied is ResNet-32 with five core layer blocks (He et al., 2016). Here we use MMC-10 to indicate the MMC loss with $C _ { \mathrm { M M } } = 1 0$ , where $C _ { \mathrm { M M } }$ is assigned based on the cross-validation results in Pang et al. (2018). The hyperparameters for the center loss, L-GM loss and the MMLDA method all follow the settings in the original papers (Pang et al., 2018; Wan et al., 2018; Wen et al., 2016). The pixel values are scaled to the interval $[ 0 , 1 ]$ . For each training loss with or without the AT mechanism, we apply the momentum SGD (Qian, 1999) optimizer with the initial learning rate of 0.01, and train for 40 epochs on MNIST, 200 epochs on CIFAR-10 and CIFAR-100. The learning rate decays with a factor of 0.1 at 100 and 150 epochs, respectively.
 Figure 4: Classification accuracy under the black-box transfer-based attacks on the test set of CIFAR-10. The substitute model one used to craft adversarial examples, and the target model is the one that an adversary actually intends to fool. Here AT refers to $\mathbf { A T _ { 1 0 } ^ { t a r } }$ to the.
When applying the AT mechanism (Madry et al., 2018), the adversarial examples for training are crafted by 10-steps targeted or untargeted PGD with $\epsilon = 8 / 2 5 5$ . In Fig. 3(a), we provide the curves of the test error rate w.r.t. the training time. Note that the MMC loss induces faster convergence rate and requires little extra computation compared to the SCE loss and its variants, while keeping comparable performance on the clean images. In comparison, implementing the AT mechanism is computationally expensive in training and will sacrifice the accuracy on the clean images.
# 4.2 ADAPTIVE ATTACKS FOR THE MMC LOSS
As stated in Athalye et al. (2018), only applying the existing attacks with default hyperparameters is not sufficient to claim reliable robustness. Thus, we apply the adaptive versions of existing attacks when evading the networks trained by the MMC loss (detailed in Appendix B.4). For instance, the non-adaptive objectives for PGD are variants of the SCE loss (Madry et al., 2018), while the adaptive objectives are $- \mathcal { L } _ { \mathrm { M M C } } ( z , y )$ and $\mathcal { L } _ { \mathrm { M M C } } ( z , y _ { t } )$ in the untargeted and targeted modes for PGD, respectively. Here $y _ { t }$ is the target label. To verify that the adaptive attacks are more effective than the non-adaptive ones, we modify the network architecture with a two-dimensional feature layer and visualize the PGD attacking procedure in Fig. 3(b). The two panels separately correspond to two randomly selected clean inputs indicated by black stars. The ten colored clusters in each panel consist of the features of all the 10,000 test samples in MNIST, where each color corresponds to one class. We can see that the adaptive attacks are indeed much more efficient than the non-adaptive one.
# 4.3 PERFORMANCE UNDER THE WHITE-BOX ATTACKS
We first investigate the white-box $l _ { \infty }$ distortion setting using the PGD attack, and report the results in Table 1. According to Carlini et al. (2019), we evaluate under different combinations of the attacking parameters: the perturbation $\epsilon$ , iteration steps, and the attack mode, i.e., targeted or untargeted.
Table 2: Experiments on CIFAR-10. Part I: Averaged $l _ { 2 }$ distortion of the white-box adversarial examples crafted by C&W with 1,000 iteration steps. Part II: Classification accuracy $( \% )$ under the block-box SPSA attack. Part III: Classification accuracy $( \% )$ under general transformations. The standard deviation $\sigma$ for the Gaussian noise is 0.05, the degree range is $\pm 3 0 ^ { \circ }$ for random rotation.
<table><tr><td rowspan=1 colspan=3>Methods</td><td rowspan=1 colspan=2>Part IC& Wtar C& Wun</td><td rowspan=1 colspan=2>Part II (ε=8/255)SPSA10 SPSA10</td><td rowspan=1 colspan=2>Part II (e=16/255)SPSA10 SPSA10</td><td rowspan=1 colspan=2>Part IIINoise Rotation</td></tr><tr><td rowspan=7 colspan=3>SCECenter lossMMLDAL-GMMMC-10</td><td rowspan=1 colspan=1>0.12</td><td rowspan=1 colspan=1>0.07</td><td rowspan=1 colspan=1>12.3</td><td rowspan=1 colspan=1>1.2</td><td rowspan=1 colspan=1>5.1</td><td rowspan=1 colspan=1>≤1</td><td rowspan=1 colspan=1>52.0</td><td rowspan=1 colspan=1>83.5</td></tr><tr><td rowspan=3 colspan=2>S</td><td rowspan=3 colspan=1>0.13</td><td rowspan=3 colspan=1>0.07</td><td rowspan=3 colspan=1>21.2</td><td rowspan=3 colspan=1>6.0</td><td></td><td></td><td></td><td></td></tr><tr><td rowspan=2 colspan=1></td><td></td><td></td><td></td><td></td></tr><tr><td rowspan=1 colspan=1>10.6</td><td rowspan=1 colspan=1>2.0</td><td rowspan=1 colspan=1>55.4</td><td rowspan=1 colspan=1>84.9</td></tr><tr><td rowspan=1 colspan=1>0.17</td><td rowspan=1 colspan=1>0.10</td><td rowspan=1 colspan=1>25.6</td><td rowspan=1 colspan=1>13.2</td><td rowspan=1 colspan=1>11.3</td><td rowspan=1 colspan=1>5.7</td><td rowspan=1 colspan=1>57.9</td><td rowspan=1 colspan=1>84.8</td></tr><tr><td rowspan=1 colspan=1>0.23</td><td rowspan=1 colspan=1>0.12</td><td rowspan=1 colspan=1>61.9</td><td rowspan=1 colspan=1>45.9</td><td rowspan=1 colspan=1>46.1</td><td rowspan=1 colspan=1>28.2</td><td rowspan=1 colspan=1>59.2</td><td rowspan=1 colspan=1>82.4</td></tr><tr><td rowspan=1 colspan=1>0.34</td><td rowspan=1 colspan=1>0.17</td><td rowspan=1 colspan=1>69.5</td><td rowspan=1 colspan=1>56.9</td><td rowspan=1 colspan=1>57.2</td><td rowspan=1 colspan=1>41.5</td><td rowspan=1 colspan=1>69.3</td><td rowspan=1 colspan=1>87.2</td></tr><tr><td rowspan=2 colspan=3>AT10 (SCE)AT10 (MMC-10)</td><td rowspan=2 colspan=1>1.191.91</td><td rowspan=1 colspan=1>0.63</td><td rowspan=1 colspan=1>81.1</td><td rowspan=1 colspan=1>67.8</td><td rowspan=1 colspan=1>77.9</td><td rowspan=1 colspan=1>59.4</td><td rowspan=2 colspan=1>82.283.5</td><td rowspan=1 colspan=1>76.0</td></tr><tr><td rowspan=1 colspan=1>0.85</td><td rowspan=1 colspan=1>79.1</td><td rowspan=1 colspan=1>69.2</td><td rowspan=1 colspan=1>74.5</td><td rowspan=1 colspan=1>62.7</td><td rowspan=1 colspan=1>75.2</td></tr><tr><td rowspan=2 colspan=3>AT10 (SCE)AT10(MMC-10)</td><td rowspan=1 colspan=1>1.26</td><td rowspan=1 colspan=1>0.68</td><td rowspan=1 colspan=1>78.8</td><td rowspan=1 colspan=1>67.0</td><td rowspan=1 colspan=1>73.7</td><td rowspan=1 colspan=1>60.3</td><td rowspan=1 colspan=1>78.9</td><td rowspan=1 colspan=1>73.7</td></tr><tr><td rowspan=1 colspan=1>1.55</td><td rowspan=1 colspan=1>0.73</td><td rowspan=1 colspan=1>80.4</td><td rowspan=1 colspan=1>69.6</td><td rowspan=1 colspan=1>74.6</td><td rowspan=1 colspan=1>62.4</td><td rowspan=1 colspan=1>80.3</td><td rowspan=1 colspan=1>75.8</td></tr></table>
Following the setting in Madry et al. (2018), we choose the perturbation $\epsilon = 8 / 2 5 5$ and 16/255, with the step size be $2 / 2 5 5$ . We have also run PGD-100 and PGD-200 attacks, and find that the accuracy converges compared to PGD-50. In each PGD experiment, we ran several times with different random restarts to guarantee the reliability of the reported results.
Ablation study. To investigate the effect on robustness induced by high sample density in MMC, we substitute uniformly sampled center set (Liu et al., 2018; Duan et al., 2019), i.e., $\mu ^ { r } = \{ \mu _ { l } ^ { r } \} _ { l \in [ L ] }$ for the MM center set $\mu ^ { * }$ , and name the resulted method as "MMC-10 (rand)" as shown in Table 1. There is also $\| \mu _ { l } ^ { r } \| _ { 2 } = C _ { \mathrm { M M } }$ , but $\mu ^ { r }$ is no longer the solution of the min-max problem in Sec. 3.3.
From the results in Table 1, we can see that higher sample density alone in "MMC-10 (rand)" can already lead to much better robustness than other baseline methods even under the adaptive attacks, while using the optimal center set $\mu ^ { * }$ as in "MMC-10" can further improve performance. When combining with the AT mechanism, the trained models have better performance under the attacks different from the one used to craft adversarial examples for training, e.g, $\mathrm { P G D } _ { 5 0 } ^ { \mathbf { u n } }$ with $\epsilon = 1 6 / 2 5 5$ .
Then we investigate the white-box $l _ { 2 }$ distortion setting. We apply the C&W attack, where it has a binary search mechanism to find the minimal distortion to successfully mislead the classifier under the untargeted mode, or lead the classifier to predict the target label in the targeted mode. Following the suggestion in Carlini & Wagner (2017a), we set the binary search steps to be 9 with the initial constant $c = 0 . 0 1$ . The iteration steps for each value of $c$ are set to be 1,000 with the learning rate of 0.005. In the Part I of Table 2, we report the minimal distortions found by the C&W attack. As expected, it requires much larger distortions to successfully evade the networks trained by MMC.
# 4.4 PERFORMANCE UNDER THE BLACK-BOX ATTACKS
Table 3: Accuracy $( \% )$ of MMC-10 under SPSA with different batch sizes.
<table><tr><td rowspan=2 colspan=3>CIFAR-10Batch SPSA10 SPSA</td></tr><tr><td rowspan=1 colspan=1>Batch</td><td rowspan=1 colspan=1>SPSA10</td></tr><tr><td rowspan=1 colspan=1>128</td><td rowspan=1 colspan=1>57.0</td><td rowspan=1 colspan=1>69.0</td></tr><tr><td rowspan=1 colspan=1>4096</td><td rowspan=1 colspan=1>41.0</td><td rowspan=1 colspan=1>52.0</td></tr><tr><td rowspan=1 colspan=1>8192</td><td rowspan=1 colspan=1>37.0</td><td rowspan=1 colspan=1>49.0</td></tr></table>
As suggested in Carlini et al. (2019), providing evidence of being robust against the black-box attacks is critical to claim reliable robustness. We first perform the transfer-based attacks using PGD and MIM. Since the targeted attacks usually have poor transferability (Kurakin et al., 2018), we only focus on the untargeted mode in this case, and the results are shown in Fig. 4. We further perform the gradient-free attacks using the SPSA method and report the results in the Part II of Table 2. To perform numerical approximations on gradients in SPSA, we set the batch size to be 128, the learning rate is 0.01, and the step size of the finite difference is $\delta = 0 . 0 1$ , as suggested by Uesato et al. (2018). We also evaluate under stronger
SPSA attacks with batch size to be 4096 and 8192 in Table 3, where the $\epsilon = 8 / 2 5 5$ . With larger batch sizes, we can find that the accuracy under the black-box SPSA attacks converges to it under the white-box PGD attacks. These results indicate that training with the MMC loss also leads to robustness under the black-box attacks, which verifies that our method can induce reliable robustness, rather than the false one caused by, e.g., gradient mask (Athalye et al., 2018).
Table 4: Experiments on CIFAR-100. Part I: Classification accuracy $( \% )$ on the clean test samples. Part II: Classification accuracy $( \% )$ under the white-box PGD attacks and the block-box SPSA attack. The attacks are adaptive for MMC. Here the batch size for SPSA is 128. Part III: Averaged $l _ { 2 }$ distortion of the white-box adversarial examples crafted by C&W with 1,000 iteration steps and 9 binary search epochs.
<table><tr><td rowspan="2">Methods</td><td rowspan="2">Part I Clean</td><td colspan="4">Part II(ε = 8/255)</td><td colspan="2">Part I</td></tr><tr><td>PGD</td><td>PGD10</td><td>SPSA</td><td>SPSA10</td><td>C&Wtar</td><td>C&Wun</td></tr><tr><td>SCE</td><td>72.9</td><td>≤1</td><td>8.0</td><td>14.0</td><td>1.9</td><td>0.16</td><td>0.047</td></tr><tr><td>Center</td><td>72.8</td><td>≤1</td><td>10.2</td><td>14.7</td><td>2.3</td><td>0.18</td><td>0.048</td></tr><tr><td>MMLDA</td><td>72.2</td><td>≤1</td><td>13.9</td><td>18.5</td><td>5.6</td><td>0.21</td><td>0.050</td></tr><tr><td>L-GM</td><td>71.3</td><td>15.8</td><td>15.3</td><td>22.8</td><td>7.6</td><td>0.31</td><td>0.063</td></tr><tr><td>MMC-10</td><td>71.9</td><td>23.9</td><td>23.4</td><td>33.4</td><td>15.8</td><td>0.37</td><td>0.085</td></tr></table>
# 4.5 PERFORMANCE UNDER THE GENERAL-PURPOSE ATTACKS
To show that our method is generally robust, we further test under the general-purpose attacks (Carlini et al., 2019). We apply the Gaussian noise (Fawzi et al., 2016; Gilmer et al., 2019) and rotation transformation (Engstrom et al., 2019), which are not included in the data augmentation for training. The results are given in the Part III of Table 2. Note that the AT methods are less robust to simple transformations like rotation, as also observed in previous work (Engstrom et al., 2019). In comparison, the models trained by the MMC loss are still robust to these easy-to-apply attacks.
# 4.6 EXPERIMENTS ON CIFAR-100
In Table 4 and Table 5, we provide the results on CIFAR-100 under the white-box PGD and C&W attacks, and the black-box gradient-free SPSA attack. The hyperparameter setting for each attack is the same as it on CIFAR-10. Compared to previous defense strategies which also evaluate on CIFAR-100 (Pang et al., 2019; Mustafa et al., 2019), MMC can improve robustness more significantly, while keeping better performance on the clean inputs. Compared to the results on CIFAR-10, the averaged distortion of C&W on CIFAR-100 is larger for a successful targeted attack and is much smaller for a successful untargeted attack. This is because when only the number of classes increases, e.g., from 10 to 100, it is easier to achieve a coarse untargeted attack, but harder to make a subtle targeted attack. Note that in Table 5, we also train on the ResNet-110 model with eighteen core block layers except for the ResNet-32 model. The results show that MMC can further benefit from deep network architectures and better exploit model capacity to improve robustness. Similar properties are also observed in previous work when applying the AT methods (Madry et al., 2018). In contrast, as shown in Table 5, the models trained by SCE are comparably sensitive to adversarial perturbations for different architectures, which demonstrates that SCE cannot take full advantage of the model capacity to improve robustness. This verifies that MMC provides effective robustness promoting mechanism like the AT methods, with much less computational cost.
# 5 CONCLUSION
In this paper, we formally demonstrate that applying the softmax function in training could potentially lead to unexpected supervisory signals. To solve this problem, we propose the MMC loss to learn more structured representations and induce high-density regions in the feature space. In our experiments, we empirically demonstrate several favorable merits of our method: (i) Lead to reliable robustness even under strong adaptive attacks in different threat models; (ii) Keep high performance on clean inputs comparable to SCE; (iii) Introduce little extra computation compared to the SCE loss; (iv) Compatible with the existing defense mechanisms, e.g., the AT methods. Our analyses in this paper also provide useful insights for future work on designing new objectives beyond the SCE framework.
# ACKNOWLEDGEMENTS
This work was supported by the National Key Research and Development Program of China (No. 2017YFA0700904), NSFC Projects (Nos. 61620106010, U19B2034, U1811461), Beijing NSF Project (No. L172037), Beijing Academy of Artificial Intelligence (BAAI), Tsinghua-Huawei Joint Research Program, a grant from Tsinghua Institute for Guo Qiang, Tiangong Institute for Intelligent Computing, the JP Morgan Faculty Research Program and the NVIDIA NVAIL Program with GPU/DGX Acceleration.
# REFERENCES
Anish Athalye, Nicholas Carlini, and David Wagner. Obfuscated gradients give a false sense of security: Circumventing defenses to adversarial examples. In International Conference on Machine Learning (ICML), 2018.
Battista Biggio, Igino Corona, Davide Maiorca, Blaine Nelson, Nedim Šrndic, Pavel Laskov, Giorgio ´ Giacinto, and Fabio Roli. Evasion attacks against machine learning at test time. In Joint European conference on machine learning and knowledge discovery in databases, pp. 387–402. Springer, 2013.
Nicholas Carlini and David Wagner. Towards evaluating the robustness of neural networks. In IEEE Symposium on Security and Privacy (S&P), 2017a.
Nicholas Carlini and David Wagner. Adversarial examples are not easily detected: Bypassing ten detection methods. In ACM Workshop on Artificial Intelligence and Security (AISec), 2017b.
Nicholas Carlini, Anish Athalye, Nicolas Papernot, Wieland Brendel, Jonas Rauber, Dimitris Tsipras, Ian Goodfellow, Aleksander Madry, and Alexey Kurakin. On evaluating adversarial robustness. arXiv preprint arXiv:1902.06705, 2019.
Yair Carmon, Aditi Raghunathan, Ludwig Schmidt, Percy Liang, and John C Duchi. Unlabeled data improves adversarial robustness. In Advances in Neural Information Processing Systems (NeurIPS), 2019.
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 10th ACM Workshop on Artificial Intelligence and Security (AISec), pp. 15–26. ACM, 2017.
Jia Deng, Wei Dong, Richard Socher, Li-Jia Li, Kai Li, and Li Fei-Fei. Imagenet: A large-scale hierarchical image database. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition (CVPR), pp. 248–255. IEEE, 2009.
Jiankang Deng, Jia Guo, Niannan Xue, and Stefanos Zafeiriou. Arcface: Additive angular margin loss for deep face recognition. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition (CVPR), pp. 4690–4699, 2019.
Yinpeng Dong, Fangzhou Liao, Tianyu Pang, Hang Su, Jun Zhu, Xiaolin Hu, and Jianguo Li. Boosting adversarial attacks with momentum. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition (CVPR), 2018.
Yueqi Duan, Jiwen Lu, and Jie Zhou. Uniformface: Learning deep equidistributed representation for face recognition. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition (CVPR), pp. 3415–3424, 2019.
Krishnamurthy Dvijotham, Sven Gowal, Robert Stanforth, Relja Arandjelovic, Brendan O’Donoghue, Jonathan Uesato, and Pushmeet Kohli. Training verified learners with learned verifiers. arXiv preprint arXiv:1805.10265, 2018a.
Krishnamurthy Dvijotham, Robert Stanforth, Sven Gowal, Timothy Mann, and Pushmeet Kohli. A dual approach to scalable verification of deep networks. In Annual Conference on Uncertainty in Artificial Intelligence (UAI), 2018b.
Logan Engstrom, Brandon Tran, Dimitris Tsipras, Ludwig Schmidt, and Aleksander Madry. A rotation and a translation suffice: Fooling cnns with simple transformations. In International Conference on Machine Learning (ICML), 2019.
Alhussein Fawzi, Seyed-Mohsen Moosavi-Dezfooli, and Pascal Frossard. Robustness of classifiers: from adversarial to random noise. In Advances in Neural Information Processing Systems (NeurIPS), pp. 1632–1640, 2016.
Alhussein Fawzi, Hamza Fawzi, and Omar Fawzi. Adversarial vulnerability for any classifier. In Advances in Neural Information Processing Systems (NeurIPS), 2018.
Jerome Friedman, Trevor Hastie, and Robert Tibshirani. The elements of statistical learning, volume 1. Springer series in statistics New York, 2001.
Justin Gilmer, Nicolas Ford, Nicolas Carlini, and Ekin Cubuk. Adversarial examples are a natural consequence of test error in noise. In International Conference on Machine Learning (ICML), 2019.
Ian Goodfellow, Yoshua Bengio, and Aaron Courville. Deep Learning. MIT Press, 2016. http: //www.deeplearningbook.org.
Ian J Goodfellow, Jonathon Shlens, and Christian Szegedy. Explaining and harnessing adversarial examples. In International Conference on Learning Representations (ICLR), 2015.
Yandong Guo and Lei Zhang. One-shot face recognition by promoting underrepresented classes. arXiv preprint arXiv:1707.05574, 2017.
Kaiming He, Xiangyu Zhang, Shaoqing Ren, and Jian Sun. Identity mappings in deep residual networks. In European Conference on Computer Vision (ECCV), pp. 630–645. Springer, 2016.
Matthias Hein and Maksym Andriushchenko. Formal guarantees on the robustness of a classifier against adversarial manipulation. In Advances in Neural Information Processing Systems (NeurIPS), pp. 2266–2276, 2017.
Cormac Herley and Paul C Van Oorschot. Sok: Science, security and the elusive goal of security as a scientific pursuit. In 2017 IEEE Symposium on Security and Privacy (S&P), pp. 99–120. IEEE, 2017.
Andrew Ilyas, Logan Engstrom, Anish Athalye, and Jessy Lin. Black-box adversarial attacks with limited queries and information. In International Conference on Machine Learning (ICML), 2018.
Andrew Ilyas, Shibani Santurkar, Dimitris Tsipras, Logan Engstrom, Brandon Anish Athalye, Tran, and Aleksander Madry. Adversarial examples are not bugs, they are features. In Advances in Neural Information Processing Systems (NeurIPS), 2019.
Sergey Ioffe and Christian Szegedy. Batch normalization: Accelerating deep network training by reducing internal covariate shift. In International Conference on Machine Learning (ICML), pp. 448–456, 2015.
John David Jackson. Classical electrodynamics. American Journal of Physics, 1999.
Harini Kannan, Alexey Kurakin, and Ian Goodfellow. Adversarial logit pairing. arXiv preprint arXiv:1803.06373, 2018.
Alex Krizhevsky and Geoffrey Hinton. Learning multiple layers of features from tiny images. Technical report, Citeseer, 2009.
Alexey Kurakin, Ian Goodfellow, and Samy Bengio. Adversarial examples in the physical world. In The International Conference on Learning Representations (ICLR) Workshops, 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.
Yann LeCun, Léon Bottou, Yoshua Bengio, and Patrick Haffner. Gradient-based learning applied to document recognition. Proceedings of the IEEE, 86(11):2278–2324, 1998.
Xuezhi Liang, Xiaobo Wang, Zhen Lei, Shengcai Liao, and Stan Z Li. Soft-margin softmax for deep classification. In International Conference on Neural Information Processing (ICNIP), pp. 413–421. Springer, 2017.
Weiyang Liu, Yandong Wen, Zhiding Yu, and Meng Yang. Large-margin softmax loss for convolutional neural networks. In International Conference on Machine Learning (ICML), 2016.
Weiyang Liu, Yandong Wen, Zhiding Yu, Ming Li, Bhiksha Raj, and Le Song. Sphereface: Deep hypersphere embedding for face recognition. In Proceedings of the IEEE conference on computer vision and pattern recognition (CVPR), pp. 212–220, 2017.
Weiyang Liu, Rongmei Lin, Zhen Liu, Lixin Liu, Zhiding Yu, Bo Dai, and Le Song. Learning towards minimum hyperspherical energy. In Advances in Neural Information Processing Systems (NeurIPS), pp. 6222–6233, 2018.
Pavel Loskot and Norman C. Beaulieu. On monotonicity of the hypersphere volume and area. Journal of Geometry, 2007.
Aleksander Madry, Aleksandar Makelov, Ludwig Schmidt, Dimitris Tsipras, and Adrian Vladu. Towards deep learning models resistant to adversarial attacks. In International Conference on Learning Representations (ICLR), 2018.
Seyed-Mohsen Moosavi-Dezfooli, Alhussein Fawzi, and Pascal Frossard. Deepfool: a simple and accurate method to fool deep neural networks. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition (CVPR), pp. 2574–2582, 2016.
Aamir Mustafa, Salman Khan, Munawar Hayat, Roland Goecke, Jianging Shen, and Ling Shao. Adversarial defense by restricting the hidden space of deep neural networks. In International Conference on Computer Vision (ICCV), 2019.
Yu Nesterov. Smooth minimization of non-smooth functions. Mathematical programming, 103(1): 127–152, 2005.
Anh Nguyen, Jason Yosinski, and Jeff Clune. Deep neural networks are easily fooled: High confidence predictions for unrecognizable images. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition (CVPR), pp. 427–436, 2015.
Frank Nielsen and Ke Sun. Guaranteed bounds on the kullback–leibler divergence of univariate mixtures. IEEE Signal Processing Letters, 23(11):1543–1546, 2016.
Tianyu Pang, Chao Du, and Jun Zhu. Max-mahalanobis linear discriminant analysis networks. In International Conference on Machine Learning (ICML), 2018.
Tianyu Pang, Kun Xu, Chao Du, Ning Chen, and Jun Zhu. Improving adversarial robustness via promoting ensemble diversity. In International Conference on Machine Learning (ICML), 2019.
Nicolas Papernot, Patrick 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), pp. 372–387. IEEE, 2016.
Nicolas Papernot, Patrick McDaniel, Arunesh Sinha, and Michael Wellman. Towards the science of security and privacy in machine learning. In European Symposium on Security and Privacy (EuroS&P), 2018.
Xianbiao Qi and Lei Zhang. Face recognition via centralized coordinate learning. arXiv preprint arXiv:1801.05678, 2018.
Ning Qian. On the momentum term in gradient descent learning algorithms. Neural networks, 12(1): 145–151, 1999.
Ludwig Schmidt, Shibani Santurkar, Dimitris Tsipras, Kunal Talwar, and Aleksander Madry. Adversarially robust generalization requires more data. In Advances in Neural Information Processing Systems (NeurIPS), pp. 5019–5031, 2018.
Florian Schroff, Dmitry Kalenichenko, and James Philbin. Facenet: A unified embedding for face recognition and clustering. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition (CVPR), pp. 815–823, 2015.
Ali Shafahi, Mahyar Najibi, Amin Ghiasi, Zheng Xu, John Dickerson, Christoph Studer, Larry S Davis, Gavin Taylor, and Tom Goldstein. Adversarial training for free! In Advances in Neural Information Processing Systems (NeurIPS), 2019.
Robert Stanforth, Alhussein Fawzi, Pushmeet Kohli, et al. Are labels required for improving adversarial robustness? In Advances in Neural Information Processing Systems (NeurIPS), 2019.
Yi Sun, Yuheng Chen, Xiaogang Wang, and Xiaoou Tang. Deep learning face representation by joint identification-verification. In Advances in Neural Information Processing Systems (NeurIPS), pp. 1988–1996, 2014.
Christian Szegedy, Wojciech Zaremba, Ilya Sutskever, Joan Bruna, Dumitru Erhan, Ian Goodfellow, and Rob Fergus. Intriguing properties of neural networks. In International Conference on Learning Representations (ICLR), 2014.
Jonathan Uesato, Brendan O’Donoghue, Aaron van den Oord, and Pushmeet Kohli. Adversarial risk and the dangers of evaluating against weak attacks. In International Conference on Machine Learning (ICML), 2018.
Weitao Wan, Yuanyi Zhong, Tianpeng Li, and Jiansheng Chen. Rethinking feature distribution for loss functions in image classification. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition (CVPR), pp. 9117–9126, 2018.
Feng Wang, Xiang Xiang, Jian Cheng, and Alan Loddon Yuille. Normface: l 2 hypersphere embedding for face verification. In Proceedings of the 25th ACM international conference on Multimedia (ACM MM), pp. 1041–1049. ACM, 2017.
Hao Wang, Yitong Wang, Zheng Zhou, Xing Ji, Dihong Gong, Jingchao Zhou, Zhifeng Li, and Wei Liu. Cosface: Large margin cosine loss for deep face recognition. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition (CVPR), pp. 5265–5274, 2018.
Yandong Wen, Kaipeng Zhang, Zhifeng Li, and Yu Qiao. A discriminative feature learning approach for deep face recognition. In European Conference on Computer Vision (ECCV), pp. 499–515. Springer, 2016.
Eric Wong and Zico Kolter. Provable defenses against adversarial examples via the convex outer adversarial polytope. In International Conference on Machine Learning (ICML), pp. 5283–5292, 2018.
Eric Wong, Frank Schmidt, Jan Hendrik Metzen, and J Zico Kolter. Scaling provable adversarial defenses. In Advances in Neural Information Processing Systems (NeurIPS), pp. 8400–8409, 2018.
Kai Y Xiao, Vincent Tjeng, Nur Muhammad Shafiullah, and Aleksander Madry. Training for faster adversarial robustness verification via inducing relu stability. In International Conference on Learning Representations (ICLR), 2019.
Cihang Xie, Yuxin Wu, Laurens van der Maaten, Alan Yuille, and Kaiming He. Feature denoising for improving adversarial robustness. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition (CVPR), 2019.
Dinghuai Zhang, Tianyuan Zhang, Yiping Lu, Zhanxing Zhu, and Bin Dong. You only propagate once: Accelerating adversarial training via maximal principle. In Advances in Neural Information Processing Systems (NeurIPS), 2019a.
Hongyang Zhang, Yaodong Yu, Jiantao Jiao, Eric P Xing, Laurent El Ghaoui, and Michael I Jordan. Theoretically principled trade-off between robustness and accuracy. In International Conference on Machine Learning (ICML), 2019b.
# A PROOF
In this section, we provide the proof of the theorems proposed in the paper.
A.1 PROOF OF THEOREM 1
According to the definition of sample density
$$\mathbb { S D } ( z ) = \frac { \Delta N } { \mathrm { V o l } ( \Delta B ) } ,$$
we separately calculate $\Delta N$ and $\mathrm { V o l } ( \Delta B )$ . Since $\mathcal { L } _ { \mathrm { g - S C E } } \sim p _ { k , \tilde { k } } ( c )$ for the data points in $\mathcal { D } _ { k , \tilde { k } }$ , recall that $\Delta B = \{ z \in \mathbb { R } ^ { d } | { \mathcal { L } } _ { \mathrm { g - S C E } } \in [ C , C + \Delta C ] \}$ , then there is
$$\begin{array} { r l } & { \Delta N = | Z ( \mathcal { D } _ { k , \tilde { k } } ) \cap \Delta B | } \\ & { \qquad = N _ { k , \tilde { k } } \cdot p _ { k , \tilde { k } } ( C ) \cdot \Delta C . } \end{array}$$
Now we calculate $\mathrm { V o l } ( \Delta B )$ by approximating it with $\mathrm { V o l } ( \Delta B _ { y , \tilde { y } } )$ . We first derive the solution of $\begin{array} { r l } { \mathcal { L } _ { y , } } & { { } = ~ C } \end{array}$ . For simplicity, we assume scaled identity covariance matrix, i.e., $\Sigma _ { i } = \sigma _ { i } I $ , where $\sigma _ { i } > 0$ are scalars. Then $\forall i , j \in [ L ]$ , $c$ is any constant, if $\sigma _ { i } \neq \sigma _ { j }$ , the solution of $h _ { i } - h _ { j } = c$ is a $( d \mathrm { - } 1 )$ -dimensional hypersphere embedded in the $d$ -dimensional space of the feature $z$ :
$$\| z - \mathbf { M } _ { i , j } \| _ { 2 } ^ { 2 } = \mathbf { B } _ { i , j } - { \frac { c } { \sigma _ { i } - \sigma _ { j } } } , { \mathrm { w h e r e } } \mathbf { M } _ { i , j } = { \frac { \sigma _ { i } \mu _ { i } - \sigma _ { j } \mu _ { j } } { \sigma _ { i } - \sigma _ { j } } } , \ \mathbf { B } _ { i , j } = { \frac { \sigma _ { i } \sigma _ { j } \| \mu _ { i } - \mu _ { j } \| _ { 2 } ^ { 2 } } { ( \sigma _ { i } - \sigma _ { j } ) ^ { 2 } } } + { \frac { B _ { i } - B _ { j } } { \sigma _ { i } - \sigma _ { j } } } .$$
Note that each value of $c$ corresponds to a specific contour, where $\mathbf { M } _ { i , j }$ and $\mathbf { B } _ { i , j }$ can be regraded as constant w.r.t. $c$ . When $\mathbf { B } _ { i , j } < ( \sigma _ { i } - \sigma _ { j } ) ^ { - 1 } c$ , the solution set becomes empty. Specially, if $\sigma _ { i } = \sigma _ { j } = \sigma$ , the hypersphere-shape contour will degenerate to a hyperplane: $z ^ { \top } ( \mu _ { i } - \mu _ { j } ) =$ $\begin{array} { r } { \frac { 1 } { 2 } \left[ \| \mu _ { i } \| _ { 2 } ^ { 2 } - \| \mu _ { j } \| _ { 2 } ^ { 2 } + \sigma ^ { - 1 } ( B _ { j } - B _ { i } + c ) \right] } \end{array}$ . For example, for the SCE loss, the solution of the contour is $z ^ { \top } ( W _ { i } - W _ { j } ) = b _ { j } - b _ { i } + c$ . For more general $\Sigma _ { i }$ , the conclusions are similar, e.g., the solution in Eq. (12) will become a hyperellipse. Now it easy to show that the solution of $\begin{array} { r l } { \mathcal { L } _ { y , } } & { { } = C } \end{array}$ when $y = k , \tilde { y } = \tilde { k }$ is the hypersphere:
$$\| z - \mathbf { M } _ { k , \tilde { k } } \| _ { 2 } ^ { 2 } = \mathbf { B } _ { k , \tilde { k } } + \frac { \log ( C _ { e } - 1 ) } { \sigma _ { k } - \sigma _ { \tilde { k } } } .$$
According to the formula of the hypersphere surface area (Loskot & Beaulieu, 2007), the volume of $\Delta B _ { y , }$ is
$$\mathrm { V o l } ( \Delta B _ { y , \tilde { y } } ) = \frac { 2 \pi ^ { \frac { d } { 2 } } } { \Gamma ( \frac { d } { 2 } ) } \left( \mathbf { B } _ { k , \tilde { k } } + \frac { \log ( C _ { e } - 1 ) } { \sigma _ { k } - \sigma _ { \tilde { k } } } \right) ^ { \frac { d - 1 } { 2 } } \cdot \Delta C ,$$
where $\Gamma ( \cdot )$ is the gamma function. Finally we can approximate the sample density as
$$\begin{array} { l } { \displaystyle \mathbb { S } \mathbb { D } ( z ) \approx \frac { \Delta N } { \Delta B _ { y , } } } \\ { \displaystyle \propto \frac { N _ { k , \tilde { k } } \cdot p _ { k , \tilde { k } } ( C ) } { \left[ \mathbf { B } _ { k , \tilde { k } } + \frac { \log ( C _ { e } - 1 ) } { \sigma _ { k } - \sigma _ { \tilde { k } } } \right] ^ { \frac { d - 1 } { 2 } } } . } \end{array}$$
# A.2 PROOF OF THEOREM 2
Similar to the proof of Theorem 1, there is
$$\begin{array} { r l } { \Delta N = | Z ( \mathcal { D } _ { k } ) \cap \Delta B | } & { } \\ { = N _ { k } \cdot p _ { k } ( C ) \cdot \Delta C . } \end{array}$$
Unlike for the $\mathbf { g }$ -SCE, we can exactly calculate $\mathrm { V o l } ( \Delta B )$ for the MMC loss. Note that the solution of $\mathcal { L } _ { \mathrm { M M C } } = C$ is the hypersphere:
$$\| z - \mu _ { y } ^ { * } \| _ { 2 } ^ { 2 } = 2 C .$$
 Figure 5: Intuitive illustration of the Max-Mahalanobis centers in the cases of $L = 2 , 3 , 4$ .
According to the formula of the hypersphere surface area (Loskot & Beaulieu, 2007), we have
$$\operatorname { V o l } ( \Delta B ) = { \frac { 2 ^ { \frac { d + 1 } { 2 } } \pi ^ { \frac { d } { 2 } } C ^ { \frac { d - 1 } { 2 } } } { \Gamma ( { \frac { d } { 2 } } ) } } \cdot \Delta C ,$$
where $\Gamma ( \cdot )$ is the gamma function. Finally we can obtain the sample density as
$$\begin{array} { l } { \displaystyle \mathbb { S D } ( z ) = \frac { \Delta N } { \Delta B } } \\ { \displaystyle \propto \frac { N _ { k } \cdot p _ { k } ( C ) } { C ^ { \frac { d - 1 } { 2 } } } . } \end{array}$$
# B TECHNICAL DETAILS
In this section, we provide more technical details we applied in our paper. Most of our experiments are conducted on the NVIDIA DGX-1 server with eight Tesla P100 GPUs.
# B.1 GENERATION ALGORITHM FOR THE MAX-MAHALANOBIS CENTERS
We give the generation algorithm for crafting the Max-Mahalanobis Centers in Algorithm 1, proposed by Pang et al. (2018). Note that there are two minor differences from the originally proposed algorithm. First is that in Pang et al. (2018) they use $C = \| \mu _ { i } \| _ { 2 } ^ { 2 }$ , while we use $C _ { \bf M M } = \| \mu _ { i } \| _ { 2 }$ . Second is that we denote the feature $z \in \mathbb { R } ^ { d }$ , while they denote $z \in \mathbb { R } ^ { p }$ . The Max-Mahalanobis centers generated in the low-dimensional cases are quite intuitive and comprehensible as shown in Fig. 5. For examples, when $L = 2$ , the Max-Mahalanobis centers are the two vertexes of a line segment; when $L = 3$ , they are the three vertexes of an equilateral triangle; when $L = 4$ , they are the four vertexes of a regular tetrahedron.
# Algorithm 1 GenerateMMcenters
<table><tr><td></td><td>Input: The constant CMm,the dimension of vectors d and the number of classes L.(L ≤d +1) Initialization: Let the L mean vectors be μ* = e1 and μ* = Od,i ÷ 1. Here e1 and Od separately</td><td></td><td></td><td></td></tr><tr><td>denote the first unit basis vector and the zero vector in Rd. fori=2 toL do</td><td></td><td></td><td></td><td></td></tr><tr><td>for j=1 toi-1 do</td><td>μ*(j)=-[1+(μ*,μ>·(L-1)]/[μ(j)·(L-1)]</td><td></td><td></td><td></td></tr><tr><td>end for</td><td></td><td></td><td></td><td></td></tr><tr><td>H(i=√1-1*12</td><td></td><td></td><td></td><td></td></tr><tr><td>end for</td><td></td><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td><td></td><td></td></tr><tr><td>for k = 1 to L do</td><td></td><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td><td></td><td></td></tr><tr><td>H=CMM·μ</td><td></td><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td><td></td><td></td></tr><tr><td>end for</td><td></td><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td><td></td><td></td></tr><tr><td>Return: The optimal mean vectors μ*,i ∈ [L].</td><td></td><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td><td></td><td></td></tr></table>
# B.2 WHY THE SQUARED-ERROR FORM IS PREFERRED
In the feature space, penalizing the distance between the features and the prefixed centers can be regarded as a regression problem. In the MMC loss, we apply the squared-error form as $\| \boldsymbol { z } - \boldsymbol { \mu } _ { y } ^ { * } \| _ { 2 } ^ { 2 }$ Other substitutes could be the absolute form $\lVert \boldsymbol { z } - \boldsymbol { \mu } _ { y } ^ { * } \rVert _ { 2 }$ or the Huber form. As stated in Friedman et al. (2001), the absolute form and the Huber form are more resistant to the noisy data (outliers) or the misspecification of the class labels, especially in the data mining applications. However, in the classification tasks that we focus on in this paper, the training data is clean and reliable. Thus the squared-error form can lead to high accuracy with faster convergence rate compared to other forms. Furthermore, in the adversarial setting, the adversarial examples have similar properties as the outliers. When we apply the AT mechanism in the training procedure, we expect the classifiers to pay more attention to the adversarial examples, i.e., the outliers. Note that this goal is the opposite of it in the data mining applications, where outliers are intended to be ignored. Therefore, due to the sensitivity to the outliers, the squared-error form can better collaborate with the AT mechanism to improve robustness.
Besides, the MMC loss can naturally perform stronger AT mechanism without additional regularizer term. Specifically, let $x$ be the clean input, $x ^ { * }$ be the adversarial example crafted based on $x$ , then in the adversarial logit pairing (ALP) method (Kannan et al., 2018), there is an extra regularizer except for SCE as:
$$\| z ( x ) - z ( x ^ { * } ) \| _ { 2 } ^ { 2 } .$$
When adding $x ^ { * }$ as an extra training point for MMC, then the MMC loss will minimize $\| z ( x ) - \mu _ { y } ^ { * } \| _ { 2 } ^ { 2 } +$ $\| z ( x ^ { * } ) - \mu _ { y } ^ { * } \| _ { 2 } ^ { 2 }$ , which is an upper bound for $\begin{array} { r } { \frac { 1 } { 2 } \| z ( x ) - z ( x ^ { * } ) \| _ { 2 } ^ { 2 } } \end{array}$ . Thus performing naive adversarial training (Goodfellow et al., 2015; Madry et al., 2018) with MMC is equivalent to performing stronger adversarial training variants like ALP. As analyzed above, the squared-error form in the MMC loss can accelerate the convergence of the AT mechanism, since the objective is sensitive to the crafted adversarial examples.
# B.3 VARIANTS OF THE MMC LOSS
In the MMC loss, we encourage the features to gather around the preset Max-Mahalanobis (MM) centers $\mu ^ { * } = \{ \mu _ { l } ^ { * } \} _ { l \in [ L ] }$ , which leads to many attractive properties. However, this ’hard’ supervision, which induces quite an orderly feature distribution may beyond the reach of the model capability, especially when the classification tasks themselves are already challenging to learn, e.g., ImageNet (Deng et al., 2009). Therefore, we propose potential variants of the MMC loss that could probably solve the problem and make our method more adaptable. We leave the experimental investigations as future work.
Note that the MMC loss can be regarded as minimizing the negative log likelihood (NLL) of $- \log ( P ( z | y ) )$ , where the conditional feature distribution is modeled as $\mathsf { \bar { z } } | y \sim \mathcal N ( \mu _ { y } ^ { * } , I )$ . As described above, this distribution model may not be easy to learn by the DNNs in some cases. Thus, we construct a softer model: $z | y , \mu _ { y } \sim \mathcal { N } ( \mu _ { y } , I )$ and $\mu _ { y } \sim \mathcal { N } ( \mu _ { y } ^ { * } , \alpha I )$ , where $\alpha > 0$ is a scalar. Here we give the feature center $\mu _ { y }$ a prior distribution, while the prior is centered at $\mu _ { y } ^ { * }$ . Intuitively, we relax the constraint that the features have to gather around $\mu _ { y } ^ { * }$ . Instead, we encourage the features to gather around a substitute $\mu _ { y }$ , while $\mu _ { y }$ should be in the vicinity of $\mu _ { y } ^ { * }$ . In the training, we minimize the joint NLL of $- \log ( P ( z , \mu _ { y } | y ) ) = - \log ( P ( z | y , \mu _ { y } ) ) - \log ( \tilde { P ( \mu _ { y } ) } )$ , which is equivalent to minimize the what we call elastic Max-Mahalanobis center (EMC) loss as:
$$\mathcal { L } _ { \mathrm { E M C } } ( Z ( x ) , y ) = \frac { 1 } { 2 } \| z - \mu _ { y } \| ^ { 2 } + \frac { 1 } { 2 \alpha } \| \mu _ { y } - \mu _ { y } ^ { * } \| ^ { 2 } .$$
Here $\mu = \{ \mu _ { l } \} _ { l \in [ L ] }$ are simply extra trainable parameters, the prior variance $\alpha$ is a hyperparameter. When $\alpha 0$ , the EMC loss degenerates to the MMC loss. Note that although $\mu _ { l } ^ { * }$ are all on the hypersphere $\{ \mathbf { z } \in \mathbb { R } ^ { d } | \| \mathbf { z } \| = C _ { \mathrm { M M } } \}$ , the support sets of $\mu _ { l }$ are the entire feature space $\mathbb { R } ^ { d }$ .
Further improvement can be made w.r.t. the MM centers $\mu ^ { * }$ . An implicit assumption behind the generation process of $\mu ^ { * }$ is that any two classes are mutually independent. This assumption could be approximately true for MNIST and CIFAR-10, but for more complex datasets, e.g., CIFAR-100 or ImageNet, this assumption may not be appropriate since there are structures in the relation among classes. These structures can usually be visualized by a tree. To solve this problem, we introduce the hierarchical Max-Mahalanobis (HM) centers $\mu ^ { \mathrm { H } } = \{ \mu _ { l } ^ { \mathrm { H } } \} _ { l \in [ L ] }$ , which adaptively craft the centers according to the tree structure. Specifically, we first assign a virtual center (i.e., the origin) to the root node. For any child node $n _ { c }$ in the tree, we denote its parent node as $n _ { p }$ , and the number of its brother nodes as $L _ { c }$ . We locally generate a set of MM centers as $\mu ^ { ( s , L _ { c } ) } =$ GenerateMMcenters $\left( C ^ { s } , d , L _ { c } \right)$ , where $s$ is the depth of the child node $n _ { c }$ , $C ^ { s }$ is a constant with smaller values for larger $s$ . Then we assign the virtual center to each child node of $n _ { p }$ from $\mu _ { n _ { p } } + \mu ^ { ( s , L _ { c } ) }$ , i.e., a shifted set of crafted MM centers, where $\mu _ { n _ { p } }$ is the virtual center assigned to $n _ { p }$ . If the child node $n _ { c }$ is a leaf node, i.e., it correspond to a class label $l$ , then there is $\mu _ { l } ^ { \mathrm { H } } = \mu _ { n _ { c } }$ . For example, in the CIFAR-100 dataset, there are 20 superclasses, with 5 classes in each superclass. We first craft $2 0 ~ \mathrm { M M }$ centers as $\mu ^ { ( 1 , 2 0 ) } =$ GenerateMMcenters $( C ^ { 1 } , d , 2 0 )$ and 5 MM centers as $\mu ^ { ( 2 , 5 ) } =$ GenerateMMcenters $( C ^ { 2 } , d , 5 )$ , where $C ^ { 2 } \ll C ^ { 1 }$ . Note that $\mu ^ { ( 2 , 5 ) }$ could be different for each superclass, e.g., by a rotation transformation. Then if the label $l$ is the $j$ -th class in the $i$ -th superclass, there is $\mu _ { l } ^ { \mathrm { H } } = \mu _ { i } ^ { ( 1 , 2 0 ) } + \mu _ { j } ^ { ( 2 , 5 ) }$
 Figure 6: Intuitive demonstration of the attacking mechanisms under different adaptive objectives. Here $_ y$ is the original label, $\begin{array} { r l } { \tilde { y } } & { { } = } \end{array}$ arg $\operatorname* { m a x } _ { l \neq y } h _ { l }$ is the label of the nearest other decision region w.r.t. the feature $_ z$ , and $y _ { t }$ is the target label of targeted attacks.
# B.4 ADAPTIVE OBJECTIVES AND THE INDUCED ATTACKING MECHANISMS
We apply the adaptive versions of existing attacks when evading the networks trained by the MMC loss. Wmode: $\mathcal { L } _ { \mathrm { A d a } } ^ { \bf u \bar { n } , 1 } = - \dot { \mathcal { L } } _ { \mathrm { M M C } } ( z , y )$ a; $\mathcal { L } _ { \mathrm { A d a } } ^ { \bar { \bf u n } , 2 } = \mathcal { L } _ { \mathrm { M M C } } ( z , \tilde { y } ) - \mathcal { L } _ { \mathrm { M M C } } ( z , y )$ $\mathcal { L } _ { \mathrm { { A d a } } }$ o minimize under the untargeted, and under the targeted mode: $\mathcal { L } _ { \mathrm { A d a } } ^ { \mathrm { t a r } , 1 } { = } \mathcal { L } _ { \mathrm { M M C } } ( z , y _ { t } )$ ; $\mathcal { L } _ { \mathrm { A d a } } ^ { \mathrm { t a r } , 2 } = \mathcal { L } _ { \mathrm { M M C } } ( z , y _ { t } ) { - \mathcal { L } _ { \mathrm { M M C } } ( z , y ) }$ , where $y _ { t }$ is the targeted label, $\tilde { y }$ is generally the highest predicted label except for by Carlini & Wagner (2017a;b). Spe $y$ as defined in Sec. 3.2. These ofically, the adaptive objectives ves rand previous workare used in the $\bar { \mathcal { L } } _ { \mathrm { A d a } } ^ { \mathrm { t a r } , 1 }$ $\mathcal { L } _ { \mathrm { A d a } } ^ { \mathbf { u n } , 1 }$ PGD, MIM and SPSA attacks, while the objectives Ltar,2Ada and $\mathcal { L } _ { \mathrm { A d a } } ^ { \mathbf { u n } , 2 }$ Ada Ada are used in the C&W attacks.
In Fig. 6, we demonstrate the attacking mechanisms induced by different adaptive adversarial objectives. Note that we only focus on the gradients and ignore the specific method which implements the attack. Different adaptive objectives are preferred under different adversarial goals. For examples, when decreasing the confidence of the true label is the goal, $\mathcal { L } _ { \mathrm { A d a } } ^ { \mathbf { u n } , 1 }$ is the optimal choice; in order to mislead the classifier to predict an untrue label or the target label, $\mathcal { L } _ { \mathrm { A d a } } ^ { \mathbf { u n } , 2 }$ and $ { \mathcal { L } } _ { \mathrm { A d a } } ^ { \mathrm { t a r } , 2 }$ are the optimal choices, respectively. Sometimes there are additional detectors, then the adversarial examples generated by $\mathcal { L } _ { \mathrm { A d a } } ^ { \mathrm { t a r } , 1 }$ could be assigned to the target label with high confidence by the classifiers.
# B.5 RELATED WORK IN THE FACE RECOGNITION AREA
There are many previous work in the face recognition area that focus on angular margin-based softmax (AMS) losses (Liu et al., 2016; 2017; Liang et al., 2017; Wang et al., 2018; Deng et al., 2019). They mainly exploit three basic operations: weight normalization (WN), feature normalization (FN), and angular margin (AN). It has been empirically shown that WN can benefit the cases with unbalanced data (Guo & Zhang, 2017); FN can encourage the models to focus more on hard examples (Wang et al., 2017); AN can induce larger inter-class margins and lead to better generalization in different facial tasks (Wang et al., 2018; Deng et al., 2019). However, there are two critical differences between our MMC loss and these AMS losses:
Table 5: Classification accuracy $( \% )$ on the white-box adversarial examples crafted on the test set of CIFAR-10 and CIFAR-100. The results w.r.t the MMC loss are reported under the adaptive versions of different attacks. MMC can better exploit deep architectures, while SCE cannot.
<table><tr><td rowspan="2">Methods</td><td rowspan="2">Cle.</td><td colspan="4">Perturbation ε = 8/255</td><td colspan="4">Perturbation ε = 16/255</td></tr><tr><td>PGD</td><td>PGD1</td><td>PGD5</td><td>PGD50</td><td>PGD</td><td>PGD</td><td>PGD5</td><td>PGD3</td></tr><tr><td colspan="9">CIFAR-10</td></tr><tr><td>SCE (Res.32)</td><td>93.6</td><td><1</td><td>3.7</td><td><1</td><td>3.6</td><td><1</td><td>2.7</td><td><1</td><td>2.9</td></tr><tr><td>MMC (Res.32)</td><td>92.7</td><td>48.7</td><td>36.0</td><td>26.6</td><td>24.8</td><td>36.1</td><td>25.2</td><td>13.4</td><td>17.5</td></tr><tr><td>SCE (Res.110) MMC (Res.110)</td><td>94.7 93.6</td><td>≤1 54.7</td><td>3.0 46.0</td><td>≤1 34.4</td><td>2.9 31.4</td><td><1 41.0</td><td>2.1 30.7</td><td>≤1 16.2</td><td>2.0 21.6</td></tr><tr><td colspan="10">CIFAR-100</td></tr><tr><td>SCE (Res.32)</td><td>72.3</td><td><1</td><td>7.8</td><td><1</td><td>7.4</td><td><1</td><td>4.8</td><td><1</td><td>4.7</td></tr><tr><td>MMC (Res.32)</td><td>71.9</td><td>23.9</td><td>23.4</td><td>15.1</td><td>21.9</td><td>16.4</td><td>16.7</td><td>8.0</td><td>15.7</td></tr><tr><td>SCE (Res.110)</td><td>74.8</td><td>≤1</td><td>7.5</td><td>≤1</td><td>7.3</td><td>≤1</td><td>4.7</td><td>≤1</td><td>4.5</td></tr><tr><td>MMC (Res.110)</td><td>73.2</td><td>34.6</td><td>22.4</td><td>23.7</td><td>16.5</td><td>24.1</td><td>14.9</td><td>13.9</td><td>10.5</td></tr></table>
# Difference one: The inter-class margin
• The AMS losses induce the inter-class margins mainly by encouraging the intra-class compactness, while the weights are not explicitly forced to have large margins (Qi & Zhang, 2018).
• The MMC loss simultaneously fixes the class centers to be optimally dispersed and encourages the intra-class distribution to be compact. Note that both of the two mechanisms can induce inter-class margins, which can finally lead to larger inter-class margins compared to the AMS losses.
# Difference two: The normalization
• The AMS losses use both WN and FN to exploit the angular metric, which makes the normalized features distribute on hyperspheres. The good properties of the AMS losses are at the cost of abandoning the radial degree of freedom, which may reduce the capability of models.
• In the MMC loss, there is only WN on the class centers, i.e., $\| \mu _ { y } ^ { * } \| = C _ { \mathrm { M M } }$ , and we leave the degree of freedom in the radial direction for the features to keep model capacity. However, note that the MMC loss $\| z - \mu _ { y } ^ { * } \| _ { 2 } ^ { 2 } \geq ( \| z \| _ { 2 } - C _ { \mathrm { M M } } ) ^ { 2 }$ is a natural penalty term on the feature norm, which encourage $\left. z \right. _ { 2 }$ to not be far from $C _ { \mathrm { M M } }$ . This prevents models from increasing feature norms for easy examples and ignoring hard examples, just similar to the effect caused by FN but more flexible.123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376# UNDERSTANDING KNOWLEDGE DISTILLATION IN NON-AUTOREGRESSIVE MACHINE TRANSLATION
Chunting Zhou1∗, Jiatao $\mathbf { G u ^ { 2 * } }$ , Graham Neubig1
Language Technologies Institute, Carnegie Mellon University Facebook AI Research2 {chuntinz, gneubig}@cs.cmu.edu, jgu@fb.com
# ABSTRACT
Non-autoregressive machine translation (NAT) systems predict a sequence of output tokens in parallel, achieving substantial improvements in generation speed compared to autoregressive models. Existing NAT models usually rely on the technique of knowledge distillation, which creates the training data from a pretrained autoregressive model for better performance. Knowledge distillation is empirically useful, leading to large gains in accuracy for NAT models, but the reason for this success has, as of yet, been unclear. In this paper, we first design systematic experiments to investigate why knowledge distillation is crucial in NAT training. We find that knowledge distillation can reduce the complexity of data sets and help NAT to model the variations in the output data. Furthermore, a strong correlation is observed between the capacity of an NAT model and the complexity of the distilled data that provides the best translation quality. Based on these findings, we further propose several approaches that can alter the complexity of data sets to improve the performance of NAT models. We achieve state-of-theart performance for NAT-based models, and close the gap with the autoregressive baseline on the WMT14 En-De benchmark.1
# 1 INTRODUCTION
Traditional neural machine translation (NMT) systems (Bahdanau et al., 2015; Gehring et al., 2017; Vaswani et al., 2017) generate sequences in an autoregressive fashion; each target token is predicted step-by-step by conditioning on the previous generated tokens in a monotonic (e.g. left-to-right) order. While such autoregressive translation (AT) models have proven successful, the sequential dependence of decisions precludes taking full advantage of parallelism afforded by modern hardware (e.g. GPUs) at inference time. In contrast, non-autoregressive translation (NAT) models (Gu et al., 2018; Lee et al., 2018) predict the whole sequence or multi-token chunks of the sequence simultaneously, alleviating this problem by trading the model’s capacity for decoding efficiency. Such a non-autoregressive factorization assumes that the output tokens are independent from each other. However, this assumption obviously does not hold in reality and as a result NAT models generally perform worse than standard AT models.
One key ingredient in the training recipe for NAT models that is used in almost all existing works (Gu et al. (2018); Lee et al. (2018); Stern et al. (2019), inter alia) is creation of training data through knowledge distillation (Hinton et al., 2015). More precisely, sequence-level knowledge distillation (Kim & Rush, 2016) – a special variant of the original approach – is applied during NAT model training by replacing the target side of training samples with the outputs from a pre-trained AT model trained on the same corpus with a roughly equal number of parameters. It is usually assumed (Gu et al., 2018) that knowledge distillation’s reduction of the “modes” (alternative translations for an input) in the training data is the key reason why distillation benefits NAT training. However, this intuition has not been rigorously tested, leading to three important open questions:
• Exactly how does distillation reduce the “modes”, and how we could we measure this reduction quantitatively? Why does this reduction consistently improve NAT models? • What is the relationship between the NAT model (student) and the AT model (teacher)? Are different varieties of distilled data better for different NAT models? • Due to distillation, the performance of NAT models is largely bounded by the choice of AT teacher. Is there a way to further close the performance gap with standard AT models?
In this paper, we aim to answer the three questions above, improving understanding of knowledge distillation through empirical analysis over a variety of AT and NAT models. Specifically, our contributions are as follows:
• We first visualize explicitly on a synthetic dataset how modes are reduced by distillation (§3.1). Inspired by the synthetic experiments, we further propose metrics for measuring complexity and faithfulness for a given training set. Specifically, our metrics are the conditional entropy and KL-divergence of word translation based on an external alignment tool, and we show that these metrics are correlated with NAT model performance (§3.2). We conduct a systematic analysis (§4) over four AT teacher models and six NAT student models with various architectures on the standard WMT14 English-German translation benchmark. These experiments find a strong correlation between the capacity of an NAT model and the optimal dataset complexity that results in the best translation quality. • Inspired by these observations, we propose approaches to further adjust the complexity of the distilled data in order to match the model’s capacity (§5). We also show that we can achieve the state-of-the-art performance for NAT models and largely match the performance of the AT model.
# 2 BACKGROUND
# 2.1 NON-AUTOREGRESSIVE NEURAL MACHINE TRANSLATION
In order to model the joint probability of the output sequence $\textbf { { y } }$ , NMT models usually generate each output token conditioned on the previously generated ones $\begin{array} { r } { p ( \pmb { y } | \pmb { x } ) = \prod _ { t = 1 } ^ { T } p ( y _ { t } | \pmb { y } _ { < t } , \pmb { x } ) } \end{array}$ . This is known as the autoregressive factorization. To generate a translation from this model, one could predict one token at a time from left to right and greedily take arg max over each output probability distribution, or use beam search to consider a fixed number of hypotheses. In this work, we study non-autoregressive translation (NAT), a special subset of NMT models with an additional restriction (the zeroth-order Markov assumption) upon the output predictions or a subset thereof. The simplest formulation of an NAT model independently factors the conditional distribution: $\begin{array} { r } { p ( \pmb { y } | \pmb { x } ) = \overline { { \prod _ { t = 1 } ^ { T } p ( y _ { t } | \pmb { x } ) } } } \end{array}$ .
Standard NAT models (Gu et al., 2018) adopt an architecture similar to the Transformer (Vaswani et al., 2017) and make non-autoregressive predictions for the entire sequence with one forward pass of the decoder. However, because multiple translations are possible for a single input sentence (the so-called multi-modality problem; Gu et al. (2018)), vanilla NAT models can fail to capture the dependencies between output tokens. As a result, they tend to make egregious mistakes such as outputting tokens repeatedly. To improve the model’s ability to handle multi-modality, recent works have incorporated approaches including (1) relaxing the fully non-autoregressive restriction and adopting $K$ decoding passes (instead of just one) to iteratively refine the generated outputs (Lee et al., 2018; Ghazvininejad et al., 2019; Wang et al., 2018; Stern et al., 2018; 2019; Gu et al., 2019); (2) using latent variables (Kaiser et al., 2018; Ma et al., 2019; Shu et al., 2019) or structured information such as syntax trees (Akoury et al., 2019) to capture translation variation; (3) training NAT models with objectives other than maximum likelihood (Wang et al., 2019; Wei et al., 2019; Shao et al., 2019) which ameliorates the effects of multi-modality. However, to achieve competitive performance with the autoregressive model, almost all existing NAT models rely on training using data distilled from a pre-trained AT model instead of the real parallel training set, as described below.
# 2.2 SEQUENCE-LEVEL KNOWLEDGE DISTILLATION
Knowledge distillation (Liang et al., 2008; Hinton et al., 2015) was originally proposed for training a weaker student classifier on the targets predicted from a stronger teacher model. A typical approach is using the label probabilities produced by the teacher as “soft targets” $q _ { i } =$ $\mathrm { e x p } ( z _ { i } \bar { / \tau } ) / { \sum _ { j } \mathrm { e x p } ( z _ { j } \bar { / \tau } ) }$ for training the student model, where $q _ { i }$ and $z _ { i }$ are the probability and the logit of class $i$ respectively and $\tau$ is the temperature. Prior work has shown the effectiveness of adopting knowledge distillation in adversarial defense (Papernot et al., 2016), neural network compression (Howard et al., 2017), and fast inference for speech synthesis (Oord et al., 2018).
In the context of sequence generation, Kim & Rush (2016) extend knowledge distillation to the sentence level using “hard targets” from a pretrained large teacher model to train a small sequence generation model. More precisely, the teacher distribution $q ( t | x )$ is approximated by its mode: $\begin{array} { r } { \bar { q } ( { \pmb t } | { \pmb x } ) \approx \mathbb { 1 } \{ { \pmb t } = \arg \operatorname* { m a x } _ { { \pmb t } \in { \mathcal T } } q ( { \pmb t } | { \pmb x } ) \} } \end{array}$ with the following objectives:
$$\mathcal { L } _ { \mathrm { s e q } , \mathrm { K D } } = - \mathbb { E } _ { \mathbf { x } \sim \mathrm { d a t a } } \sum _ { t \in \mathcal { T } } q ( t | x ) \log p ( t | x ) \approx - \mathbb { E } _ { \mathbf { x } \sim \mathrm { d a t a } , \hat { y } = \mathbf { a r g } \operatorname* { m a x } _ { t \in \mathcal { T } } \mathbf { \Phi } } q ( t | x ) \left[ \log p ( t = \hat { y } | x ) \right] ,$$
where $t \in \tau$ is the space of possible target sequences. This can also be seen as a special case of standard distillation over the sentence space when the temperature $\tau$ approaches 0, which is equivalent to taking the arg max over all feasible translations. While the “hard target” $\hat { y }$ is the most likely translation predicted by the teacher, in practice we use beam search as an approximation. As mentioned earlier, almost all the existing literature trains NAT models using sequence-level knowledge distillation from a pre-trained AT model to achieve competitive performance. Particularly, it is common to train the teacher model as a standard autoregressive Transformer (Vaswani et al., 2017) with a roughly equal number of trainable parameters as the desired NAT model on the real data. Next, we will first study how this knowledge distillation process affects the behavior of NAT models.
# 3 HOW DOES DISTILLATION IMPROVE NAT?
In this section, we start from an introductory example to illustrate how NAT models fail to capture the multi-modality of data. Then we propose a metric to assess the multi-modality of a data set and use it to test our hypothesis about how knowledge distillation affects NAT models.
# 3.1 SYNTHETIC EXPERIMENT FOR MULTI-MODALITY
Dataset. We start by investigating NAT’s difficulties in modeling multi-modality in output data using a synthetic setup where we explicitly include multiple modes in the training data. More specifically, we utilize three language pairs – English-German (En-De), English-French (En-Fr), and English-Spanish (En-Es) – from the Europarl parallel corpus.2 We extract sentences that have aligned sentences for all languages, and create a multi-target En-De/Es/Fr corpus. In this case every English input sentence always corresponds to target sentences in three different languages, which forms three explicit output modes. Notably, this is similar to the one-to-many translation setting in Johnson et al. (2017) but in our case we do not have an explicit signal (e.g. target language tag) to tell the NMT model which target language to translate to.
Models. We train both the AT and NAT models on this concatenated data set, then compare the distributions of translations with each other. We use the standard Transformer(base) model (Vaswani et al., 2017) as the AT model, and a simplified version of Gu et al. (2018) as the NAT model where the decoder’s inputs are monotonically copied from the encoder embeddings and a length predictor is learned to predict the target sentence length. Both models are trained for 300, 000 steps using maximum likelihood. After training, we use both models to translate the English sentences in the validation and test sets.
Visualization of AT Outputs. The synthetic setup enables us to better understand and visualize the modes in the outputs more easily. First, we visualize the outputs from the AT model. For every translated sentence, we visualize the estimated probability distribution of language classes as a point in Fig. 1 (a). This probability is calculated as the average of the posterior probability of each token, and it is estimated based on the Bayes’ law:
$$p ( l _ { i } | \pmb { y } ) \approx \frac { 1 } { T } \sum _ { t = 1 } ^ { T } p ( l _ { i } | y _ { t } ) = \frac { 1 } { T } \sum _ { t = 1 } ^ { T } \frac { p ( y _ { t } | l _ { i } ) p ( l _ { i } ) } { \sum _ { k } p ( y _ { t } | l _ { k } ) p ( l _ { k } ) }$$
 Figure 1: Posterior distribution of language IDs for the outputs from different models. Each translation is represented as a point inside the simplex $\Delta ^ { 2 } = \{ ( p _ { \mathrm { d e } } , p _ { \mathrm { e s } } , p _ { \mathrm { f r } } ) | p _ { k } \in ( 0 , 1 ) , p _ { \mathrm { d e } } + p _ { \mathrm { e s } } + p _ { \mathrm { f r } } = 1 \}$ where $p _ { k }$ is the estimated probability of being translated into language $k \in ( \mathrm { d e } , \mathrm { e s } , \mathrm { f r } )$ . We distinguish the language that has the largest probability with different colors.
where $l _ { i }$ denotes the language class $i$ , and $p ( y _ { t } | l _ { i } )$ is the token frequency of $y _ { t }$ in language $l _ { i }$ . We assume $p ( l _ { i } )$ follows a uniform distribution. As shown in Fig. 1 (a), points of the AT outputs are clustered closely to each vertex of the simplex, indicating that the AT model prefers to generate the whole sequence in one language. This phenomenon verifies our assumption that decoding with the AT model (distillation) is essentially selecting “modes” over the real data.
Visualization of NAT Outputs. We visualize outputs for the NAT model trained on the same data in Fig. 1 (b). In contrast to the AT results, the NAT points are scattered broadly inside the simplex, indicating that the NAT model fails to capture the mode of language types. Instead, it predicts tokens mixed with multiple languages, which corroborates our hypothesis that the NAT model has trouble consistently selecting a single mode when multiple modes exist.
Next, we create two datasets that have fewer modes than the original dataset. First, we randomly select a single target sentence from one of the three languages for each source sentence. Second, we perform distillation, decoding from the AT model trained on the combined training set. As noted in the AT results, distillation will also roughly be selecting a language mode, but we conjecture that this selection may be more systematic, selecting a particular language for a particular type of training sentence. As shown in Fig. 1(c) (d), NAT models trained on both of these datasets are more likely to choose one mode (language) when generating translations, showing that training with reduced modes is essential for NAT model. Furthermore, points in Fig. 1 (d) are clearly clustered better than (c) indicating that modes selected by AT models are indeed likely more systematic and easy to capture than those generated by randomly assigning a language for each sentence.
# 3.2 QUANTITATIVE MEASURES FOR PARALLEL DATA
To better study why distillation is crucial for NAT models, in this section, we propose quantitative measures for analyzing the complexity and faithfulness of parallel data, two properties that we hypothesize are important for NAT training.
Measure of Complexity. Inspired by the observations in the synthetic experiments, we propose to use a measure of translation uncertainty, specifically operationalized as conditional entropy, as the measurement of complexity $C ( d )$ for any given dataset $d = \{ ( \pmb { x } _ { 1 } , \pmb { y } _ { 1 } ) , . . . , ( \pmb { x } _ { N } , \pmb { y } _ { N } ) \}$ , where $( { \pmb x } , { \pmb y } )$ is sentence pair instantiation of $( \mathbf { \bar { X } } , \mathbf { Y } )$ and $\mathbf { X } \in { \mathcal { X } } , \mathbf { Y } \in { \mathcal { Y } }$ :
asm.1: conditional independence
$$\begin{array} { r l } { \mathcal { H } ( { \mathbf { Y } } | { \mathbf { X } } = x ) = \displaystyle \sum _ { y \in \mathcal { Y } } p ( y | x ) \log p ( y | x ) } \\ & { ~ \mathrm { ~ } } \\ { \approx \displaystyle \sum _ { y \in \mathcal { Y } } ( \displaystyle \prod _ { \substack { l = 1 } } ^ { T _ { y } } p ( y | x ) ) ( \displaystyle \sum _ { t = 1 } ^ { T _ { y } } \log p ( y _ { t } | x ) ) } \\ & { ~ \approx \displaystyle \sum _ { t = 1 } ^ { T _ { y } } \displaystyle \sum _ { y _ { t } < A ( x ) } p ( y _ { t } | \mathrm { A l i g n } ( y _ { t } ) ) \log p ( y _ { t } | \mathrm { A l i g n } ( y _ { t } ) ) } \\ & { ~ = \displaystyle \sum _ { t = 1 } ^ { T _ { x } } \mathcal { H } ( y | x = x _ { t } ) } \end{array}$$
<table><tr><td>d</td><td>En-De</td><td>En-Es</td><td></td><td>En-Fr丨Full Real Data</td><td>Random Selection</td><td>Distillation</td></tr><tr><td>C(d)</td><td>3.12</td><td>2.81</td><td>2.89</td><td>3.67</td><td>3.30</td><td>2.64</td></tr></table>
Table 1: Complexity $C ( d )$ $\uparrow$ more complex) of the Europarl data set of different settings in $\ S 3 . 1$ .
where we use $x$ and $y$ to denote a word in the source and target vocabulary respectively. $T _ { x }$ and $T _ { y }$ denote the length of the source and target sentences. To make the computation tractable, we make two additional assumptions on the conditional distribution $p ( \pmb { y } | \pmb { x } )$ :
• Assumption 1: We assume the target tokens are independent given the source sentence. Then the conditional entropy of a sentence can be converted into the sum of entropy of target words conditioned on the source sentence $_ { \textbf { \em x } }$ . • Assumption 2: We assume the distribution of $p ( y _ { t } | \pmb { x } )$ follows an alignment model (Dyer et al., $2 0 1 3 ) ^ { \bar { 3 } }$ where $y _ { t }$ is is generated from the word alignment distribution $p ( y _ { t } | \mathrm { A l i g n ( y _ { t } ) } )$ . This makes it possible to simplify the conditional entropy to the sum of entropy of target words conditioned on the aligned source words denoted $\mathcal { H } ( y \vert x = x _ { t } )$ ).
The corpus level complexity $C ( d )$ is then calculated by adding up the conditional entropy $\mathcal { H } ( \mathbf { Y } | \mathbf { X } =$ ${ \pmb x } )$ of all sentences. To prevent $C ( d )$ from being dominated by frequent words, we calculate $\ddot { C } ( d )$ by averaging the entropy of target words conditioned on a source word, denoted $C ( d ) \ =$ $\begin{array} { r } { \frac { 1 } { | \mathcal { V } _ { x } | } \overset { \cdot } { \sum _ { x \in \mathcal { V } _ { x } } } \mathcal { H } ( y | x ) } \end{array}$ .
To illustrate that the proposed metric is a reasonable measure of complexity of a parallel corpus, in Tab. 1 we compute $C ( d )$ for parallel data from different language pairs, the concatenated data set, and the data distilled from the AT model described in $\ S 3 . 1$ . We observe that the conditional entropy of the distilled data is much smaller than that of the concatenated or randomly selected data mentioned above. Additionally, we find that the conditional entropy of En-Es and En-Fr are similar but that of En-De is relatively larger, which can also explain why the student NAT model prefers to predict the modes of Es or Fr more often than De as shown in Fig. 1(d).
Measure of Faithfulness. $C ( d )$ reflects the level of multi-modality of a parallel corpus, and we have shown that a simpler data set is favorable to an NAT model. However, it is not fair to assess the data set only by its complexity; we can trivially construct a simple data set with no variations in the output, which obviously won’t be useful for training. The other important measurement of the data set is its faithfulness to the real data distribution. To measure the faithfulness of a parallel corpus $d$ , we use KL-divergence of the alignment distribution between the real parallel data set $r$ and an altered parallel data set $d$ , denoted $F ( d )$ :
$$F ( d ) = \frac { 1 } { | \mathcal { V } _ { x } | } \sum _ { x \in \mathcal { V } _ { x } } \sum _ { y \in \mathcal { V } _ { y } } p _ { r } ( y | x ) \log \frac { p _ { r } ( y | x ) } { p _ { d } ( y | x ) }$$
# 4 EMPIRICAL STUDY
In this section, we perform an extensive study over a variety of non-autoregressive (NAT) models trained from different autoregressive (AT) teacher models to assess how knowledge distillation affects the performance of NAT models.
# 4.1 EXPERIMENTAL SETTINGS
Data. We use the data set commonly used by prior work as our evaluation benchmark: WMT14 English-German $( \mathrm { E n - D e } ) ^ { 4 }$ . We use newstest2013 as the validation set for selecting the best model, and newstest2014 as the test set. We learn a byte-pair encoding (BPE, Sennrich et al., 2016) vocabulary of 37,000 on the tokenized data.
AT Models. We set up four Transformer models with different parameter sizes: Transformertiny/small/base/big denoted as tiny, small, base, big respectively. We build base and big models following settings described in Vaswani et al. (2017), and reduce the model sizes for tiny, small to create weaker teacher models. Details of the model architectures can be found in Appendix A.
All the models are trained using the Adam optimizer (Kingma & Ba, 2014) with the maximum number of steps set to 300, 000. After training, we use the resulting AT models to decode the whole training set with beam size 5 and replace the real target sentences to create a new parallel corpus.
NAT Models. We consider the following NAT models, from vanilla to state-of-the-art. All the models are using the Transformer as the basic backbone and are (re-)implemented based on Fairseq5 except for FlowSeq. We briefly outline the methods and parameters here, and describe detailed settings in the Appendix A.
• Vanilla NAT (Gu et al., 2018): Similarly to $\ S 3 . 1$ , we use a simplified version where the decoder’s inputs are directly copied from the encoder without considering latent variables. • FlowSeq (Ma et al., 2019): FlowSeq adopts normalizing flows (Kingma & Dhariwal, 2018) as the latent variables to model the mappings from source sentences to a latent space. • NAT with Iterative Refinement (iNAT, Lee et al., 2018): iNAT extends the vanilla NAT by iteratively reading and refining the translation. The number of iterations is set to 10 for decoding. • Insertion Transformer (InsT, Stern et al., 2019): InsT adopts a similar architecture as iNAT while generating the sequence by parallel insertion operations. Here, we only consider InsT trained with uniform loss as described in the original paper. • MaskPredict (MaskT, Ghazvininejad et al., 2019): MaskT adopts a masked language model (Devlin et al., 2018) to progressively generate the sequence from an entirely masked input. The number of iterations is set to be 10. • Levenshtein Transformer (LevT, Gu et al., 2019): LevT uses similar architectures as in InsT and MaskT while generating based on both insertion and deletion operations. We experiment with a base and big LevT model (LevT and LevT-big in Tab. 2).
We also summarize the parameter size, performance and relative decoding speed of the NAT models introduced in Tab. 2. We use the decoding time of vanilla NAT to represent one unit of time, and $\mathtt { I t e r s } \times \mathtt { P a s s }$ represents the relative time units used for each model.
As mentioned earlier, we analyze each model by training from both the real and 4 distilled targets. We train the NAT models for the same number of steps as the AT models. For a fair comparison of the actual ability of each NAT-based model, we test all the models based on greedy decoding without any advanced search algorithms (e.g. length beam (Ghazvininejad et al., 2019), noisy parallel decoding (Ma et al., 2019), or re-ranking from the teacher model (Gu et al., 2018)). Notably, the vanilla NAT and FlowSeq output translations with single forward pass, while the remaining models are based on the iterative refinement.
# 4.2 ANALYSIS OF THE DISTILLED DATA
Table 2: AT and NAT models. Number of parameters and test BLEU when trained on the real data demonstrate model capacity. Iters is number of passes used in decoding for output length $n$ and hyperparameter $k$ . Pass is relative time used for one pass of decoding.
<table><tr><td>Models</td><td>Params</td><td>BLEU</td><td>Pass</td><td>Iters</td></tr><tr><td>AT models</td><td></td><td></td><td></td><td></td></tr><tr><td>AT-tiny</td><td>16M</td><td>23.3</td><td></td><td>n</td></tr><tr><td>AT-small</td><td>37M</td><td>25.6</td><td></td><td>n</td></tr><tr><td>AT-base</td><td>65M</td><td>27.1</td><td></td><td>n</td></tr><tr><td>AT-big</td><td>218M</td><td>28.2</td><td></td><td>n</td></tr><tr><td>NAT models</td><td></td><td></td><td></td><td></td></tr><tr><td>vanilla</td><td>71M</td><td>11.4</td><td>1</td><td>1</td></tr><tr><td>FlowSeq</td><td>73M</td><td>18.6</td><td>13</td><td>1</td></tr><tr><td>iNAT</td><td>66M</td><td>19.3</td><td>1</td><td>k<n</td></tr><tr><td>InsT</td><td>66M</td><td>20.9</td><td>1</td><td>~ log2 n</td></tr><tr><td>MaskT</td><td>66M</td><td>23.5</td><td>1</td><td>10</td></tr><tr><td>LevT</td><td>66M</td><td>25.2</td><td>1</td><td>3k<n</td></tr><tr><td>LevT-big</td><td>220M</td><td>26.5</td><td>~3</td><td>3k<n</td></tr></table>
We compare different dimensions of the data generated by the four AT models and the real data set in Fig. 3. First, Fig. 3 (a) shows that as the capacity of the AT model increases, the
complexity $\dot { C } ( d )$ of the distilled data increases, which indicates that the multi-modality increases as well. At the same time, we observe that $F ( d )$ defined in $\ S 3 . 2$ also decreases, showing that the distilled data more faithfully represents the word-level translation distribution of the original data.
Source For more than 30 years , Josef Winkler has been writing from the heart , telling of the hardships of his childhood and youth . Distilled Target Seit mehr als 30 Jahren schreibt Josef Winkler aus dem Herzen und erzählt von der Not seiner Kindheit und Jugend . Real Target Josef Winkler schreibt sich seit mehr als 30 Jahren die Nöte seiner Kindheit und Jugend von der Seele .
 Figure 2: A sampled pair together with its real target from the distilled data of the base-AT model. Chunks annotated in the same colors are approximately aligned with each other. Figure 3: Complexity $C ( d )$ (↑ more complex), faithfulness $F ( d )$ ( $\downarrow$ more faithful), training BLEU, and reordering score $\uparrow$ more monotonic alignment) of different distilled sets of WMT14-ENDE.
Second, we plot the BLEU score of the distilled data w.r.t to the real data set in (b) and we observe that the BLEU score of the distilled data from a higher-capacity teacher model is higher, which is both intuitive and in agreement with the results on KL divergence.
We also investigate how the relative ordering of words in the source and target sentences is changed during distillation. We use the fuzzy reordering score proposed in Talbot et al. (2011). A larger fuzzy reordering score indicates the more monotonic alignments. As shown in Fig 3 (c), the distilled data has significantly less reordering compared to the real parallel sentences, and the distilled data from a weaker AT teacher is more monotonic than a stronger AT teacher. We also show a randomly sampled example in Fig. 2 where compared to the real translation, the AT distilled target is much more monotonically aligned to the source sentence. This has potential benefits in that these simpler reordering patterns may be easier to learn for NAT models, but also disadvantages in that it may prevent NAT models from learning complex reordering patterns.
# 4.3 ANALYSIS OF DISTILLATION STRATEGIES
In $\ S 4 . 2$ , we have shown that decoding with an AT model reduces the conditional entropy of the parallel data set, which mitigates multi-modality in the output data. But does the decoding method of the AT model affect this change in the data set? We also investigate different decoding strategies when creating distilled data, using the base Transformer model as the teacher and the vanilla NAT model as the student. In Tab. 3, four decoding methods are presented: sampling, sampling within the top-10 candidates, beam search, and greedy decoding. With the same AT model, the performance of the NAT model differs widely depending on the decoding approach, where distillation with beam search results in the best performance.
We can see that beam search or greedy decoding can reduce the complexity of the real data the most while maintaining high faithfulness. In contrast, sampling based decoding methods less aggressively reduce the modes in the output sequence. This finding is in concert with Ott et al. (2018), who demonstrate that because beam search approximately selects the most probable translation, it effectively reduces diversity in the output translations compared to sampling or the true distribution.
Table 3: Comparisons of decoding methods on WMT14-ENDE newstest 2014 test set.
<table><tr><td>Decoding Method</td><td>C(d)</td><td>F(d)</td><td>BLEU</td></tr><tr><td> sampling</td><td>3.623</td><td>3.354</td><td>6.6</td></tr><tr><td>sampling (Top 10)</td><td>2.411</td><td>2.932</td><td>14.6</td></tr><tr><td>greedy</td><td>1.960</td><td>2.959</td><td>18.9</td></tr><tr><td>beam search</td><td>1.902</td><td>2.948</td><td>19.5</td></tr></table>
# 4.4 DISTILLED DATA V.S. NAT MODELS
We next examine the relationship between the NAT students and distilled training data from different AT models. In Fig. 4, we demonstrate results for the NAT models listed in $\ S 4 . 1$ . We use the test set performance on real data as a simple metric to measure the capacity of the NAT model and arrange the subfigures in an increasing order of the performance (left-to-right, top-to-bottom). The results in the figure demonstrate that, interestingly, weaker NAT students prefer distilled data with smaller complexity as measured above in $\ S 4 . 2$ . The best performance of NAT models – from lower capacity ones to higher capacity ones – is achieved with distilled data of lower complexity to higher complexity, i.e. the vanilla NAT model performs best when using the distilled data from a small Transformer whereas LevT achieves the best performance when training with the distilled data from a big Transformer. Third, and notably, by simply changing the distilled data set upon which the models are trained, we are able to significantly improve the state-of-the-art results for models in a particular class. For example, FlowSeq increased to 22, by simply changing from the distilled data of Transformer(base) to Transformer(small). Finally, we find that by distilling from a big AT model, LevT is able to close the gap with the Transformer (base) with a similar number of parameters. Both LevT and LevT-big achieve the state-of-the-art performance for NAT-based models.
 Figure 4: The performance of NAT models of varying capacity trained on both the real and the distilled data from tiny, small, base and big AT models on WMT14-ENDE newstest 2014 test sets.
# 5 IMPROVEMENTS TO KNOWLEDGE DISTILLATION
The previous section shows that the optimal complexity of the dataset is highly correlated with the capacity of the NAT model. In this section, we introduce three techniques that can be used to alter the distilled data to match the capacity of NAT model. Specifically, these techniques can be used to simplify the data further (BANs, MoE) for a lower-capacity student model or increase faithfulness of the data set (Interpolation) for a higher-capacity student model.
Born-Again Networks. We apply Born-Again neworks (BANs) to create a simplified dataset for NAT models. BANs were originally proposed as a self-distillation technique (Furlanello et al., 2018) that uses the output distribution of a trained model to train the original model. Starting from the real data, we repeatedly train new AT models with decoded sentences from the AT model at the previous iteration. This process is repeated for $k$ times and yields $k$ distilled data sets, upon which we perform NAT training and examine how the $k$ born-again teachers affect the performance of NAT students.
We conduct experiments using the vanilla NAT model (Gu et al., 2018) (which achieved the best performance with distilled data from a small Transformer in $\ S 4 . 4 )$ and the base Transformer as the AT model. As shown in Fig. 5, we can make the following observations: (i) The performance of the base AT model almost remains unchanged during the reborn iterations. (ii) The performance of the vanilla NAT model can be improved by 2 BLEU when using the distilled data from reborn iteration 6. (iii) As the reborn iterations continue, the complexity of the distilled data decreases and becomes constant eventually. Meanwhile, the quality of the distilled data compared to the real data decreases.
 Figure 5: Reborn experiments: (from left to right) performance of the base AT model, performance of the vanilla NAT model, $C ( d )$ and $F ( d )$ of distilled data sets. R-i denotes the $i$ -th reborn iteration.
 Figure 6: MoE experiments: (from left to right) performance of the base AT model, performance of the vanilla NAT model, $C ( d )$ and $F ( d )$ of distilled data sets w.r.t the number of experts.
Mixture-of-Experts. The mixture-of-expert model (MoE; Shen et al. (2019)) learns different experts for diverse machine translation, and different mixture components were shown to capture consistent translation styles across examples. Inspired by this, we use one expert from the mixture model to translate the training data, which is supposed to generate a single style of translation and reduce the diversity in the original data set. Then we use the best single-expert translations as the distilled data to train the vanilla NAT model. Specifically, we follow Shen et al. (2019)’s setup, using the base Transformer model and uniform hard mixture model, varying the number of experts.
In Fig. 6, we observe that the performance of the best expert of MoE tends to decrease as the number of experts increases. However, the complexity $( C ( d ) )$ and faithfulness $( F ( D ) )$ of distilled data from different MoE models has a relatively large variance. Compared to using the distilled data from a plain base AT model, the performance of NAT model is improved by 1.21 BLEU when using the distilled data from the MoE model with the number of experts of 3 which produces the distilled data with the least complexity.
<table><tr><td>d</td><td>C(d)</td><td>F(d)</td><td>BLEU</td></tr><tr><td>base</td><td>1.902</td><td>2.948</td><td>26.94</td></tr><tr><td>base-inter</td><td>1.908</td><td>2.916</td><td>27.32</td></tr></table>
Sequence-Level Interpolation. $\ S 4 . 4$ shows stronger NAT models (e.g. MaskT, LevT) have the ability to learn from the dataset that is closer to the real data, and achieve better performance. We adopt the sequence-level interpolation proposed in Kim & Rush (2016) as a natural way to create a better dataset. Different from distillation, interpolation picks the sentence with the highest sentence-level BLEU score w.r.t. the ground truth from $K$ −best beam search hy
Table 4: Results w/ and w/o sequencelevel interpolation with LevT.
potheses. In our experiments, we first run beam search using the base Transformer model with a beam size of 5 then select the sentences with the highest BLEU score from the top-3 candidates.
Tab. 4 compares the performance of LevT trained with distilled data from the AT model with the standard distillation or interpolation. We observe that selection with BLEU score from the base AT model (base-inter) improves the performance of LevT $\sim 0 . 4$ BLEU while the dataset complexity $C ( d )$ does not increase much.
# 6 CONCLUSION
In this paper, we first systematically examine why knowledge distillation improves the performance of NAT models. We conducted extensive experiments with autoregressive teacher models of different capacity and a wide range of NAT models. Furthermore, we defined metrics that can quantitatively measure the complexity of a parallel data set. Empirically, we find that a higher-capacity
NAT model requires a more complex distilled data to achieve better performance. Accordingly, we propose several techniques that can adjust the complexity of a data set to match the capacity of an NAT model for better performance.
# REFERENCES
Nader Akoury, Kalpesh Krishna, and Mohit Iyyer. Syntactically supervised transformers for faster neural machine translation. In Proceedings of the 57th Annual Meeting of the Association for Computational Linguistics, pp. 1269–1281, Florence, Italy, July 2019. Association for Computational Linguistics. doi: 10.18653/v1/P19-1122. URL https://www.aclweb.org/ anthology/P19-1122.
Dzmitry Bahdanau, Kyunghyun Cho, and Yoshua Bengio. Neural machine translation by jointly learning to align and translate. In International Conference on Learning Representations (ICLR), 2015.
Satanjeev Banerjee and Alon Lavie. Meteor: An automatic metric for mt evaluation with improved correlation with human judgments. In Proceedings of the acl workshop on intrinsic and extrinsic evaluation measures for machine translation and/or summarization, pp. 65–72, 2005.
Jacob Devlin, Ming-Wei Chang, Kenton Lee, and Kristina Toutanova. BERT: pre-training of deep bidirectional transformers for language understanding. CoRR, abs/1810.04805, 2018. URL http://arxiv.org/abs/1810.04805.
Chris Dyer, Victor Chahuneau, and Noah Smith. A simple, fast, and effective reparameterization of IBM Model 2. In NAACL, 2013.
Tommaso Furlanello, Zachary Lipton, Michael Tschannen, Laurent Itti, and Anima Anandkumar. Born-again neural networks. In International Conference on Machine Learning, pp. 1602–1611, 2018.
Jonas Gehring, Michael Auli, David Grangier, Denis Yarats, and Yann N Dauphin. Convolutional sequence to sequence learning. In Proceedings of the 34th International Conference on Machine Learning-Volume 70, pp. 1243–1252. JMLR. org, 2017.
Marjan Ghazvininejad, Omer Levy, Yinhan Liu, and Luke Zettlemoyer. Constant-time machine translation with conditional masked language models. arXiv preprint arXiv:1904.09324, 2019.
Jiatao Gu, James Bradbury, Caiming Xiong, Victor O.K. Li, and Richard Socher. Non-autoregressive neural machine translation. In 6th International Conference on Learning Representations, ICLR 2018, Vancouver, Canada, April 30-May 3, 2018, Conference Track Proceedings, 2018.
Jiatao Gu, Changhan Wang, and Jake Zhao. Levenshtein transformer. In Advances in Neural Information Processing Systems 33. 2019.
Geoffrey Hinton, Oriol Vinyals, and Jeff Dean. Distilling the knowledge in a neural network. arXiv preprint arXiv:1503.02531, 2015.
Andrew G Howard, Menglong Zhu, Bo Chen, Dmitry Kalenichenko, Weijun Wang, Tobias Weyand, Marco Andreetto, and Hartwig Adam. Mobilenets: Efficient convolutional neural networks for mobile vision applications. arXiv preprint arXiv:1704.04861, 2017.
Hideki Isozaki, Tsutomu Hirao, Kevin Duh, Katsuhito Sudoh, and Hajime Tsukada. Automatic evaluation of translation quality for distant language pairs. In Proceedings of the 2010 Conference on Empirical Methods in Natural Language Processing, pp. 944–952. Association for Computational Linguistics, 2010.
Melvin Johnson, Mike Schuster, Quoc V. Le, Maxim Krikun, Yonghui Wu, Zhifeng Chen, Nikhil Thorat, Fernanda Viegas, Martin Wattenberg, Greg Corrado, Macduff Hughes, and Jeffrey Dean. ´ Google’s multilingual neural machine translation system: Enabling zero-shot translation. Transactions of the Association for Computational Linguistics, 5:339–351, 2017.
Lukasz Kaiser, Samy Bengio, Aurko Roy, Ashish Vaswani, Niki Parmar, Jakob Uszkoreit, and Noam Shazeer. Fast decoding in sequence models using discrete latent variables. In International Conference on Machine Learning, pp. 2395–2404, 2018.
Yoon Kim and Alexander M Rush. Sequence-level knowledge distillation. In Proceedings of the 2016 Conference on Empirical Methods in Natural Language Processing, pp. 1317–1327, 2016.
Diederik Kingma and Jimmy Ba. Adam: A method for stochastic optimization. arXiv preprint arXiv:1412.6980, 2014.
Durk P Kingma and Prafulla Dhariwal. Glow: Generative flow with invertible 1x1 convolutions. In Advances in Neural Information Processing Systems, pp. 10215–10224, 2018.
Jason Lee, Elman Mansimov, and Kyunghyun Cho. Deterministic non-autoregressive neural sequence modeling by iterative refinement. In Proceedings of the 2018 Conference on Empirical Methods in Natural Language Processing, pp. 1173–1182, 2018.
Percy Liang, Hal Daume III, and Dan Klein. Structure compilation: trading structure for features. ´ In ICML, pp. 592–599, 2008.
Xuezhe Ma, Pengcheng Yin, Jingzhou Liu, Graham Neubig, and Eduard Hovy. Softmax qdistribution estimation for structured prediction: A theoretical interpretation for raml. arXiv preprint arXiv:1705.07136, 2017.
Xuezhe Ma, Chunting Zhou, Xian Li, Graham Neubig, and Eduard Hovy. Flowseq: Nonautoregressive conditional sequence generation with generative flow. In Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing, Hong Kong, November 2019.
Aaron Oord, Yazhe Li, Igor Babuschkin, Karen Simonyan, Oriol Vinyals, Koray Kavukcuoglu, George Driessche, Edward Lockhart, Luis Cobo, Florian Stimberg, et al. Parallel wavenet: Fast high-fidelity speech synthesis. In International Conference on Machine Learning, pp. 3915–3923, 2018.
Myle Ott, Michael Auli, David Grangier, and Marc’Aurelio Ranzato. Analyzing uncertainty in neural machine translation. In Proceedings of the 35th International Conference on Machine Learning, ICML 2018, Stockholmsmassan, Stockholm, Sweden, July 10-15, 2018 ¨ , pp. 3953–3962, 2018. URL http://proceedings.mlr.press/v80/ott18a.html.
Myle Ott, Sergey Edunov, Alexei Baevski, Angela Fan, Sam Gross, Nathan $\mathrm { N g }$ , David Grangier, and Michael Auli. fairseq: A fast, extensible toolkit for sequence modeling. In Proceedings of NAACL-HLT 2019: Demonstrations, 2019.
Nicolas Papernot, Patrick McDaniel, Xi Wu, Somesh Jha, and Ananthram Swami. Distillation as a defense to adversarial perturbations against deep neural networks. In 2016 IEEE Symposium on Security and Privacy (SP), pp. 582–597. IEEE, 2016.
Maja Popovic. chrf: character n-gram f-score for automatic mt evaluation. In ´ Proceedings of the Tenth Workshop on Statistical Machine Translation, pp. 392–395, 2015.
Rico Sennrich, Barry Haddow, and Alexandra Birch. Neural machine translation of rare words with subword units. In Proceedings of the 54th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), pp. 1715–1725, Berlin, Germany, August 2016. Association for Computational Linguistics. doi: 10.18653/v1/P16-1162. URL https://www.aclweb. org/anthology/P16-1162.
Chenze Shao, Yang Feng, Jinchao Zhang, Fandong Meng, Xilin Chen, and Jie Zhou. Retrieving sequential information for non-autoregressive neural machine translation. arXiv preprint arXiv:1906.09444, 2019.
Tianxiao Shen, Myle Ott, Michael Auli, et al. Mixture models for diverse machine translation: Tricks of the trade. In International Conference on Machine Learning, pp. 5719–5728, 2019.
Raphael Shu, Jason Lee, Hideki Nakayama, and Kyunghyun Cho. Latent-variable nonautoregressive neural machine translation with deterministic inference using a delta posterior. arXiv preprint arXiv:1908.07181, 2019.
Matthew Snover, Bonnie Dorr, Richard Schwartz, Linnea Micciulla, and John Makhoul. A study of translation edit rate with targeted human annotation. In In Proceedings of Association for Machine Translation in the Americas, pp. 223–231, 2006.
Milos Stanojevic and Khalil Simaan. Beer: Better evaluation as ranking. In Proceedings of the Ninth Workshop on Statistical Machine Translation, pp. 414–419, 2014.
Mitchell Stern, Noam Shazeer, and Jakob Uszkoreit. Blockwise parallel decoding for deep autoregressive models. In Advances in Neural Information Processing Systems, pp. 10107–10116, 2018.
Mitchell Stern, William Chan, Jamie Kiros, and Jakob Uszkoreit. Insertion transformer: Flexible sequence generation via insertion operations. arXiv preprint arXiv:1902.03249, 2019.
David Talbot, Hideto Kazawa, Hiroshi Ichikawa, Jason Katz-Brown, Masakazu Seno, and Franz J Och. A lightweight evaluation framework for machine translation reordering. In Proceedings of the Sixth Workshop on Statistical Machine Translation, pp. 12–21. Association for Computational Linguistics, 2011.
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.
Chunqi Wang, Ji Zhang, and Haiqing Chen. Semi-autoregressive neural machine translation. In Proceedings of the 2018 Conference on Empirical Methods in Natural Language Processing, pp. 479–488, 2018.
Yiren Wang, Fei Tian, Di He, Tao Qin, ChengXiang Zhai, and Tie-Yan Liu. Non-autoregressive machine translation with auxiliary regularization. arXiv preprint arXiv:1902.10245, 2019.
Bingzhen Wei, Mingxuan Wang, Hao Zhou, Junyang Lin, and Xu Sun. Imitation learning for nonautoregressive neural machine translation. arXiv preprint arXiv:1906.02041, 2019.
# A EXPERIMENTAL DETAILS
# A.1 AT MODELS
Model All the AT models are implemented based on the Transformer model using fairseq (Ott et al., 2019), and we basically follow the fairseq examples to train the transformers6. Following the notation from Vaswani et al. (2017), we list the basic parameters of all the AT model we used:
Table 5: Basic hyper-parameters of architecture for AT models.
<table><tr><td>Models</td><td>tiny</td><td>small</td><td>base</td><td>big</td></tr><tr><td>dmodel</td><td>256</td><td>512</td><td>512</td><td>1024</td></tr><tr><td>dhidden</td><td>1024</td><td>1024</td><td>2048</td><td>4096</td></tr><tr><td>nlayers</td><td>3</td><td>3</td><td>6</td><td>6</td></tr><tr><td>nheads</td><td>4</td><td>8</td><td>8</td><td>16</td></tr><tr><td>Pdropout</td><td>0.1</td><td>0.1</td><td>0.3</td><td>0.3</td></tr></table>
Training For all experiments, we adopt the Adam optimizer (Kingma & Ba, 2014) using $\beta _ { 1 } =$ $0 . 9 , \beta _ { 2 } = 0 . 9 8$ , $\epsilon = 1 e - 8$ . The learning rate is scheduled using inverse sqrt with a maximum learning rate 0.0005 and 4000 warmup steps. We set the label smoothing as 0.1. All the models are run on 8 GPUs for 300, 000 updates with an effective batch size of 32, 000 tokens. The best model is selected based on the validation loss except for FlowSeq which uses valid BLEU score.
Decoding After training, we use beam-search with a fixed beam size 5 for all AT models to create the distilled dataset. We use length normalization without length penalty.
# A.2 NAT MODELS
Model Tab. 2 also lists all the NAT models we test in this work. In general, all the NAT models except FlowSeq and LevT-big adopts a similar architecture and hyper-parameters as the Transformerbase (see Tab. 5). LevT-big is a naive extension of the original LevT model with a comparable parameter setting as Transformer-big (Tab. 5). For FlowSeq, we use the base model (FlowSeq-base) described in (Ma et al., 2019). We re-implemented the vanilla NAT as a simplified version of Gu et al. (2018) where instead of modeling fertility as described in the original paper, we monotonically copy the encoder embeddings to the input of the decoder. All the models except InsT require the additional module to predict the length of the output sequence, or the number of placeholders to be inserted, which is implemented as a standard softmax classifier over the lengths of [0, 256). For LevT, we also have a binary classifier to predict the deletion of the incorrect tokens.
Training Similar to the AT models, all the NAT models are trained using the Adam optimizer with the same learning rate scheduler, in which the warmup steps are set to 10, 000. We train the FlowSeq model on 32 GPUs with a batch size as 2048 sentences, while all the other models are trained on 8 GPUs with an effective batch size of 64, 000 tokens. Note that, the batch sizes for training NAT is typically larger than the AT model, which improves final results. There are also specialized training settings for each models:
• iNAT (Lee et al., 2018): following the original paper, we train the iNAT model jointly with 4 iterations of refinement during training. For each iteration, the model has the $5 0 \%$ probability to learn as a denoising autoencoder, and the rest of the probability to learn from the model’s own prediction. • InsT (Stern et al., 2019): in this work, we only consider training the Insertion Transformer (InsT) using the slot-loss based on the uniform loss function (Stern et al., 2019). That is, we assign equal probabilities to all the insertable tokens inside each slot. • MaskT (Ghazvininejad et al., 2019): following the original paper, we train the model as a typical masked language model where the ratio of masked tokens is sampled from $0 \sim 1 0 0 \%$ .
• LevT (Gu et al., 2019): in this work, we only consider sequence generation tasks, which means the training of LevT is very similar to InsT. We use sentences with randomly deleted tokens to learn insertion, and learn deletion based on the model’s own prediction.
Decoding For a fair comparison over all the NAT models, we use greedy decoding for all the models without considering any advanced decoding methods such as searching or re-ranking from a teacher model. For the vanilla NAT and FlowSeq, decoding is quite straight-forward and simply picks the arg max at every position. For iNAT and MaskT, we fix the decoding steps to 10. Both InsT and LevT decode in an adaptive number of iterations, and we set the maximum iterations for both models to be 10. A special EOS penalty that penalizes generating too short sequences is tuned based on the validation set for both InsT and LevT.
For all models, final results are calculated using tokenized BLEU score.
# B REAL DATA STATISTICS
The detailed dataset split for WMT14 En-De is shown in Tab. 6. In Fig. 7, we also plot the histogram of the conditional entropy of each pair of sentences $\scriptstyle { \mathcal { H } } ( y | x )$ in the real parallel data and different distilled data sets from the big-AT, base-AT, small-AT and tiny-AT respectively. It shows that the distribution of the sentence-level conditional entropy differs widely. The mode of $\scriptstyle { \mathcal { H } } ( y | x )$ in the real data is the highest and follows by distilled data from the big-AT, base-AT, small-AT and tiny-AT. This observation aligns with the complexity value $C ( d )$ proposed in $\ S 3 . 2$ .
Table 6: Dataset statistics for WMT14 En-De.
<table><tr><td>Dataset</td><td>Train</td><td>Valid</td><td>Test</td><td>Vocabulary</td></tr><tr><td>WMT'14 En-De</td><td>4,500,966</td><td>3000</td><td>3003</td><td>37,009</td></tr></table>
 Figure 7: Density of conditional entropy $C ( d )$ of each sentence pairs in different distilled data sets and the real data.
# C ADDITIONAL METRICS
In Figure 8, we also showed results with different metrics together with BLEU scores considering that BLEU scores sometimes cannot fully capture the changes in the system. We considered 5 additional metrics in our experiments: METEOR (Banerjee & Lavie, 2005), RIBES (Isozaki et al., 2010), ChrF (Popovic, 2015) TER (Snover et al., 2006), and BEER (Stanojevic & Simaan, 2014). ´ Not surprisingly, we find that all the metrics are correlated with the original BLEU scores quite well showing a similar trend as discussed earlier.
 Figure 8: The performance of variant measure (BLEU $\uparrow$ , METEOR $\uparrow$ , RIBES $\uparrow$ , ChrF $\uparrow$ , TER $\downarrow$ BEER $\uparrow$ ) for the vanilla NAT model trained on the distilled data from tiny, small, base and big AT models on WMT14-ENDE newstest 2014 test sets.
# D SYNTHETIC DATA WITH ACCESS TO THE TRUE DISTRIBUTION
D.1 BACKGROUND: BAYESIAN DECISION THEORY
Bayesian decision theory is a fundamental statistical approach to the problem of pattern classification, which provides a principled rule of finding the optimal classification decision using probability and losses that accompany such decisions.
In the problem of structured prediction (Ma et al., 2017), let $_ { \textbf { \em x } }$ denote the input sequence and $\textbf { { y } }$ denote the output label sequence. Let $\mathcal { H }$ denote all the possible hypothesis functions from the input to the output space: $\mathcal { H } = \{ h : \mathcal { X } \mathcal { Y } \}$ . Let $r ( \pmb { y } | \pmb { x } )$ denote the conditional risk on the input $_ { \textbf { \em x } }$ , which is the expected loss of predicting $\textbf { { y } }$ based on the posterior probabilities:
$$r ( { \pmb y } | { \pmb x } ) = \mathbb { E } _ { P ( { \pmb y } ^ { \prime } | { \pmb x } ) } [ L ( { \pmb y } , { \pmb y } ^ { \prime } ) ] ,$$
, where $L ( \boldsymbol { y } , \boldsymbol { y } ^ { \prime } )$ is the loss function that penalizes predicting the true target $\boldsymbol { y } ^ { \prime }$ as $\textbf { { y } }$ . The classification task aims to find a hypothesis function $h$ that minimizes the overall risk $R$ given by
$$R ( h ) = \mathbb { E } _ { P ( \pmb { x } ) } [ r ( h ( \pmb { x } ) | \pmb { x } ) ]$$
This is known as the Bayes risk. To minimize the overall risk, obviously we need to minimize the conditional risk for each input $_ { \textbf { \em x } }$ . The Bayesian decision rule states that the global minimum of $R ( h )$ is achieved when the classifier make predictions that minimize each conditional risk given $_ { \textbf { \em x } }$ and this gives the Bayes optimal classifier:
$$h ^ { * } ( { \pmb x } ) = \arg \operatorname* { m i n } _ { { \pmb y } \in { \pmb y } } r ( { \pmb y } | { \pmb x } )$$
Let us consider two loss functions defined in Eq. 5. First is the sequence-level loss $L _ { s e q } ( { \pmb y } , { \pmb y } ^ { \prime } ) =$ $1 - \mathbb { I } ( { \pmb y } = { \pmb y } ^ { \prime } )$ , then in this case the Bayes classifier is:
$$h _ { s e q } ^ { * } ( { \pmb x } ) = \arg \operatorname* { m a x } _ { { \pmb y } \in \mathcal { V } } P ( { \pmb y } | { \pmb x } )$$
, which is the most probable output label sequence given the input sequence $_ { \textbf { \em x } }$
Second let us consider the token-level loss $\begin{array} { r } { L _ { t o k } ( \pmb { y } , \pmb { y } ^ { \prime } ) = \sum _ { t = 1 } ^ { T } 1 - \mathbb { I } ( y _ { t } = y _ { t } ^ { \prime } ) } \end{array}$ , i.e the sum of zero-one loss at each time step. We have:
$$\begin{array} { r l } { h _ { t o k } ^ { * } ( \pmb { x } ) } & { = \underset { y \in \pmb { \mathscr { Y } } } { \mathrm { a r g ~ m i n ~ } } \mathbb { E } _ { P ( \pmb { y ^ { \prime } } | \pmb { x } ) } [ L _ { 2 } ( \pmb { y } , \pmb { y ^ { \prime } } ) ] } \\ & { = \underset { y \in \pmb { \mathscr { Y } } } { \mathrm { a r g ~ m a x ~ } } \mathbb { E } _ { P ( \pmb { y ^ { \prime } } | \pmb { x } ) } [ \sum _ { t = 1 } ^ { T } \mathbb { I } ( y _ { t } = y _ { t } ^ { \prime } ) ] } \\ & { = \underset { y \in \pmb { \mathscr { Y } } } { \mathrm { a r g ~ m a x } } \sum _ { t = 1 } ^ { T } \mathbb { E } _ { P ( \pmb { y ^ { \prime } } | \pmb { x } ) } [ \mathbb { I } ( y _ { t } = y _ { t } ^ { \prime } ) ] } \\ & { = \underset { y \in \pmb { \mathscr { Y } } } { \mathrm { a r g ~ m a x } } \sum _ { t = 1 } ^ { T } \mathbb { E } _ { P ( y _ { t } ^ { \prime } | \pmb { x } ) } [ \mathbb { I } ( y _ { t } = y _ { t } ^ { \prime } ) ] } \\ & { = \underset { y \in \pmb { \mathscr { Y } } } { \mathrm { a r g ~ m a x } } \underset { t = 1 } { \overset { T } { \prod } } P ( y _ { t } | \pmb { x } ) } \end{array}$$
This suggests that the Bayes classifier finds the most probable label at each time step given the input sequence.
# D.2 EXPERIMENTAL SETUPS AND ANALYSIS
To study how training data affects the performance of a weaker classifier, we construct a Hidden Markov Model (HMM) by sampling the parameters of the transition and emission probabilities uniformly within $( 0 , a ]$ and $( 0 , b ]$ respectively. A higher value of $a$ and $b$ indicates an HMM model with higher uncertainty. We refer this HMM as the “true HMM” as our real data generator. Next we consider a weaker classifier that uses a low-dimension bidirectional-LSTM (Bi-LSTM) to encode the input sequence and individual softmax functions at each time step to predict labels independently, which is referred as the “Bi-LSTM” classifier. Obviously, the Bi-LSTM classifier is not able to model the dependencies between output labels embedded in the HMM, and it is equivalent to a simplified non-autoregressive generation model.
We generate the real training data $D _ { r e a l } = \{ ( { \pmb x } _ { 1 } , { \pmb y } _ { 1 } ) , \cdot \cdot \cdot , ( { \pmb x } _ { N } , { \pmb y } _ { N } ) \}$ of size $N$ by sampling from the joint probability of the true HMM. Similarly we sample $N _ { t e s t }$ data points as the test data and $N _ { v a l i d }$ data points as the validation data. We evaluate the classifier’s token-level accuracy tacc and sequand n the test data respectively, where . These two metrics correspond $\begin{array} { r } { t a c c = \frac { \sum _ { i = 1 } ^ { N _ { t e s t } } \sum _ { t = 1 } ^ { T } \mathbb { I } ( h ( \pmb { x } _ { i } ) ^ { t } = \pmb { y } _ { i } ^ { t } ) } { T \times N _ { t e s t } } } \end{array}$ $\begin{array} { r } { s a c c \ = \ \frac { \sum _ { i = 1 } ^ { N _ { t e s t } } { \mathbb { I } \left( { h ( { \bf { x } } _ { i } ) = y _ { i } } \right) } } { N _ { t e s t } } } \end{array}$ $L _ { t o k }$ sequence-level loss $L _ { s e q }$ on each data point of the test data.
First, we use $h _ { s e q } ^ { * } ( { \pmb x } )$ to generate the distillation labels $\boldsymbol { y } ^ { \prime }$ from the true HMM, which corresponds to applying the Viterbi decoding to each $\mathbf { \Delta } _ { \mathbf { \mathcal { X } } _ { i } }$ in $D _ { r e a l }$ . The training data set $D _ { s e q }$ is created with $( { \pmb x } _ { i }$ , $\pmb { y } _ { i } ^ { \prime } )$ . Next, we use $h _ { t o k } ^ { * } ( x )$ to generate the distillation labels $\hat { y }$ and create the training data $D _ { t o k }$ of $( \dot { \pmb x } _ { i } , \hat { \pmb y } _ { i } )$ . To generate $\hat { y }$ , we apply the forward-backward algorithm to each $\mathbf { \Delta } _ { \mathbf { \mathcal { X } } _ { i } }$ in $D _ { r e a l }$ and obtain $P ( y _ { i } ^ { t } | \mathbf { x } _ { i } )$ . We take arg max over the label space $\mathcal { L }$ : $\hat { y } _ { i } ^ { t } = \underset { y _ { i } ^ { t } \in \mathcal { L } } { \operatorname { a r g m a x } } P ( y _ { i } ^ { t } | \mathbf { x } _ { i } )$ .
We use these three training data $( D _ { r e a l } , D _ { t o k } , D _ { s e q } )$ to train the Bi-LSTM classifier respectively. We repeat the experiment for 50 times by constructing 50 HMM models with different random seeds as the data generator. We find that when evaluating with the token-level accuracy tacc, models trained with $D _ { t o k }$ yields the best performance (Bi-LSTM trained with $D _ { t o k }$ win $9 7 . 6 \%$ runs); when evaluating with the sequence-level accuracy sacc, models trained with $D _ { s e q }$ yields the best performance (Bi-LSTM trained with $D _ { s e q }$ win $9 8 . 5 \%$ runs). This is because the Bi-LSTM classifier has difficulty modeling the true data distribution defined by an HMM. On the other hand, it is easier for the Bi-LSTM classifier to model the distributions of $D _ { s e q }$ and $D _ { t o k }$ . Data sets $D _ { s e q }$ and $D _ { t o k }$ define deterministic conditional distributions over the input data, which are much simpler than the real data distribution. By definition, $D _ { t o k }$ is created by the optimal Bayes classifier $\bar { h } _ { t o k } ^ { * } ( { \pmb x } )$ , this means that the Bi-LSTM classifier trained with $D _ { t o k }$ can better capture the distribution of $P ( y _ { t } | \mathbf { x } ) = \operatorname* { m a x } _ { u _ { t } } P ( u _ { t } | \mathbf { x } )$ , which can generalize better to the test data when evaluated with the token-level accuracy. Similarly, Bi-LSTM trained with $D _ { s e q }$ performs better on the test data with the sequence-level metric.
This corroborates our observation in machine translation task that NAT has difficulty in modeling the real conditional distribution of true sentence pairs. However, when using the distilled data translated from a pretrained autoregressive model with beam-search decoding, it performs better on the test set when evaluated with the BLEU score metric.123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316# Utilizing Edge Features in Graph Neural Networks via Variational Information Maximization
Anonymous authors Paper under double-blind review
# Abstract
Graph Neural Networks (GNNs) broadly follow the scheme that the representation vector of each node is updated recursively using the message from neighbor nodes, where the message of a neighbor is usually pre-processed with a parameterized transform matrix. To make better use of edge features, we propose the Edge Information maximized Graph Neural Network (EIGNN) that maximizes the Mutual Information (MI) between edge features and message passing channels. The MI is reformulated as a differentiable objective via a variational approach. We theoretically show that the newly introduced objective enables the model to preserve edge information, and empirically corroborate the enhanced performance of MI-maximized models across a broad range of learning tasks including regression on molecular graphs and relation prediction in knowledge graphs.
# 1 Introduction
Many real-world datasets naturally come in the form of graphs, such as citation networks (Kipf & Welling, 2017), social networks Hamilton et al. (2017), knowledge graphs (Schlichtkrull et al., 2018), molecular graphs (Scarselli et al., 2009; Duvenaud et al., 2015) etc., all of which consist of a number of nodes and edges equipped with their inherent features. Recently, impressive performance has been achieved in graph learning tasks with various forms of Graph Neural Networks (GNNs) (Zhou et al., 2018). Compared to prior works, such as node2vec (Grover & Leskovec, 2016), GNNs learn the state of a node by recursively aggregating messages from its neighbors: combining the graph structure with node features. Intuitively, edge features should play an important role in graph learning tasks. For example, chemical bonds in a molecule have a high impact on chemical properties of molecules, and edge features in knowledge graphs encode important relations between concepts, data, and entities. Our proposed method focuses on improving the usage of edge features in GNNs.
The expressive power of GNNs largely depends on how the message is passed between nodes. A widely adopted scheme is multiplying neighbor node states with a parameterized transform matrix before aggregation (Gilmer et al., 2017; Xu et al., 2019). Despite tremendous success of GNNs, existing models do not exhaustively exploit the full potentials of edge features on graphs. For example, many GNNs such as GCN (Kipf & Welling, 2017), ChebyNet (Defferrard et al., 2016) and GAT (Veličković et al., 2018) do not even consider categorized edge types. To utilize edge features in multi-relational graphs, RGCN (Schlichtkrull et al., 2018) proposes to learn a different transform matrix for each edge type, respectively. However, it does not generalize to edge features in continuous space. MPNN (Gilmer et al., 2017) introduces an edge network that takes edge feature vectors as input and outputs transform matrices, which are used to transform states of neighbor nodes. In principle, the MPNN framework can handle complex edge features. Yet, the lack of maximization of MI between edge and message channels implies that the MPNN may give an edge-independent transform matrix.
In this work, we aim to more efficiently exploit the full potentials of edge features from the perspective of training. We propose the Edge Information maximized Graph Neural Network (EIGNN) that maximizes the Mutual Information (MI) between edge features and the message passing channel which is parameterized as the transform matrix in the widely-accepted message passing framework (transformation and aggregation) (Gilmer et al., 2017; Xu et al., 2019). Considering the challenge of computing the MI, we adopt a variational approach to reformulate it as an differentiable objective, which can be easily applied as a regularization term. We theoretically show that EIGNN can reduce information loss of edge features. Apart from demonstrating the impressive performance of EIGNN on extensive benchmarks of molecular graphs and knowledge graphs, we also analyze and attribute the enhanced effectiveness of EIGNN to the exploitation of edge features instead of the regularization effects. Notably, attribution analysis on molecular graphs show that EIGNN can capture domain knowledge without human interference.
Preliminaries Let $G = ( \nu , \mathcal { E } )$ be a graph with node feature vectors $x _ { v } \in \mathbb { R } ^ { d }$ for node $v \in \nu$ and edge feature vectors $e _ { v w } \in \mathcal { E }$ for the edge connecting node $v$ and $w$ . In GNNs, the state of each node is updated recursively using neighbor nodes. Let $\mathcal { N } _ { v }$ be the set of neighbor nodes of $v$ and $h _ { v } ^ { ( l ) } \in \mathbb { R } ^ { d _ { l } }$ be the hidden state of $v$ at $\it l$ -th layer, where $d _ { l }$ is the dimension of the hidden layer. For simplicity of notation, we use a single $d$ to denote the dimension such that $h _ { v } ^ { ( l ) } \in \mathbb { R } ^ { d }$ . We also have $h _ { v } ^ { ( 0 ) } = x _ { v }$ at the input layer.
# 2 Related works
# 2.1 Relational Modeling in Graph Neural Networks
Single-relational modeling. Many variants such as GCN (Kipf & Welling, 2017), GAT (Veličković et al., 2018), ChebyNet (Defferrard et al., 2016), GraphSAGE (Hamilton et al., 2017) focus on learning node states. These models can assign weight to neighbors, but they can not handle various edge features. A typical neighborhood aggregation scheme is
$$h _ { v } ^ { ( l + 1 ) } = \sigma \left( \sum _ { w \in \mathcal { N } _ { v } } \alpha _ { v w } W _ { 1 } ^ { ( l ) } h _ { w } ^ { ( l ) } + W _ { 0 } ^ { ( l ) } h _ { v } ^ { ( l ) } \right) ,$$
where $\sigma$ denotes an activation function, $\alpha _ { v w }$ can be a normalization constant or a learned attention coefficient (Veličković et al., 2018). States of all neighbors are multiplied by the same trainable transform matrix $W _ { 1 } ^ { ( l ) }$ . Sometimes the self-connection is also treated in the same way, s.t., W (l)0 = W (l)1 .
Multi-relational modeling. A simple strategy to handle multi-relational graphs is assigning each edge type with a separate transform matrix as presented in RGCN (Schlichtkrull et al., 2018) and adopted by GGNN (Li et al., 2016) and LNet (Liao et al., 2019). RGCN updates node states according to the following scheme
$$\begin{array} { r } { h _ { v } ^ { ( l + 1 ) } = \sigma \left( \sum _ { r \in \mathcal { R } } \sum _ { w \in \mathcal { N } _ { v } ^ { r } } \alpha _ { v w , r } W _ { r } ^ { ( l ) } h _ { w } ^ { ( l ) } + W _ { 0 } ^ { ( l ) } h _ { v } ^ { ( l ) } \right) , } \end{array}$$
where $\mathcal { N } _ { v } ^ { r }$ is the collection of neighboring nodes of $\boldsymbol { v }$ with relation $r \in \mathcal { R }$ and $\alpha _ { v w , r }$ is a normalization constant similar as $\alpha _ { v w }$ in Eq. (1). Such a scheme faces challenge in handling edge features of continuous space. GGNN and LNet do not focus on the improvement of edge expressibility. GGNN introduces Gated Recurrent Unit (GRU) (Cho et al., 2014) and LNet focus on handling multi-scale connections.
Complex-relational modeling. The relation in a graph can be quite complex, expressed as a general feature vector $e$ . MPNN (Gilmer et al., 2017) introduces an edge network which takes edge feature vectors as input and outputs transform matrices. A single edge network is shared in a MPNN model. The forward propagation is formalized as
$$m _ { v } ^ { ( l + 1 ) } = \sigma \left( \sum _ { w \in \mathcal { N } _ { v } } f ( e _ { v w } ) h _ { w } ^ { ( l ) } + W _ { 0 } ^ { ( l ) } h _ { v } ^ { ( l ) } \right) , \quad h _ { v } ^ { ( l + 1 ) } = \mathrm { G R U } ( h _ { v } ^ { ( l ) } , m _ { v } ^ { ( l + 1 ) } ) ,$$
where $f : e W$ denotes the edge network. Recently, some research works treat a multirelational problem as the complex-relational one by introducing a continuous edge embedding vector for each edge type, so as to handle increasing number of relations (Nathani et al., 2019). Although the MPNN architecture allows the usage of arbitrary edge features, this advantage is not utilized in practice. MPNN can actually learn an edge-independent transform matrix. A GNN model that efficiently utilizes edge features is yet to emerge.
# 2.2 Readout functions
After several forward propagations, GNNs yield final states of all nodes, which are suitable for node/edge classification or regression. For graph classification or regression tasks, we can apply a readout function (Ying et al., 2018; Vinyals et al., 2015) such that
$$y = R ( \{ h _ { v } ^ { L } | v \in G \} ) ,$$
where $h _ { v } ^ { L }$ is the state of $v$ at the last layer, $R$ is the readout function that outputs a graph-level representation $y$ , e.g., summing up the final node states, applying hierarchical pooling (Ying et al., 2018) or using the set2set model (Vinyals et al., 2015).
# 3 Our method
# 3.1 The Usage of Mutual Information
In probability theory and information theory, MI is a measure of mutual dependence between two random variables. Our method proposes to preserve edge information in GNNs, which is important in many real-world graph structures such as molecules - apart from node (atom) features, attributes of edges (bonds) are equally important for predicting properties of molecules. To this end, we maximize $I ( e ; W )$ - the MI between the edge feature vector $e$ and the message passing channel, i.e., the transform matrix $W$ which is used to transform neighbor node states in the forward propagation. Our method can be easily generalized to directly maximize the MI between edge features and the message itself in methods that do not explicitly have the transform matrix, e.g., the message from node $w$ to node $v$ can be expressed as $f ( h _ { v } , e _ { v w } , h _ { w } )$ rather than $f ( e _ { v w } ) h _ { w }$ , which is shown in Section 4.3.
An general principle of maximum MI is described for unsupervised learning task by (Linsker, 1988) and MI inspired objective functions have long been adopted in unsupervised learning (Bridle et al., 1992; Barber & Agakov, 2006; Veličković et al., 2019; Hjelm et al., 2019), semi-supervised learning (Krause et al., 2010) and generative adversarial networks (Chen et al., 2016). Specifically, DGI (Veličković et al., 2019) also applies MI to GNNs. DGI proposes to learn node-wise representations in an unsupervised manner by maximizing the MI between node representations and corresponding high-level summaries of graphs, using adversarial learning and negative sampling. The node representations may then be retrieved and used for downstream tasks, such as node classification. DGI can be used to pre-train GNNs, as demonstrated in Hu et al. (2019). Our EIGNN also proposes information maximization but targets a completely different objective and adopts a quite different approach.
# 3.2 A Variational Approach to Maximize Mutual Information
Computing $I ( e ; W )$ itself is intractable in practice, needless to say that training a model requires the derivative. Thus, we adopt a variational approach (Agakov, 2004) to reformulate $I ( e ; W )$ as a differentiable objective. We show that our objective is an approximated lower bound of $I ( e ; W )$ and notably, optimizing our objective does lead to maximizing $I ( e ; W )$ . Following MPNN (Gilmer et al., 2017), we use an edge network to parameterize the transform matrix $W$ and relate it to edge features. Therefore, the prior $p ( W | e )$ is
$$p ( W | e ) = \delta ( W - f ( e ) ) ,$$
where $\delta ( \cdot )$ is the Dirac delta function. The posterior $p ( e | W )$ is intractable, so we define a variational distribution $q ( e | W )$ , which can be obtained by defining a neural network $g : W \to e$ Specifically, $q ( e | W )$ substitutes to some distribution (such as Gaussian distribution) with parameter $g ( W )$ . In this way, $f$ and $g$ are similar to the probabilistic encoder and decoder in the Variational Auto-Encoder (VAE) (Kingma $\&$ Welling, 2013). Then we can approximate $I ( e ; W )$ with a differentiable objective $L _ { I } ( f , g ; e )$ as follows.
Theorem 1. Let e be the edge feature vector, $W$ be the transform matrix with conditional distribution $p ( W | e )$ specified by the probabilistic encoder $f$ as shown in Eq. (5) and $q ( e | W )$ be the variational distribution specified by the probabilistic decoder $g$ , then we have
$$I ( e ; W ) \geq H ( e ) + \mathbb { E } _ { e \sim p ( e ) } [ \mathcal { L } _ { I } ( f , g ; e ) ] ,$$
where $\mathcal { L } _ { I } ( f , g ; e ) = \log q ( e | f ( e ) )$ and $H ( \cdot )$ denotes the entropy.
Proof. Let $D _ { K L } ( \cdot \parallel \cdot )$ denote the KL-divergence, which should be nonnegative, then we have
$$\begin{array} { r l } { I ( e ; W ) = H ( e ) - H ( e | W ) } & { } \\ { \ } & { = H ( e ) + \mathbb { E } _ { W \sim p ( W ) } [ \mathbb { E } _ { e \sim p ( e | W ) } [ \log p ( e | W ) ] ] } \\ { \ } & { = H ( e ) + \mathbb { E } _ { W \sim p ( W ) } [ \mathbb { E } _ { e \sim p ( e | W ) } [ \log p ( e | W ) - \log q ( e | W ) + \log q ( e | W ) ] ] } \\ { \ } & { = H ( e ) + \mathbb { E } _ { W \sim p ( W ) } [ D _ { K L } ( p ( e | W ) \| q ( e | W ) ) + \mathbb { E } _ { e \sim p ( e | W ) } [ \log q ( e | W ) ] ] } \\ { \ } & { \geq H ( e ) + \mathbb { E } _ { W \sim p ( W ) } [ \mathbb { E } _ { e \sim p ( e | W ) } [ \log q ( e | W ) ] ] } \\ { \ } & { = H ( e ) + \mathbb { E } _ { e \sim p ( e ) , W \sim p ( W | e ) } [ \log q ( e | W ) ] } \\ { \ } & { \stackrel { ( a ) } { = } H ( e ) + \mathbb { E } _ { e \sim p ( e ) } [ \log q ( e | f ( e ) ) ] } \end{array}$$
where the equality ( $a$ ) follows from Eq. (5).
According to Theorem 1, we can maximize the variational lower bound for $I ( e ; W )$ . The bound becomes tight when the variational distribution $q ( e | W )$ approaches the true posterior $p ( e | W )$ . Moreover, $H ( e )$ is a constant because the distribution of edge feature vector $e$ is fixed for given graphs, hence we can equivalently maximize $\mathcal { L } _ { I } ( f , g ; e )$ . We choose the widely accepted Gaussian distribution as the prior distribution for the probabilistic decoder $g$ ,
$$q ( e | W ) = \mathcal { N } ( e ; g ( W ) , \sigma ^ { 2 } I ) .$$
Then we have
$$\mathcal { L } _ { I } ( f , g ; e ) = \log q ( e | f ( e ) ) = \log \mathcal { N } ( e ; g ( f ( e ) ) , \sigma ^ { 2 } I ) = - \lambda \| e - g ( f ( e ) ) \| _ { 2 } ^ { 2 }$$
where $\lambda > 0$ is a constant determined by $\sigma$ and the dimension of $e$ , taken as a tunable parameter. The following Theorem 2 shows that maximizing the objective in Eq. (8) does lead to the maximization of $I ( e ; W )$ , hence enables the model to preserve edge information.
Theorem 2. Assume the optimal solution of maximizing $\mathcal { L } _ { I } ( f , g ; e )$ is $f ^ { \star }$ and $g ^ { \star }$ , then $f ^ { \star }$ also maximizes $I ( e ; W )$ .
Proof. Note that $H ( e )$ is a constant when the graphs are given. In information theory, we have
$$H ( g ( f ( e ) ) ) \leq H ( f ( e ) ) \leq H ( e ) .$$
$I ( e ; W )$ is upper bounded by $H ( e )$ ,
$$I ( e ; W ) = I ( e ; f ( e ) ) = H ( f ( e ) ) - H ( f ( e ) | e ) = H ( f ( e ) ) \leq H ( e ) .$$
Since $f ^ { \star }$ and $g ^ { \star }$ is the optimal solution of maximizing $\mathcal { L } _ { I } ( f , g ; e )$ presented in Eq. (8), it is not difficult to see that $e = g ^ { \star } ( f ^ { \star } ( e ) ) , \forall e \in \mathcal { E }$ . In this case, the inequalities in Eq. 9 become equalities, i.e.,
$$H ( g ^ { \star } ( f ^ { \star } ( e ) ) ) = H ( f ^ { \star } ( e ) ) = H ( e ) .$$
Therefore, we have $I ( e ; W ) = H ( e )$ , i.e., the maximum is attained in this case.
3.3 Edge Information Maximized Graph Neural Networks
Our EIGNN is derived by implementing our MI objective in GNNs. As a concrete example, the forward propagation of our model follows the formulation in Eq. (3), where the dege network $f : e W$ is expressed as a multi-layer perceptron (MLP). According to theoretical analysis presented in Sec. 3.2 , we introduce another MLP $g : W \to e$ as the decoder.
For graph regression or classification tasks, the model outputs a prediction $y$ for each graph $G$ , which has label $\hat { y }$ . Without MI maximization, we denote the vanilla loss as $\mathcal { L } _ { 0 } ( \hat { y } , y ; G )$ . Common choice of $\mathcal { L } _ { 0 }$ includes Mean Square Error (MSE), Mean Absolute Error (MAE) and Cross Entropy (CE). For a graph $G = ( \nu , \mathcal { E } )$ , EIGNN maximizes $\mathcal { L } _ { I } ( f , g ; e )$ and minimizes $\mathcal { L } _ { 0 } ( \hat { y } , y ; G )$ using the following loss function
$$\mathcal { L } _ { E I G N N } ( G ) = \mathcal { L } _ { 0 } ( \hat { y } , y ; G ) - \lambda \mathbb { E } _ { e \in \mathcal { E } } [ \mathcal { L } _ { I } ( f , g ; e ) ] ,$$
where $\mathbb { E } _ { e \in \mathcal { E } } [ \cdot ]$ denotes taking the mean over all edges in $G = ( \nu , \mathcal { E } )$ and $\lambda$ is the regularization parameter. When EIGNN is trained using mini-batches, $\mathcal { L } _ { 0 } ( \hat { y } , y ; G )$ is averaged over all graphs in the batch while $\mathcal { L } _ { I } ( f , g ; e )$ is averaged over all edges of all graphs in the batch.
Similarly, for relational prediction tasks in knowledge graphs, EIGNN directly yields nodelevel representations $h _ { v }$ for each node $v \in \mathcal V$ and edge-level representations $e$ for each relationship. The objective function of EIGNN can be derived from the translational scoring function Bordes et al. (2013), which learns embedding such that for a given valid triple $t _ { v w } = ( h _ { v } , e _ { v w } , h _ { w } )$ from the valid set $S$ , the condition $d _ { t _ { v w } } = h _ { v } + e _ { v w } - h _ { w } \approx 0$ holds. Let $\mathcal { L } _ { 0 } = \mathbb { E } _ { t _ { v w } \in S } \mathbb { E } _ { t _ { v w } ^ { \prime } \in S ^ { \prime } } \operatorname* { m a x } \{ d _ { t _ { v w } ^ { \prime } } - d _ { t _ { v w } } + \gamma , 0 \}$ , where $S ^ { \prime }$ denotes a set of invalid triples and $\gamma$ is a margin hyper-parameter, EIGNN can be trained by minimizing the following loss,
$$\mathcal { L } _ { E I G N N } ( G ) = \mathcal { L } _ { 0 } - \lambda \mathbb { E } _ { e \in \mathcal { E } } [ \mathcal { L } _ { I } ( f , g ; e ) ] .$$
# 4 Experiments
In this section, we first conduct experiments on a large quantum chemistry benchmark QM9, which is challenging for most baselines. Then we evaluate EIGNN on several useful molecule benchmarks and use attribution analysis to show that EIGNN increases the impact of edges and captures domain knowledge without human interference. Finally, we adopt our method to large-scale knowledge graphs and evaluate the performance on challenging relation prediction tasks using a wide variety of real-world datasets. All experimental results demonstrate a clear and substantial improvement of EIGNN over the state-of-the-art methods.
# 4.1 Quantum Chemistry
QM9 (Ramakrishnan et al., 2014) is a large benchmark containing 134k molecules with 12 quantum chemistry regression properties, which have been show to be quite challenging for many GNNs (Gilmer et al., 2017). Feature engineering of nodes and edges exactly follows (Gilmer et al., 2017) such that molecules are preprocessed as graphs according to atom features and bond features. We compare our EIGNN with nine state-of-the-art baselines which can be categorized into three groups according to the ability of handling edge features: i) GCN, ChebyNet, GAT and GIN (Xu et al., 2019) which simply use binary edge features to indicate the existence of a bond without any other edge features; ii) RGCN, GGNN, LNet and simplified MPNN (sMPNN) which consider bond types (no bond, single, double, triple, or aromatic); iii) MPNN and our EIGNN which use edge feature vectors to indicate both edge types and pairwise distance between atoms.
For a fair comparison, we repeat all experiments 3 times with different random seeds while during each run, all methods share the same random seed. We randomly choose 10k molecules for validation, 10k molecules for testing, and keep the rest for training. Each target property is normalized to zero mean and unit variance for training. Each model is trained to predict the 12 target properties simultaneously. $\lambda$ is naively set to 1 for EIGNN. We use mean square error (MSE) loss to train the models for at most 300 epochs till convergence, and the performance is measured by mean absolute error (MAE). For LNet and GGNN, implementation of the readout function follows the original paper. While for all other models, we use the same set2set (Vinyals et al., 2015) readout, which has been demonstrated to work well in (Gilmer et al., 2017).
Table 1: Quantum property regressions for 12 targets and overall performance (top two raws) on QM9. We repeat all experiments 3 times with different random seeds and report the average performance. Full results with standard deviation are presented in Appendix A, e.g., for MPNN and EIGNN, we have Avg. nMAE $0 . 0 3 9 8 \pm 0 . 0 0 0 2$ and 0.0357 ± 0.0005.
<table><tr><td>Method</td><td>GCN</td><td>ChebyNet</td><td>GAT</td><td>GIN</td><td>RGCN</td><td>GGNN</td><td>LNet</td><td>sMPNN</td><td>MPNN</td><td>EIGNN</td></tr><tr><td>Avg.nMAE</td><td>0.135</td><td>0.121</td><td>0.137</td><td>0.100</td><td>0.102</td><td>0.099</td><td>0.099</td><td>0.089</td><td>0.040</td><td>0.036</td></tr><tr><td>Avg.MAE</td><td>5.306</td><td>4.303</td><td>5.470</td><td>3.480</td><td>3.817</td><td>3.661</td><td>3.653</td><td>3.161</td><td>0.693</td><td>0.633</td></tr><tr><td>mu</td><td>0.568</td><td>0.518</td><td>0.567</td><td>0.478</td><td>0.506</td><td>0.518</td><td>0.472</td><td>0.472</td><td>0.110</td><td>0.097</td></tr><tr><td>alpha</td><td>0.881</td><td>0.793</td><td>0.891</td><td>0.621</td><td>0.632</td><td>0.608</td><td>0.623</td><td>0.528</td><td>0.332</td><td>0.294</td></tr><tr><td>HOMO(10-3)</td><td>5.451</td><td>4.775</td><td>5.429</td><td>4.183</td><td>4.453</td><td>4.483</td><td>3.889</td><td>3.854</td><td>2.481</td><td>2.230</td></tr><tr><td>LUMO(10-3)</td><td>6.400</td><td>5.674</td><td>6.331</td><td>4.796</td><td>5.138</td><td>5.153</td><td>4.194</td><td>4.549</td><td>2.862</td><td>2.593</td></tr><tr><td>gap(10-3)</td><td>8.201</td><td>7.097</td><td>8.193</td><td>6.096</td><td>6.500</td><td>6.602</td><td>5.813</td><td>5.634</td><td>3.620</td><td>3.275</td></tr><tr><td>R2</td><td>53.56</td><td>41.95</td><td>54.52</td><td>34.65</td><td>40.10</td><td>39.68</td><td>35.27</td><td>33.49</td><td>6.064</td><td>5.646</td></tr><tr><td>ZPVE(10-3)</td><td>2.533</td><td>2.527</td><td>2.271</td><td>1.744</td><td>1.477</td><td>1.292</td><td>1.438</td><td>1.345</td><td>0.679</td><td>0.612</td></tr><tr><td>UO</td><td>2.042</td><td>1.984</td><td>2.290</td><td>1.422</td><td>1.059</td><td>0.697</td><td>1.806</td><td>0.791</td><td>0.416</td><td>0.357</td></tr><tr><td>U</td><td>2.042</td><td>1.984</td><td>2.290</td><td>1.422</td><td>1.059</td><td>0.697</td><td>1.755</td><td>0.791</td><td>0.416</td><td>0.357</td></tr><tr><td>H</td><td>2.042</td><td>1.984</td><td>2.290</td><td>1.422</td><td>1.059</td><td>0.697</td><td>1.796</td><td>0.791</td><td>0.416</td><td>0.357</td></tr><tr><td>G</td><td>2.042</td><td>1.984</td><td>2.290</td><td>1.422</td><td>1.059</td><td>0.696</td><td>1.778</td><td>0.791</td><td>0.416</td><td>0.357</td></tr><tr><td>Cv</td><td>0.473</td><td>0.420</td><td>0.479</td><td>0.309</td><td>0.317</td><td>0.315</td><td>0.312</td><td>0.262</td><td>0.134</td><td>0.121</td></tr></table>
 Figure 1: Ablation study. Training and validation error on QM9. The shadow area indicates $m e a n \pm s t d$ over 3 runs.
In Table 1, we list regression results for all methods. We report individual MAE for each target in their original scale, averaged MAE (Avg. MAE) over 12 properties, and averaged normalized MAE (Avg. nMAE; averaged over normalized target properties since different targets have different units and ranges). Our EIGNN achieves the best performance for each metric and each target. Now we are ready to answer the following research questions. i) Are edge features important? Yes. The error has a trend of decreasing with increasing edge features. The comparison between sMPNN (using edge types) and MPNN (using edge types and distance) directly verifies the importance of edge features. It is also consistent with the expert knowledge that distances between pairwise atoms are closely related to quantum properties. For example, the smaller the distance between the two atoms, the stronger the bond is, and consequently a higher bond energy is associated with this atom pair. ii) Does the EIGNN work? Yes. EIGNN achieves the best performance on each target, outperforming the strong baseline MPNN. Moreover, the advantage of EIGNN over MPNN is consistent over 3 runs and the standard deviation on this task is quite small. Detailed results are shown in Table 4 of Appendix A. iii) How does the EIGNN work? Our MI objective is easily implemented on top of vanilla loss function. We have shown that our objective enables preserving of edge information. Fig. 1 demonstrates that regularization such as $L _ { 2 }$ weight decay can increase training error while our objective does not. Moreover, the validation performance verifies that regularization itself does not reduce the validation error. Thus, the effectiveness of EIGNN is due to exploiting edge features rather than the regularization effect. We further run an ablation study where we concatenate edge features to node representations (i.e., MPNN+concat in Fig. 1) in message passing. Concatenation is unable to identify correlations between edges and nodes (Gilmer et al., 2017) and our results show that it slightly reduces the mean validation error but increases the variance.
# 4.2 More Molecule Benchmarks with Potential Applications
We further evaluate EIGNN on three molecule benchmarks: Lipophilicity (Wu et al., 2018), ESOL (Delaney, 2004) and FreeSolv (Mobley & Guthrie, 2014). These datasets contain fewer molecules, and have potential usages in applications such as chemistry, drug discovery, and materials science. For example, the property lipophilicity is an important feature of drug molecules that affects both membrane permeability and solubility. The dataset Lipophilicity contains 4200 compounds. ESOL provides water solubility data for 1128 compounds. FreeSolv contains hydration free energy of 642 small molecules in water. We conduct graph regression experiments on these benchmarks. All datasets are split into training, validation and test according to a proportion of 0.8/0.1/0.1. MPNN and our EIGNN share the same architecture with 3 layers of message passing and 3 steps of set2set. We repeat each experiment 3 times with different random seeds. Results of testing root mean square error (RMSE) in Table 2 verify the effectiveness of our method. Our EIGNN outperforms MPNN on each dataset and each run. Detailed results for each run are presented in Appendix B.
Table 2: Testing RMSE on Lipophilicity, ESOL and FreeSolv.
<table><tr><td>Dataset</td><td colspan="2">Lipophilicity</td><td colspan="2">ESOL</td><td colspan="2">FreeSolv</td></tr><tr><td>Method</td><td>MPNN</td><td>EIGNN</td><td>MPNN</td><td>EIGNN</td><td>MPNN</td><td>EIGNN</td></tr><tr><td>mean±std</td><td>0.678±0.042</td><td>0.653±0.025</td><td>0.805±0.064</td><td>0.776±0.071</td><td>1.398±0.081</td><td>1.273±0.137</td></tr></table>
 Figure 2: Attribution analysis. The color indicates the impact of an edge/atom on the output, i.e., the regression result. EIGNN i) increases the edge attribution, ii) reduces the prediction error and iii) can learn domain knowledge without human interference.
Attribution analysis. To understand how our EIGNN reduces the regression error, we conduct attribution analysis, i.e., attributing the prediction of a deep network to its input features, which usually builds up on the standard gradient operator (Sundararajan et al., features 2017). For an output $e$ as $\begin{array} { r } { S _ { e } = | \frac { \partial y } { \partial e } | } \end{array}$ $y$ , i.e., the prediction of a GNN, we define its sensitivity to an edge with , where $\left. \cdot \right.$ denotes the $L _ { 1 }$ norm. Similarly, the sensitivity to an atom with features $x$ is $\begin{array} { r } { S _ { x } = | \frac { \partial y } { \partial x } | } \end{array}$ . Then $S _ { e }$ and $S _ { x }$ are used as the metrics of attribution in our experiments. As an example, we show in Fig. 2 the attribution for two molecules in Lipophilicity: (a) $N c I n o n c I C ( = N O ) N c \mathcal { Q } c c c ( F ) c ( C l ) c \mathcal { Q }$ and (b) Oc1c2ncc3ccccc3c2nn1c4ccccc4 . Molecule in (a) has the potential to be used to treat, prevent and/or diagnose cancer Prinz et al. (2019). Compared with MPNN, we can observe an increasing of overall edge attribution under our EIGNN and a decreasing of prediction error in both cases. Interestingly, the attribution under EIGNN is similar to the expert knowledge of chemists: halogen atoms such as {Cl, Br, I} and their bond with the carbon atom greatly effect the lipophilicity of a molecule Wilcken et al. (2013), while atoms {O, N} also have high impact on the lipophilicity but usually in a negative way (Augustijns & Brewster, 2007). In Fig. 2 (a), the attribution of the halogen bond C-Cl and the pair {O, N} under our EIGNN is much higher than the one under MPNN, which is consistent with the expert knowledge. In Fig. 2 (b), similarly, the attribution of atoms {O, N} and the bond C-O under EIGNN is much higher. More examples are presented in Appendix C.
# 4.3 Predicting Relations in Knowledge Graphs
In this subsection, we adopt EIGNN to tackle the problem of relation prediction in knowledge graphs (KGs), which entails predicting whether a given triple is valid or not. For example, a triple (London, capital of, United Kingdom) should be classified as valid or London should be predicted as the capital of United Kingdom. KGs represent human knowledge as a directed graph, and have been widely used in practical applications, such as semantic search, dialogue generation, question answering etc. Recovering missing relations in KGs have been a major task for practical usages of KGs. We evaluate our methods on three benchmark datasets, WN18RR (Dettmers et al., 2018), FB15k-237 (Toutanova et al., 2015) and NELL-995 (Xiong et al., 2017). Without the reversible relation problem (Dettmers et al., 2018), WN18RR includes 11 relations scraped from WordNet for 40, 943 synsets. FB15k-237 is a subset of Freebase, and contains 14, 541 entities associated with 237 types of edge. NELL-995 is constructed from the $9 9 5 ^ { t h }$ iteration of NELL system, containing 75, 492 entities and 200 types of edge.
Table 3: Experimental results on WN18RR, FB15K-237 and NELL-995 test sets. Hits@N values are in percentage. The best score is in bold and second best score is underlined.
<table><tr><td rowspan="3">Dataset</td><td colspan="4">WN18RR</td><td colspan="4">FB15K-237</td><td colspan="4">NELL-995</td></tr><tr><td colspan="4"></td><td rowspan="2">MRR</td><td colspan="3">Hit@N%</td><td rowspan="2">MRR</td><td colspan="3">Hit@N %</td></tr><tr><td>MRR</td><td>@1</td><td>@3</td><td>@10</td><td>@1</td><td>@3</td><td>@10</td><td>@1</td><td>@3</td><td>@10</td></tr><tr><td>DistMult</td><td>0.444</td><td>41.2</td><td>47</td><td>50.4</td><td>0.281</td><td>19.9</td><td>30.1</td><td>44.6</td><td>0.485</td><td>40.1</td><td>52.4</td><td>61</td></tr><tr><td>ComplEx</td><td>0.449</td><td>40.9</td><td>46.9</td><td>53</td><td>0.278</td><td>19.4</td><td>29.7</td><td>45</td><td>0.482</td><td>39.9</td><td>52.8</td><td>60.6</td></tr><tr><td>ConvE</td><td>0.456</td><td>41.9</td><td>47</td><td>53.1</td><td>0.312</td><td>22.5</td><td>34.1</td><td>49.7</td><td>0.491</td><td>40.3</td><td>53.1</td><td>61.3</td></tr><tr><td>TransE</td><td>0.243</td><td>42.7</td><td>44.1</td><td>53.2</td><td>0.279</td><td>19.8</td><td>37.6</td><td>44.1</td><td>0.401</td><td>34.4</td><td>47.2</td><td>50.1</td></tr><tr><td>ConvKB</td><td>0.265</td><td>58.2</td><td>44.5</td><td>55.8</td><td>0.289</td><td>19.8</td><td>32.4</td><td>47.1</td><td>0.43</td><td>37.0</td><td>47</td><td>54.5</td></tr><tr><td>R-GCN</td><td>0.123</td><td>8</td><td>13.7</td><td>20.7</td><td>0.164</td><td>10</td><td>18.1</td><td>30</td><td>0.12</td><td>8.2</td><td>12.6</td><td>18.8</td></tr><tr><td>KBGAT</td><td>0.436</td><td>35.8</td><td>48.1</td><td>57.8</td><td>0.431</td><td>36.1</td><td>45.8</td><td>56.9</td><td>0.514</td><td>42.9</td><td>55.3</td><td>67.8</td></tr><tr><td>EIGNN</td><td>0.438</td><td>35.7</td><td>48.8</td><td>58.1</td><td>0.451</td><td>37.4</td><td>48.2</td><td>60.5</td><td>0.523</td><td>43.8</td><td>56.1</td><td>68.3</td></tr></table>
A critical issue of applying Eq. (3) to KGs is that high-dimensional embedding vectors are required to distinguish massive amount of entities and relations, leading to a rapid growth in number of parameters in EIGNN. To address this issue, we adopt the architecture of (Nathani et al., 2019) and learn graph attention based embeddings that target relation prediction on KGs as follows,
$$\begin{array} { r } { m _ { v w } = f \big ( h _ { v } ^ { ( l ) } , e _ { v w } ^ { l } , h _ { w } ^ { ( l ) } \big ) , \alpha _ { v w } ^ { l } = \mathrm { s o f t m a x } \big ( a ^ { l } m _ { v w } ^ { l } \big ) , h _ { v } ^ { ( l + 1 ) } = \sigma \left( \sum _ { w \in \mathcal { N } _ { v } } \alpha _ { v w } ^ { l } m _ { v w } ^ { l } \right) . } \end{array}$$
Compared with Eq. (3), where $m _ { v w } = f ( e _ { v w } ) h _ { w }$ , the above equation absorbs the transform matrix $f ( e _ { v w } )$ into $f ( h _ { v } ^ { ( l ) } , e _ { v w } , h _ { w } ^ { ( l ) } )$ and reduces the model parameters. In the following experiments, we implement $f$ using a MLP as in previous experiments, and maximizes the MI between $e _ { v w }$ and $m _ { v w }$ by introducing another MLP with $\lambda = 0 . 0 1$ . Multi-head attention is further introduced to stabilize the learning process and encapsulate more information about neighbors according to (Veličković et al., 2018). After training EIGNN, ConvKB (Nguyen et al., 2018) is adopted as a regression function for a given triple by analyzing the global embedding properties across each dimension.
In the relation prediction task, the aim is to predict a triple $( v , e _ { v w } , w )$ with $\boldsymbol { v }$ or $w$ missing. We can generate a set of candidate triples for each missing entity $v$ by randomly replacing it with an arbitrary one. Scores can be calculated by ConvKB for all triples, and we find the rank of a correct triple by sorting all scores in ascending order. Thus, the performance of relation prediction task can be evaluated by mean reciprocal rank (MRR) and the proportion of correct entities in the top $N$ ranks (Hits@N) for $N = 1 , 3$ , and 10 (Bordes et al., 2013). We compare our EIGNN with seven state-of-the-art baselines focusing on this task: DistMult (Yang et al., 2014), ComplEx (Trouillon et al., 2016), ConvE (Dettmers et al., 2018), TransE (Bordes et al., 2013), ConvKB (Nguyen et al., 2018), RGCN (Schlichtkrull et al., 2018) and KBGAT (Nathani et al., 2019). As shown in Table 3, our EIGNN achieves the best performance for each metric on FB15K-237 and NELL-995, and achieves the best performance on WN18RR with Hit $^ \mathrm { ( a 3 }$ and 10 metrics. The results of KBGAT are reproduced following the official implementation1, and the results of other methods can be found in the previous peer-reviewed publications, i.e. (Nathani et al., 2019).
# 5 Conclusions
In this work, to make better use of edge features in GNNs, we proposed the edge information maximized graph neural network (EIGNN) that maximizes the mutual information between edge feature vectors and message passing channels. We reformulated the mutual information as a differentiable objective by adopting a variational approach. We have theoretically proved that our proposed objective enables EIGNN to preserve edge information and empirically evaluated EIGNN’s performance on a variety of benchmarks incorporating an array of challenging molecular datasets and knowledge graphs. These results clearly manifested a substantial improvement of EIGNN over the prior state-of-the-art methods. Apart from demonstrating the impressive performance of EIGNN, we also showed that its effectiveness is due to exploitation of edge features instead of the regularization effect. Notably, attribution analysis on molecular graphs show that EIGNN can capture domain knowledge in an end-to-end fashion.
# References
David Barber Felix Agakov. The im algorithm: a variational approach to information maximization. NeurIPS, 2004.
Patrick Augustijns and Marcus E Brewster. Solvent systems and their selection in pharmaceutics and biopharmaceutics, volume 190. Springer, 2007.
David Barber and Felix V Agakov. Kernelized infomax clustering. In NeurIPS, 2006.
Antoine Bordes, Nicolas Usunier, Alberto Garcia-Duran, Jason Weston, and Oksana Yakhnenko. Translating embeddings for modeling multi-relational data. In NeurIPS, pp. 2787–2795, 2013.
John S Bridle, Anthony JR Heading, and David JC MacKay. Unsupervised classifiers, mutual information and’phantom targets. In NeurIPS, 1992.
Xi Chen, Yan Duan, Rein Houthooft, John Schulman, Ilya Sutskever, and Pieter Abbeel. Infogan: interpretable representation learning by information maximizing generative adversarial nets. In NeurIPS, 2016.
Kyunghyun Cho, Bart Van Merriënboer, Dzmitry Bahdanau, and Yoshua Bengio. On the properties of neural machine translation: Encoder-decoder approaches. arXiv preprint arXiv:1409.1259, 2014.
Michaël Defferrard, Xavier Bresson, and Pierre Vandergheynst. Convolutional neural networks on graphs with fast localized spectral filtering. In NeurIPS, 2016.
John S Delaney. Esol: estimating aqueous solubility directly from molecular structure. Journal of chemical information and computer sciences, 44(3):1000–1005, 2004.
Tim Dettmers, Pasquale Minervini, Pontus Stenetorp, and Sebastian Riedel. Convolutional 2d knowledge graph embeddings. In AAAI, 2018.
David K Duvenaud, Dougal Maclaurin, Jorge Iparraguirre, Rafael Bombarell, Timothy Hirzel, Alán Aspuru-Guzik, and Ryan P Adams. Convolutional networks on graphs for learning molecular fingerprints. In NeurIPS, 2015.
Justin Gilmer, Samuel S Schoenholz, Patrick F Riley, Oriol Vinyals, and George E Dahl. Neural message passing for quantum chemistry. In ICML, 2017.
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.
Will Hamilton, Zhitao Ying, and Jure Leskovec. Inductive representation learning on large graphs. In NeurIPS, pp. 1024–1034, 2017.
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. 2019.
Weihua Hu, Bowen Liu, Joseph Gomes, Marinka Zitnik, Percy Liang, Vijay Pande, and Jure Leskovec. Pre-training graph neural networks. arXiv preprint arXiv:1905.12265, 2019.
Diederik P Kingma and Max Welling. Auto-encoding variational bayes. arXiv preprint arXiv:1312.6114, 2013.
Thomas N Kipf and Max Welling. Semi-supervised classification with graph convolutional networks. In ICLR, 2017.
Andreas Krause, Pietro Perona, and Ryan G Gomes. Discriminative clustering by regularized information maximization. In NeurIPS, 2010.
Yujia Li, Daniel Tarlow, Marc Brockschmidt, and Richard Zemel. Gated graph sequence neural networks. In ICLR, 2016.
Renjie Liao, Zhizhen Zhao, Raquel Urtasun, and Richard S Zemel. Lanczosnet: Multi-scale deep graph convolutional networks. In ICLR, 2019.
Ralph Linsker. Self-organization in a perceptual network. Computer, 21(3):105–117, 1988.
David L Mobley and J Peter Guthrie. Freesolv: a database of experimental and calculated hydration free energies, with input files. Journal of computer-aided molecular design, 28 (7):711–720, 2014.
Christopher Morris, Martin Ritzert, Matthias Fey, William L Hamilton, Jan Eric Lenssen, Gaurav Rattan, and Martin Grohe. Weisfeiler and leman go neural: Higher-order graph neural networks. In AAAI, volume 33, pp. 4602–4609, 2019.
Deepak Nathani, Jatin Chauhan, Charu Sharma, and Manohar Kaul. Learning attentionbased embeddings for relation prediction in knowledge graphs. The 57th Annual Meeting of the Association for Computational Linguistics (ACL), 2019.
Dai Quoc Nguyen, Tu Dinh Nguyen, Dat Quoc Nguyen, and Dinh Phung. A novel embedding model for knowledge base completion based on convolutional neural network. In Proceedings of the 2018 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, Volume 2 (Short Papers), pp. 327–333, 2018.
Bianka Prinz, Jerry M Thomas, Ansgar Brock, Viviana Cremasco, Catherine Anne SabatosPeyton, Glenn Dranoff, Scott Chapel, Andrew Lake, Alison Paterson, Rachel W O’connor, et al. Antibody molecules to cd73 and uses thereof, January 31 2019. US Patent App. 16/014,744.
Raghunathan Ramakrishnan, Pavlo O Dral, Matthias Rupp, and O Anatole Von Lilienfeld. Quantum chemistry structures and properties of 134 kilo molecules. Scientific data, 1: 140022, 2014.
Franco Scarselli, Marco Gori, Ah Chung Tsoi, Markus Hagenbuchner, and Gabriele Monfardini. The graph neural network model. IEEE Transactions on Neural Networks, 20(1): 61–80, 2009.
Michael Schlichtkrull, Thomas N Kipf, Peter Bloem, Rianne Van Den Berg, Ivan Titov, and Max Welling. Modeling relational data with graph convolutional networks. In European Semantic Web Conference, pp. 593–607. Springer, 2018.
Mukund Sundararajan, Ankur Taly, and Qiqi Yan. Axiomatic attribution for deep networks. In ICML, pp. 3319–3328. JMLR. org, 2017.
Kristina Toutanova, Danqi Chen, Patrick Pantel, Hoifung Poon, Pallavi Choudhury, and Michael Gamon. Representing text for joint embedding of text and knowledge bases. In Proceedings of the 2015 Conference on Empirical Methods in Natural Language Processing, pp. 1499–1509, 2015.
Théo Trouillon, Johannes Welbl, Sebastian Riedel, Éric Gaussier, and Guillaume Bouchard. Complex embeddings for simple link prediction. In ICML, pp. 2071–2080, 2016.
Petar Veličković, Guillem Cucurull, Arantxa Casanova, Adriana Romero, Pietro Lio, and Yoshua Bengio. Graph attention networks. In ICLR, 2018.
Petar Veličković, William Fedus, William L Hamilton, Pietro Liò, Yoshua Bengio, and R Devon Hjelm. Deep graph infomax. In ICLR, 2019.
Oriol Vinyals, Samy Bengio, and Manjunath Kudlur. Order matters: Sequence to sequence for sets. arXiv preprint arXiv:1511.06391, 2015.
Rainer Wilcken, Markus O Zimmermann, Andreas Lange, Andreas C Joerger, and Frank M Boeckler. Principles and applications of halogen bonding in medicinal chemistry and chemical biology. Journal of medicinal chemistry, 56(4):1363–1388, 2013.
Zhenqin Wu, Bharath Ramsundar, Evan N Feinberg, Joseph Gomes, Caleb Geniesse, Aneesh S Pappu, Karl Leswing, and Vijay Pande. Moleculenet: a benchmark for molecular machine learning. Chemical science, 9(2):513–530, 2018. Wenhan Xiong, Thien Hoang, and William Yang Wang. Deeppath: A reinforcement learning method for knowledge graph reasoning. In Proceedings of the 2017 Conference on Empirical Methods in Natural Language Processing, pp. 564–573, 2017. Keyulu Xu, Weihua Hu, Jure Leskovec, and Stefanie Jegelka. How powerful are graph neural networks? In ICLR, 2019. Bishan Yang, Wen-tau Yih, Xiaodong He, Jianfeng Gao, and Li Deng. Embedding entities and relations for learning and inference in knowledge bases. ICLR, 2014. Zhitao Ying, Jiaxuan You, Christopher Morris, Xiang Ren, Will Hamilton, and Jure Leskovec. Hierarchical graph representation learning with differentiable pooling. In NeurIPS, pp. 4800–4810, 2018. Jie Zhou, Ganqu Cui, Zhengyan Zhang, Cheng Yang, Zhiyuan Liu, and Maosong Sun. Graph neural networks: A review of methods and applications. arXiv preprint arXiv:1812.08434, 2018.
# A Full Results on QM9
Table 4: Full results of quantum property regressions for 12 targets and overall performance (nMAE and MAE in top two raws) on QM9. We repeat all experiments 3 times with different random seeds and report the average performance and standard deviation. This is a supplement for Table 1. in the main text.
<table><tr><td>Method</td><td>GCN</td><td>ChebyNet</td><td>GAT</td><td>GIN</td></tr><tr><td>Avg.nMAE</td><td>0.1350±0.0046</td><td>0.1206±0.0084</td><td>0.1367±0.0050</td><td>0.1001±0.0007</td></tr><tr><td>Avg.MAE</td><td>5.3063±0.1964</td><td>4.3032±0.4814</td><td>5.4698±0.2040</td><td>3.4799±0.0402</td></tr><tr><td>mu</td><td>0.5679±0.0078</td><td>0.5180±0.0131</td><td>0.5670±0.0102</td><td>0.4783±0.0041</td></tr><tr><td>alpha</td><td>0.8811±0.0308</td><td>0.7932±0.0778</td><td>0.8913±0.0314</td><td>0.6209±0.0028</td></tr><tr><td>HOMO(10-3)</td><td>5.4510±0.0790</td><td>4.7750±0.2040</td><td>5.4290±0.1660</td><td>4.1830±0.0370</td></tr><tr><td>LUMO(10-3)</td><td>6.4000±0.1230</td><td>5.6740±0.2670</td><td>6.3310±0.2390</td><td>4.7960±0.0520</td></tr><tr><td>gap(10-3)</td><td>8.2010±0.2150</td><td>7.0970±0.3620</td><td>8.1930±0.2910</td><td>6.0960±0.0420</td></tr><tr><td>R2</td><td>53.563±1.0319</td><td>41.950±4.8289</td><td>54.519±1.5992</td><td>34.647±0.2167</td></tr><tr><td>ZPVE(10-3)</td><td>2.5330±0.1070</td><td>2.5270±0.3560</td><td>2.2710±0.1450</td><td>1.7440±0.0100</td></tr><tr><td>UO</td><td>2.0422±0.3281</td><td>1.9842±0.2035</td><td>2.2899±0.2000</td><td>1.4215±0.0857</td></tr><tr><td>U</td><td>2.0422±0.3281</td><td>1.9842±0.2035</td><td>2.2899±0.2000</td><td>1.4215±0.0857</td></tr><tr><td>H</td><td>2.0422±0.3281</td><td>1.9842±0.2035</td><td>2.2899±0.2000</td><td>1.4215±0.0857</td></tr><tr><td>G</td><td>2.0423±0.3281</td><td>1.9842±0.2036</td><td>2.2899±0.2000</td><td>1.4215±0.0857</td></tr><tr><td>Cv</td><td>0.4730±0.0209</td><td>0.4199±0.0499</td><td>0.4787±0.0164</td><td>0.3093±0.0035</td></tr><tr><td>Method</td><td>RGCN</td><td>GGNN</td><td>LNet</td><td>sMPNN</td></tr><tr><td>Avg.nMAE</td><td>0.1021±0.0016</td><td>0.0992±0.0013</td><td>0.0992±0.0061</td><td>0.0888±0.0014</td></tr><tr><td>Avg.MAE</td><td>3.8175±0.0605</td><td>3.6608±0.0723</td><td>3.6527±0.3417</td><td>3.1610±0.0697</td></tr><tr><td>mu</td><td>0.5056±0.0048</td><td>0.5179±0.0076</td><td>0.4717±0.0063</td><td>0.4718±0.0096</td></tr><tr><td>alpha</td><td>0.6321±0.0145</td><td>0.6077±0.0092</td><td>0.6225±0.0508</td><td>0.5278±0.0106</td></tr><tr><td>HOMO(10-3)</td><td>4.4530±0.1290</td><td>4.4830±0.0650</td><td>3.8889±0.1617</td><td>3.8540±0.0410</td></tr><tr><td>LUMO(10-3)</td><td>5.1380±0.1210</td><td>5.1530±0.0890</td><td>4.1935±0.2205</td><td>4.5490±0.0810</td></tr><tr><td>gap(10-3)</td><td>6.5000±0.1390</td><td>6.6020±0.1400</td><td>5.8132±0.6456</td><td>5.6340±0.0570</td></tr><tr><td>R2</td><td>40.102±0.7428</td><td>39.685±0.8212</td><td>35.275±3.0531</td><td>33.489±0.6562</td></tr><tr><td>ZPVE(10-3)</td><td>1.4770±0.0090</td><td>1.2920±0.0340</td><td>1.4376±0.0769</td><td>1.3450±0.0260</td></tr><tr><td>UO</td><td>1.0589±0.0231</td><td>0.6969±0.0413</td><td>1.8058±0.2533</td><td>0.7914±0.0446</td></tr><tr><td>U</td><td>1.0589±0.0231</td><td>0.6966±0.0418</td><td>1.7555±0.2196</td><td>0.7914±0.0446</td></tr><tr><td>H</td><td>1.0589±0.0231</td><td>0.6974±0.0408</td><td>1.7964±0.2428</td><td>0.7914±0.0446</td></tr><tr><td>G</td><td>1.0589±0.0231</td><td>0.6961±0.0421</td><td>1.7780±0.2458</td><td>0.7914±0.0446</td></tr><tr><td>Cv</td><td>0.3170±0.0152</td><td>0.3146±0.0125</td><td>0.3124±0.0303</td><td>0.2625±0.0040</td></tr><tr><td>Method</td><td>MPNN</td><td>EIGNN</td><td></td><td></td></tr><tr><td>Avg.nMAE</td><td>0.0398±0.0002</td><td>0.0357±0.0005</td><td></td><td></td></tr><tr><td>Avg.MAE</td><td>0.6929±0.0212</td><td>0.6331±0.0298</td><td></td><td></td></tr><tr><td>mu</td><td>0.1095±0.0014</td><td>0.0974±0.0026</td><td></td><td></td></tr><tr><td>alpha</td><td>0.3318±0.0026</td><td>0.2939±0.0054</td><td></td><td></td></tr><tr><td>HOMO(10-3)</td><td>2.4810±0.0200</td><td>2.2300±0.0310</td><td></td><td></td></tr><tr><td>LUMO(10-3)</td><td>2.8620±0.0370</td><td>2.5930±0.0440</td><td></td><td></td></tr><tr><td>gap(10-3)</td><td>3.6200±0.0180</td><td>3.2750±0.0520</td><td></td><td></td></tr><tr><td>R2</td><td>6.0637±0.2511</td><td>5.6464±0.3098</td><td></td><td></td></tr><tr><td>ZPVE(10-3)</td><td>0.6790±0.0140</td><td>0.6120±0.0170</td><td></td><td></td></tr><tr><td>UO</td><td>0.4164±0.0225</td><td>0.3574±0.0100</td><td></td><td></td></tr><tr><td>U</td><td>0.4164±0.0225</td><td>0.3575±0.0100</td><td></td><td></td></tr><tr><td>H</td><td>0.4164±0.0225</td><td>0.3574±0.0100</td><td></td><td></td></tr><tr><td>G</td><td>0.4164±0.0225</td><td>0.3575±0.0101</td><td></td><td></td></tr><tr><td>Cv</td><td>0.1339±0.0013</td><td>0.1208±0.0027</td><td></td><td></td></tr></table>
We present full results of quantum property regressions on QM9 with average performance and standard deviation in Table 4. The $( 1 0 ^ { - 3 }$ ) in the parentheses indicates that the values in the corresponding raw of the table should multiply by $1 0 ^ { - 3 }$ . This is simply for clear presentation of the values. We also present a detailed descriptions on the target properties in Table 5 for your reference.
In our results, we directly report MAE instead of Error Ratio [(MAE)/(Chemical Accuracy) (Gilmer et al., 2017)], because it is common to report MAE in terms of chemical unit. This practice has been widely adopted not only in computational chemistry but also in the machine learning community working on molecular graphs (Wu et al., 2018; Morris et al., 2019). Still, we add Table 6 which contains the Error Ratio for MPNN and our EIGNN. In this comparison, we follow (Gilmer et al., 2017) and train models separately to predict each target. Our EIGNN consistently outperforms MPNN.
Table 5: Regression targets on QM9.
<table><tr><td>Target property</td><td>Description</td><td>Unit</td></tr><tr><td>mu</td><td>Dipole moment</td><td>D</td></tr><tr><td>alpha</td><td>Isotropic polarizability</td><td>a</td></tr><tr><td>HOMO</td><td>Highest occupied molecular orbital energy</td><td>Eh</td></tr><tr><td>LUMO</td><td>Lowest unoccupied molecular orbital energy</td><td>Eh</td></tr><tr><td>gap</td><td>Gap between HOMO and LUMO</td><td>Eh</td></tr><tr><td>R2</td><td>Electronic spatial extent</td><td>品</td></tr><tr><td>ZPVE</td><td>Zero point vibrational energy</td><td>Eh</td></tr><tr><td>UO</td><td>Internal energy at OK</td><td>Eh</td></tr><tr><td>U</td><td>Internal energy at 298.15K</td><td>Eh</td></tr><tr><td>H</td><td>Enthalpy at 298.15K</td><td>Eh</td></tr><tr><td>G</td><td>Free energy at 298.15K</td><td>Eh</td></tr><tr><td>Cv</td><td>Heat capavity at 298.15K</td><td>cal molK</td></tr></table>
Table 6: Error Ratio [(MAE)/(Chemical Accuracy) (Gilmer et al., 2017)] on QM9. Note that the energy values of $\{ \mathrm { U 0 , ~ U , ~ H , ~ G } \}$ are per molecule rather than per atom. Following (Gilmer et al., 2017), models are separately trained on each target.
<table><tr><td>Target</td><td>MPNN</td><td>EIGNN</td><td>Improvement (%)</td></tr><tr><td>mu</td><td>0.87</td><td>0.80</td><td>8.24</td></tr><tr><td>alpha</td><td>2.64</td><td>2.44</td><td>7.57</td></tr><tr><td>HOMO</td><td>1.54</td><td>1.39</td><td>10.2</td></tr><tr><td>LUMO</td><td>1.31</td><td>1.28</td><td>2.13</td></tr><tr><td>gap</td><td>2.20</td><td>1.97</td><td>10.4</td></tr><tr><td>R2</td><td>1.00</td><td>0.72</td><td>28.4</td></tr><tr><td>ZPVE</td><td>5.31</td><td>4.43</td><td>16.5</td></tr><tr><td>UO</td><td>64.3</td><td>35.8</td><td>44.4</td></tr><tr><td>U</td><td>56.6</td><td>23.6</td><td>58.3</td></tr><tr><td>H</td><td>77.4</td><td>35.2</td><td>54.5</td></tr><tr><td>G</td><td>46.6</td><td>34.4</td><td>26.1</td></tr><tr><td>Cv</td><td>1.69</td><td>1.79</td><td>-6.22</td></tr></table>
B Full Results on Lipophilicity, ESOL and FreeSolv
In this section, we present experimental results on Lipophilicity, ESOL and FreeSolv with detailed results for each run. The results in Table 7 verify that our EIGNN consistently outperforms MPNN.
# C More Examples of Attribution
In this section, we present more examples of attribution analysis on Lipophilicity. As a supplement for Fig. 2 in the main text, the observation here is similar. Compared with MPNN, we can observe an increasing of overall edge attribution under our EIGNN and a decreasing of prediction error in both cases. Notably, our EIGNN is able to capture the expert knowledge. (a) The molecule is $C N [ C @ \mathbb { Q } H ] ( C ) C ( = O ) N [ C @ \mathbb { Q } H ] ( C 1 C C C C T 1 ) C ( =$ $O ) N [ C @ H ] 2 C C C N ( C C c ( F ) c c 3 ) C 2$ . The attribution of $\{ \mathrm { O } , \mathrm { N } \}$ and the halogen atom $\mathrm { F }$ is higher under EIGNN. (b) The molecule is $C C ( C ) N 1 C C N [ C @ H ] ( C 1 ) C ( =$ $O ) N 2 C C N ( C C 2 ) C ( = O ) N c 3 c c c ( C l ) c ( C l ) c 3$ . Our EIGNN successfully captures the importance of two critical halogen atoms Cl and several atoms N. (c) The molecule is $C O c 1 c c ( c c 1 ) C ( = \ O ) N 2 C C C C 2 \ = \ O$ . The attribution of two atoms $\mathrm { \ o }$ at the top is
Table 7: Testing RMSE on Lipophilicity, ESOL and FreeSolv. This is a supplement for Table 2 in the main text.
<table><tr><td>Dataset</td><td colspan="2">Lipophilicity</td><td colspan="2">ESOL</td><td colspan="2">FreeSolv</td></tr><tr><td>Seed</td><td>MPNN</td><td>EIGNN</td><td>MPNN</td><td>EIGNN</td><td>MPNN</td><td>EIGNN</td></tr><tr><td>0</td><td>0.718</td><td>0.676</td><td>0.770</td><td>0.718</td><td>1.396</td><td>1.109</td></tr><tr><td>1</td><td>0.696</td><td>0.664</td><td>0.750</td><td>0.733</td><td>1.299</td><td>1.265</td></tr><tr><td>2</td><td>0.620</td><td>0.619</td><td>0.894</td><td>0.876</td><td>1.499</td><td>1.443</td></tr><tr><td>mean±std</td><td>0.678±0.042</td><td>0.653±0.025</td><td>0.805±0.064</td><td>0.776±0.071</td><td>1.398±0.081</td><td>1.273±0.137</td></tr></table>
much higher under EIGNN. (d) The molecule is $C c 1 c c 2 N C ( = O ) C ( = C C ( = O ) c 2 c c 1 C ) O$ . The attribution of atoms O is much higher under EIGNN.
 Figure 3: More examples of attribution analysis. The color indicates the impact of an edge/atom on the output, i.e., the regression result. EIGNN i) increases the edge attribution, ii) reduces the prediction error and iii) can learn domain knowledge without human interference.md/train/-oUhJJILWHb/-oUhJJILWHb.mdAdded+197
md/train/1-j4VLSHApJ/1-j4VLSHApJ.mdAdded+256
md/train/9CPc4EIr2t1/9CPc4EIr2t1.mdAdded+294
md/train/B1eksh4KvH/B1eksh4KvH.mdAdded+258
md/train/B1g5sA4twr/B1g5sA4twr.mdAdded+442
md/train/B1l08oAct7/B1l08oAct7.mdAdded
md/train/B1n8LexRZ/B1n8LexRZ.mdAdded+438
md/train/BJ5UeU9xx/BJ5UeU9xx.mdAdded+236
md/train/BJlahxHYDS/BJlahxHYDS.mdAdded+567
md/train/BJuysoFeg/BJuysoFeg.mdAdded+240
md/train/BJxH22EKPS/BJxH22EKPS.mdAdded+390
md/train/BJxpIJHKwB/BJxpIJHKwB.mdAdded+417
md/train/BklIxyHKDr/BklIxyHKDr.mdAdded+466
md/train/By4HsfWAZ/By4HsfWAZ.mdAdded+313
md/train/ByJWeR1AW/ByJWeR1AW.mdAdded+288
md/train/Byg9A24tvB/Byg9A24tvB.mdAdded+515
md/train/BygFVAEKDH/BygFVAEKDH.mdAdded+376
md/train/BygZK2VYvB/BygZK2VYvB.mdAdded+316
md/train/ByxkijC5FQ/ByxkijC5FQ.mdAdded
md/train/E4PK0rg2eP/E4PK0rg2eP.mdAdded
md/train/EsA9Nr9JHvy/EsA9Nr9JHvy.mdAdded
md/train/GY6-6sTvGaf/GY6-6sTvGaf.mdAdded
md/train/H1K6Tb-AZ/H1K6Tb-AZ.mdAdded
md/train/H1edIiA9KQ/H1edIiA9KQ.mdAdded
md/train/H1ltQ3R9KQ/H1ltQ3R9KQ.mdAdded
md/train/HJC2SzZCW/HJC2SzZCW.mdAdded
md/train/HJe4Cp4KwH/HJe4Cp4KwH.mdAdded
md/train/HJeO7RNKPr/HJeO7RNKPr.mdAdded
md/train/HJxyZkBKDr/HJxyZkBKDr.mdAdded
md/train/HWX5j6Bv_ih/HWX5j6Bv_ih.mdAdded
md/train/HkezXnA9YX/HkezXnA9YX.mdAdded
md/train/HkgHk3RctX/HkgHk3RctX.mdAdded
md/train/HkzRQhR9YX/HkzRQhR9YX.mdAdded
md/train/HkzSQhCcK7/HkzSQhCcK7.mdAdded
md/train/HyEtjoCqFX/HyEtjoCqFX.mdAdded
md/train/HygUOoC5KX/HygUOoC5KX.mdAdded
md/train/LSFCEb3GYU7/LSFCEb3GYU7.mdAdded
md/train/LU687itn08w/LU687itn08w.mdAdded
md/train/LVWcGZr-8h/LVWcGZr-8h.mdAdded
md/train/MNVjrDpu6Yo/MNVjrDpu6Yo.mdAdded
md/train/N9oPAFcuYWX/N9oPAFcuYWX.mdAdded
md/train/QYjO70ACDK/QYjO70ACDK.mdAdded
md/train/QkRbdiiEjM/QkRbdiiEjM.mdAdded
md/train/QpT9Q_NNfQL/QpT9Q_NNfQL.mdAdded
md/train/RHY_9ZVcTa_/RHY_9ZVcTa_.mdAdded
md/train/RYcgfqmAOHh/RYcgfqmAOHh.mdAdded
md/train/S1lyyANYwr/S1lyyANYwr.mdAdded
md/train/S1x1IkHtPr/S1x1IkHtPr.mdAdded
md/train/SJDJNzWAZ/SJDJNzWAZ.mdAdded
md/train/SJTQLdqlg/SJTQLdqlg.mdAdded