Datasets:
Tasks:
Question Answering
Modalities:
Image
Formats:
imagefolder
Languages:
English
Size:
100K - 1M
ArXiv:
License:
Add files using upload-large-folder tool
Browse filesFiles changed (50)
- md/train/2VXyy9mIyU3/2VXyy9mIyU3.mdAdded
- md/train/3g5KdPD8LIL/3g5KdPD8LIL.mdAdded+504
- md/train/9uFiX_HRsIL/9uFiX_HRsIL.mdAdded+221
- md/train/Aw96fN64soV/Aw96fN64soV.mdAdded+334
- md/train/B1hYRMbCW/B1hYRMbCW.mdAdded+671
- md/train/BJj6qGbRW/BJj6qGbRW.mdAdded+346
- md/train/BJlgt2EYwr/BJlgt2EYwr.mdAdded+266
- md/train/BkgnhTEtDS/BkgnhTEtDS.mdAdded+381
- md/train/BkgzniCqY7/BkgzniCqY7.mdAdded+580
- md/train/BkxthxHYvr/BkxthxHYvr.mdAdded+368
- md/train/ByxhOyHYwH/ByxhOyHYwH.mdAdded+246
- md/train/DktZb97_Fx/DktZb97_Fx.mdAdded+634
- md/train/H1gpET4YDB/H1gpET4YDB.mdAdded+283
- md/train/H1gsz30cKX/H1gsz30cKX.mdAdded+437
- md/train/HJV1zP5xg/HJV1zP5xg.mdAdded+385
- md/train/HJewiCVFPB/HJewiCVFPB.mdAdded+408
- md/train/HJlSmC4FPS/HJlSmC4FPS.mdAdded
- md/train/HJrDIpiee/HJrDIpiee.mdAdded
- md/train/HkCjNI5ex/HkCjNI5ex.mdAdded
- md/train/HkgeGeBYDB/HkgeGeBYDB.mdAdded
- md/train/Hkxr1nCcFm/Hkxr1nCcFm.mdAdded
- md/train/Hy6GHpkCW/Hy6GHpkCW.mdAdded
- md/train/HyzMyhCcK7/HyzMyhCcK7.mdAdded
- md/train/IXexLXymbZ9/IXexLXymbZ9.mdAdded
- md/train/LwEQnp6CYev/LwEQnp6CYev.mdAdded
- md/train/MXmmuhJYPdU/MXmmuhJYPdU.mdAdded
- md/train/MuSYkd1hxRP/MuSYkd1hxRP.mdAdded
- md/train/N1i6BJzouX4/N1i6BJzouX4.mdAdded
- md/train/OGg9XnKxFAH/OGg9XnKxFAH.mdAdded
- md/train/QjINdYOfq0b/QjINdYOfq0b.mdAdded
- md/train/S1GkToR5tm/S1GkToR5tm.mdAdded
- md/train/SJCscQcge/SJCscQcge.mdAdded
- md/train/SJICXeWAb/SJICXeWAb.mdAdded
- md/train/SK7A5pdrgov/SK7A5pdrgov.mdAdded
- md/train/SkeuexBtDr/SkeuexBtDr.mdAdded
- md/train/SkxbDsR9Ym/SkxbDsR9Ym.mdAdded
- md/train/TmkN9JmDJx1/TmkN9JmDJx1.mdAdded
- md/train/US-TP-xnXI/US-TP-xnXI.mdAdded
- md/train/a-xFK8Ymz5J/a-xFK8Ymz5J.mdAdded
- md/train/e12NDM7wkEY/e12NDM7wkEY.mdAdded
- md/train/ebS5NUfoMKL/ebS5NUfoMKL.mdAdded
- md/train/hu2aMLzOxC/hu2aMLzOxC.mdAdded
- md/train/jh-rTtvkGeM/jh-rTtvkGeM.mdAdded
- md/train/rh0vIXw6i33/rh0vIXw6i33.mdAdded
- md/train/rkeZIJBYvr/rkeZIJBYvr.mdAdded
- md/train/rkgPnhNFPB/rkgPnhNFPB.mdAdded
- md/train/rylBK34FDS/rylBK34FDS.mdAdded
- md/train/rylejExC-/rylejExC-.mdAdded
- md/train/sy4Kg_ZQmS7/sy4Kg_ZQmS7.mdAdded
- md/train/zx_uX-BO7CH/zx_uX-BO7CH.mdAdded
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504# CUD-NET: Color Universal Design Neural Filter for the Color Weakness
Anonymous Author(s) Affiliation Address email
# Abstract
1 Information on images should be visually understood to anyone, including the color 2 weakness. However, it is not recognizable if color that seems distorted to the color 3 weakness meets an adjacent object. We suggest CUD-NET1 based on convolutional 4 deep neural network to generate color universal design (CUD) images that satisfy 5 both color preservation and distinguishment of color for input images. CUD-NET 6 regresses the node point of the piecewise linear function based on information of 7 input images and comprises a specific filter per image. We present the following 8 methods to generate CUD images for the color weakness. First, we refine the CUD 9 dataset on specific criteria by color experts. Second, the input image information 10 is expanded through the pre-processing specialized on the color weakness vision. 11 Third, we suggest a multi-modal feature fusion architecture that combines features 12 to process expanded images. Finally, we suggest a deformable loss function by the 13 composition of the predicted image through the model to avoid the one-to-many 14 problems of the dataset.
# 15 1 Introduction
# 16 1.1 Motivation
17 The green and red color blindness are made up of $8 \%$ of males and $0 . 5 \%$ of females in Northern 18 European descent[Won11], which is almost up to rate of one person in 20 people. Green and red 19 blindness is the most common pattern, followed by blue, yellow, and total color blindness. In this 20 paper, we generate Color Universal Design (CUD) images, which are color weakness friendly design 21 forms, through deep learning around the aspect of the red color weakness (protanopia) and green 22 color weakness (deuteranopia) vision. Protanopia is insensitive to red color and deuteranopia is 23 insensitive to green color, although it varies depending on individual color weakness extent.
There are studies that help color discrimination to the color weakness, including wearable devices and surgeries[VZCR20]. However, since these research require time and cost, we simply generate CUD images with an image enhancement method based on deep learning to make the corresponding color visible for the color weakness. For an example of the left-above image $I$ in Figure 1, the people who are not color weakness can distinguish the letter $\cdot 5 '$ in the image. But as a deuteranopia vision in left-below image $I ^ { d }$ , the surrounding color and the letter $\cdot 5 '$ are very analogous, making it ambiguous to distinguish the bound of adjacent object. The right-bottom target image ${ \bf \bar { \boldsymbol { T } } } ^ { d }$ , refined image by color expert designers, shows that the letter $\cdot 5 '$ appeared well at the deuteranopia vision. Here, we define the non-CUD objects as the letter $\cdot 5 '$ and surroundings invisible to deuteranopia vision in the image $I$ , and define the CUD objects as the letter $\bullet _ { 5 } ,$ and surroundings visible to deuteranopia vision in the image $T$ . In other words, CUD object means that adjacent objects are distinguishable on both the
 Figure 1: Comparisons of the non-CUD image, our CUD-NET’s predicted image, and CUD image. The above row is represented in normal vision, and below row is represented in deuteranopia vision.
35 normal vision and the color weakness vision. The non-CUD object means that adjacent objects are 36 distinguishable on normal vision but not the color weakness vision. Consequently, we generate $\hat { I }$ that 37 satisfies CUD with a specific filter to the image $I$ . 38 We want to apply as weak filter as possible to CUD objects to preserve color, which requires a 39 certain level of object comprehension mechanism to do so. There are various studies from classic 40 PCA[WEG87] to machine learning-based object segmentation methods[TSC20, $Z \mathrm { G L } ^ { * } 2 0 ]$ to define 41 specific objects or areas in image. The research on semantic segmentation, which even provides labels 42 between objects, seems that deep learning still does not have a complete comprehension of all objects 43 in the real-world. The visual question answering to arbitrary questions about object’s interactions, 44 the most general issue on comprehension of object, does not have high transmission power to be 45 practical uses $[ \mathrm { A H B ^ { * } } 1 8$ , $\mathrm { K Z G ^ { * } } 1 7$ , $\mathrm { L Y L } ^ { * } 2 0 ]$ . Therefore, we expand feature of the input image around 46 the information of color weakness vision and define the robust neural filter. In summary, we suggest 47 a CUD-NET that generates an image suitable for CUD, while complying with the color preservation 48 for the source image. 49 In this paper, we suggest the Color Universal Design Network (CUD-NET) to satisfy both color 50 preservation and contrast of non-CUD objects (CUD suitability). We introduce 4 core contributions 51 of CUD-NET.
• Dataset refinement criteria for CUD image We refine training data into two groups, the one with a simple color tone image based on H and $\mathrm { v }$ in the HSV color space, the other with two or more non-CUD objects that must be distinguished in publications. • Image pre-processing for CUD-NET We carry out pre-processing to expand the information of the input image. Input image $I$ is reconstructed with three expanded feature information with noise removed. Multi-modal feature fusion architecture We define a feature layer, the fusion layer, and a regression layer to handle pre-processed images. The three features from the feature extracting layer are combined into the one fusion feature, and finally a filter is constructed by regressing the node point of the piecewise linear function, or indicator of filter. • Variational loss function We suggest a deformable loss function by the composition of the predicted image through the model. Our data have a problem of one-to-many, where the specific color in input image $I$ is mapped into multiple colors in target image $T$ .
# 65 1.2 Related Works
66 Image-to-Image translation based on GAN GAN is used in various image translation areas, 67 including image generation, style transfer, and colorization[KWK21, IZZE17]. In a preliminary 68 experiment, Cycle-GAN[PEZZ20] has reached the best performance in maximizing the contrast of 69 non-CUD objects. However, our goal is to keep the color preservation of the input image as well, 70 so in the case of black color, which has lost all its color of the input image, it is considered the 71 worst case for color preservation. Enlighten-GAN[JGL $^ { * } 2 1$ ] complements those instability, enabling 72 them to generate more stable results on color preservation. But since most of the GAN-based image 73 translation fixes the size of the predicted image, reshaping a high-resolution image causes information 74 loss of source image. Also, it is difficult to reconstruct the complete geometry for the source image 75 as it generates images through the dilated convolution layer. 76 Image enhancement based on neural filter estimation Unlike GAN, there are researches that 77 scale the pixel values of images based on neural filter estimation $[ \mathrm { W } \mathrm { Z F ^ { * } } 1 9 $ , DLT18, BCPS19]. Zero 78 $\mathrm { D C E } [ \mathrm { G L G } ^ { * } 2 0 ]$ is a low-light image enhancement research that provides a brighter visual display 79 of input image. It estimates pixel-wise and high-order filter for dynamic range adjustment of input 80 images with lightweight deep network, DCE-Net. DeepLPF $\mathbf { M M M } ^ { * } 2 0 ]$ tried to solve the problem by 81 using a graduated filter, elliptical filter, and polynomial filter. The authors not only tried to visually 82 enhance the contrast of images but also to comprise stable filters that are easy to understand for 83 the spectators while keeping the color preservation. In our problem, however, the contrast factor is 84 almost same results as the input image in both visions, while complying the high color preservation, 85 resulting over-stable filter. It is assumed that the inability in comprehension of object’s interaction 86 leads to over-stable filter.
 Figure 2: The ideal color conversion of predicted image between contrast and color preservation. Non-CUD object $a$ should increase the gap compared to the input image and preserve its original color, while the CUD object $b$ maintain both contrast and color.
# 87 2 Methodology
88 We define the ideal predicted image as an increase in the contrast between non-CUD objects and the 89 color preservation for the input image. The non-CUD object $a$ should be mapped into $\acute { a }$ and CUD 90 object $b$ should preserve its color and contrast like an ideal example of Figure 2. However, as our 91 neural filter affects the whole pixels throughout the image, we have the constraint of applying the 92 same filter to objects $a$ and $b$ . It is very hard to make the contrast and color of object $b$ exactly the 93 same as before the filter adjustment while maximizing the contrast of object $a$ . Therefore, we propose 94 a deep learning-based regression to comprise the specific filter per image that maximizes the contrast 95 of object $a$ while minimizing the adjustment of features on object $b$ . 96 First, we propose a solution to maximize the contrast of the $\mathrm { L }$ channel values in CIELab color 97 space[RG19]. We empirically confirmed that protanopia and deuteranopia, which account for the 98 most proportion of color weakness, can distinguish the difference by $\mathrm { L }$ channel values in common 99 when the non-CUD objects are adjacent to each other. To illustrate Figure 1 again, the $\mathrm { L }$ channel 100 value of letter $^ { \bullet } 5 ^ { \bullet }$ in image $I$ is 61 and the surrounding color is 61. The distinguishment between 101 the two objects is easy to normal vision, however the image $I ^ { d }$ , the deuteranopia vision, is very 102 ambiguous. On the contrary, the CUD target image $T$ and $T ^ { d }$ have a difference of $\mathrm { L }$ channel value 75 103 for the letter $\bullet _ { 5 } ,$ and 45 for the surroundings, making it easy to distinguish between the normal and 104 the deuteranopia vision. Due to the characteristics of these data, we refine a data pair by defining a 105 criterion that separates two invisible non-CUD objects by $\mathrm { L }$ channel values. 106 Secondly, we propose a variational loss function and multi-modal feature fusion network for color 107 preservation. It can be said that the increase in the contrast of $\mathrm { L }$ channel values between non-CUD 108 objects is quantitatively superior, but not in the case of increasing the differences in color preservation 109 of input images. When non-CUD objects exist, as a simple example, the most likely way to maximize 110 contrast is to polarize the color of the object black and white. But it is the result of complete ignorance 111 for color preservation, so just enabling to distinguish between non-CUD objects is not always a good 112 answer. A strong filter must be applied to distinguish non-CUD object, but its impact should not be 113 too extensive to leading the loss of information in CUD objects. In this paper, we solve this problem 114 by taking an appropriate trade-off of color preservation and contrast of L channel value.
# 115 2.1 Dataset refinement criteria for CUD image
116 The training data is refined by two groups. The one is vectorized image with two colors divided 117 by value $\mathrm { v }$ and hue degree H in HSV color space[HMKO19], and the other is image with two 118 or more objects that must be distinguished while preserving the color of non-CUD objects. The 119 training data is grouped about 1,600 color combinations into the same V and then simulates them 120 with the deuteranopia vision, converting to the adjacent color family to comply color preservation. 121 All conversions are scaled within only S and V in HSV color space to increase at least 15 difference 122 in the L channel value of selected non-CUD objects. The colors are combined with the 10 essential H 123 and tones, and the similar color simulated with the deuteranopia vision was converted. Consequently, 124 the key part of refining training data is preservation of color, allowing the models to comply with the 125 same approach on learning.
# 2.2 Image pre-processing
127 Our model regresses node points of piecewise linear function, which will be described in the model 128 architecture section, and the final filter is a multiplication operation for the input image. Therefore, 129 the multiplication operations of less than the number 1 tend to fade the color saturation. The image 130 without color inversion converges the white color value to 1, so if the multiplying value is in the [0, 131 1] range, the white color is shifted to the black. By inverting the color of input image, it ignores the 132 multiplication operations for white value with 0. 133 We generate the map image $I ^ { m }$ based on original RGB input images calculating the difference value 134 between the image with an aspect of normal vision and the image with an aspect of deuteranopia vision. 135 Recent studies have been conducted to augment the information or expanded the models’ perspective 136 through transformer models[JSZK16, RFB15]. In our experiment, however, the transformer model 137 tends to generate the predicted image ignoring the source color, which result in the polarized color to 138 black and white like Cycle-GAN’s.
$${ \cal I } ^ { m } = \vert i n v e r t ( I ^ { n } ) - i n v e r t ( I ^ { d } ) \vert$$
$${ \cal I } ~ = ~ \delta \left( c a t ^ { c h a n n e l } \left( I ^ { n } , I ^ { d } , I ^ { m } \right) \right)$$
139 After applying color inversion from the original RGB input image $I ^ { n }$ , we generate the image $I ^ { d }$ with 140 an aspect of deuteranopia vision in equation 1. From these two generated images, we can get the 141 absolute difference value to compose the map image $I ^ { m }$ . In equation 2, the final input $I$ concatenated 142 with $9 \times H \times W$ dimensions passes through the model. The $\bar { \delta } ( . )$ clips output to a range of [0, 1].
# 2.3 Model Architecture
144 CUD-NET regresses the node points of piecewise linear filter function from the input. The value 145 of each node points computes the multiplication operation and generates the predicted image. The 146 input $I$ is compressed into 3 feature blocks matching each input through convolution layer, pooling 147 layer, and global pooling layer. The input with 9 channels is separated into $3 \times 3$ channels before 148 passing the model. The first 3 channels are literally used as the main inputs, where the multiplication 149 operation takes place, while the remaining 6 channels are used as features. 150 First of all, we use multi-modal fusion architecture for three separate inputs to extract expanded 151 features. The three inputs converted to the HSV color space pass through a weights-sharing convolu 152 tion layer to extract a feature block corresponding to the inputs. Each convolution layer consists of 153 kernel size $^ { = 3 }$ , stride $^ { : = 1 }$ , and padding=1, reducing dimension through average pooling. We empirically 154 noticed that the most values of output feature have distribution within the range of [-1, 1] with valid 155 values for constructing the node points, so we use hyperbolic tan for activation function. Since we 156 use inputs with unstructured image size, the last global pooling block holds the size of the feature 157 instead of the average pooling block[LCY14]. 158 The three feature blocks are combined through the multi-modal compact bilinear pooling gate 159 $( \mathbf { M C B } ) [ \mathbf { F P Y ^ { * } } 1 6 ]$ , following the fusion process shown in Figure 3. The MCB gate allows both 160 features to interact in a multiplicative way with low memory consumption and computation 161 times. The fusion features are complemented to enhanced feature through the split attention 162 mechanism $[ Z \mathrm { W } Z ^ { \ast } 2 0 ]$ . At the beginning of the experiment, we have applied the convolutional 163 block attention mechanism[WPLK18] of each MCB gate, but we found that it does not make sense 164 of understanding the feature itself, so we apply only one attention block to the last fusion feature. 165 The enhanced feature pass through the fully-connected regression layer. We picked the 64 points 166 to be regressed to compose the piecewise linear function, which is empirically confirmed to the 167 optimized number of points in this research. The first half of the values construct the node points of 168 the S channel and the other half comprise the $\mathrm { v }$ channel in HSV color space. Finally, node points 169 become the scaling factors to generate predicted image in equation 3[MMS19].
 Figure 3: Overview structure of CUD image generation
$$S \left( I _ { i } ^ { s , v } \right) = k _ { 0 } + \sum _ { m = 0 } ^ { M - 1 } \left( k _ { m + 1 } - k _ { m } \right) \delta \left( M I _ { i } ^ { s , v } - m \right)$$
170 The total number of node point $M$ , each pixel values of S, V channel in input image $I _ { i } ^ { s , v }$ are 171 multiplicated with the slope of actual regressed value $k _ { m }$ , the $m - t h$ generated node point. The 172 specific node points $M$ is scaled through a multiplication operation to pixel value of the input image 173 according to each node point.
# 174 2.4 Loss function
175 Our dataset has one-to-many problems between input and target data. In dataset pair 176 $( I _ { 1 } , T _ { 1 } )$ , $( I _ { 2 } , T _ { 2 } )$ , . . . , $( I _ { n } , T _ { n } )$ , for example, the red color in $I _ { 1 }$ can be targeted to purple color in 177 $T _ { 1 }$ , and the red color in $I _ { 2 }$ can be targeted to orange color in $T _ { 2 }$ . With these one-to-many dataset 178 structures, we design the loss function $\mathcal { L }$ that expresses the potential and the diversity of predicted 179 image in equation 4.
$$\mathcal { L } = \sum _ { i = 1 } ^ { N } L a b _ { l o s s } \left( V \left( \Phi \left( \hat { I } _ { i } \right) \right) \right) + H _ { l o s s } \left( \Phi \left( \hat { I } _ { i } \right) \right)$$
180 Stencil Masking As explained in the dataset refining criteria, we do not proceed with color 181 conversion for all areas in the target images, but only for areas with color combinations that are 182 invisible to the deuteranopia (non-CUD object). For this reason, the input image has color regions of 183 converting color and unconverting color, which also can be referred to as non-CUD object and CUD 184 object. To imply the color bound to model, the stencil masking method is introduced.
$$\Phi \left( { \hat { I } } _ { i } \right) = { \hat { I } } _ { i j } \parallel ( I _ { i j } \cdot T _ { i j } )$$
185 We consist a stencil maps through the logical and operations ’·’ of each pixel value $I _ { i j }$ , $T _ { i j }$ . Stencil 186 map can specify the non-CUD area and be computed with predicted image $\hat { I } _ { i j }$ of logical or operation 187 ’ $| |$ ’in equation 5. Consequently, CUD object of the image adjusted with a stencil mask does not carry 188 out the neural filter computation, such as the same way we refine the target image. This refined image 189 is calculated on the loss function. 190 CIELab Loss We use the CIELab channel loss function to maximize the contrast of color on 191 deuteranopia vision. To stabilize the contrast and brightness of the predicted image, we calculate the 192 MS· SSIM(multi-scale structural similarity[WSB03]) of $\mathrm { L }$ channel.
$$L a b _ { l o s s } = \left\| L a b \left( \hat { I } _ { i } ^ { r g b } \right) - L a b \left( T _ { i } ^ { r g b } \right) \right\| _ { 1 } + M S \cdot S S I M \left( L a b \left( \hat { I } _ { i } ^ { L } \right) , L a b \left( T _ { i } ^ { L } \right) \right)$$
193 The $L a b \left( . \right)$ expression in equation 6 returns the CIELab channel corresponding to the RGB channel, 194 and all calculations are made only on the L channel. 195 Histogram Loss We use the histogram loss function to comply with the color preservation of the 196 image. The RGB channel is used to preserve its color, contrary to using only the $\mathrm { L }$ channel in other 197 loss functions. Handling the RGB channel as a loss function rather than using Lab’s ab channels has 198 shown better results on color preservation.
$$H _ { l o s s } = - { \omega _ { h i s t } } \int N \left( \hat { I } _ { i } ^ { r g b } ; \sigma \right) - { \cal N } \left( T _ { i } ^ { r g b } ; \sigma \right)$$
199 When simply designing a loss function with the L1 distance of the RGB channel pixel values, it was 200 very sensitive to certain values and the gradients are diverged, resulting in an untrainable experiment. 201 Therefore, we used a gaussian expansion method $[ S \mathbf { A } C ^ { * } 1 7 ]$ denoted by $N ( . )$ to infer a differentiable 202 histogram loss function in equation 7. We compute the difference of the RGB channel of the 203 differentiable histogram function, which can be altered to mean squared error or cosine similarity. 204 The scaler $\omega _ { h i s t }$ is determined in inverse proportion to the size of the input image. By maintaining 205 the RGB similarity between the predicted image and the target image, we can comply with the color 206 preservation. 207 Variational Prediction There are various ways to maximize difference of the L channel in the 208 image. And the target image is converted at least two colors compared to the input image. However, 209 the predicted image of the model is generated by the neural filter, so it is unpredictable which area 210 of color is modified. Therefore, if the color in predicted image is over-shifted or in the color value 211 of opposite shifts to the target, the loss will rather increase. In addition to one-to-many problem 212 that the data pair itself does not matches one-to-one in a particular color, it is necessary to generate 213 alternative predicted image with the same aspect of the data pair. We calculate the loss function with 214 a variational prediction based on the predicted image for potential color shifts. 215 The first potential is the case of excessive shifts. Assume that $I _ { i } ^ { L } = \{ 7 4 , 4 1 , 7 9 \}$ , $\hat { I } _ { i } ^ { L } = \{ 9 7 , 1 0 , 7 0 \}$ , 216 $T _ { i } ^ { L } \ = \ \{ 5 0 , 4 1 , 8 0 \}$ in L channel value. The first and third components of each image is non-CUD 217 objects, and second component is CUD object. Therefore, we refined data paired with a difference of 218 15 on L channel. Here, we clip the excessive $\mathrm { L }$ channel value in $\hat { I } _ { i } ^ { L }$ by equation 8. Up to this point, 219 no calculation is made as no value is exceeded in this example. The second potential is the case of 220 opposite shifts. It can be said that a complete neural filter has been proceeded for value 97, 10, 70 221 where $\mathrm { L }$ channel difference is 27. However, if we actually calculate the mean square error between 222 $\hat { I } _ { i } ^ { L }$ and $T _ { i } ^ { L }$ , it will be an large value over 1k. Here we can generate alternative predicted image from 223 equation 9 and 10.
$$c l i p \left( \hat { I } _ { i j } \right) \ = \ \left\{ { m a x } { \left( \hat { I } _ { i j } , { T } _ { i j } \right) } , \qquad I _ { i j } \ > T _ { i j } \right.$$
$$R _ { 1 } = \ 2 I _ { i j } - \ \hat { I } _ { i j } , R _ { 2 } = \ \hat { I } _ { i j }$$
$$V \left( { \hat { I } } _ { i j } \right) = a r g m i n \left( \left\| c l i p \left( R _ { 1 , 2 } \right) - T _ { i j } \right\| _ { 2 } \right)$$
224 As mentioned above, we define thresholds by the maximum and minimum value of each corresponding 225 pixel position of $\hat { I } _ { i } ^ { L }$ and $T _ { i } ^ { L }$ . By computing a difference of residual map and the input image, we 226 induce the alternative two images $R _ { 1 }$ , $R _ { 2 }$ . As a result, $\hat { I } _ { i } ^ { L }$ with a smaller L2 distance is selected to 227 alternative predicted image in equation 10, and it is finally computed with loss function compared to 228 the $T _ { i } ^ { L }$ . The above equation establishes $V \left( \Phi \left( \hat { I } _ { i } \right) \right) = \{ \stackrel { \cdot } { 5 4 } , 4 1 , \stackrel { \cdot } { 8 0 } \}$ and the mean square error to the 229 target image is approximately 5, which is agreeable loss value respect to $\hat { I } _ { i } ^ { L }$ itself. 230 Identity Loss[ZPIE17, TPW16] We use $\mathcal { L } _ { i d e n t i t y } \left( T _ { i } \right)$ to apprehend the CUD object to the model. 231 In the case of target image that already satisfy the CUD, the filter should be relatively weakly applied 232 than input image. The input of identity loss is target image $T _ { i j }$ instead of input image $I _ { i j }$ , and the 233 reference of the loss function is also target image $T _ { i j }$ to maintain the value itself. In computing 234 identity loss, we do not require variational prediction as we cannot judge the potential region by 235 equation 10.
# 236 3 Experiments
237 The experiment was performed with Tesla V100 SXM2 and Intel Xeon Gold 5120 and the computation 238 speed was about 40 images per minutes. We refined a dataset with Adobe Photoshop to maximize 239 contrast in the L channel by adjusting saturation and brightness for areas that require color conversion 240 based on deuteranopia vision simulation. Color experts has refined about 1,500 vectorized image for 241 the training data and 300 publication images for the validation data. All the comparative experimental 242 models used the same train, test, validation data in this paper. We used the inference data in 243 publications, which is almost composed of vectorized images, as colors often appear distorted in a 244 gradation-rich image. The Figure 4 is arranged in descending order of the number of combinations in 245 colors from the top image. 246 Both structure similarity (SSIM)[ZBSS04] and peak signal to noise ratio (PSNR) in Table 1 can 247 indicate whether the image is suitable for CUD or not. As a notable aspect, the result has shown that 248 comparative models with lower metrics are sensitive to high-gradation input images, which generated 249 color-heterogeneous image. SSIM and PSNR itself can determine the increase in contrast compared 250 to the target image but do not determine whether the color preservation complied. Therefore, we 251 evaluated SSIM and PSNR with three references, inputs images $I$ , predicted images $\hat { I }$ , and target 252 images $T$ . The higher the estimation of the $\hat { I }$ and $I$ , the more color preservation factor worked. 253 The higher the estimation of the $\hat { I }$ and $T$ , the more increase in contrast can be considered. We also 254 define SSIM mean absolute error, PSNR mean absolute error to measure the extent of the conversion 255 between the $F : I T$ and $F : \dot { I } \hat { I }$ in equation 11 and 12, respectively. The $N$ is total number 256 of inference data.
$$S S I M \cdot M A E = \frac { 1 } { N } \sum _ { i = 1 } ^ { N } | S S I M ( \hat { I } _ { i } , \mathcal { T } _ { i } ) - S S I M ( I _ { i } , T _ { i } ) |$$
$$P S N R \cdot M A E = \frac { 1 } { N } \sum _ { i = 1 } ^ { N } | P S N R ( \hat { I } _ { i } , \mathcal { T } _ { i } ) - P S N R ( I _ { i } , T _ { i } ) |$$
 Figure 4: Comparisons of predicted images in deuteranopia vision. The color experts selected the validation data that do not satisfy the CUD in publications.
Table 1: Evaluation table of comparison experiment. The CUD-NET with a low bottle-neck feature achieves better results in the experiment of the deuteranopia and the protanopia subjects(Figure 5), although the evaluation metrics are lower than that of CUD-NET.
<table><tr><td rowspan=1 colspan=1>Architecture</td><td rowspan=1 colspan=1>sSIM(i,1)</td><td rowspan=1 colspan=1>SSIM(i,T)</td><td rowspan=1 colspan=1>PSNR(i,1)</td><td rowspan=1 colspan=1>PSNR(i,T)</td><td rowspan=1 colspan=1>SSIM-MAE</td><td rowspan=1 colspan=1>PSNR·MAE</td></tr><tr><td rowspan=2 colspan=1>Cycle-GANZero-DCE</td><td rowspan=1 colspan=1>0.630</td><td rowspan=1 colspan=1>0.634</td><td rowspan=1 colspan=1>13.28</td><td rowspan=1 colspan=1>13.83</td><td rowspan=1 colspan=1>0.3191</td><td rowspan=1 colspan=1>8.4430</td></tr><tr><td rowspan=1 colspan=1>0.924</td><td rowspan=1 colspan=1>0.888</td><td rowspan=1 colspan=1>21.95</td><td rowspan=1 colspan=1>18.67</td><td rowspan=1 colspan=1>0.0661</td><td rowspan=1 colspan=1>3.7300</td></tr><tr><td rowspan=2 colspan=1>DeepLPFEnlighten-GAN</td><td rowspan=1 colspan=1>0.850</td><td rowspan=1 colspan=1>0.831</td><td rowspan=1 colspan=1>26.31</td><td rowspan=1 colspan=1>20.34</td><td rowspan=1 colspan=1>0.1220</td><td rowspan=1 colspan=1>2.0566</td></tr><tr><td rowspan=1 colspan=1>0.820</td><td rowspan=1 colspan=1>0.808</td><td rowspan=1 colspan=1>21.85</td><td rowspan=1 colspan=1>19.58</td><td rowspan=1 colspan=1>0.1470</td><td rowspan=1 colspan=1>3.9983</td></tr><tr><td rowspan=1 colspan=1>Enlighten-GAN(scaled)</td><td rowspan=1 colspan=1>0.966</td><td rowspan=1 colspan=1>0.921</td><td rowspan=1 colspan=1>24.86</td><td rowspan=1 colspan=1>21.36</td><td rowspan=1 colspan=1>0.0392</td><td rowspan=1 colspan=1>3.4937</td></tr><tr><td rowspan=2 colspan=1>CUD-NET(low bottle-neck feature)CUD-NET</td><td rowspan=1 colspan=1>0.897</td><td rowspan=1 colspan=1>0.866</td><td rowspan=1 colspan=1>27.77</td><td rowspan=1 colspan=1>21.01</td><td rowspan=1 colspan=1>0.0901</td><td rowspan=1 colspan=1>2.0826</td></tr><tr><td rowspan=1 colspan=1>0.962</td><td rowspan=1 colspan=1>0.924</td><td rowspan=1 colspan=1>29.54</td><td rowspan=1 colspan=1>21.19</td><td rowspan=1 colspan=1>0.0312</td><td rowspan=1 colspan=1>1.4760</td></tr></table>
257 Cycle-GAN and Zero-DCE showed worse result than others. Cycle-GAN model had difficulty 258 reconstructing a geometry of a particular object, and overall color had low saturation and brightness, 259 resulting in color conversion into an almost grey scale image. Zero-DCE is faded in color, and the 260 contrast was not much different from the input image. The overall image lost its color preservation, 261 which we focused to solve in this paper. 262 DeepLPF meets both the color preservation and contrast that we deal with for. However, DeepLPF 263 tends to color be over-stably filtered for the images with fewer color combinations. Although the 264 color preservation has complied better than other experiments, there were many failed results from 265 the perspective of contrast, which the over-stable filter leads to by DeepLPF. 266 Remarkably, predicted images of Enlighten-GAN showed reasonable results. However, simple color 267 combinations or the images with already satisfying the CUD often showed results degenerated with 268 low CUD suitability. Enlighten-GAN was able to generate the results we targeted, but its deviation of 269 filter is so high that it sometimes failed to satisfy the contrast even on simple images or decreased 270 the contrast. As the problem of GAN-based method including Enlighten-GAN, moreover, model 271 fixes the width and height of the predicted image. If width and height of $T$ and $I$ down-scaled
to size of Enlighten-GAN 272 $\hat { I }$ (approximately 25K pixels in this experiment), the $S S I M \left( \hat { I } , I \right)$ and $P S N R \left( \hat { I } , T \right)$ showed higher estimation in some metrics than CUD-NET. In the opposite case of $\hat { I }$ up-scaled to size of $T$ and $I$ , the significantly low estimation was recorded due to the information loss of up-scaling problem.
CUD-NET showed stable and robust predicted images in both color preservation and increase in the contrast compared to other experiments. In comparing the values in the same region of $I$ and $\hat { I }$ , the model scaled two $\mathrm { L }$ channel values with opposite side in the most of case, the one goes up and the other goes down. When we reduced the number of bottle-neck feature of model, it tends to record relatively high deviation of filter scales according to the number of combinations of colors. In summary, the CUD-NET showed the highest estimations for 4 evaluation metrics. Moreover, as our model adopted a neural filter unlike generation models, there is no loss of information regarding the scaling of predicted images.
 Figure 5: The box bar is ordered to the left side, input image $I$ , Enlighten-GAN, DeepLPF, CUDNET. The y position of box bar represents a mean and length of the box bar represents a deviation of each experiment. The lower the graph is, the higher the rank is.
284 The figure 5 shows the evaluation of the deuteranopia and the protanopia. The evaluation metrics 285 consist of object distinguishability and color harmony in order of input image I, predicted image 286 of Enlighten GAN, DeepLPF, and CUD-NET. User study has tested upon the total of 6 subjects, 4 287 deuteranomaly and 2 protanomaly. The subjects were asked to list the ranks of object distinguishability 288 and color harmony of 4-paired-image for each model-blinded item. As the experimental results, 289 the deuteranopia subject ranked the 1-st in the object distinguishability of CUD-NET at an average 290 rank of 1.821, followed by Enlighten-GAN at an average rank of 2.512. Similarly, the protanopia 291 subject also ranked the 1-st in CUD, followed by Enlighten-GAN, DeepLPF, and input images. The 292 evaluation of color harmony showed that the subjects tend to assume that the image with a good 293 object distinguishability has good color harmony preferentially. For a total of six subjects, the five 294 subjects chose the CUD-NET, with the exception of one who ranked Enlighten-GAN by a subtle gap
# 295 4 Conclusion
296 In this paper, we proposed deep network to generate CUD images from non-CUD input images. The 297 pre-processing and multi-modal fusion layer could comprehend the information for color weakness, 298 and the variational loss function makes the model further adapt to CUD dataset. Compared to other 299 research, we are able to maintain high-resolution images and both stable color preservation and 300 contrast with neural filter per images. 301 Our current research shows a robust filter for a single color, such as vectorized images, but it is 302 difficult to expect stable results in the case of a real-world image with high gradation in hues. We 303 consider the same limitation of our work when the certain pixel values react sensitively, making noise 304 appear more prominent in the predicted image. In the future, we plan to create additional datasets 305 with gradation on the vectorized image and focus on the fusion layer to improve performance of the 306 model. 307 References 308 [AHB∗18] ANDERSON P., HE X., BUEHLER C., TENEY D., JOHNSON M., GOULD S., ZHANG L.: Bottom 309 up and top-down attention for image captioning and visual question answering. In Proceedings of 310 the IEEE Conference on Computer Vision and Pattern Recognition (CVPR) (June 2018). 311 [BCPS19] BIANCO S., CUSANO C., PICCOLI F., SCHETTINI R.: Content-preserving tone adjustment for 312 image enhancement. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern 313 Recognition (CVPR) Workshops (June 2019). 314 [DLT18] DENG Y., LOY C. C., TANG X.: Aesthetic-driven image enhancement by adversarial learning. 315 In Proceedings of the 26th ACM International Conference on Multimedia (New York, NY, USA, 316 2018), MM ’18, Association for Computing Machinery, p. 870–878. URL: https://doi.org/ 317 10.1145/3240508.3240531, doi:10.1145/3240508.3240531. 318 $\mathrm { [ F P Y ^ { * } 1 6 ] }$ FUKUI A., PARK D. H., YANG D., ROHRBACH A., DARRELL T., ROHRBACH M.: Multimodal 319 compact bilinear pooling for visual question answering and visual grounding, 2016. arXiv: 320 1606.01847. 321 [GLG∗20] GUO C., LI C., GUO J., LOY C. C., HOU J., KWONG S., CONG R.: Zero-reference deep curve 322 estimation for low-light image enhancement. In Proceedings of the IEEE/CVF Conference on 323 Computer Vision and Pattern Recognition (CVPR) (June 2020). 324 [HMKO19] HIRA S., MATSUMOTO A., KIHARA K., OHTSUKA S.: Hue rotation (hr) and hue blending (hb): 325 Real-time image enhancement methods for digital component video signals to support red-green 326 color-defective observers. Journal of the Society for Information Display 27, 7 (2019), 409–426. 327 URL: https://onlinelibrary.wiley.com/doi/abs/10.1002/jsid.758, arXiv:https: 328 //onlinelibrary.wiley.com/doi/pdf/10.1002/jsid.758, doi:https://doi.org/10. 329 1002/jsid.758. 330 [IZZE17] ISOLA P., ZHU J.-Y., ZHOU T., EFROS A. A.: Image-to-image translation with conditional 331 adversarial networks. In Proceedings of the IEEE Conference on Computer Vision and Pattern 332 Recognition (CVPR) (July 2017). 333 [JGL∗21] JIANG Y., GONG X., LIU D., CHENG Y., FANG C., SHEN X., YANG J., ZHOU P., WANG Z.: 334 Enlightengan: Deep light enhancement without paired supervision. IEEE Transactions on Image 335 Processing 30 (2021), 2340–2349. doi:10.1109/TIP.2021.3051462. 336 [JSZK16] JADERBERG M., SIMONYAN K., ZISSERMAN A., KAVUKCUOGLU K.: Spatial transformer 337 networks, 2016. arXiv:1506.02025. 338 [KWK21] KUMAR M., WEISSENBORN D., KALCHBRENNER N.: Colorization transformer. In International 339 Conference on Learning Representations (2021). URL: https://openreview.net/forum?id= 340 5NA1PinlGFu. 341 [KZG∗17] KRISHNA R., ZHU Y., GROTH O., JOHNSON J., HATA K., KRAVITZ J., CHEN S., KALANTIDIS 342 Y., LI L.-J., SHAMMA D. A., BERNSTEIN M. S., FEI-FEI L.: Visual genome: Connecting 343 language and vision using crowdsourced dense image annotations. Int. J. Comput. Vision 123, 1 344 (May 2017), 32–73. URL: https://doi.org/10.1007/s11263-016-0981-7, doi:10.1007/ 345 s11263-016-0981-7. 346 [LCY14] LIN M., CHEN Q., YAN S.: Network in network, 2014. arXiv:1312.4400. 347 $[ \mathrm { L Y L } ^ { * } 2 0 ]$ LI X., YIN X., LI C., ZHANG P., HU X., ZHANG L., WANG L., HU H., DONG L., WEI F., 348 CHOI Y., GAO J.: Oscar: Object-semantics aligned pre-training for vision-language tasks. In 349 Computer Vision – ECCV 2020 (Cham, 2020), Vedaldi A., Bischof H., Brox T., Frahm J.-M., 350 (Eds.), Springer International Publishing, pp. 121–137. 351 $[ \mathbf { M M M } ^ { * } 2 0 ]$ MORAN S., MARZA P., MCDONAGH S., PARISOT S., SLABAUGH G.: Deeplpf: Deep local 352 parametric filters for image enhancement. In Proceedings of the IEEE/CVF Conference on 353 Computer Vision and Pattern Recognition (CVPR) (June 2020). 354 [MMS19] MORAN S., MCDONAGH S., SLABAUGH G.: Curl: Neural curve layers for global image 355 enhancement, 2019. arXiv:1911.13175. 356 [PEZZ20] PARK T., EFROS A. A., ZHANG R., ZHU J.-Y.: Contrastive learning for unpaired image-to-image 357 translation. In Computer Vision – ECCV 2020 (Cham, 2020), Vedaldi A., Bischof H., Brox T., 358 Frahm J.-M., (Eds.), Springer International Publishing, pp. 319–345. 359 [RFB15] RONNEBERGER O., FISCHER P., BROX T.: U-net: Convolutional networks for biomedical image 360 segmentation. In Medical Image Computing and Computer-Assisted Intervention – MICCAI 2015 361 (Cham, 2015), Navab N., Hornegger J., Wells W. M., Frangi A. F., (Eds.), Springer International 362 Publishing, pp. 234–241. 363 [RG19] RIBEIRO M., GOMES A. J. P.: Recoloring algorithms for colorblind people: A survey. ACM 364 Comput. Surv. 52, 4 (Aug. 2019). URL: https://doi.org/10.1145/3329118, doi:10.1145/ 365 3329118. 366 [SAC∗17] SCHÜTT K. T., ARBABZADAH F., CHMIELA S., MÜLLER K. R., TKATCHENKO A.: Quantum 367 chemical insights from deep tensor neural networks. Nature Communications 8, 1 (2017). 368 [TPW16] TAIGMAN Y., POLYAK A., WOLF L.: Unsupervised cross-domain image generation, 2016. 369 arXiv:1611.02200. 370 [TSC20] TAO A., SAPRA K., CATANZARO B.: Hierarchical multi-scale attention for semantic segmentation, 371 2020. arXiv:2005.10821. 372 [VZCR20] VARIKUTI V. N., ZHANG C., CLAIR B., REYNOLDS A. L.: Effect of enchroma glasses on color 373 vision screening using ishihara and farnsworth d-15 color vision tests. Journal of American Associ 374 ation for Pediatric Ophthalmology and Strabismus 24, 3 (2020), 157.e1–157.e5. URL: https: 375 //www.sciencedirect.com/science/article/pii/S1091853120301002, doi:https:// 376 doi.org/10.1016/j.jaapos.2020.03.006. 377 [WEG87] WOLD S., ESBENSEN K., GELADI P.: Principal component analysis. Chemo 378 metrics and Intelligent Laboratory Systems 2, 1 (1987), 37–52. Proceedings of 379 the Multivariate Statistical Workshop for Geologists and Geochemists. URL: https: 380 //www.sciencedirect.com/science/article/pii/0169743987800849, doi:https:// 381 doi.org/10.1016/0169-7439(87)80084-9. 382 [Won11] WONG B.: Points of view: Color blindnesss, 2011. doi:https://doi.org/10.1038/nmeth. 383 1618. 384 [WPLK18] WOO S., PARK J., LEE J.-Y., KWEON I. S.: Cbam: Convolutional block attention module. In 385 Proceedings of the European Conference on Computer Vision (ECCV) (September 2018). 386 [WSB03] WANG Z., SIMONCELLI E. P., BOVIK A. C.: Multiscale structural similarity for image quality 387 assessment. In The Thrity-Seventh Asilomar Conference on Signals, Systems Computers, 2003 388 (2003), vol. 2, pp. 1398–1402 Vol.2. doi:10.1109/ACSSC.2003.1292216. 389 [WZF∗19] WANG R., ZHANG Q., FU C.-W., SHEN X., ZHENG W.-S., JIA J.: Underexposed photo 390 enhancement using deep illumination estimation. In Proceedings of the IEEE/CVF Conference on 391 Computer Vision and Pattern Recognition (CVPR) (June 2019). 392 [ZBSS04] ZHOU WANG, BOVIK A. C., SHEIKH H. R., SIMONCELLI E. P.: Image quality assessment: 393 from error visibility to structural similarity. IEEE Transactions on Image Processing 13, 4 (2004), 394 600–612. doi:10.1109/TIP.2003.819861. 395 [ZGL∗20] ZOPH B., GHIASI G., LIN T.-Y., CUI Y., LIU H., CUBUK E. D., LE Q. V.: Rethinking 396 pre-training and self-training, 2020. arXiv:2006.06882. 397 [ZPIE17] ZHU J.-Y., PARK T., ISOLA P., EFROS A. A.: Unpaired image-to-image translation using 398 cycle-consistent adversarial networks. In Proceedings of the IEEE International Conference on 399 Computer Vision (ICCV) (Oct 2017). 400 [ZWZ∗20] ZHANG H., WU C., ZHANG Z., ZHU Y., LIN H., ZHANG Z., SUN Y., HE T., MUELLER 401 J., MANMATHA R., LI M., SMOLA A.: Resnest: Split-attention networks, 2020. arXiv: 402 2004.08955.
# 403 Checklist
1. For all authors...
(a) Do the main claims made in the abstract and introduction accurately reflect the paper’s contributions and scope? [Yes] (b) Did you describe the limitations of your work? [Yes] See on conclusion section (c) Did you discuss any potential negative societal impacts of your work? [N/A] This work is for positive societal impacts (d) Have you read the ethics review guidelines and ensured that your paper conforms to them? [Yes]
2. If you ran experiments...
(a) Did you include the code, data, and instructions needed to reproduce the main experimental results (either in the supplemental material or as a URL)? [Yes] See on github: https://github.com/Anonymous68864576/CUD-NET-anonymous
(b) Did you specify all the training details (e.g., data splits, hyperparameters, how they were chosen)? [Yes] on github repository (c) Did you report error bars (e.g., with respect to the random seed after running experiments multiple times)? [Yes] See on section 2.3 (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 on Experiment section
3. 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] Cooperated with Co-author (b) Did you mention the license of the assets? [Yes] on github repository (c) Did you include any new assets either in the supplemental material or as a URL? [Yes] on github repository (d) Did you discuss whether and how consent was obtained from people whose data you’re using/curating? [Yes] on github repository (e) Did you discuss whether the data you are using/curating contains personally identifiable information or offensive content? [N/A]123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221# CLIPORT: What and Where Pathways for Robotic Manipulation
Mohit Shridhar 1,† Lucas Manuelli 2 Dieter Fox 1,2 1University of Washington 2NVIDIA mshr@cs.washington.edu lmanuelli@nvidia.com fox@cs.washington.edu
cliport.github.io
Abstract: How can we imbue robots with the ability to manipulate objects precisely but also to reason about them in terms of abstract concepts? Recent works in manipulation have shown that end-to-end networks can learn dexterous skills that require precise spatial reasoning, but these methods often fail to generalize to new goals or quickly learn transferable concepts across tasks. In parallel, there has been great progress in learning generalizable semantic representations for vision and language by training on large-scale internet data, however these representations lack the spatial understanding necessary for fine-grained manipulation. To this end, we propose a framework that combines the best of both worlds: a two-stream architecture with semantic and spatial pathways for vision-based manipulation. Specifically, we present CLIPORT, a language-conditioned imitationlearning agent that combines the broad semantic understanding (what) of CLIP [1] with the spatial precision (where) of Transporter [2]. Our end-to-end framework is capable of solving a variety of language-specified tabletop tasks from packing unseen objects to folding cloths, all without any explicit representations of object poses, instance segmentations, memory, symbolic states, or syntactic structures. Experiments in simulated and real-world settings show that our approach is data efficient in few-shot settings and generalizes effectively to seen and unseen semantic concepts. We even learn one multi-task policy for 10 simulated and 9 real-world tasks that is better or comparable to single-task policies.
# 1 Introduction
Ask a person to “get a scoop of coffee beans” or “fold the cloth in half” and they can naturally take concepts like scoop or fold and ground them in concrete physical actions within an accuracy of a few centimeters. We humans do this intuitively, without explicit geometric or kinematic models of coffee beans or cloths. Moreover, we can generalize to a broad range of tasks and concepts from a minimal set of examples on what needs to be achieved. How can we imbue robots with this ability to efficiently ground abstract semantic concepts in precise spatial reasoning?
Recently, a number of end-to-end frameworks have been proposed for vision-based manipulation [2, 3, 4, 5]. While these methods do not use any explicit representations of object poses, instance segmentations, or symbolic states, they can only replicate demonstrations with a narrow range of variability and have no notion of the semantics underlying the tasks. Switching from packing red pens to blue pens involves collecting a new training set [2], or if using goal-conditioned policies, involves the user providing a goal-image from the scene [5, 6]. In realistic human-robot interaction settings, collecting additional demonstrations or providing goal-images is often infeasible and unscalable. A natural solution to both these problems is to condition policies with natural language. Language provides an intuitive interface for specifying goals and also for implicitly transferring concepts across tasks. While language-grounding for manipulation has been explored in the past [7, 8, 9, 10], these pipelines are limited by object-centric representations that cannot handle granular or deformable objects and often do not reason about perception and action in an integrated manner. In parallel, there has been great progress in learning models for visual representations [11, 12] and aligning representations of vision and language [13, 14, 15] by training on large-scale internet data. However, these models lack a fine-grained understanding on how to manipulate objects, i.e. physical affordances.
 Figure 1. Language-Conditioned Manipulation Tasks: CLIPORT is a broad framework applicable to a wide range of language-conditioned manipulation tasks in tabletop settings. We conduct large-scale experiments in Ravens [2] on 10 simulated tasks (a-j) with 1000s of unique instances per task. See Appendix A for challenges pertaining to each task. CLIPORT can even learn one multi-task model for all 10 tasks that achieves better or comparable performance to single-task models. Similarly, we demonstrate our approach on a Franka Panda manipulator with one multi-task model for 9 real-world tasks (k-o; only 5 shown) trained with just 179 image-action pairs.
To this end, we propose the first framework that combines the best of both worlds: end-to-end learning for fine-grained manipulation with the multi-goal and multi-task generalization capabilities of vision-language grounding systems. We introduce a two-stream architecture for manipulation with semantic and spatial pathways broadly inspired by (or vaguely analogous to) the two-stream hypothesis in cognitive psychology [16, 17, 18]. Specifically, we present CLIPORT, a languageconditioned imitation-learning agent that integrates the semantic understanding (what) of CLIP [1] with the spatial precision (where) of Transporter [2]. Transporter has been applied to a wide range of rearragement tasks from industrial packing [2] to manipulating deformable objects [6]. The key insight of the approach is formulating tabletop manipulation as a series of pick-and-place affordance predictions, where the objective is to detect actions rather than detect objects and then learn a policy. This action-centric approach to perception [19] is data efficient and effective at circumventing the need for explicit “objectness” in learnt representations. However, Transporter is a tabula rasa system that learns all visual representations from scratch and so every new goal or task requires collecting a new set of demonstrations. To address this problem, we bake in a strong semantic prior while learning policies. We condition our semantic stream with visual and language-goal features from a pre-trained CLIP model [1]. Since CLIP is pre-trained to align image and language features from millions of image-caption pairs from the internet, it provides a powerful prior for grounding semantic concepts that are common across tasks like categories, parts, shapes, colors, texts, and other visual attributes, all without a top-down pipeline that requires bounding boxes or instance segmentations [13, 14, 15, 20]. This allows us to formulate tabletop rearrangement as a series of language-conditioned affordance predictions, a predominantly vision-based inference problem, and thus benefit from the strengths of data-driven paradigms like scale and generalization.
To study these benefits, we conduct large-scale experiments in the Ravens [2] framework with a simulated suction-gripper robot. We propose 10 language-conditioned tasks with 1000s of unique instances per task that require both semantic and spatial reasoning (see Figure $1 \ \mathrm { a - j }$ ). CLIPORT is not only effective at solving these tasks, but surprisingly, it can even learn a multi-task model for all 10 tasks that achieves better or comparable performance to single-task models. Further, our evaluations indicate that our multi-task model can effectively transfer attributes like “pink block” across tasks, having never seen pink blocks or the word ‘pink’ in the context of the evaluation task. We also demonstrate our approach on a Franka Panda manipulator with one multi-task model for 9 real-world tasks trained with just 179 image-action pairs (see Figure $1 \ k { - } 0$ ).
In summary, our contributions are as follows:
• An extended benchmark of language-grounding tasks for manipulation in Ravens [2]. • Two-stream architecture for using internet pre-trained vision-language models for conditioning precise manipulation policies with language goals. • Empirical results on a broad range of manipulation tasks, including multi-task models, validated with real-robot experiments.
The benchmark, code, and pre-trained models are available at: cliport.github.io.
# 2 Related Work
Vision-based Manipulation. Traditionally, perception for manipulation has centered around object detectors, segmentors, and pose estimators [21, 22, 23, 24, 25, 26]. These methods cannot handle deformable objects, granular media, or generalize to unseen objects without object-specific training data. Alternatively, dense descriptors [27, 28, 29] and keypoint representations [30, 31, 32] forgo segmentation and pose representations, but do not reason about sequential actions and struggle to represent scenes with variable numbers of objects. On the other hand, end-to-end perception-toaction models can learn precise sequential policies [2, 4, 6, 33, 34, 35], but these methods have limited understanding of semantic concepts and rely on goal-images to condition policies. In contrast, Yen-Chen et. al [36] showed that pre-training on semantic tasks like classification and segmentation helps in improving efficiency and generalization of grasping predictions.
Semantic Models. With the advent of large-scale models [37, 38, 39], a number of methods for learning joint vision and language representations have been proposed [13, 14, 15, 20, 40]. However, these methods are restricted to bounding boxes or instance segmentations, which make them inapplicable for detecting things like piles of coffee beans or squares on a chessboard. Alternatively, works in contrastive learning forgo top-down object-detection and learn continuous representations by pre-training on unlabeled data [11, 12]. Recently, CLIP [1] applied a similar approach to align vision and language representations by training on millions of image-caption pairs from the internet.
Language Grounding for Robotics. Several works have proposed systems for instructing robots with natural language [7, 8, 9, 10, 41, 42, 43, 44, 45, 46, 47]. However, these methods use disentangled pipelines for perception and action with the language primarily being used to guide the perception. As such, these pipelines lack the spatial precision necessary for tasks like folding cloths. Recently, Lynch et. al [48] proposed an end-to-end system for grounding language in continuous control, but it requires several hours of human teleoperation data for a single simulated desk setting.
Two-Stream Architectures are prevalent in action-recognition networks [49, 50, 51] and audiorecognition systems [52, 53]. In robotics, Zeng et. al [54] and Jang et. al [55] have proposed twostream pipelines for affordance predictions of novel objects. The former requires goal-images and the latter is restricted to one-step grasps with single-category goals. In contrast, our framework provides a rich and intuitive interface with composable language commands for sequential tasks.
# 3 CLIPORT
CLIPORT is an imitation-learning agent based on four key principles: (1) Manipulation through a two-step primitive where each action involves a start and final end-effector pose. (2) Visual representations of actions that are equivariant to translations and rotations [56, 57]. (3) Two separate pathways for semantic and spatial information. (4) Language-conditioned policies for specifying goals and also transferring concepts across tasks. Combining (1) and (2) from Transporter with (3) and (4) allows us to achieve generalizable policies that go beyond just imitating demonstrations.
Section 3.1 describes the problem formulation, gives an overview of Transporter [2], and presents our language-conditioned model. Section 3.2 provides details on the training approach.
# 3.1 Language-Conditioned Manipulation
We consider the problem of learning a goal-conditioned policy $\pi$ that outputs actions $\mathbf { a } _ { t }$ given input $\gamma _ { t } = ( \mathbf { o } _ { t } , \mathbf { l } _ { t } )$ consisting of a visual observation $\mathbf { o } _ { t }$ and an English language instruction ${ \bf l } _ { t }$ :
$$\pi ( \gamma _ { t } ) = \pi ( \mathbf { o } _ { t } , \mathbf { l } _ { t } ) \mathbf { a } _ { t } = ( { \mathcal { T } } _ { \mathrm { p i c k } } , { \mathcal { T } } _ { \mathrm { p l a c e } } ) \in \mathcal { A }$$
 Figure 2. CLIPORT Two-Stream Architecture. An overview of the semantic and spatial streams. The semantic stream uses a frozen CLIP ResNet50 [1] to encode RGB input, and its decoder layers are conditioned with tiled language features from the CLIP sentence encoder. The spatial stream encodes RGB-D input, and its decoder layers are laterally fused with the semantic stream. The final output is a map of dense pixelwise features that is used for pick or place affordance predictions. This same two-stream architecture is used in all 3 FullyConvolutional-Networks $f _ { \mathrm { p i c k } }$ , $\Phi _ { \mathrm { q u e r y } }$ , and $\Phi _ { \mathrm { k e y } }$ with $f _ { \mathrm { p i c k } }$ is used to predict pick actions, and $\Phi _ { \mathrm { q u e r y } }$ and $\Phi _ { \mathrm { k e y } }$ are used to predict place actions. See Appendix C for the exact architecture.
The actions $\mathbf { a } = ( T _ { \mathrm { p i c k } } , T _ { \mathrm { p l a c e } } )$ specify the end-effector pose for picking and placing, respectively. We consider tabletop tasks where $\mathcal { T } _ { \mathrm { p i c k } } , \mathcal { T } _ { \mathrm { p l a c e } } \in \mathbf { S } \mathbf { E } ( 2 )$ . The visual observation $\mathbf { o } _ { t }$ is a top-down orthographic RGB-D reconstruction of the scene where each pixel corresponds to a point in 3D space. The language instruction ${ \bf l } _ { t }$ either specifies step-by-step instructions e.g. “pack the scissors” “pack the purple tape” etc., or a single goal description for the whole task e.g “pack all the blue and yellow boxes in the brown box”. See Figure 4 for specific examples.
We assume access to a dataset $\mathcal { D } = \{ \zeta _ { 1 } , \zeta _ { 2 } , \ldots , \zeta _ { n } \}$ of $n$ expert demonstrations with associated discrete-time input-action pairs $\zeta _ { i } = \{ ( \mathbf { o } _ { 1 } , \mathbf { l } _ { 1 } , \mathbf { a } _ { 1 } ) , ( \mathbf { o } _ { 2 } , \mathbf { l } _ { 2 } , \mathbf { a } _ { 2 } ) , . . . \}$ where $\mathbf { a } _ { t } = ( T _ { \mathrm { p i c k } } , T _ { \mathrm { p l a c e } } )$ corresponds to expert pick-and-place coordinates at timestep $t$ . These expert demonstrations are used to supervise the policy $\pi$ .
Transporter for Pick-and-Place. The policy $\pi$ is trained with Transporter [2] to perform spatial manipulation. The model first (i) attends to a local region to decide where to pick, then (ii) computes a placement location by finding the best match through cross-correlation of deep visual features.
Following Transporter [2, 6], the policy $\pi$ is composed of two action-value modules (Q-functions): The pick module $\mathcal { Q } _ { \mathrm { p i c k } }$ decides where to pick, and conditioned on this pick action the place module $\mathcal { Q } _ { \mathrm { p l a c e } }$ decides where to place. These modules are implemented as Fully-Convolutional-Networks (FCNs) that are translationally equivariant by design. As we will describe in more detail below, we extend these networks to two-stream architectures that can handle language input. The pick FCN $f _ { \mathrm { p i c k } }$ takes input $\gamma _ { t } = \left( \mathbf { o } _ { t } , \mathbf { l } _ { t } \right)$ and outputs a dense pixelwise prediction $\mathbf { \bar { \mathcal { Q } } _ { \mathrm { p i c k } } } ^ { } \in \mathbb { R } ^ { H \times \dot { W } }$ of action-values, where are used to predict the pick action $\tau _ { \mathrm { p i c k } }$ :
$$\mathcal { T } _ { \mathrm { p i c k } } = \underset { ( u , v ) } { \mathrm { a r g m a x } } \ : \mathcal { Q } _ { \mathrm { p i c k } } ( ( u , v ) | \gamma _ { t } )$$
Since $\mathbf { o } _ { t }$ is an orthographic heightmap, each pixel location $( u , v )$ can be mapped to a 3D picking location using the known camera calibration. $f _ { \mathrm { p i c k } }$ is trained in a supervised manner to predict the pick action $\mathcal { T } _ { \mathrm { p i c k } }$ that imitates the expert demonstration with the specified language instruction at timestep $t$ .
The second FCN $\Phi _ { \mathrm { q u e r y } }$ takes in $\gamma _ { t } [ \mathcal { T } _ { \mathrm { p i c k } } ]$ , which is a $c \times c$ crop of $\mathbf { o } _ { t }$ centered at $\tau _ { \mathrm { p i c k } }$ along with the language instruction ${ \bf l } _ { t }$ , and outputs a query feature embedding of shape $\mathbb { R } ^ { c \times c \times d }$ . The third FCN $\Phi _ { \mathrm { k e y } }$ consumes the full input $\gamma _ { t }$ and outputs a key feature embedding of shape $\mathbb { R } ^ { H \times W \times d }$ . The place action-values $\mathcal { Q } _ { \mathrm { p l a c e } }$ are then computed by cross-correlating the query and key features:
$$\begin{array} { r } { \mathcal { Q } _ { \mathrm { p l a c e } } ( \Delta \tau | \gamma _ { t } , \mathcal { T } _ { \mathrm { p i c k } } ) = \left( \Phi _ { \mathrm { q u e r y } } ( \gamma _ { t } [ \mathcal { T } _ { \mathrm { p i c k } } ] ) * \Phi _ { \mathrm { k e y } } ( \gamma _ { t } ) \right) [ \Delta \tau ] } \end{array}$$
where $ { \Delta \tau } \in S E ( 2 )$ represents a potential placement pose. Since $\mathbf { o } _ { t }$ is an orthographic heightmap, rotations in the placement pose $\Delta \tau$ can be captured by stacking $k$ discrete angle rotations of the crop before passing it through the query network $\Phi _ { \mathrm { q u e r y } }$ . Then $\begin{array} { r } { \mathcal { T } _ { \mathrm { p l a c e } } ^ { \mathrm { ~ \tiny ~ \bar { ~ } ~ } } = \arg \operatorname* { m a x } _ { \Delta \tau } \mathcal { Q } _ { \mathrm { p l a c e } } ( \Delta \tau | \gamma _ { t } , \mathcal { T } _ { \mathrm { p i c k } } ) , } \end{array}$ , where the place module is trained to imitate the placements in the expert demonstrations. For all models, we use $c = 6 4$ , $k = 3 6$ and $d = 3$ . As in Transporter [2, 6], our framework can be extended to handle any motion primitive like pushing, sliding, etc. that can be parameterized by two end-effector poses at each timestep. For more details, we refer the reader to the original paper [2].
Two-Stream Architecture. In CLIPORT, we extend the network architecture of all three FCNs $f _ { \mathrm { p i c k } }$ , $\Phi _ { \mathrm { q u e r y } }$ and $\Phi _ { \mathrm { k e y } }$ from Transporter [2] to allow for language input and reasoning about high-level semantic concepts. We extend the FCNs to two-pathways: semantic (ventral) and spatial (dorsal). The semantic stream is conditioned with language features at the bottleneck and fused with intermediate features from the spatial stream. See Figure 2 for an overview of the architecture.
The spatial stream is identical to the ResNet architecture in Transporter – a tabula rasa network that takes in RGB-D input $\mathbf { o } _ { t }$ and outputs dense features through an hourglass encoder-decoder model. The semantic stream uses a frozen pre-trained CLIP ResNet50 [1] to encode the RGB input2 $\tilde { \mathbf { o } } _ { t }$ up until the penultimate layer $\tilde { \mathbf { o } } _ { t } \mathbf { v } _ { t } ^ { ( 0 ) } : \mathbb { R } ^ { 7 \times 7 \times 2 0 4 8 }$ and then introduces decoding layers that ! t upsample the feature tensors to mimic the spatial stream $\mathbf { v } _ { t } ^ { ( l - 1 ) } \to \mathbf { v } _ { t } ^ { ( l ) } : \mathbb { R } ^ { h \times w \times C }$ at each layer $l$ .
The language instruction ${ \bf l } _ { t }$ is encoded with CLIP’s Transformer-based sentence encoder to produce a goal encoding $\mathbf { l } _ { t } \mathbf { g } _ { t } : \mathbb { R } ^ { 1 0 2 4 }$ . This goal encoding $\mathbf { g } _ { t }$ is downsampled with fully-connected layers to match the channel dimension $C$ and tiled to match the spatial dimensions of the decoder features such that $\mathbf { g } _ { t } \ \to \ \mathbf { g } _ { t } ^ { ( l ) } \ : \ \mathbb { R } ^ { h \times w \times C }$ . The decoder features are then conditioned with the tiled goal features through an element-wise product $\mathbf { v } _ { t } ^ { ( l ) } \odot \mathbf { g } _ { t } ^ { ( l ) }$ (Hadamard product). Since CLIP was trained with contrastive loss on the dot-product alignment between pooled image features and language encodings, the element-wise product allows us to use this alignment while the tiling preserves the spatial dimensions of the visual features. This language conditioning is repeated for three subsequent layers after the bottleneck inspired by LingUNet [58]. We also add skip connections to these layers from the CLIP ResNet50 encoder to utilize different levels of semantic information from shapes to parts to object-level concepts [59]. Finally, following existing two-stream architectures in videoaction recognition [51], we add lateral connections from the spatial stream to the semantic stream. These connections invothe channel dimension ng , w $1 \times 1$ uceare $[ \mathbf { v } _ { t } ^ { ( l ) } \odot \mathbf { g } _ { t } ^ { ( l ) } ; \mathbf { d } _ { t } ^ { ( l ) } ] : \mathbb { R } ^ { h \times w \times C _ { \mathbf { v } } + C _ { \mathbf { d } } } \mathbb { R } ^ { h \times w \times \check { C } _ { \mathbf { v } } }$ $\mathbf { v } _ { t } ^ { ( l ) }$ ) and d(l)t the semantic and spatial tensors at layer $l$ , respectively. For the final fusion of dense features, addition for $f _ { \mathrm { p i c k } }$ and $1 \times 1$ conv fusion for $\Phi _ { \mathrm { q u e r y } }$ and $\Phi _ { \mathrm { k e y } }$ worked the best empirically. See Appendix C for details on the exact architecture.
# 3.2 Implementation Details
Training from demonstrations. Similar to Transporter [2] we train CLIPORT through imitation learning from a set of expert demonstrations $\mathcal { D } = \{ \zeta _ { 1 } , \zeta _ { 2 } , . . . , \zeta _ { n } \}$ consisting of discrete-time inputaction pairs $\zeta _ { i } = \{ ( \mathbf { o } _ { 1 } , \mathbf { \bar { l } } _ { 1 } , \mathbf { a } _ { 1 } ) , ( \mathbf { o } _ { 2 } , \mathbf { l } _ { 2 } , \mathbf { a } _ { 2 } ) , \dots \}$ . During training, we randomly sample an inputaction pair from the dataset and supervise the model end-to-end with one-hot pixel encodings of demonstration actions $Y _ { \mathrm { p i c k } } : \mathbb { R } ^ { H \times \dot { W } \times k }$ and $Y _ { \mathrm { p l a c e } } : \mathbb { R } ^ { H \times W \times k }$ with $k$ discrete rotations. In simulated experiments with the suction-gripper, we use $k = 1$ for pick actions and $k = 3 6$ for place actions. The model is trained with cross-entropy loss: $\mathcal { L } = \dot { - } \mathbb { E } _ { Y _ { \mathrm { { p i c k } } } } [ \log \mathcal { V } _ { \mathrm { { p i c k } } } ] - \mathbb { E } _ { Y _ { \mathrm { { 0 i c e } } } } [ \log \mathcal { \bar { V } } _ { \mathrm { { p l a c e } } } ]$ where $\mathcal { V } _ { \mathrm { p i c k } } = \operatorname { s o f t m a x } \left( \mathcal { Q } _ { \mathrm { p i c k } } ( ( u , v ) | \gamma _ { t } ) \right)$ and $\mathcal { V } _ { \mathrm { p l a c e } } = \mathrm { s o f t m a x } ( \mathcal { Q } _ { \mathrm { p l a c e } } ( ( u ^ { \prime } , v ^ { \prime } , \omega ^ { \prime } ) | \gamma _ { t } , \dot { \mathcal { T } } _ { \mathrm { p i c k } } ) )$ . Compared to the original Transporter models that were trained for 40K iterations, we train our models for $2 0 0 \mathrm { K }$ iterations (with data augmentation; see Appendix E) to account for additional semantic variation in tasks – randomized colors, shapes, objects. All models are trained on a single commodity GPU for 2 days with a batch size of 1.
Training multi-task models. Multi-task training is nearly identical to single-task training except for the sampling of training data. First, we randomly sample a task, and then select a random inputaction pair from that task in the dataset. Using this strategy, all tasks are equally likely to be sampled but longer horizon tasks are less likely to reach full coverage of input-action pairs available in the dataset. To compensate for this, we train all multi-task models $3 \times$ longer for 600K iterations or 6 GPU days.
# 4 Results
We perform experiments both in simulation and hardware aimed at answering the following questions: 1) How effective is the language-conditioned two-stream architecture for fine-grained manipulation compared to one-stream alternatives and other simpler baselines? 2) Is it possible to train a multi-task model for all tasks, and how well does it perform and generalize? 3) How well do these models generalize to seen and unseen semantic attributes like colors, shapes, and object categories?
# 4.1 Simulation Setup
Environment. All simulated experiments are based on a Universal Robot UR5e with a suction gripper. The setup provides a systematic and reproducible environment for evaluation, especially for benchmarking the ability to ground semantic concepts like colors and object categories. The input observation is a top-down RGB-D reconstruction from 3 cameras positioned around a rectangular table: one in the front, one on the left shoulder, and one on the right shoulder, all pointing towards the center. Each camera has a resolution of $6 4 0 \times 4 8 0$ and is noiseless.
Language-Conditioned Manipulation Tasks. We extend the Ravens benchmark [2] set in PyBullet [60] with 10 language-conditioned manipulation tasks. See Figure 1 for examples and Table 3 for challenges associated with each task. Each task instance is constructed by sampling a set of objects and attributes: poses, colors, sizes, and object categories. 8 of the 10 tasks have two variants, denoted by seen and unseen, depending on whether the task has unseen attributes (e.g. color) at test time. For colors: $\mathbb { T } _ { \mathrm { s e e n c o l o r s } } = \{ \mathtt { y e l l o w }$ , brown, gray, cyan} and $\mathbb { T } _ { \mathrm { u n s e e n c o l o r s } } =$ {orange, purple, pink, white $\}$ with 3 overlapping colors $\mathbb { T } _ { \mathrm { a l l } } ~ = ~ \{ \mathrm { r e d }$ , green, blue} used in both the seen and unseen spilts. For packing objects, we use 56 tabletop objects from the Google Scanned Objects dataset [61] and split them into 37 seen and 19 unseen objects. The language instructions are constructed from templates for simulated experiments, and human-annotated for real-world experiments. For more details about individual tasks, see Appendix A.
Evaluation Metric. We adopt the 0 (fail) to 100 (success) scores proposed in the Ravens benchmark [2]. The score assigns partial credit based on the task, e.g. $3 / 5 \Rightarrow 6 0 . 0$ for packing 3 out of 5 objects specified in the instructions, or $3 0 / 5 6 \Rightarrow 5 3 . 6$ for pushing 30 out of 56 particles into the correct zone. See Appendix A for the specific evaluation metric used in each task. During an evaluation episode, an agent keeps interacting with the scene until an oracle indicates task-completion. We report scores on 100 evaluation runs for agents trained with $n = 1 , 1 0$ , 100, 1000 demonstrations.
# 4.2 Simulation Results
Table 1 presents results from our large-scale experiments in Ravens [2] and Figure 3 summarizes these results with average scores across seen and unseen splits.
 Figure 3. Average scores across seen and unseen splits for all tasks in Table 1.
# Baseline Methods. To study
the effectiveness of our two-stream architecture, we broadly compare against two baselines: Transporter-only and CLIP-only. Transporter-only is the original Transporter [2], or equivalently, the spatial stream of CLIPORT with RGB-D input. Although Transporter-only does not receive any language goals, it shows what can be achieved through chance by exploiting the most likely actions seen during training. On the other hand, CLIP-only is just the semantic stream of CLIPORT with RGB and language input. CLIP-only shows what can be achieved by fine-tuning a pre-trained semantic model for manipulation without spatial information, particularly depth.
Two-Stream Performance. Figure 3 (seen) captures the essence of our main claims. The performance of Transporter-only saturates at $5 0 \%$ since it doesn’t use the language instruction to ground the desired goal. CLIP-only does have a goal, but lacks the spatial precision to go the last mile and thus saturates at $7 6 \%$ . Only CLIPORT (single) achieves more than $9 0 \%$ , which indicates that both the semantic and spatial streams are crucial for fine-grained manipulation. Further, CLIPORT (single) achieves $8 6 \%$ on most tasks with just 100 demonstrations, showcasing its efficiency.
In addition to these baselines, we present various ablations and alternative one-stream and twostream models in Appendix F. To briefly summarize these results, CLIP is essential for few-shot
<table><tr><td></td><td colspan="4">packing-box-pairs seen-colors</td><td colspan="4">packing-box-pairs unseen-colors</td><td colspan="4">packing-seen-google objects-seq</td><td colspan="4">packing-unseen-google objects-seq</td><td colspan="4">packing-seen-google objects-group</td><td colspan="4">packing-unseen-google objects-group</td></tr><tr><td>Method</td><td>1</td><td>10</td><td>100</td><td>1000</td><td>1 10</td><td>100</td><td>1000</td><td>1</td><td>10</td><td>100</td><td>1000</td><td>1</td><td>10</td><td>100</td><td>1000</td><td>1</td><td>10</td><td>100</td><td>1000</td><td>1</td><td>10</td><td>100</td><td>1000</td></tr><tr><td>Transporter-only [2]</td><td>44.2 55.2 54.2</td><td></td><td></td><td></td><td></td><td></td><td>54.1</td><td>26.2 39.7</td><td></td><td>45.4</td><td></td><td></td><td>19.9 29.8</td><td>28.7</td><td>37.3</td><td></td><td></td><td></td><td>59.9</td><td></td><td></td><td>46.2 54.7 49.8</td><td></td></tr><tr><td>CLIP-only</td><td></td><td></td><td></td><td>52.4</td><td>34.648.747.2</td><td></td><td></td><td></td><td></td><td></td><td>46.3</td><td></td><td></td><td></td><td></td><td></td><td>60.0 54.3 61.5</td><td></td><td></td><td></td><td></td><td></td><td>:52.0</td></tr><tr><td>RN50-BERT</td><td></td><td></td><td></td><td></td><td>38.6 69.7 88.5 87.1 33.0 65.5 68.8</td><td></td><td>61.2</td><td></td><td>29.1 67.9</td><td>)89.3</td><td>95.8</td><td></td><td></td><td></td><td>37.1 49.4 60.4 57.8</td><td></td><td>52.5 62.0 89.6 92.7</td><td></td><td></td><td></td><td></td><td></td><td>43.465.9 73.1 70.0</td></tr><tr><td>CLIPORT (single)</td><td></td><td></td><td></td><td></td><td>36.2 64.0 94.7 90.3 31.4 52.7 65.6</td><td></td><td>72.1</td><td></td><td>32.948.4 87.9 94.0</td><td></td><td></td><td></td><td></td><td></td><td>)29.348.548.356.1 71.9</td><td>52.7</td><td></td><td></td><td></td><td></td><td></td><td></td><td>46.452.9 76.586.4 43.2 52.0 66.3 73.7</td></tr><tr><td>CLIPORT (multi)</td><td colspan="4">51.6 82.9 92.7 66.888.694.196.659.0 69.776.271.441.678.485.084.4 40.751.165.870.371.384.689.68.368.4 69.678.480.3</td><td colspan="4">98.2 45.6 65.3 68.6 71.5</td><td colspan="4"></td><td colspan="4">14.8 59.5 86.8 96.2 27.2 50.0 65.5</td><td colspan="4">67.0 84.1</td><td colspan="4">94.061.5 66.2 78.4 81.5</td></tr><tr><td rowspan="4"> CLIPORT (multi-attr)</td><td colspan="4"></td><td colspan="4">46.2 72.0 86.2 80.3</td><td colspan="4"></td><td colspan="4">35.4 45.1 78.9 87.4</td><td colspan="4"></td><td colspan="4">48.6 69.3 84.8 89.1</td></tr><tr><td></td><td>stack-block-pyramid seq-seen-colors</td><td></td><td></td><td>stack-block-pyramid</td><td>seq-unseen-colors</td><td></td><td></td><td>separating-piles seen-colors</td><td></td><td></td><td></td><td>separating-piles unseen-colors</td><td></td><td></td><td></td><td>towers-of-hanoi</td><td></td><td></td><td></td><td></td><td>towers-of-hanoi</td><td></td></tr><tr><td>1</td><td>10</td><td>100</td><td>1000</td><td>1</td><td>10</td><td>100</td><td>1000 1</td><td>10</td><td>100</td><td>1000</td><td></td><td>10</td><td></td><td>1000</td><td>1</td><td>seq-seen-colors 10</td><td></td><td></td><td></td><td></td><td></td><td>seq-unseen-colors</td></tr><tr><td></td><td>4.5</td><td>2.3</td><td>5.2 4.5</td><td>3.0</td><td>4.0</td><td>2.3</td><td>5.8</td><td>42.7</td><td>52.3</td><td>42.0</td><td>48.4</td><td>1 41.2 49.2</td><td></td><td>100 44.7</td><td>52.3</td><td>67.9</td><td>98.0</td><td>100 1000 99.9</td><td></td><td>1</td><td>10 100 24.344.671.7 80.7</td><td>1000</td></tr><tr><td>Transporter-only [2] CLIP-only</td><td>6.328.7 55.7 54.8</td><td></td><td></td><td></td><td>2.012.2</td><td>18.3</td><td></td><td>19.543.5</td><td>55.0</td><td>84.9 90.25</td><td></td><td>59.949.6</td><td></td><td>73.0</td><td>71.0</td><td>25.4 9.4</td><td>52.6 88.645.3</td><td></td><td></td><td></td><td></td><td></td><td>24.747.067.0 58.0</td></tr><tr><td>RN50-BERT CLIPORT (single)</td><td>5.335.0 89.097.5 28.364.7 93.3 98.8</td><td></td><td></td><td></td><td>6.2 12.2 13.7 24.3</td><td>21.5 31.2</td><td>30.7 41.3</td><td>31.8 47.8 54.5 59.5</td><td></td><td>93.1</td><td>98.0</td><td>)47.2</td><td>46.546.533.444.4 51.0</td><td>41.3 76.6</td><td>44.9 75.2</td><td>59.4</td><td>28.0 66.1 92.9</td><td>91.392.1 97.4100</td><td></td><td>56.1</td><td></td><td></td><td>17.4 75.1 85.3 89.3 89.7 95.9 99.4</td></tr><tr><td>CLIPORT (multi)</td><td>33.5 75.3 96.8 96.5 23.3 26.831.7 22.2 48.9 72.4 90.3 89.0 56.6 62.6 64.9 62.8</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>49.9 51.8 48.2 59.8</td><td></td><td></td><td></td><td></td><td>61.6 96.3 98.7 98.1</td><td></td><td></td><td></td><td></td><td></td><td>60.1 65.6 76.7 68.7</td></tr><tr><td> CLIPORT (multi-attr)</td><td>一</td><td></td><td></td><td></td><td></td><td></td><td>15.5 51.5 59.3 79.8</td><td>assembling-kits-seq</td><td></td><td></td><td></td><td>assembling-kits-seq</td><td></td><td></td><td></td><td>put-blocks-in-bowls</td><td></td><td></td><td></td><td></td><td></td><td></td><td>56.7 78.0 88.3 96.9 put-blocks-in-bowls</td></tr><tr><td></td><td></td><td>align-rope</td><td></td><td></td><td> packing-unseen-shapes</td><td></td><td></td><td></td><td>seen-colors</td><td></td><td></td><td></td><td></td><td>unseen-colors</td><td></td><td></td><td>seen-colors</td><td></td><td></td><td></td><td></td><td>unseen-colors</td><td></td></tr><tr><td>Transporter-only [2]</td><td>1</td><td>10</td><td>100</td><td>1000</td><td>1</td><td>10 100</td><td>1000</td><td>1</td><td>10</td><td>100</td><td>1000</td><td>1</td><td>10</td><td>100</td><td>1000</td><td>1</td><td>10</td><td>100</td><td>1000</td><td>1</td><td>10</td><td>100</td><td>1000</td></tr><tr><td>CLIP-only</td><td>6.930.633.1</td><td></td><td></td><td>51.5</td><td></td><td>16.0 20.0 22.0</td><td>22.0</td><td>5.8</td><td>11.6</td><td></td><td>28.6 29.6</td><td>7.8</td><td>17.6</td><td>25.6</td><td>28.4</td><td>16.8 333.3 62.7</td><td></td><td></td><td>64.7</td><td>11.7</td><td></td><td>17.2 14.8</td><td>18.7 11.2 34.2 33.2 44.5</td></tr><tr><td>RN50-BERT CLIPORT (single)</td><td></td><td>3.125.063.8</td><td>13.4 48.7 70.4</td><td>70.7 57.1</td><td>19.0 25.0</td><td>13.0 28.0 44.0 32.0</td><td>50.0 44.0</td><td>0.8 2.2</td><td>9.2 5.6</td><td>19.8 11.6</td><td>23.0 21.8</td><td>2.0 1.6</td><td>4.6 6.4</td><td>10.8 10.4</td><td>19.8 18.4</td><td>23.5 60.2 93.5 13.8 44.581.2</td><td></td><td>91.8</td><td>97.7</td><td></td><td></td><td></td><td>223.030.323.8</td></tr><tr></table>
Table 1. Language-Conditioned Test Results. Task success scores (mean $\%$ ) from 100 evaluation instances vs. # of training demonstrations (1, 10, 100, or 1000). The challenges pertaining to each task are described in Appendix A. CLIPORT (single) models are trained on seen splits, and evaluated on both seen and unseen splits. CLIPORT (multi) models are trained on seen splits of all 10 tasks with 1T, 10T, 100T, and 1000T demonstrations where $\mathbb { T } = 1 0$ . CLIPORT (multi-attr) indicate CLIPORT (multi) models trained on seen-and-unseen splits from all tasks except for that one particular heldout task, for which it is trained only the seen split. See Figure 3 for an overview with average scores.
learning (i.e. $n \geq 1 0 .$ ) in lieu of semantic stream alternatives like ImageNet-trained ResNet50 [62] with BERT [38]. Image-goal models outperform CLIPORT (single) in packing Google objects, but this is only because they do not have to solve the language-grounding problem.
Multi-Task Performance. In realistic scenarios, we want the robot to be capable of any task, not just one task. We investigate this through CLIPORT (multi) in Table 1 with one multi-task model trained on all 10 tasks. CLIPORT (multi) models are trained only on seen-splits of tasks, so an unseen attribute like ‘pink’ is consistent throughout single and multi-task settings. Surprisingly, CLIPORT (multi) outperforms single-task CLIPORT (single) models in $4 1 / 7 2 = 5 7 \%$ of the evaluations in Table 1. This trend is also evident in Figure 3 (seen), especially in instances with 100 demonstrations or less. Although CLIPORT (multi) is trained on more diverse data from other tasks, both CLIPORT (multi) and CLIPORT (single) have access to the same amount of data per task. This supports our premise that language is a strong conditioning mechanism for reusing concepts from other tasks without learning them from scratch. It also validates a trait of data-driven approaches where training on lots of diverse data leads to more robust and generalizable representations [1, 63]. However, CLIPORT (multi) performs worse on longer-horizon tasks like align-rope. We hypothesize that this is because longer-horizon tasks get less coverage of input-action pairs in the dataset. Future works could use better sampling methods that balance tasks according to their average time horizon.
Generalizing to Unseen Attributes. Tasks that require generalizing to novel colors, shapes, and objects are more difficult and all our agents achieve relatively lower performance on these tasks, as shown in Figure 3 (unseen). However, CLIPORT (single) models do substantially better than chance, i.e., Transporter-only. The lower performances are due to the difficulty of grounding unseen attributes such as ‘pink’ and ‘orange’ in the language instruction “put the pink block on the orange bowl”, when the agent has never encountered words ‘orange’, ‘pink’ or their corresponding visual characteristics in the context of the physical environment. Although pre-trained CLIP has been exposed to the attribute ‘pink’, it could correspond to different concepts in the physical setting depending on factors like lighting condition, and thus requires at least few examples to condition the trainable semantic decoder layers. Additionally, we notice that CLIPORT (single) is also less prone to overfitting compared to Transporter-only. As evidenced in towers-of-hanoi-seq-unseen-colors task in Table 1, Transporter-only suffers from a performance drop because of rings with unseen colors despite the fact that Tower of Hanoi can be solved without attending to the colors and simply focusing on the ring size. We hypothesize that since CLIP was trained on diverse internet data, it enables our agent to focus on task-relevant concepts while ignoring irrelevant aspects of the task.
 Figure 4. Affordance predictions from CLIPORT (multi) models in sim (left two) and real settings (right three). More examples in Appendix H.
Transferring Attributes across Tasks. One solution for dealing with unseen attributes is to explicitly learn these attributes from other tasks. We study this with CLIPORT (multi-attr) in Table 1 and Figure 3 (unseen). For these models, CLIPORT (multi) is trained on both seen-and-unseen splits from all tasks except for the task being evaluated on, for which it was only trained on the seen split. As such, this evaluation measures whether having seen pink blocks in put-blocks-in-bowl-unseen-colors helps solve “pack all the pink and cyan boxes” in packing-box-pairs-unseen-colors. Results indicate that such explicit transfers result in significant improvements. For instance, on the put-blocks-inbowls-unseen-colors task for $n = 1 0 0 0$ , CLIPORT (multi)’s performance increases from 45.8 to 75.7.
# 4.3 Real-Robot Experiments
We validated our results in hardware with a Franka Panda manipulator. See Appendix D for setup details. Table 2 reports success rates for a multi-task model trained and evaluated on 9 real-world tasks. Due to COVID restrictions, we could not conduct largescale user-studies, so we report on small train (5-10 demos) and test sets (5-10 runs) per task. Overall, CLIPORT (multi) is effective at few-shot learning with just 179 samples, and the performances roughly correspond to those in simulated experiments, with simple block manipulation tasks achieving $\sim 7 0 \%$ . We estimate that for more robust real-world performance at least 50 to 100 training demonstrations are necessary, as evident in Figure 3. Interestingly, we observed that the model sometimes exploits biases in the training data instead of learning to ground instructions. For instance, in Put Blocks in Bowl, the training set consisted of only one datapoint on “yellow blocks” being placed inside a “blue bowl”. This made it difficult to condition the model to place “yellow blocks” in non-blue bowls. But instances with just one or two examples where a colored block went to different colored bowls was sufficient to make the model pay attention to the language. In summary, unbiased datasets containing both a good coverage of expected skills and invariances, and a decent number of training demonstrations, are crucial for good real-world performance.
<table><tr><td>Task # Train (Samples) #Test Succ.%</td></tr><tr><td>Stack Blocks</td></tr><tr><td>5 (13) 10 70.0 5(10) 10 65.0</td></tr><tr><td>Put Blocks in Bowl Pack Objects 10 (31) 10 60.0</td></tr><tr><td>Move Rook 4(29) 10 70.0</td></tr><tr><td>Fold Cloth 9(9) 10 57.0</td></tr><tr><td>Read Text 2(26) 10 55.0</td></tr><tr><td>Loop Rope 4(12) 10 60.0</td></tr><tr><td>Sweep Beans 5 (23) 5 60.6</td></tr><tr><td>Pick Cherries 4(26) 5 75.0</td></tr></table>
Table 2. Success rates $( \% )$ of a multi-task model trained an evaluated 9 real-world tasks (see Figure 1). Samples indicate total image-action pairs, e.g 1 in Figure 9.
# 5 Conclusion
We introduced CLIPORT, an end-to-end framework for language-conditioned fine-grained manipulation. Our experiments, specifically with multi-task models, indicate that data-driven approaches to generalization have yet to be fully-exploited in robotics. Coupled with the right action abstraction and spatio-semantic priors, end-to-end methods can quickly learn new skills without requiring top-down pipelines that need task-specific engineering.
While CLIPORT can solve a range of tabletop tasks, extending it to dexterous 6-DOF manipulation that goes beyond the two-step primitive remains a challenge. As such, it cannot handle complex partially-observable scenes, or output continuous control for multi-fingered hands, or predict task-completion (see Appendix I for an extended discussion). But overall, we are excited by the confluence of data and structural priors for building scalable and generalizable robotic systems.
# Acknowledgments
All simulated experiments were facilitated through the Hyak computing cluster funded by the STF at the University of Washington. We thank Mohak Bhardwaj for help with the Franka setup at UW. We are also grateful to our colleagues Chris Xie, Jesse Thomason, and Valts Blukis for providing feedback on the initial draft. This work was funded in part by ONR under award #1140209-405780.
# References
[1] A. Radford, J. W. Kim, C. Hallacy, A. Ramesh, G. Goh, S. Agarwal, G. Sastry, A. Askell, P. Mishkin, J. Clark, G. Krueger, and I. Sutskever. Learning Transferable Visual Models From Natural Language Supervision. arXiv:2103.00020 [cs], Feb. 2021. [2] A. Zeng, P. Florence, J. Tompson, S. Welker, J. Chien, M. Attarian, T. Armstrong, I. Krasin, D. Duong, V. Sindhwani, and J. Lee. Transporter networks: Rearranging the visual world for robotic manipulation. Conference on Robot Learning (CoRL), 2020. [3] I. Akkaya, M. Andrychowicz, M. Chociej, M. Litwin, B. McGrew, A. Petron, A. Paino, M. Plappert, G. Powell, R. Ribas, et al. Solving rubik’s cube with a robot hand. arXiv preprint arXiv:1910.07113, 2019. [4] D. Kalashnikov, A. Irpan, P. Pastor, J. Ibarz, A. Herzog, E. Jang, D. Quillen, E. Holly, M. Kalakrishnan, V. Vanhoucke, et al. Qt-opt: Scalable deep reinforcement learning for visionbased robotic manipulation. Conference on Robot Learning (CoRL), 2018. [5] D. Kalashnikov, J. Varley, Y. Chebotar, B. Swanson, R. Jonschkowski, C. Finn, S. Levine, and K. Hausman. Mt-opt: Continuous multi-task robotic reinforcement learning at scale. arXiv preprint arXiv:2104.08212, 2021. [6] D. Seita, P. Florence, J. Tompson, E. Coumans, V. Sindhwani, K. Goldberg, and A. Zeng. Learning to rearrange deformable cables, fabrics, and bags with goal-conditioned transporter networks. In IEEE International Conference on Robotics and Automation (ICRA), 2021. [7] M. Shridhar and D. Hsu. Interactive visual grounding of referring expressions for human-robot interaction. In Proceedings of Robotics: Science and Systems (RSS), 2018. [8] C. Matuszek, L. Bo, L. Zettlemoyer, and D. Fox. Learning from unscripted deictic gesture and language for human-robot interactions. In Proceedings of the AAAI Conference on Artificial Intelligence, volume 28, 2014. [9] M. Bollini, S. Tellex, T. Thompson, N. Roy, and D. Rus. Interpreting and executing recipes with a cooking robot. In Experimental Robotics, pages 481–495. Springer, 2013. [10] D. K. Misra, J. Sung, K. Lee, and A. Saxena. Tell me dave: Context-sensitive grounding of natural language to manipulation instructions. The International Journal of Robotics Research (IJRR), 35(1-3):281–300, 2016. [11] T. Chen, S. Kornblith, M. Norouzi, and G. Hinton. A simple framework for contrastive learning of visual representations. In International conference on machine learning, pages 1597–1607. PMLR, 2020. [12] K. He, H. Fan, Y. Wu, S. Xie, and R. Girshick. Momentum contrast for unsupervised visual representation learning. In The IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), pages 9729–9738, 2020. [13] J. Lu, D. Batra, D. Parikh, and S. Lee. Vilbert: Pretraining task-agnostic visiolinguistic representations for vision-and-language tasks. In Advances in Neural Information Processing Systems (NeuRIPS), 2019. [14] Y. C. Chen, L. Li, L. Yu, A. El Kholy, F. Ahmed, Z. Gan, Y. Cheng, and J. Liu. Uniter: Universal image-text representation learning. In European Conference on Computer Vision, pages 104–120. Springer, 2020. [15] H. Tan and M. Bansal. Lxmert: Learning cross-modality encoder representations from transformers. In Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing (EMNLP), 2019. [16] D. H. Hubel and T. N. Wiesel. Receptive fields and functional architecture in two nonstriate visual areas (18 and 19) of the cat. Journal of neurophysiology, 28(2):229–289, 1965. [17] M. Livingstone and D. Hubel. Segregation of form, color, movement, and depth: anatomy, physiology, and perception. Science, 240(4853):740–749, 1988. [18] A. Derrington and P. Lennie. Spatial and temporal contrast sensitivities of neurones in lateral geniculate nucleus of macaque. The Journal of physiology, 357(1):219–240, 1984. [19] J. J. Gibson. The ecological approach to visual perception: classic edition. Psychology Press, 2014. [20] A. Kamath, M. Singh, Y. LeCun, I. Misra, G. Synnaeve, and N. Carion. Mdetr–modulated detection for end-to-end multi-modal understanding. arXiv preprint arXiv:2104.12763, 2021. [21] K. He, G. Gkioxari, P. Dollar, and R. Girshick. Mask r-cnn. In ´ The IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), 2017. [22] Y. Xiang, T. Schmidt, V. Narayanan, and D. Fox. Posecnn: A convolutional neural network for 6d object pose estimation in cluttered scenes. In Proceedings of Robotics: Science and Systems (RSS), 2018. [23] M. Zhu, K. G. Derpanis, Y. Yang, S. Brahmbhatt, M. Zhang, C. Phillips, M. Lecce, and K. Daniilidis. Single image 3d object detection and pose estimation for grasping. In 2014 IEEE International Conference on Robotics and Automation (ICRA), pages 3936–3943. IEEE, 2014. [24] A. Zeng, K.-T. Yu, S. Song, D. Suo, E. Walker, A. Rodriguez, and J. Xiao. Multi-view selfsupervised deep learning for 6d pose estimation in the amazon picking challenge. In 2017 IEEE international conference on robotics and automation (ICRA), pages 1386–1383. IEEE, 2017. [25] X. Deng, Y. Xiang, A. Mousavian, C. Eppner, T. Bretl, and D. Fox. Self-supervised 6d object pose estimation for robot manipulation. In 2020 IEEE International Conference on Robotics and Automation (ICRA), pages 3665–3671. IEEE, 2020. [26] C. Xie, Y. Xiang, A. Mousavian, and D. Fox. The best of both modes: Separately leveraging rgb and depth for unseen object instance segmentation. In Conference on Robot Learning (CoRL), pages 1369–1378. PMLR, 2020. [27] P. R. Florence, L. Manuelli, and R. Tedrake. Dense object nets: Learning dense visual object descriptors by and for robotic manipulation. In Conference on Robot Learning (CoRL), 2018. [28] P. Florence, L. Manuelli, and R. Tedrake. Self-supervised correspondence in visuomotor policy learning. IEEE Robotics and Automation Letters, 5(2):492–499, 2019. [29] P. Sundaresan, J. Grannen, B. Thananjeyan, A. Balakrishna, M. Laskey, K. Stone, J. E. Gonzalez, and K. Goldberg. Learning rope manipulation policies using dense object descriptors trained on synthetic depth data. In 2020 IEEE International Conference on Robotics and Automation (ICRA), pages 9411–9418. IEEE, 2020. [30] L. Manuelli, W. Gao, P. Florence, and R. Tedrake. kpam: Keypoint affordances for categorylevel robotic manipulation. In International Symposium on Robotics Research (ISRR), 2019. [31] T. D. Kulkarni, A. Gupta, C. Ionescu, S. Borgeaud, M. Reynolds, A. Zisserman, and V. Mnih. Unsupervised learning of object keypoints for perception and control. Advances in neural information processing systems (NeuRIPS), 32:10724–10734, 2019. [32] X. Liu, R. Jonschkowski, A. Angelova, and K. Konolige. Keypose: Multi-view 3d labeling and keypoint estimation for transparent objects. In The IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), pages 11602–11610, 2020. [33] K. Zakka, A. Zeng, J. Lee, and S. Song. Form2fit: Learning shape priors for generalizable assembly from disassembly. In 2020 IEEE International Conference on Robotics and Automation (ICRA), pages 9404–9410. IEEE, 2020. [34] S. Song, A. Zeng, J. Lee, and T. Funkhouser. Grasping in the wild: Learning 6dof closedloop grasping from low-cost demonstrations. IEEE Robotics and Automation Letters, 5(3): 4978–4985, 2020. [35] Y. Wu, W. Yan, T. Kurutach, L. Pinto, and P. Abbeel. Learning to Manipulate Deformable Objects without Demonstrations. In Proceedings of Robotics: Science and Systems (RSS), 2020. [36] L. Yen-Chen, A. Zeng, S. Song, P. Isola, and T.-Y. Lin. Learning to see before learning to act: Visual pre-training for manipulation. In IEEE International Conference on Robotics and Automation (ICRA), 2020. [37] A. Vaswani, N. Shazeer, N. Parmar, J. Uszkoreit, L. Jones, A. N. Gomez, L. Kaiser, and I. Polosukhin. Attention is all you need. In Advances in Neural Information Processing Systems (NeuRIPS), 2017. [38] J. Devlin, M. W. Chang, K. Lee, and K. Toutanova. Bert: Pre-training of deep bidirectional transformers for language understanding. In Proceedings of the Conference of the North American Chapter of the Association for Computational Linguistics (NAACL), 2018. [39] A. Dosovitskiy, L. Beyer, A. Kolesnikov, D. Weissenborn, X. Zhai, T. Unterthiner, M. Dehghani, M. Minderer, G. Heigold, S. Gelly, et al. An image is worth 16x16 words: Transformers for image recognition at scale. In International Conference on Learning Representations, 2020. [40] F. Yu, J. Tang, W. Yin, Y. Sun, H. Tian, H. Wu, and H. Wang. Ernie-vil: Knowledge enhanced vision-language representations through scene graph. arXiv preprint arXiv:2006.16934, 2020. [41] Y. Bisk, D. Yuret, and D. Marcu. Natural language communication with robots. In Proceedings of the North American Chapter of the Association for Computational Linguistics (NAACL), pages 751–761, 2016. [42] J. Thomason, S. Zhang, R. J. Mooney, and P. Stone. Learning to interpret natural language commands through human-robot dialog. In Twenty-Fourth International Joint Conference on Artificial Intelligence (IJCAI), 2015. [43] J. Hatori, Y. Kikuchi, S. Kobayashi, K. Takahashi, Y. Tsuboi, Y. Unno, W. Ko, and J. Tan. Interactively picking real-world objects with unconstrained spoken language instructions. In Proceedings of International Conference on Robotics and Automation (ICRA), 2018. [44] Y. Chen, R. Xu, Y. Lin, and P. A. Vela. A Joint Network for Grasp Detection Conditioned on Natural Language Commands. arXiv:2104.00492 [cs], Apr. 2021. [45] V. Blukis, R. A. Knepper, and Y. Artzi. Few-shot object grounding for mapping natural language instructions to robot control. In Conference on Robot Learning (CoRL), 2020. [46] C. Paxton, Y. Bisk, J. Thomason, A. Byravan, and D. Fox. Prospection: Interpretable plans from language by predicting the future. In International Conference on Robotics and Automation (ICRA), pages 6942–6948. IEEE, 2019. [47] S. Tellex, T. Kollar, S. Dickerson, M. Walter, A. Banerjee, S. Teller, and N. Roy. Understanding natural language commands for robotic navigation and mobile manipulation. In Proceedings of the AAAI Conference on Artificial Intelligence (AAAI), 2011. [48] C. Lynch and P. Sermanet. Grounding language in play. arXiv preprint arXiv:2005.07648, 2020. [49] K. Simonyan and A. Zisserman. Two-stream convolutional networks for action recognition in videos. arXiv preprint arXiv:1406.2199, 2014. [50] C. Feichtenhofer, A. Pinz, and A. Zisserman. Convolutional two-stream network fusion for video action recognition. In The IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), pages 1933–1941, 2016. [51] C. Feichtenhofer, H. Fan, J. Malik, and K. He. Slowfast networks for video recognition. In Proceedings of the IEEE/CVF International Conference on Computer Vision (CVPR), pages 6202–6211, 2019. [52] E. Kazakos, A. Nagrani, A. Zisserman, and D. Damen. Slow-fast auditory streams for audio recognition. In ICASSP 2021-2021 IEEE International Conference on Acoustics, Speech and Signal Processing (ICASSP), pages 855–859. IEEE, 2021. [53] F. Xiao, Y. J. Lee, K. Grauman, J. Malik, and C. Feichtenhofer. Audiovisual slowfast networks for video recognition. arXiv preprint arXiv:2001.08740, 2020. [54] A. Zeng, S. Song, K.-T. Yu, E. Donlon, F. R. Hogan, M. Bauza, D. Ma, O. Taylor, M. Liu, E. Romo, et al. Robotic pick-and-place of novel objects in clutter with multi-affordance grasping and cross-domain image matching. In 2018 IEEE international conference on robotics and automation (ICRA), pages 3750–3757. IEEE, 2018. [55] E. Jang, S. Vijayanarasimhan, P. Pastor, J. Ibarz, and S. Levine. End-to-end learning of semantic grasping. In Conference on Robot Learning (CoRL), Proceedings of Machine Learning Research. PMLR, 2017. [56] R. Kondor and S. Trivedi. On the generalization of equivariance and convolution in neural networks to the action of compact groups. In International Conference on Machine Learning (ICML), 2018. [57] T. Cohen and M. Welling. Group equivariant convolutional networks. In International conference on machine learning (ICML), 2016. [58] D. Misra, A. Bennett, V. Blukis, E. Niklasson, M. Shatkhin, and Y. Artzi. Mapping instructions to actions in 3d environments with visual goal prediction. In Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing (EMNLP), 2018. [59] G. Goh, N. C. †, C. V. †, S. Carter, M. Petrov, L. Schubert, A. Radford, and C. Olah. Multimodal neurons in artificial neural networks. Distill, 2021. doi:10.23915/distill.00030. https://distill.pub/2021/multimodal-neurons. [60] E. Coumans and Y. Bai. Pybullet, a python module for physics simulation for games, robotics and machine learning. 2016. [61] Google scanned objects dataset, 2020. URL https://app.ignitionrobotics.org/ GoogleResearch/fuel/collections/Google%20Scanned%20Objects. [62] K. He, X. Zhang, S. Ren, and J. Sun. Deep residual learning for image recognition. In The IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), pages 770–778, 2016. [63] J. Lu, V. Goswami, M. Rohrbach, D. Parikh, and S. Lee. 12-in-1: Multi-task vision and language representation learning. In The IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), June 2020. [64] A. Paszke, S. Gross, F. Massa, A. Lerer, J. Bradbury, G. Chanan, T. Killeen, Z. Lin, N. Gimelshein, L. Antiga, et al. Pytorch: An imperative style, high-performance deep learning library. arXiv preprint arXiv:1912.01703, 2019. [65] V. Sanh, L. Debut, J. Chaumond, and T. Wolf. Distilbert, a distilled version of bert: smaller, faster, cheaper and lighter. arXiv preprint arXiv:1910.01108, 2019. [66] J. Deng, W. Dong, R. Socher, L.-J. Li, K. Li, and L. Fei-Fei. Imagenet: A large-scale hierarchical image database. In 2009 IEEE conference on computer vision and pattern recognition, pages 248–255. Ieee, 2009. [67] J. Mao, C. Gan, P. Kohli, J. B. Tenenbaum, and J. Wu. The neuro-symbolic concept learner: Interpreting scenes, words, and sentences from natural supervision. arXiv preprint arXiv:1904.12584, 2019. [68] D. Ding, F. Hill, A. Santoro, and M. Botvinick. Object-based attention for spatio-temporal reasoning: Outperforming neuro-symbolic models with flexible distributed architectures. arXiv preprint arXiv:2012.08508, 2020. [69] E. M. Bender, T. Gebru, A. McMillan-Major, and S. Shmitchell. On the dangers of stochastic parrots: Can language models be too big? In Proceedings of the 2021 ACM Conference on Fairness, Accountability, and Transparency, pages 610–623, 2021.123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334# Neural Analysis and Synthesis: Reconstructing Speech from Self-Supervised Representations
Hyeong-Seok Choi1,4 Juheon Lee1,4 Wansoo Kim1,4
Jie Hwan Lee4 Hoon Heo4 Kyogu Lee1,2,3,4
1MARG, Department of Intelligence and Information, Seoul National University 2GSAI 3AIIS 4Supertone Inc.
{kekepa15, juheon2, wansookim, kglee}@snu.ac.kr, {wiswisbus, hoon}@supertone.ai
# Abstract
We present a neural analysis and synthesis (NANSY) framework that can manipulate voice, pitch, and speed of an arbitrary speech signal. Most of the previous works have focused on using information bottleneck to disentangle analysis features for controllable synthesis, which usually results in poor reconstruction quality. We address this issue by proposing a novel training strategy based on information perturbation. The idea is to perturb information in the original input signal (e.g., formant, pitch, and frequency response), thereby letting synthesis networks selectively take essential attributes to reconstruct the input signal. Because NANSY does not need any bottleneck structures, it enjoys both high reconstruction quality and controllability. Furthermore, NANSY does not require any labels associated with speech data such as text and speaker information, but rather uses a new set of analysis features, i.e., wav2vec feature and newly proposed pitch feature, Yingram, which allows for fully self-supervised training. Taking advantage of fully selfsupervised training, NANSY can be easily extended to a multilingual setting by simply training it with a multilingual dataset. The experiments show that NANSY can achieve significant improvement in performance in several applications such as zero-shot voice conversion, pitch shift, and time-scale modification 1.
# 1 Introduction
Analyzing and synthesizing an arbitrary speech signal is inarguably a significant research topic that has been studied for decades. Traditionally, this has been studied in the digital signal processing (DSP) field using fundamental methods such as sinusoidal modeling or linear predictive coding (LPC), and it is the analysis and synthesis framework that lies at the heart of those fundamental methods $[ \sqrt { 2 6 } , \bigstar ]$ . These traditional methods, however, are limited in terms of controllability because the decomposed representations are still low-level representations. It is obvious that the closer we decompose a signal into high-level/interpretable representations, the more we gain access to the controllability. Given this consideration, we aim to design a neural analysis and synthesis (NANSY) framework by decomposing a speech signal into analysis features that represent pronunciation, timbre, pitch, and energy. The decomposed representations can be manipulated and re-synthesized, enabling users to manipulate speech signals in various ways.
It is worth noting that many similar ideas have been recently proposed in the context of voice conversion applications. We categorize the previous works in two ways, i.e., 1. Text-based approach,
2. Information bottleneck approach. The first approach exploits the fact that the text modality is inherently disentangled from the speaker identity. One of the most popular text-based approaches is to use a pre-trained automatic speech recognition (ASR) network to extract a phonetic posteriogram (PPG) and use it as a linguistic feature [41]. Then, combining the PPG with the target speaker information, the features are re-synthesized to a speech signal. Another alternative approach is to directly use text scripts by aligning it to a paired source signal $\mathbb { \lVert 3 3 \rVert }$ . Although these ideas have shown promising results, it is important to note that these approaches have common problems. First, in order to extract the PPG features, it is required to train an ASR network in a supervised manner, which demands a lot of paired text and waveform datasets. Additionally, the language dependency of the ASR network limits the model’s capability to be extended to multilingual settings or languages with low-resources. To address these concerns, efforts have been made to divert from using the text information and the most popular approach is to use an information bottleneck. The key idea is to restrict the information flow by reducing time/channel dimension, and normalizing/quantizing intermediate representations [36, 10, 51]. Although these ideas have been explored in many ways, one critical problem is that there exists an inevitable trade-off between the degree of disentanglement and the reconstruction quality. In other words, there is a trade-off between speaker similarity and the preservation of original content such as linguistic and pitch information.
To avoid the major concern of the text-based approach, we suggest to use two analysis features which are wav2vec and a newly proposed feature, Yingram. In order to preserve the linguistic information without any text information, we utilize wav2vec $2 . 0 \mathbb { H }$ , trained on 53 languages in total $\mathbb { m }$ . While the features from wav2vec 2.0 have mostly been used for a downstream task, we seek the possibility of using them for an upstream/generation task. In addition, we propose a new feature that can effectively represent and control pitch information. Although it is the fundamental frequency $( f _ { 0 } )$ that is mostly used to represent the pitch information, $f _ { 0 }$ is sometimes ill-defined when there exists sub-harmonics in the signal (e.g., vocal fry) [16, 1, 2]. We address this issue by proposing a controllable but more abstract feature than $f _ { 0 }$ that still includes information such as sub-harmonics. Because the proposed feature is heavily inspired by the famous Yin algorithm $\mathbb { \lVert \lambda \rVert }$ , we refer to this feature as Yingram.
Although the analysis features above have enough information to reconstruct the original speech signal, we have found that the information in the proposed analysis features share common information such as pitch and timbre. To disentangle the common information so each feature can control a specific attribute for its desired purpose (e.g., wav2vec linguistic information only, Yingram pitch information only), we propose an information perturbation approach, a simple yet effective solution to this problem. The idea is to simply perturb all the information we do not want to control from the input features, thereby training the neural network to not extract the undesirable attributes from the features. Through this way, the model no longer suffers from the unavoidable trade-off between reconstruction quality and feature disentanglement, unlike the information bottleneck approach.
Lastly, we would like to deal with unseen languages at test time. To this end, we propose a new test-time self-adaptation (TSA) strategy. The proposed self-adaptation strategy does not fine-tune the model parameters but only the input linguistic feature, which consequently modifies the mispronounced parts of the reconstructed sample. Because the proposed TSA requires only a single sample at test-time, it adds a large flexibility for the model to be used in many scenarios (e.g., low-resource language).
The contributions of this paper are as follows:
• We propose a neural analysis and synthesis (NANSY) framework that can be trained in a fully self-supervised manner (no text, no speaker information needed). The proposed method is based on a new set of analysis features and information perturbation. • The proposed model can be used for various applications, including zero-shot voice conversion, formant preserving pitch shift, and time-scale modification. • We propose a new test-time self-adaptation (TSA) technique than can be used even on unseen languages using only a single test-time speech sample.
 Figure 1: The overview of the training procedure and information flow of the proposed neural analysis and synthesis (NANSY) framework. The waveform is first perturbed using functions $f$ and $g$ . $f$ perturbs formant, pitch, and frequency response. $g$ perturbs formant and frequency response while preserving pitch. w2v denotes wav2vec encoder and spk denotes a speaker embedding network. L, P, S, E denotes Linguistic, Pitch, Speaker, and Energy information, respectively. The tilde symbol is attached when the information is perturbed using the perturbation functions. The dashed boxes denote the modules that are being trained.
# 2.1 Analysis Features
Linguistic To reconstruct an intelligible speech signal, it is crucial to extract rich linguistic information from the speech signal. To this end, we resort to XLSR-53: a wav2vec 2.0 model pre-trained on $5 6 \mathrm { k }$ hours of speech in 53 languages [11]. The extracted features from XLSR-53 have shown superior performance on downstream tasks such as ASR, especially on low-resource languages. We conjecture, therefore, that the extracted features from this model can provide language-agnostic linguistic information. Now the question is, from which layer should the features be extracted? Recently, it has been reported that the representation from different layers of wav2vec 2.0 exhibit different characteristics. Especially, Shah et al. $\mathbb { \lVert 3 9 \rVert }$ showed that it is the output from the middle layer that has the most relevant characteristics to pronunciation2. In light of this empirical observation, we decided to use the intermediate features of XLSR-53. More specifically, we used the output from the 12th layer of the 24-layer transformer encoder.
Speaker Perhaps the most common approach to extract speaker embeddings is to first train a speaker recognition network in a supervised manner and then reuse the network for the generation task, assuming that the speaker embedding from the trained network can represent the characteristics of unseen speakers [21, 36]. Here we would like to take one step further and assume that we do not have speaker labels to train a speaker recognition network in a supervised manner. To mitigate this disadvantage, we again use the representation from XLSR-53, which makes the proposed method fully self-supervised. To determine which layer of XLSR-53 to extract the representation from, we first analyzed the features from each layer. Specifically, we averaged the representation of each layer along the time-axis and visualized utterances of 20 randomly selected speakers from the VCTK dataset using TSNE [47, 46]. In Fig. $\bigstar$ we can observe that the representation from the 1st layer of XLSR-53 already forms clusters for each speaker, while the latter layers (especially the last layer) tend to lack them. Note that this is in accordance with the previous observation in $\dot { \mathbb { I B } }$ . Taking this into consideration, we train a speaker embedding network that uses the 1st layer of XLSR-53 as an input. For the speaker embedding network, we borrow the neural architecture from a state-of-the-art speaker recognition network $\pmb { \mathbb { I } } \pmb { \ 4 } \|$ , which is based on 1D-convolutional neural networks (1D-CNN) with an attentive statistics pooling layer. The speaker embedding was $L _ { 2 }$ -normalized before conditioning. The speaker embeddings of seen and unseen speakers during training are also shown in Fig. 2.
Pitch Due to the irregular periodicity of the glottal pulse, we often hear creaky voice in speech, which is usually manifested as jitter or sub-harmonics in signals. This makes hard for $f _ { 0 }$ trackers to estimate $f _ { 0 }$ because the $f _ { 0 }$ itself is not well defined in such cases [16, 1, 2]. We take a hint from the popular Yin algorithm to address this issue. The Yin algorithm uses the cumulative mean normalized difference function $d _ { t } ^ { \prime } ( \tau )$ to extract frame-wise features from a raw waveform, which is defined as follows,
 Figure 2: The visualization of intermediate representations of XLSR-53 using TSNE.
$$d _ { t } ^ { \prime } ( \tau ) = \left\{ \begin{array} { l l } { 1 , } & { \mathrm { i f } \ \tau = 0 } \\ { d _ { t } ( \tau ) / \sum _ { j = 1 } ^ { \tau } d _ { t } ( j ) , } & { \mathrm { o t h e r w i s e . } } \end{array} \right.$$
The $d _ { t } ( \tau )$ is a difference function that outputs a small value when there exists a periodicity on time-lag $\tau$ and it is defined as follows,
$$d _ { t } ( \tau ) = \sum _ { j = 1 } ^ { W } \left( x _ { j } - x _ { j + \tau } \right) ^ { 2 } = r _ { t } ( 0 ) + r _ { t + \tau } ( 0 ) - 2 r _ { t } ( \tau ) ,$$
where $t , \tau , W$ , and $r _ { t }$ denote frame index, time lag, window size, and the auto-correlation function, respectively. After some post processing steps, the Yin algorithm selects $f _ { 0 }$ from multiple $f _ { 0 }$ candidates. See $\mathbb { \lVert \lambda \rVert }$ for more details. Rather than explicitly selecting $f _ { 0 }$ , we would like to train the network to generate pitch harmonics from the output of the function $d _ { t } ^ { \prime } ( \tau )$ . However, $d _ { t } ^ { \prime } ( \tau )$ itself is limited to be used as a pitch feature because it lacks controllability, unlike $f _ { 0 }$ . Therefore, we propose Yingram $Y$ by converting the time-lag axis to the midi-scale axis as follows,
$$Y _ { t } ( m ) = \frac { d _ { t } ^ { \prime } ( \lceil c ( m ) \rceil ) - d _ { t } ^ { \prime } ( \lfloor c ( m ) \rfloor ) } { \lceil c ( m ) \rceil - \lfloor c ( m ) \rfloor } \cdot ( c ( m ) - \lfloor c ( m ) \rfloor ) + d _ { t } ^ { \prime } ( \lfloor c ( m ) \rfloor ) ,$$
$$c ( m ) = \frac { s r } { 4 4 0 \cdot 2 ^ { ( \frac { m - 6 9 } { 1 2 } ) } } ,$$
where $m$ , $c ( m )$ , and $s r$ denote midi note, midi-to-lag conversion function, and sampling rate, respectively. We set 20 bins of Yingram to represent a semitone range. In addition, we set Yingram to represent the frequency between $1 0 . 7 7 \mathrm { h z }$ and $1 0 0 0 . 4 0 \mathrm { h z }$ by setting $W$ to 2048 and the range of $\tau$ between 22 and 2047. In the training stage, the input to the synthesis network is the frequency range between $2 5 . 1 1 \mathrm { h z }$ and $4 3 0 . 1 9 \mathrm { h z }$ , which is shown as scope in Fig. $\textcircled { 3 }$ After the training is finished, we can change the pitch by shifting the scope. That is, in the inference stage, one could simply change the pitch of the speech signal by shifting the scope. For example, if we move the scope down 20 bins, the pitch can be raised by a semitone.
 Figure 3: The visualization of Yingram and the corresponding mel spectrogram.
Energy For the energy feature, we simply took an average from a log-mel spectrogram along the frequency axis.
# 2.2 Synthesis Network
 Figure 4: The outputs of $\mathcal { G } _ { S }$ and $\mathcal { G } _ { F }$ . The two outputs from each generator are summed to reconstruct a mel spectrogram.
It is well-known that speech production can be explained by source-filter theory. Inspired by this, we separate synthesis networks into two parts, source generator $\mathcal { G } _ { S }$ and filter generator $\mathcal { G } _ { F }$ . While the energy and speaker features are common inputs for both generators, $\mathcal { G } _ { S }$ and $\mathcal { G } _ { F }$ differ in that they take Yingram and wav2vec features, respectively. Because the acoustic feature can be interpreted as a sum of source and filter in the log magnitude domain, we incorporate inductive bias in the model by summing the outputs from each generator similarly to $[ [ 2 5 ] ]$ . As will be discussed in more detail in the next section, even though the training loss is only defined using mel spectrograms, the network learns to separately generate the spectral envelope and pitch harmonics as shown in Fig. $4 .$ Note that this separation not only provides the interpretability to the model but also enables formant preserving pitch shifting. To summarize, the acoustic feature, mel spectrogram $\hat { M }$ , is generated as follows,
$$\hat { M } = \mathcal { G } _ { S } ( \mathrm { Y i n g r a m } , S , E ) + \mathcal { G } _ { F } ( \mathrm { w a v } 2 \mathrm { v e c } , S , E ) ,$$
where $S$ and $E$ denote speaker embedding and energy features. We used stacks of 1D-CNN layers with gated linear units (GLU) $\pmb { \mathbb { I } }$ for generators. The detailed neural architecture of the generator is described in Appendix $\mathbf { B } .$ Note that each generator shares the same neural architecture. The only difference is the input features to the networks. Finally, the generated mel spectrogram is converted to waveform using the pre-trained HiFi-GAN vocoder $\pmb { \Vert 2 4 \Vert }$ .
# 3 Training
# 3.1 Information Perturbation
In our initial experiments, a neural network can be easily trained to reconstruct mel spectrograms using only the wav2vec feature. This implies that the wav2vec feature contains not only rich linguistic information but also information related to pitch and speaker. For that reason, we would like to train $\mathcal { G } _ { F }$ to selectively extract only the linguistic-related information from the wav2vec feature, not pitch and speaker information. In addition, we would like to train $\mathcal { G } _ { S }$ to selectively extract only the pitch-related information from the Yingram feature, not speaker information. To this end, we propose to perturb the information included in input waveform $x$ by using three functions that are 1. formant shifting $( f s )$ , 2. pitch randomization $( p r )$ , and 3. random frequency shaping using a parametric equalizer $( p e q ) \ L ^ { | 3 | }$ We applied a function $f$ on the wav2vec input, which is a chain of all three functions as follows, $\bar { f ( x ) } = \bar { f s ( p r ( p e q ( x ) ) ) }$ . On the Yingram side, we applied function $g$ , which is a chain of two functions $f s$ and peq so that $f _ { 0 }$ information is still preserved as follows, $g ( x ) = f s ( p e q ( x ) )$ . This way, we expect $\mathcal { G } _ { F }$ to take only the linguistic-related information from the wav2vec feature, and $\mathcal { G } _ { S }$ to take only pitch-related from the Yingram feature. Since the wav2vec and Yingram features can no longer provide the speaker-related information, the control of speaker information becomes uniquely dependent on the speaker embedding. The overview of the information flow is shown in Fig.
1. The hyperparameters of the perturbation functions are described more in Appendix A.
# 3.2 Training Loss
We used L1 loss between the generated mel spectrogram $\hat { M }$ and ground truth mel spectrogram $M$ to train the generators and speaker embedding network. However, it is well-known that the speech synthesis networks trained with L1 or L2 loss suffer from over-smootheness of the generated acoustic feature, which results in poor quality of the speech signal. Therefore, in addition to the L1 loss, we used the recent speaker conditional generative adversarial training method to mitigate this issue [8]. Writing the discriminator as $\bar { \cal D } ( { \cal M } , { \pmb { c } } _ { + } , { \pmb { c } } _ { - } ) : = \sigma ( h ( { \cal M } , { \pmb { c } } _ { + } , { \pmb { c } } _ { - } ) )$ , Choi et al. $\checkmark$ proposed to use projection conditioning $\mathbb { \left[ \left[ 2 \right] \right] }$ not only with the positive pairs but also with the negative pairs as follows,
$$h ( M , \pmb { c } _ { + } , \pmb { c } _ { - } ) = \psi ( \phi ( M ) ) + \pmb { c } _ { + } ^ { T } \phi ( M ) - \pmb { c } _ { - } ^ { T } \phi ( M ) ,$$
where $M$ denotes a mel spectrogram, $\sigma ( \cdot )$ denotes a sigmoid function, $c _ { + }$ denotes a speaker embedding from a positively paired input speech sample, and $c _ { - }$ denotes a speaker embedding from a randomly sampled speech utterance. $\phi ( \cdot )$ denotes an output from the intermediate layer of discriminator and $\psi ( \cdot )$ denotes a function that maps input vector to a scalar value. The detailed neural architecture of $\mathcal { D }$ is shown in Appendix B. The loss functions for discriminator $L _ { \mathcal { D } }$ and generator $L _ { \mathcal { G } }$ are as follows:
$$\begin{array} { r l } & { L _ { \mathcal { D } } = - \mathbb { E } _ { ( M , c _ { + } , c _ { - } ) \sim p _ { d a t a } , \hat { M } \sim p _ { g e n } } [ l o g ( \sigma ( h ( M , c _ { + } , \pmb { c } _ { - } ) ) ) - l o g ( \sigma ( h ( \hat { M } , \pmb { c } _ { + } , \pmb { c } _ { - } ) ) ) ] , } \\ & { L _ { \mathcal { G } } = - \mathbb { E } _ { ( M , c _ { + } , c _ { - } ) \sim p _ { d a t a } , \hat { M } \sim p _ { g e n } } [ l o g ( \sigma ( h ( \hat { M } , \pmb { c } _ { + } , \pmb { c } _ { - } ) ) ) ] + | M - \hat { M } | . } \end{array}$$
# 3.3 Test-time Self-Adaptation
Although the synthesis network can reconstruct an intelligible speech from the wav2vec feature in most cases, we observed that the network sometimes outputs speech signals with wrong pronunciation, especially when tested on unseen languages. To alleviate this problem, we propose to modify only the input representation, that is, the wav2vec feature, without having to train the whole network again from scratch. As shown in Fig. $\textcircled { 5 }$ we first compute L1 loss between the generated mel spectrogram $\hat { M }$ and ground truth mel spectrogram $M$ in the test-time. Then, we
 Figure 5: The illustration of TSA.
update only the parameterized wav2vec feature using the backpropagation signal from the loss. Note that the loss gradient (shown in red) is backpropagated only through the filter generator. Because this test-time training scheme requires only a single test-time sample and updates the input parameters by targeting the test-time sample itself, we call it test-time self-adaptation (TSA).
# 4 Experiments
# 4.1 Implementation Details
Dataset To train NANSY on English, we used two datasets, i.e., 1. VCTK4 [47], 2. train-clean-360 subset of LibriTTS3 [54]. We trained the model using $90 \%$ of samples for each speaker. The speakers of train-clean-360 were included to the training set only when the total length of speech samples exceeds 15 minutes. To test on English speech samples we used two datasets; 1. For the seen speaker test we used $10 \%$ unseen utterances of VCTK. 2. For the unseen speaker test we used test-clean subset of LibriTTS.
To train NANSY on multi-language, we used $\mathrm { C S S 1 0 ^ { 3 } }$ dataset $\lVert \overline { { 3 2 } } \rVert$ . CSS10 includes 10 speakers and each speaker use different language. Note that there is no English speaking speaker included in CSS10. To train the model, we used $90 \%$ of samples for each speaker. To test on multilingual speech samples, we used the rest $10 \%$ unseen utterances of CSS10.
Training We used $2 2 , 0 5 0 \mathrm { h z }$ sampling rate for every analysis feature except for wav2vec input that takes waveform with the sampling rate of $1 6 { , } 0 0 0 \mathrm { h z }$ . We used 80 bands for mel spectrogram, where FFT, window, and hop size were set to 1024, 1024, and 256, respectively. The samples were randomly cropped approximately to 1.47-second, which results in 128 mel spectrogram frames. The networks were trained using Adam optimizer with $\beta _ { 1 } = 0 . 5$ and $\beta _ { 2 } = 0 . 9$ . The learning rate was fixed to $1 0 ^ { - 4 }$ . We trained every model using one RTX 3090 with batch size 32. The training was done after 50 epochs.
# 4.2 Reconstruction
For the reconstruction (analysis and synthesis) tests, we report character error rate (CER $( \% )$ ), and 5-scale mean opinon score (MOS ([1-5])), 5-scale degradation mean opinion score (DMOS ([1-5])). For MOS, higher is better. For DMOS and CER, lower is better. To estimate the characters from speech samples, we used google cloud ASR API. For MOS and DMOS, we used amazon mechanical turk (MTurk). The details of MOS and DMOS are shown in Appendix D.
Yingram vs $f _ { 0 }$ We compared two models trained with Yingram and $f _ { 0 }$ to check which pitch feature shows more robust reconstruction performance. We used RAPT algorithm for $f _ { 0 }$ estimation $\lVert \overline { { 4 2 } } \rVert$ which is known as a reliable $f _ { 0 }$ tracker among many other algorithms $\overline { { \| 2 2 } }$ . Because RAPT algorithm works sufficiently well in most cases, we first manually listened to the reconstructed samples using the model trained with $f _ { 0 }$ . We first chose 30 reconstructed samples in the testset that failed to faithfully reconstruct the original samples using the model trained with $f _ { 0 }$ . After that we reconstructed the same 30 samples using the model trained with Yingram. Finally, we conducted ABX test to ask participants which of the two samples (A and B) sounds closer to the original sample (X). The ABX test was conducted on MTurk. The results showed that the participants chose Yingram with a chance of $6 8 . 3 \%$ . This shows that Yingram can be used as a more robust pitch feature than $f _ { 0 }$ , when $f _ { 0 }$ cannot be accurately estimated.
Reconstruction test We randomly sampled 50 speech samples from VCTK (seen speaker) and sampled another 50 speech samples from test-clean subset of LibriTTS (unseen speaker) to test the reconstruction performance of NANSY trained on English datasets. The results in Table $\bigstar$ shows that NANSY can perform high quality analysis and synthesis task. In addition, to test if the proposed framework can cover various languages, we trained and tested it with the multilingual dataset, CSS10. We randomly sampled 100 speech samples from CSS10 to test the reconstruction performance of NANSY trained on multi-language. The results are shown in Table $\boxed { 2 }$ Although we do not impose any explicit labels for each language, the model was able to reconstruct various languages with high quality. The results of CER on each language is shown in Fig. $\bigtriangledown$ MUL.
Table 1: English reconstruction results.
<table><tr><td></td><td>CER</td><td>MOS</td><td>DMOS</td></tr><tr><td>GT</td><td>n/a</td><td>4.28 ± 0.09</td><td>n/a</td></tr><tr><td>Recon</td><td>5.6</td><td>4.18 ± 0.09</td><td>1.93 ± 0.09</td></tr></table>
Table 2: Multilingual reconstruction results.
<table><tr><td></td><td>CER</td><td>MOS</td><td>DMOS</td></tr><tr><td>GT</td><td>n/a</td><td>4.19 ± 0.08</td><td>n/a</td></tr><tr><td>Recon</td><td>7.3</td><td>4.14 ± 0.09</td><td>1.74 ± 0.09</td></tr></table>
Test-time self-adaptation To test the proposed test-time self-adaptation (TSA), we compared the CER performance of NANSY trained in three different configurations, 1. English (ENG), 2. English with TSA (ENG-TSA), 3. Multi-language (MUL). For every experiment, we iteratively updated the wav2vec feature 100 times. The results are shown in Fig. $\triangledown$ Naturally, MUL generally showed better CER performance than other configurations. Interestingly, however, ENG-TSA sometimes showed similar or even better performance than MUL, which shows the effectiveness of the proposed TSA technique.
 Figure 6: The CER results on 10 languages (NL: Dutch, HU: Hungarian, FR: French, JP: Japanese, CH: Chinese, RU: Russian, FI: Finnish, GR: Greek, ES: Spanish, DE: German).
# 4.3 Voice conversion
NANSY can perform zero-shot voice conversion by simply passing the desired target speech utterance to the speaker embedding network. We first compared the English voice conversion performance of NANSY with recently proposed zero-shot voice conversion models. Next, we tested the multilingual voice conversion performance. Finally, we tested unseen language voice conversion for both seen speaker and unseen speaker targets. Note that in every voice conversion experiment, we shifted the median pitch of a source utterance to the median pitch of a target utterance by shifting the scope of Yingram. We measured naturalness with 5-scale mean opinion score (MOS [1-5]). Speaker similarity (SSIM $( \% )$ ) were measured with a binary decision and uncertainty options, following $\pmb { \Vert 5 0 \Vert }$ . For MOS and SSIM, we again used MTurk. The details of MOS and SSIM are shown in Appendix D. One of the crucial criteria for evaluating the quality of the converted samples is to check the intelligibility of them. Previous zero-shot voice conversion models, however, have only reported MOS or SSIM and have been negligent on assessing the intelligibility of the converted samples [36, 10, 51]. To this end, we report character error rate (CER $( \% ) _ { , }$ ) between estimated characters of source and converted pairs. To estimate the characters from speech samples, we used google cloud ASR API.
Algorithm comparison Here, we report three source-to-target speaker conversion settings, 1. seen-to-seen (many-to-many, M2M), 2. unseen-to-seen (any-to-many, A2M), 3. unseen-to-unseen (any-to-any, A2A). For every setting, we considered 4 gender-to-gender combination, i.e., male-tomale $( { \mathrm { m } } 2 { \mathrm { m } } )$ , male-to-female (m2f), female-to-male $( \mathrm { f } 2 \mathrm { m } )$ , and female-to-female (f2f). For M2M setting, we randomly sampled 25 seen speakers from VCTK and randomly assigned 2 random speakers from VCTK, resulting in 200 $( = 2 5 { \times } 2 { \times } 4 )$ conversion pairs in total. For A2M setting, we randomly sampled 10 seen speakers from test-clean subset of LibriTTS and randomly assigned 2 random speakers from VCTK resulting in 80 $( = 1 0 \times 2 \times 4 )$ ) conversion pairs in total. For A2A setting, we randomly sampled 10 seen speakers from test-clean subset of LibriTTS and randomly assigned 2 random speakers from test-clean subset of LibriTTS resulting in 80 $( = 1 0 \times 2 \times 4 )$ conversion pairs in total. We trained three baseline models with official implementations - ${ \mathrm { V Q V C } } +$ [51], AdaIN $[ \mathbb { 1 0 } ]$ , AUTOVC $\pmb { \mathbb { B } } 6 \|$ - using the same dataset and mel spectrogram configuration as NANSY. For a fair comparison, we used a pre-trained HiFi-GAN vocoder for every model. Table $\triangledown$ shows that NANSY significantly outperforms previous models in terms of every evaluation measure. This implies that the proposed information perturbation approach does not suffer from the trade-off between CER and SSIM unlike information bottleneck approaches. The SSIM results for all possible gender-to-gender combinations are shown in Fig. 9 in Appendix C.
<table><tr><td>一</td><td></td><td>M2M</td><td></td><td></td><td>A2M</td><td></td><td></td><td>A2A</td><td></td></tr><tr><td></td><td></td><td>[CER[%] MOS[1-5]</td><td></td><td></td><td>]SSIM[%]|CER[%]MOS[1-5]</td><td></td><td></td><td>SSIM[%]|CER[%] MOS[1-5]</td><td>SSIM[%]</td></tr><tr><td>SRC as TGT</td><td>n/a</td><td>4.23 ± 0.05</td><td>0</td><td>n/a</td><td>4.28 ± 0.09</td><td>0.60</td><td>n/a</td><td>4.26 ± 0.07</td><td>0.25</td></tr><tr><td>TGT as TGT</td><td>n/a</td><td>4.32 ± 0.05</td><td>94.9</td><td>n/a</td><td>4.29 ± 0.05</td><td>92.4</td><td>n/a</td><td>4.27 ± 0.07</td><td>96.2</td></tr><tr><td>VQVC+</td><td>54.0</td><td>1.76 ± 0.05</td><td>54.5</td><td>74.7</td><td>1.73 ± 0.11</td><td>15.6</td><td>69.3</td><td>1.83 ± 0.09</td><td>13.8</td></tr><tr><td>AdaIN</td><td>62.9</td><td>2.22 ± 0.07</td><td>24.0</td><td>79.6</td><td>1.92 ± 0.12</td><td>18.1</td><td>59.3</td><td>2.12 ± 0.10</td><td>21.2</td></tr><tr><td>AUTOVC</td><td>31.7</td><td>3.41 ±0.06</td><td>47.3</td><td>36.1</td><td>2.74 ±0.11</td><td>33.2</td><td>28.2</td><td>2.59 ±0.08</td><td>23.3</td></tr><tr><td>NANSY</td><td>7.5</td><td>3.79 ± 0.07</td><td>91.4</td><td>7.6</td><td>3.73 ± 0.05</td><td>88.1</td><td>8.6</td><td>3.44 ± 0.07</td><td>64.6</td></tr></table>
Table 3: Evaluation results on English voice conversion. SRC and TGT denote, source and target, respectively.
Multilingual voice conversion We tested multilingual voice conversion performance with the model trained on the multilingual dataset, CSS10. We randomly sampled 50 samples for each language speaker from CSS10 and assigned random single target speaker from CSS10 for each source language, resulting in 500 $( = 5 0 \times 1 0 )$ ) conversion pairs in total. The results in Table 4 show that the proposed framework can successfully perform multilingual voice conversion by training it with the multilingual dataset. However, there is still a room for improvement for multilingual voice conversion when comparing to the results in Table 3, where NANSY is just trained on English.
Unseen language voice conversion We tested the voice conversion performance on unseen source languages using NANSY trained on English. We tested the performance on two settings, 1. unseen source language (CSS10) to seen target voice (VCTK) and 2. unseen source language (CSS10) to unseen target voice (CSS10). For the first experiment, we randomly sampled 50 samples for each unseen language speaker from CSS10 and assigned random English target speakers from VCTK, resulting in 500 $( = 5 0 \times 1 0 )$ conversion pairs in total. The second experiment was conducted identically to the multilingual voice conversion experiment setting. The results in Table $\boxed { 5 }$ shows that NANSY can be successfully extended even to unseen language sources, although there was a decrease on SSIM compared to the results in Table 4 $( 6 9 . 5 \% \bar { } 6 \bar { 1 } . 0 \% )$ ).
Table 4: The multilingual voice conversion results. The model was trained using only CSS10.
<table><tr><td></td><td>|CER MOS</td><td>SSIM</td></tr><tr><td></td><td>TGT as TGT|n/a 4.23 ±0.06</td><td>98.0</td></tr><tr><td>NANSY</td><td>18.8 3.68 ±0.09</td><td>69.5</td></tr></table>
<table><tr><td></td><td colspan="3">Seen Speaker</td></tr><tr><td></td><td>|CER MOS</td><td>SSIM|CER</td><td>MOS SSIM</td></tr><tr><td>TGT as TGT NANSY</td><td>n/a 4.24 ±0.07 14.8 3.75 ± 0.10</td><td>100 90.0</td><td>n/a 4.23 ± 0.06 92.0 15.6 3.76 ± 0.09 61.0</td></tr></table>
Table 5: The voice conversion results on unseen language dataset, CSS10. The model was trained using only the English datasets.
# 4.4 Pitch shift and time-scale modification
To check the robustness of pitch shift (PS) and time-scale modification (TSM) performance of NANSY, we compared it with other robust algorithms, i.e., PSOLA 5 and WORLD vocoder [29, 28].
Pitch shift We tested PS performance with 5 semitone ranges, -6, -3, 0, 3, 6. The pitch was changed by shifting the scope of the proposed Yingram feature. Note that $\mathbf { \bar { \rho } } _ { 0 } ,$ was used to check analysissynthesis performance. We randomly selected 20 samples for each semitone range from $10 \%$ unseen utterances of VCTK. We evaluated the naturalness of speech samples with MOS on MTurk. The results in Table $6$ show that NANSY generally outperforms algorithms such as PSOLA and WORLD vocoder on PS task.
Time-scale modification We tested TSM performance with 5 time-scale ratios, 1/2, 1/1.5, 1, 1.5, 2. The time-scale was modified by simply manipulating the hop length of the analysis features. Note that $\cdot _ { 1 } \cdot$ was used to check analysis-synthesis performance. We randomly selected 20 samples for each time-scale ratio from $10 \%$ unseen utterances of VCTK. We evaluated the naturalness of speech samples with MOS on MTurk. The results in Table 7 show that NANSY achieved competitive performance on TSM compared to the well-established PSOLA and WORLD vocoder.
<table><tr><td></td><td>-6</td><td>-3</td><td>0</td><td>3</td><td>6</td></tr><tr><td>WORLD 28</td><td>3.433.53</td><td></td><td></td><td>33.853.63</td><td>3.53</td></tr><tr><td>PSOLA 四</td><td></td><td></td><td></td><td></td><td>3.633.553.933.753.48</td></tr><tr><td>NANSY</td><td>3.60 3.68</td><td></td><td>4.05</td><td>3.90</td><td>3.78</td></tr></table>
Table 6: Pitch shift results.
Table 7: Time-scale modification results.
<table><tr><td></td><td>1/2</td><td>1/1.5 1</td><td>1.5</td><td>2</td></tr><tr><td>WORLD I28I</td><td>2.403.603.833.38</td><td></td><td></td><td>83.03</td></tr><tr><td>PSOLA 四</td><td>2.55 3.66 3.953.68</td><td></td><td></td><td>2.85</td></tr><tr><td>NANSY</td><td>2.453.63</td><td>33.983.70</td><td></td><td>2.93</td></tr></table>
# 5 Related Works
Self-supervised representation learning and synthesis of speech There has been an increasing interest in the self-supervised learning methods within the machine learning and speech processing community. Oord et al. [31] first proposed to use noise contrastive estimation loss to train speech representations. Baevski et al. [4] extended this idea by integrating masked language modeling $\mathbb { \lVert 1 5 \rVert }$ . Another popular self-supervised learning method for speech representation is to train a neural network by targeting multiple self-supervision tasks [34, 37]. Most recently, $\pmb { \Vert 3 5 \Vert }$ used the discrete disentangled self-supervised representations to re-synthesize them into a waveform. Although using the discrete units has its own advantage in that it is disentangled with speaker information, we found that an inaccurate quantization process often leads to mispronounced samples, which is why we turned to use continuous representation as it can provide more accurate results on linguistic information.
Zero-shot voice conversion Research on zero-shot voice conversion has been most actively conducted through the information bottleneck approach. Qian et al. $\textcircled { \lvert 3 6 \rvert }$ proposed to perform zero-shot voice conversion by utilizing the pre-trained speaker recognition network and information bottleneck by carefully designing the bottleneck of an auto-encoder. Inspired by the success of style conversion in computer vision, Chou and Lee $\mathbb { \ m }$ also focused on restricting the information flow using instance normalization $\pm \ddagger { 4 }$ and adaptive instance normalization $\mathbb { \lVert 1 9 \rVert }$ . Lastly, Wu et al. [51] used multiple vector quantization layers $\bar { \mathbb { B } } \bar { 0 } \bar { 1 }$ to restrict the information flow.
Inductive bias for audio generation It has been shown that neural networks can be combined with traditional speech/sound production models for efficient and strong performance. One of the speech production models that has been integrated with neural networks is the source-filter model. By modeling source and filter components with deep networks, it has been used for applications such as vocoder [49, 23, 45] and acoustic feature generation $\lVert 2 5 \rVert$ . Furthermore, Engel et al. $\mathbb { \ m }$ proposed to integrate a harmonic plus noise model $\bar { \big \| } \bar { 3 8 } \bar { \big \| }$ and neural networks to produce natural audio signal.
Consistency learning Learning representations by augmenting the data has been one of the key ideas to leverage the performance of classification tasks [43, 52]. This shares the similar idea with the proposed information perturbation strategy in that the data is perturbed so that the neural network must learn to ignore the perturbations and learn the consistency from the data. However, the key difference between the consistency learning and the information perturbation is that the information perturbation method is designed for “generative” task and that it is the “decoder” (e.g., Generator) that is trained to selectively take the essential attributes to reconstruct the signal from the given perturbed representations.
# 6 Conclusions and Discussion
In this work, we proposed a neural analysis and synthesis framework (NANSY) that can perform zero-shot voice conversion, formant preserving pitch shift, and time-scale modification with a single model. The proposed model can be trained in a fully self-supervised manner, that is, it can be trained without any labeled data such as text or speaker information. We showed the effectiveness of the proposed information perturbation approach by showing the voice conversion results on various settings. Furthermore, we showed the effectiveness of the proposed TSA method by testing it on unseen languages, which shows the possibility of NANSY to be extended on low-resource languages. Although the proposed method empowers controllability over several attributes of a speech signal, it is still limited in terms of lacking controllability over linguistic information. As a future work, therefore, we would like to investigate on a hybrid approach that integrates text information as a side input so that the user can manipulate even the linguistic information in the speech signal. Finally, to prevent the proposed framework being used maliciously (e.g., voice phishing), it would be important to develop a detection algorithm that can discriminate a synthesized speech sample from a real speech sample. To examine the potential of such a detection system, we have tried using the trained Discriminator from the NANSY framework, which is expected to discriminate fake samples from real samples. We measured the accuracy of classifying 185 reconstructed samples and 185 ground truth samples. In addition, we measured the accuracy of classifying 560 voice conversion samples and 560 ground truth samples. The accuracy was $9 1 . 4 \%$ on the reconstruction set and $9 5 . 5 \%$ on the voice conversion set. This shows the possibility of Discriminator being used as a byproduct network to discriminate real speech samples from fake speech samples. However, we also found that Discriminator is prone to being deceived by the generated samples from other speech generative models as Discriminator was not jointly trained with those generative models. Therefore, we expect more robust synthesized speech detection algorithms to be developed in the future such as [48, 40, 9, 6].
# Broader Impacts
The proposed NANSY framework shows that a generative model can benefit from self-supervised representations. By choosing proper domain specific “information perturbation” functions, we believe that one can achieve controllable generative modeling in a fully self-supervised way. The information perturbation training strategy may also be used for other modalities and facilitate self-supervised representation learning methods too. With the proposed training framework, one can manipulate various aspects of speech samples. Among the various controllabilities, it is rather obvious that the voice conversion technique can be misused and potentially harm other people. More concretely, there are possible scenarios where it is being used by random unidentified users and contributing to spreading fake news. In addition, it can raise concerns about biometric security systems based on speech. To mitigate such issues, the proposed system should not be released without a consent so that it cannot be easily used by random users with malicious intentions. That being said, there is still a potential for this technology to be used by unidentified users. As a more solid solution, therefore, we believe a detection system that can discriminate between fake and real speech should be developed. The preliminary results of the detection system is reported in section 6.
# Acknowledgments and Disclosure of Funding
This work was supported by Institute of Information & communications Technology Planning & Evaluation (IITP) grant funded by the Korea government(MSIT) [NO.2021-0-01343, Artificial Intelligence Graduate School Program (Seoul National University)]
References [1] Luc Ardaillon. Synthesis and expressive transformation of singing voice. PhD thesis, 11 2017. [2] Luc Ardaillon and Axel Roebel. Gci detection from raw speech using a fully-convolutional network. In ICASSP 2020-2020 IEEE International Conference on Acoustics, Speech and Signal Processing (ICASSP), pages 6739–6743. IEEE, 2020. [3] Bishnu S Atal and Suzanne L Hanauer. Speech analysis and synthesis by linear prediction of the speech wave. The journal of the acoustical society of America, 50(2B):637–655, 1971. [4] Alexei Baevski, Yuhao Zhou, Abdelrahman Mohamed, and Michael Auli. wav2vec 2.0: A framework for self-supervised learning of speech representations. In H. Larochelle, M. Ranzato, R. Hadsell, M. F. Balcan, and H. Lin, editors, Advances in Neural Information Processing Systems, volume 33, pages 12449–12460. Curran Associates, Inc., 2020. URL https://proceedings.neurips.cc/paper/2020/file/ 92d1e1eb1cd6f9fba3227870bb6d7f07-Paper.pdf. [5] Paul Boersma and Vincent Van Heuven. Speak and unspeak with praat. Glot International, 5 (9/10):341–347, 2001. [6] Clara Borrelli, Paolo Bestagini, Fabio Antonacci, Augusto Sarti, and Stefano Tubaro. Synthetic speech detection through short-term and long-term prediction traces. EURASIP Journal on Information Security, 2021(1):1–14, 2021. [7] Mingjian Chen, Xu Tan, Bohan Li, Yanqing Liu, Tao Qin, sheng zhao, and Tie-Yan Liu. Adaspeech: Adaptive text to speech for custom voice. In International Conference on Learning Representations, 2021. URL https://openreview.net/forum?id=Drynvt7gg4L. [8] Hyeong-Seok Choi, Changdae Park, and Kyogu Lee. From inference to generation: End-to-end fully self-supervised generation of human face from speech. In International Conference on Learning Representations, 2020. URL https://openreview.net/forum?id=H1guaREYPr. [9] Yeunju Choi, Youngmoon Jung, and Hoirin Kim. Neural mos prediction for synthesized speech using multi-task learning with spoofing detection and spoofing type classification. In 2021 IEEE Spoken Language Technology Workshop (SLT), pages 462–469. IEEE, 2021. [10] Ju-Chieh Chou and Hung-Yi Lee. One-Shot Voice Conversion by Separating Speaker and Content Representations with Instance Normalization. In Proc. Interspeech 2019, pages 664– 668, 2019. doi: 10.21437/Interspeech.2019-2663. URL http://dx.doi.org/10.21437/ Interspeech.2019-2663. [11] Alexis Conneau, Alexei Baevski, Ronan Collobert, Abdelrahman Mohamed, and Michael Auli. Unsupervised cross-lingual representation learning for speech recognition. arXiv preprint arXiv:2006.13979, 2020. [12] Yann N Dauphin, Angela Fan, Michael Auli, and David Grangier. Language modeling with gated convolutional networks. In International conference on machine learning, pages 933–941. PMLR, 2017. [13] Alain De Cheveigné and Hideki Kawahara. Yin, a fundamental frequency estimator for speech and music. The Journal of the Acoustical Society of America, 111(4):1917–1930, 2002. [14] Brecht Desplanques, Jenthe Thienpondt, and Kris Demuynck. ECAPA-TDNN: Emphasized Channel Attention, Propagation and Aggregation in TDNN Based Speaker Verification. In Proc. Interspeech 2020, pages 3830–3834, 2020. doi: 10.21437/Interspeech.2020-2650. URL http://dx.doi.org/10.21437/Interspeech.2020-2650.
[15] 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), pages 4171–4186, Minneapolis, Minnesota, June 2019. Association for Computational Linguistics. doi: 10.18653/v1/N19-1423. URL https://www.aclweb.org/anthology/N19-1423.
[16] Thomas Drugman, Paavo Alku, Abeer Alwan, and Bayya Yegnanarayana. Glottal source processing: From analysis to applications. Computer Speech & Language, 28(5):1117–1138, 2014. ISSN 0885-2308. doi: https://doi.org/10.1016/j.csl.2014.03.003. URL https://www. sciencedirect.com/science/article/pii/S0885230814000229.
[17] Jesse Engel, Lamtharn (Hanoi) Hantrakul, Chenjie Gu, and Adam Roberts. Ddsp: Differentiable digital signal processing. In International Conference on Learning Representations, 2020. URL https://openreview.net/forum?id=B1x1ma4tDr.
[18] Zhiyun Fan, Meng Li, Shiyu Zhou, and Bo Xu. Exploring wav2vec 2.0 on speaker verification and language identification. arXiv preprint arXiv:2012.06185, 2020.
[19] Xun Huang and Serge Belongie. Arbitrary style transfer in real-time with adaptive instance normalization. In Proceedings of the IEEE International Conference on Computer Vision, pages 1501–1510, 2017.
[20] Yannick Jadoul, Bill Thompson, and Bart De Boer. Introducing parselmouth: A python interface to praat. Journal of Phonetics, 71:1–15, 2018.
[21] Ye Jia, Yu Zhang, Ron J. Weiss, Quan Wang, Jonathan Shen, Fei Ren, Zhifeng Chen, Patrick Nguyen, Ruoming Pang, Ignacio Lopez-Moreno, and Yonghui Wu. Transfer learning from speaker verification to multispeaker text-to-speech synthesis. In Advances in Neural Information Processing Systems, pages 4485–4495, 2018.
[22] Denis Jouvet and Yves Laprie. Performance analysis of several pitch detection algorithms on simulated and real noisy speech data. In 2017 25th European Signal Processing Conference (EUSIPCO), pages 1614–1618. IEEE, 2017.
[23] Lauri Juvela, Bajibabu Bollepalli, Vassilis Tsiaras, and Paavo Alku. Glotnet—a raw waveform model for the glottal excitation in statistical parametric speech synthesis. IEEE/ACM Transactions on Audio, Speech, and Language Processing, 27(6):1019–1030, 2019.
[24] Jungil Kong, Jaehyeon Kim, and Jaekyoung Bae. Hifi-gan: Generative adversarial networks for efficient and high fidelity speech synthesis. In H. Larochelle, M. Ranzato, R. Hadsell, M. F. Balcan, and H. Lin, editors, Advances in Neural Information Processing Systems, volume 33, pages 17022–17033. Curran Associates, Inc., 2020. URL https://proceedings.neurips. cc/paper/2020/file/c5d736809766d46260d816d8dbc9eb44-Paper.pdf.
[25] Juheon Lee, Hyeong-Seok Choi, Chang-Bin Jeon, Junghyun Koo, and Kyogu Lee. Adversarially Trained End-to-End Korean Singing Voice Synthesis System. In Proc. Interspeech 2019, pages 2588–2592, 2019. doi: 10.21437/Interspeech.2019-1722. URL http://dx.doi.org/10. 21437/Interspeech.2019-1722.
[26] Robert McAulay and Thomas Quatieri. Speech analysis/synthesis based on a sinusoidal representation. IEEE Transactions on Acoustics, Speech, and Signal Processing, 34(4):744–754, 1986.
[27] Takeru Miyato and Masanori Koyama. cGANs with projection discriminator. In International Conference on Learning Representations, 2018. URL https://openreview.net/forum? id=ByS1VpgRZ.
[28] Masanori Morise, Fumiya Yokomori, and Kenji Ozawa. World: a vocoder-based high-quality speech synthesis system for real-time applications. IEICE TRANSACTIONS on Information and Systems, 99(7):1877–1884, 2016.
[29] Eric Moulines and Francis Charpentier. Pitch-synchronous waveform processing techniques for text-to-speech synthesis using diphones. Speech communication, 9(5-6):453–467, 1990.
[30] Aaron van den Oord, Oriol Vinyals, and Koray Kavukcuoglu. Neural discrete representation learning. arXiv preprint arXiv:1711.00937, 2017.
[31] Aaron van den Oord, Yazhe Li, and Oriol Vinyals. Representation learning with contrastive predictive coding. arXiv preprint arXiv:1807.03748, 2018.
[32] Kyubyong Park and Thomas Mulc. CSS10: A Collection of Single Speaker Speech Datasets for 10 Languages. In Proc. Interspeech 2019, pages 1566–1570, 2019. doi: 10.21437/Interspeech. 2019-1500. URL http://dx.doi.org/10.21437/Interspeech.2019-1500.
[33] Seung-won Park, Doo-young Kim, and Myun-chul Joe. Cotatron: Transcription-guided speech encoder for any-to-many voice conversion without parallel data. arXiv preprint arXiv:2005.03295, 2020.
[34] Santiago Pascual, Mirco Ravanelli, Joan Serrà, Antonio Bonafonte, and Yoshua Bengio. Learning Problem-Agnostic Speech Representations from Multiple Self-Supervised Tasks. In Proc. Interspeech 2019, pages 161–165, 2019. doi: 10.21437/Interspeech.2019-2605. URL http://dx.doi.org/10.21437/Interspeech.2019-2605.
[35] Adam Polyak, Yossi Adi, Jade Copet, Eugene Kharitonov, Kushal Lakhotia, Wei-Ning Hsu, Abdelrahman Mohamed, and Emmanuel Dupoux. Speech Resynthesis from Discrete Disentangled Self-Supervised Representations. In Proc. Interspeech 2021, pages 3615–3619, 2021. doi: 10.21437/Interspeech.2021-475.
[36] Kaizhi Qian, Yang Zhang, Shiyu Chang, Xuesong Yang, and Mark Hasegawa-Johnson. Autovc: Zero-shot voice style transfer with only autoencoder loss. In International Conference on Machine Learning, pages 5210–5219. PMLR, 2019.
[37] Mirco Ravanelli, Jianyuan Zhong, Santiago Pascual, Pawel Swietojanski, Joao Monteiro, Jan Trmal, and Yoshua Bengio. Multi-task self-supervised learning for robust speech recognition. In ICASSP 2020-2020 IEEE International Conference on Acoustics, Speech and Signal Processing (ICASSP), pages 6989–6993. IEEE, 2020.
[38] Xavier Serra et al. Musical sound modeling with sinusoids plus noise. Musical signal processing, pages 91–122, 1997.
[39] Jui Shah, Yaman Kumar Singla, Changyou Chen, and Rajiv Ratn Shah. What all do audio transformer models hear? probing acoustic representations for language delivery and its structure. arXiv preprint arXiv:2101.00387, 2021.
[40] Arun Kumar Singh and Priyanka Singh. Detection of ai-synthesized speech using cepstral & bispectral statistics. arXiv preprint arXiv:2009.01934, 2020.
[41] Lifa Sun, Kun Li, Hao Wang, Shiyin Kang, and Helen Meng. Phonetic posteriorgrams for manyto-one voice conversion without parallel data training. In 2016 IEEE International Conference on Multimedia and Expo (ICME), pages 1–6. IEEE, 2016.
[42] David Talkin and W Bastiaan Kleijn. A robust algorithm for pitch tracking (rapt). Speech coding and synthesis, 495:518, 1995.
[43] Antti Tarvainen and Harri Valpola. Mean teachers are better role models: Weightaveraged consistency targets improve semi-supervised deep learning results. arXiv preprint arXiv:1703.01780, 2017.
[44] Dmitry Ulyanov, Andrea Vedaldi, and Victor Lempitsky. Instance normalization: The missing ingredient for fast stylization. arXiv preprint arXiv:1607.08022, 2016.
[45] Jean-Marc Valin and Jan Skoglund. Lpcnet: Improving neural speech synthesis through linear prediction. In ICASSP 2019-2019 IEEE International Conference on Acoustics, Speech and Signal Processing (ICASSP), pages 5891–5895. IEEE, 2019.
[46] Laurens Van der Maaten and Geoffrey Hinton. Visualizing data using t-sne. Journal of machine learning research, 9(11), 2008.
[47] Christophe Veaux, Junichi Yamagishi, and Simon King. The voice bank corpus: Design, collection and data analysis of a large regional accent speech database. In 2013 international conference oriental COCOSDA held jointly with 2013 conference on Asian spoken language research and evaluation (O-COCOSDA/CASLRE), pages 1–4. IEEE, 2013. [48] Run Wang, Felix Juefei-Xu, Yihao Huang, Qing Guo, Xiaofei Xie, Lei Ma, and Yang Liu. Deepsonar: Towards effective and robust detection of ai-synthesized fake voices. In Proceedings of the 28th ACM International Conference on Multimedia, pages 1207–1216, 2020. [49] Xin Wang, Shinji Takaki, and Junichi Yamagishi. Neural source-filter-based waveform model for statistical parametric speech synthesis. In ICASSP 2019-2019 IEEE International Conference on Acoustics, Speech and Signal Processing (ICASSP), pages 5916–5920. IEEE, 2019. [50] Mirjam Wester, Zhizheng Wu, and Junichi Yamagishi. Analysis of the voice conversion challenge 2016 evaluation results. In Interspeech, pages 1637–1641, 2016. [51] Da-Yi Wu, Yen-Hao Chen, and Hung yi Lee. VQVC $^ +$ : One-Shot Voice Conversion by Vector Quantization and U-Net Architecture. In Proc. Interspeech 2020, pages 4691–4695, 2020. doi: 10.21437/Interspeech.2020-1443. URL http://dx.doi.org/10.21437/Interspeech. 2020-1443. [52] Qizhe Xie, Zihang Dai, Eduard Hovy, Minh-Thang Luong, and Quoc V Le. Unsupervised data augmentation for consistency training. arXiv preprint arXiv:1904.12848, 2019. [53] Vadim Zavalishin. The art of va filter design. Native Instruments, Berlin, Germany, 2012. [54] Heiga Zen, Viet Dang, Rob Clark, Yu Zhang, Ron J. Weiss, Ye Jia, Zhifeng Chen, and Yonghui Wu. Libritts: A corpus derived from librispeech for text-to-speech. In Interspeech, pages 1526–1530, 2019.
# 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] We described the goal and contribution of this paper and conducted experiments accordingly. (b) Did you describe the limitations of your work? [Yes] We explained the limitation of this work in the conclusion. (c) Did you discuss any potential negative societal impacts of your work? [Yes] We discussed the potential negative societal impacts (e.g., voice phishing) of our work in the conclusion. (d) Have you read the ethics review guidelines and ensured that your paper conforms to them? [Yes] We have read the ethics review guidelines.
2. If you are including theoretical results...
(a) Did you state the full set of assumptions of all theoretical results? [No] We do not include theoretical results. (b) Did you include complete proofs of all theoretical results? [No] We do not include theoretical results.
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)? [No] The code is proprietary. (b) Did you specify all the training details (e.g., data splits, hyperparameters, how they were chosen)? [Yes] See section $4 . 1$ and Appendix A. (c) Did you report error bars (e.g., with respect to the random seed after running experiments multiple times)? [Yes] We have included the error bars for crowdsourcing evaluation.
(d) Did you include the total amount of compute and the type of resources used (e.g., type of GPUs, internal cluster, or cloud provider)? [Yes] See section 4.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] We cited all three datasets we used for experiments. (b) Did you mention the license of the assets? [Yes] See section 4.1. (c) Did you include any new assets either in the supplemental material or as a URL? [No] We did not curate/release any new assets. (d) Did you discuss whether and how consent was obtained from people whose data you’re using/curating? [Yes] We cited the paper of the datasets we are using in which they explain all the details regarding speaker recruitment. (e) Did you discuss whether the data you are using/curating contains personally identifiable information or offensive content? [Yes] We used speaker labels to split the datasets as described in section 4.1.
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? [Yes] We have attached the screenshots of MTurk instructions in Appendix D. (b) Did you describe any potential participant risks, with links to Institutional Review Board (IRB) approvals, if applicable? [Yes] This work is approved by IRB (IRB No. 2105/004-008). We have announced that the de-identified information such as worker ID will be collected through MTurk instructions. (c) Did you include the estimated hourly wage paid to participants and the total amount spent on participant compensation? [Yes] It is shown in Appendix D.123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671# ON THE REGULARIZATION OF WASSERSTEIN GANS
Henning Petzka∗ Fraunhofer Institute IAIS, Sankt Augustin, Germany henning.petzka@gmail.com
Asja Fischer∗& Denis Lukovnikov Department of Computer Science, University of Bonn, Germany asja.fischer@gmail.com lukovnik@cs.uni-bonn.de
# ABSTRACT
Since their invention, generative adversarial networks (GANs) have become a popular approach for learning to model a distribution of real (unlabeled) data. Convergence problems during training are overcome by Wasserstein GANs which minimize the distance between the model and the empirical distribution in terms of a different metric, but thereby introduce a Lipschitz constraint into the optimization problem. A simple way to enforce the Lipschitz constraint on the class of functions, which can be modeled by the neural network, is weight clipping. Augmenting the loss by a regularization term that penalizes the deviation of the gradient norm of the critic (as a function of the network’s input) from one, was proposed as an alternative that improves training. We present theoretical arguments why using a weaker regularization term enforcing the Lipschitz constraint is preferable. These arguments are supported by experimental results on several data sets.
# 1 INTRODUCTION
General adversarial networks (GANs) (Goodfellow et al., 2014) are a class of generative models that have recently gained a lot of attention. They are based on the idea of defining a game between two competing neural networks (NNs): a generator and a classifier (or discriminator). While the classifier aims at distinguishing generated from real data, the generator tries to generate samples which the classifier can not distinguish from the ones from the empirical distribution. Realizing the potential behind this new approach to generative models, more recent contributions focused on the stabilization of training, including ensemble methods (Tolstikhin et al., 2017), improved network structure (Radford et al., 2015; Salimans et al., 2016) and theoretical improvements (Nowozin et al., 2016; Salimans et al., 2016; Arjovsky & Bottou, 2017; Chen et al., 2016) that helped to successfully model complex distributions using GANs.
It was proposed by Arjovsky et al. (2017) to train generator and discriminator networks by minimizing the Wasserstein-1 distance, a distance with properties superior to the Jensen-Shannon distance (used in the original GAN) in terms of convergence. Accordingly, this version of GAN was called Wasserstein GAN (WGAN). The change of metric introduces a new minimization problem, which requires the discriminator function to lie in the space of 1-Lipschitz functions. In the same paper, the Lipschitz constraint was guaranteed by performing weight clipping, i.e., by constraining the parameters of the discriminator NN to be smaller than a given value in magnitude. An improved training strategy was proposed by Gulrajani et al. (2017) based on results from optimal transport theory (see Villani, 2008). Here, instead of clipping weights, the loss gets augmented by a regularization term that penalizes any deviation of the norm of the gradient of the critic function (with respect to its input) from one.
We review these results and present both theoretical considerations and empirical results, leading to the proposal of a less restrictive regularization term for WGANs.1 More precisely, our contributions are as follows:
• We review the arguments that the regularization technique proposed by Gulrajani et al. (2017) is based on and make the following two observations: (i) The regularization strategy requires training samples and generated samples to be drawn from a certain joint distribution. In practice, however, samples are drawn independently from their marginals. (ii) The arguments further assume the discriminator to be differentiable. We explain why both can be harmful for training.
• We propose a less restrictive regularization term and present empirical results strongly supporting our theoretical considerations.
# 2 OPTIMAL TRANSPORT
We will require the notion of a coupling of two probability distributions. Although a coupling can be defined more generally, we state the definition in the setting of our interest, i.e., we consider all spaces involved to equal $\mathbb { R } ^ { n }$ .
Definition 1. Let $\mu$ and $\nu$ be two probability distributions on $\mathbb { R } ^ { n }$ . A coupling $\pi$ of $\mu$ and $\nu$ is a probability distribution on $\mathbb { R } ^ { n } \times \mathbb { R } ^ { n }$ such that $\pi ( A , \mathbb { R } ^ { n } ) = \mu ( A )$ and $\pi ( \mathbb { R } ^ { n } , A ) = \nu ( A )$ for all measurable sets $A \subseteq \mathbb { R } ^ { n }$ . The set of all couplings of $\mu$ and $\nu$ is denoted by $\Pi ( \mu , \nu )$ .
The following theorem plays a central role in the theory of optimal transport (OT) and is known as the Kantorovich duality. Note, that the presented theorem is a less general, but to our needs adapted version of Theorem 5.10 from Villani (2008).2 A proof of how to derive our version from the referenced one can be found in Appendix C.1. We will denote by $\mathcal { L } i p _ { 1 }$ the set of all 1-Lipschitz functions, i.e., the set of all functions $f$ such that $f ( y ) - f ( x ) \leq | | { \dot { x } } - { \bar { y } } | | _ { 2 }$ for all $x , y$ .
Theorem 1 (Kantorovich). Let $\mu$ and $\nu$ be two probability distributions on $\mathbb { R } ^ { n }$ such that $\begin{array} { r } { \int _ { \mathbb { R } ^ { n } } | | x | | _ { 2 } d \mu ( x ) < \infty } \end{array}$ and $\begin{array} { r } { \int _ { \mathbb { R } ^ { n } } | | x | | _ { 2 } d \nu ( x ) < \infty } \end{array}$ . Then
$$\operatorname* { m i n } _ { \pi \in \Pi ( \mu , \nu ) } \int _ { \mathbb { R } ^ { n } \times \mathbb { R } ^ { n } } | | x - y | | _ { 2 } d \pi ( x , y ) = \operatorname* { m a x } _ { f \in \mathcal { L } i p _ { 1 } } \left( \int _ { \mathbb { R } ^ { n } } f ( x ) d \mu ( x ) - \int _ { \mathbb { R } ^ { n } } f ( x ) d \nu ( x ) \right) \ .$$
In particular, both minimum and maximum exist.
(ii) The following two statements are equivalent:
(a) $\pi ^ { * }$ is an optimal coupling (minimizing the value on the left hand side of (1)). (b) Any optimal function $f ^ { \ast } \in \mathcal { L } i p _ { 1 }$ (at which the maximum is attained for the right hand side of (1)) satisfies that for all $( x , y )$ in the support of $\pi ^ { * }$ : $f ^ { * } ( x ) - f ^ { * } ( y ) = | | x - y | | _ { 2 }$ .
The field of OT offers several approaches to the computation of optimal couplings. To speed up the computation of an optimal coupling, Cuturi (2013) introduced a regularized version of the primal problem in which an entropic term $E ( \pi )$ is added leading to the minimization of $\begin{array} { r } { \int _ { \mathbb { R } ^ { n } \times \mathbb { R } ^ { n } } | | x \stackrel { \cdot } { - } y | | _ { 2 } \ d \pi ( x , y ) + \epsilon E ( \pi ) } \end{array}$ , with regularization parameter $\epsilon$ . Regularized OT was generalized by Dessein et al. (2016) to a more general class of regularization terms $\Omega ( \pi )$ . As we will discuss in Section 5, the learning algorithm we propose in this paper has connections to the approach using $\begin{array} { r } { \Omega ( \pi ) = \int \left( \frac { \mathrm { d } \pi ( x , y ) } { \mathrm { d } \mu ( x ) \mathrm { d } \nu ( y ) } \right) ^ { 2 } \mathrm { d } \mu ( x ) \mathrm { d } \nu ( y ) } \end{array}$ . By Blondel et al. (2017), this leads to the dual problem given by
$$\operatorname* { s u p } _ { f , g } \left\{ \mathbb { E } _ { x \sim \mu } [ f ( x ) ] - \mathbb { E } _ { y \sim \nu } [ g ( y ) ] - \frac { 4 } { \epsilon } \int \int \operatorname* { m a x } \left\{ 0 , \left( f ( x ) - g ( y ) - | | x - y | | _ { 2 } \right) \right\} ^ { 2 } \mathrm { d } \mu ( x ) \mathrm { d } \nu ( y ) \right\} \ .$$
# 3 WASSERSTEIN GANS
Formally, given an empirical distribution $\mu$ , a class of generative distributions $\nu$ over some space $\mathcal { X }$ , and a class of discriminators $d : \mathcal { X } [ 0 , 1 ]$ , GAN training (Goodfellow et al., 2014) aims at solving the optimization problem given by $\begin{array} { r } { \operatorname* { m i n } _ { \nu } \operatorname* { m a x } _ { d } \mathbb { E } _ { x \sim \mu } [ \log ( d ( x ) ) ] + \mathbb { E } _ { y \sim \nu } [ \log ( 1 - d ( y ) ) ] } \end{array}$ . 3 In practice, the parameters of the generator and the discriminator networks are updated in an alternating fashion based on (several steps) of stochastic gradient descent. The discriminator thereby tries to assign a value close to zero to generated data points and values close to one to real data points. As an opposing agent, the generator aims to produce data where the discriminator expects to see real data. Theorem 1 by Goodfellow et al. (2014) shows that, if the optimal discriminator is found in each iteration, minimization of the resulting loss function of the generator leads to minimization of the Jensen-Shannon (JS) divergence. Instead of minimizing the JS divergence, Arjovsky et al. (2017) proposed to minimize the Wasserstein-1 distance, also known as Earth-Mover (EM) distance, which is defined for any Polish space $( M , c )$ and probability distributions $\mu$ and $\nu$ on $M$ by
$$W ( \mu , \nu ) = \operatorname* { i n f } _ { \pi \in \Pi ( \mu , \nu ) } \int _ { M \times M } c ( x , y ) d \pi ( x , y ) .$$
From the Kantorovich duality (see Theorem 1, (i)) it follows that, in the special case we are considering, the infimum is attained and, instead of computing this minimum in Equation (3), the Wasserstein-1 distance can also be computed as
$$W ( \mu , \nu ) = \operatorname* { m a x } _ { f \in \mathcal { L } i p _ { 1 } } \mathbb { E } _ { x \sim \mu } [ f ( x ) ] - \mathbb { E } _ { y \sim \nu } [ f ( y ) ] \mathrm { ~ , ~ }$$
where the maximum is taken over the set of all 1-Lipschitz functions $\mathcal { L } i p _ { 1 }$
Thus, the WGAN objective is to solve
$$\operatorname* { m i n } _ { \nu } \operatorname* { m a x } _ { f \in \mathcal { L } i p _ { 1 } } \mathbb { E } _ { x \sim \mu } [ f ( x ) ] - \mathbb { E } _ { y \sim \nu } [ f ( y ) ] \mathrm { ~ , ~ }$$
which can be achieved by alternating gradient descent updates for the generating network $\nu$ and the 1-Lipschitz function $f$ (also modeled by a NN), just as in the case of the original GAN. The objective of the generator is still to generate real-looking data points and is led by function values of $f$ that plays the role of an appraiser (or critic). The appraiser’s goal is to assign a value of confidence to each data point, which is as low as possible on generated data points and as high as possible on real data. The confidence value it can assign is bounded by a constraint of similarity, where similarity is measured by the distance of data points. This can be motivated by the idea that similar points should have similar values of confidence for being real. The new role of the critic helps to solve convergence problems, but the interpretation of its value as classifying real (close to 1) and fake data (close to 0) is lost. We refer to Appendix A for a detailed discussion.
# 4 IMPROVED TRAINING OF WGANS
Modeling the WGAN critic function by a NN raises the question on how to enforce the 1-Lipschitz constraint of the objective in Equation (5). As proposed by Arjovsky et al. (2017) a simple way to restrict the class of functions $f$ that can be modeled by the NN to $\alpha$ -Lipschitz continuous functions (for some $\alpha$ ) is to perform weight clipping, i.e. to enforce the parameters of the network not to exceed a certain value $c _ { \operatorname* { m a x } } > 0$ in absolute value. As the authors note, this is not a good but simple choice. We further demonstrate this in Appendix B by proving (for a standard NN architecture) that, using weight clipping, the optimal function is in general not contained in the class of functions modeled by the network.
Recently, an alternative to weight clipping was proposed by Gulrajani et al. (2017). The basic idea is to augment the WGAN loss by a regularization term that penalizes the deviation of the gradient norm of the critic with respect to its input from one (leading to a variant referred to as WGAN-GP, where GP stands for gradient penalty). More precisely, the loss of the critic to be minimized is then given by
$$\begin{array} { r } { \mathbb { E } _ { y \sim \nu } [ f ( y ) ] - \mathbb { E } _ { x \sim \mu } [ f ( x ) ] + \lambda \mathbb { E } _ { \hat { x } \sim \tau } [ ( | | \nabla f ( \hat { x } ) | | _ { 2 } - 1 ) ^ { 2 } ] \ , } \end{array}$$
where $\tau$ is the distribution of $\hat { x } = t x + ( 1 - t ) y$ for $t \sim U [ 0 , 1 ]$ and $x \sim \mu , y \sim \nu$ being a real and a generated sample, respectively. The regularization term is derived based on the following result.
Proposition 1. Let $\mu$ and $\nu$ be two probability distributions on $\mathbb { R } ^ { n }$ . Let $f ^ { * }$ be an optical critic, leading to the maximum $\begin{array} { r } { \operatorname* { m a x } _ { f \in \mathcal { L } i p _ { 1 } } \bar { \int } _ { \mathbb { R } ^ { n } } f ( x ) \mathop { d \mu ( x ) } - \int _ { \mathbb { R } ^ { n } } f ( x ) \mathop { d \nu } ( x ) } \end{array}$ , and let $\pi ^ { * }$ be an optimal coupling with respect to $\begin{array} { r } { \operatorname* { m i n } _ { \pi \in \Pi ( \mu , \nu ) } \int _ { \mathbb { R } ^ { n } \times \mathbb { R } ^ { n } } | | x - y | | _ { 2 } d \pi ( x , y ) } \end{array}$ . If $f ^ { * }$ is differentiable and $x _ { t } =$ $t x + ( 1 - t ) y$ for $0 \leq t \leq 1$ , it holds that $\begin{array} { r } { \mathbb { P } _ { ( x , y ) \sim \pi ^ { * } } \Big [ ( \nabla f ^ { * } ( x _ { t } ) = \frac { y - x _ { t } } { | | y - x _ { t } | | } ) \Big ] = 1 } \end{array}$ . This in particular implies, that the norms of the gradients are one $\pi ^ { * }$ -almost surely on such points $x _ { t }$ .
For the convenience of the reader, we provide a simple argument for obtaining this result in Appendix C.2.
Note, that Proposition 1 holds only when $f ^ { * }$ is differentiable and $x$ and $y$ are sampled from the optimal coupling $\pi ^ { * }$ . However, sampling independently from the marginal distributions $\mu$ and $\nu$ very likely results in points $( x , y )$ that lie outside the support of $\pi ^ { * }$ . Furthermore, the optimal cost function $f ^ { * }$ does not need not to be differentiable everywhere. These two points will be discussed in more detail in the following subsections.
# 4.1 SAMPLING FROM THE MARGINALS INSTEAD OF THE OPTIMAL COUPLING
Observation 1. Suppose $f ^ { * } \in \mathcal L i p _ { 1 }$ is an optimal critic function and $\pi ^ { * }$ the optimal coupling determined by the Kantorovich duality in Theorem 1. Then $| f ^ { * } ( y ) - f ^ { * } ( x _ { t } ) | = | | x _ { t } - y | | _ { 2 }$ on the line $x _ { t } = t x + ( 1 - t ) y$ , $0 \leq t \leq 1$ , for $( x , y )$ sampled from $\pi ^ { * }$ , but not necessarily on the lines connecting an arbitrary pair of a real and $a$ generated data point, i.e. arbitrary $x \sim \mu$ and $y \sim \nu$ .
Consider the examples in Figure 1, where every $\mathrm { X }$ denotes a sample from the generator and every O a real data sample. Optimal couplings $\pi ^ { * }$ are indicated in red, and values of an optimal critic function are indicated in blue (optimality is shown in Appendix A.1).
 Figure 1: A one (left) and a two (right) dimensional example showing that $f ^ { * } ( \mathbf { O } )$ - $f ^ { * } ( \mathbf { X } ) { = } | \mathbf { O } { - } \mathbf { X } |$ only holds for coupled pairs $( \mathbf { X } , 0 ) \sim \pi ^ { * }$ .
In the one-dimensional example on the left, the left-most X and the right-most O satisfy $f ^ { * } ( 0 ) -$ $f ^ { * } ( \mathbf { \boldsymbol { X } } ) = \frac { 1 } { 7 } | 0 - \mathbf { \boldsymbol { X } } | \neq | 0 - \dot { \mathbf { \boldsymbol { X } } | }$ , illustrating that the basis for the derivation of the condition, that the norm of the gradient equals one between generated and real points, only holds for points sampled from the optimal coupling. Note, while here the gradient is still of norm 1 almost everywhere, this does not necessarily hold in higher dimensions, where not all points lie on a line between some pair of points sampled from $\pi ^ { * }$ . This is exemplified for two dimensions on the right side of Figure 1, where blue numbers with $a \in \mathbb { R }$ denote the values of an optimal critic function at these points (the values at these points is all that matters). Without loss of generality we can assume the value at position $( 1 , 2 )$ to be zero, taking into account that an optimal critic function remains optimal under addition of an arbitrary constant. Since the Lipschitz constraint of $f ^ { * }$ must be satisfied, we get $1 - a \leq { \sqrt { 2 } }$ and $a + 1 \le { \sqrt { 2 } }$ . Therefore $a \in [ \bar { 1 } - \sqrt { 2 } , \sqrt { 2 } - 1 ]$ and one of the inequalities of the Lipschitz constraint must be strict.
# 4.2 DIFFERENTIABILITY OF THE CRITIC
Observation 2. The assumption of differentiability of the optimal critic is not valid at points of interest.
Consider the example of two discrete probability distributions and its optimal critic function $f ^ { * }$ shown on the left in Figure 2. We can see that the indicated function $f ^ { * } ( x ) = 1 - | x | \in \mathcal { L } i p _ { 1 }$ is optimal as it leads to an equality in the equation of the Kantorovich dual. (Also, it is the only continuous function, up to a constant, that realizes $f ^ { * } ( x ) - f ^ { * } ( y ) = | y - x |$ for coupled points $( x , y )$ .) However, it is not differentiable at 0.
 Figure 2: Non-differentiable optimal critic functions $\mathrm { f ^ { * } }$ (shown in blue). Left: For two discrete distributions: Circles and crosses belong to samples from the empirical distribution and the generative model, respectively. An approximating differentiable function is shown in green. Right: For two continuous distributions: The empirical distribution $\mu$ is shown in gray, the generative distribution $\nu$ is shown in green.
The counterexample can be made continuous by considering the points as the center points of Gaussians, as illustrated on the right in Figure 2. This is formalized by the following proposition showing that the critic indicated in blue is indeed optimal for the depicted gray Gaussian of real data and the green mixture of two Gaussians of generated data.
Proposition 2. Let $\mu = \mathcal { N } ( 0 , 1 )$ be a normal distribution centered around zero and $\nu = \nu _ { - 1 } + \nu _ { 1 }$ be a mixture of the two normal distributions $\begin{array} { r } { \nu _ { - 1 } = \frac { 1 } { 2 } \mathcal { N } ( - 1 , 1 ) } \end{array}$ and $\begin{array} { r } { \nu _ { 1 } = \frac { 1 } { 2 } \mathcal { N } ( 1 , 1 ) } \end{array}$ over the real line. If $\mu$ describes the distribution of real data and $\nu$ describes the distribution of the generative model, then an optimal critic function is given by $\phi ^ { * } ( x ) = - | x |$ .
The proof can be found in Appendix C.3.
The issue with non-differentiability can be generalized to higher-dimensional spaces based on the observation that an optimal coupling is in general not deterministic. Deterministic couplings are particularly nice in the sense that they allow a transport plan assigning each point $x$ from one distribution deterministically to a point $y$ of the other distribution, without having to split any masses (the search for deterministic optimal couplings is called the Monge problem). However, in a lot of settings no deterministic coupling exists. The notion of a deterministic coupling is formalized in the following definition.
Definition 2. Let $( X , \mu )$ and $( Y , \nu )$ be two probability spaces. A coupling $\pi \in \Pi ( \mu , \nu )$ is called deterministic if there is a measurable function $\rho : X Y$ such that su $\eta ( \pi ) \subseteq \{ ( x , \rho ( x ) ) | x \in X \}$ .
We can now formulate the following observation.
Observation 3. Suppose $\pi ^ { * }$ is a non-deterministic optimal coupling between two probability distributions over $\mathbb { R } ^ { n }$ so that there exist points $( x , y )$ and $( x , y ^ { \prime } )$ in $s u p p ( \pi ^ { * } )$ . Suppose further that there is no $\lambda > 0$ with $( y - x ) = \lambda \cdot ( y ^ { \prime } - x )$ (in particular this implies $y \ne y ^ { \prime }$ ). Then any optimal critic function $f ^ { * }$ is not differentiable at $x$ .
The arguments can be found in Appendix C.5.
In practice, where the optimal critic is approximated by a NN, the situation is slightly different: A function modeled by an NN is (almost) everywhere differentiable (depending on the activation functions). By the Stone-Weierstrass theorem, on compact sets, we can approximate any (Lipschitz-)continuous function by differentiable functions uniformly. Nevertheless, it seems to be a strong constraint on an approximating function to have a gradient of norm one in the neighborhood of a non-differentiability (cf. Figure 2 (a)). Therefore, we argue – in contrast to the argumentation of Gulrajani et al. (2017) – that the gradient should not be assumed to equal one for arbitrary points on the line between an arbitrary real point $x$ and a generated point $y$ .
# 5 HOW TO REGULARIZE WGANS
In the following, we will discuss how the regularization of WGANs can be improved.
Penalizing the violation of the Lipschitz constraint. For the critic function, we have nothing more at hand than the inequality of the Lipschitz-constraint. Moreover (as shown in Lemma 1 in the Appendix) the exhaustion of the Lipschitz constant is automatic by maximizing the objective function. Therefore, a natural choice of regularization is to penalize the given constraint directly, i.e., sample two points $x \sim \mu$ and $y \sim \nu$ from the empirical and the generated distribution respectively and add the regularization term
$$\left( \operatorname* { m a x } \left\{ 0 , { \frac { | f ( x ) - f ( y ) | } { | | x - y | | _ { 2 } } } - 1 \right\} \right) ^ { 2 }$$
to the cost function. (We square to penalize larger deviations more than smaller ones.) Note the similarity of the regularization term to the squared Hinge loss, which is also used to turn a hard constraint into a soft one in the optimization problem connected to support vector machines.
Alternatively, since the NN generates (almost everywhere) differentiable functions, we can penalize whenever gradient norms are strictly larger than one, an option referred to as “one-sided penalty” and shortly discussed as an alternative to penalizing any deviation from one by Gulrajani et al. $( 2 0 1 7 ) ^ { 4 }$ . Note that enforcing the gradient to be smaller than one in norm has the advantage that we penalize when the partial derivative has norm $> 1$ into the direction of steepest descent. Hence, all partial derivatives are implicitly enforced to be bounded in norm by one, too. At the same time, enforcing $\leq 1$ for the gradient of smooth approximating functions is not an unreasonable constraint even at points of non-differentiability. For these reasons we suggest to add the regularization term $\big ( \operatorname* { m a x } { \{ 0 , \lvert \lvert \nabla f ( \hat { x } ) \rvert \rvert - 1 \} } \big ) ^ { 2 }$ to the cost function. Different ways of sampling the point $\hat { x }$ are analyzed in Appendix D.4. Thus, our proposed method (WGAN-LP, where LP stands for Lipschitz penalty) alternates between updating the discriminator to minimize
$$\begin{array} { r } { \mathbb { E } _ { y \sim \nu } [ f ( y ) ] - \mathbb { E } _ { x \sim \mu } [ f ( x ) ] + \lambda \mathbb { E } _ { \hat { x } \sim \tau } [ ( \operatorname* { m a x } \left\{ 0 , | | \nabla f ( \hat { x } ) | | - 1 \right\} ) ^ { 2 } ] \ , } \end{array}$$
(where $\tau$ depends on the concrete sampling strategy chosen) and updating the generator network modeling $\nu$ to minimize $- \mathbb { E } _ { y \sim \nu } [ f ( y ) ]$ using gradient descent.
The connection to regularized optimal transport. Consider Equation (2) of regularized OT. For a hard constraint $f ( x ) - g ( y ) \leq | | x - y | | _ { 2 }$ , one can attain the supremum over $\bar { \mathbb { E } } _ { x \sim \mu } [ f ( x ) ] -$ $\mathbb { E } _ { y \sim \nu } [ g ( y ) ] - 0$ by setting $f ( x ) = \operatorname* { i n f } _ { y } g ( y ) + | | x - y | | _ { 2 } = g ( x )$ and subsequently maximize over one function only. Taking the advantage of dealing with a single function as a motivation, one may similarly replace $f = g$ in Equation 2, which uses a soft constraint (even though this can now only approximate the supremum). This leads to an objective of minimizing
$$\mathbb { E } _ { y \sim \nu } [ f ( y ) ] - \mathbb { E } _ { x \sim \mu } [ f ( x ) ] + \frac { 4 } { \epsilon } \int \int \operatorname* { m a x } \big \{ 0 , ( f ( x ) - f ( y ) - | | x - y | | _ { 2 } ) \big \} ^ { 2 } \mathrm { d } \mu ( x ) \mathrm { d } \nu ( y )$$
that, similarly to Equation (7), softly penalizes whenever $f ( x ) - f ( y ) > | | x - y | | _ { 2 }$ for a real sample $x$ and a generated sample $y$ . It is noteworthy that to justify the replacement $f \ = \ g$ one would require a high regularization parameter $\lambda = \frac { 4 } { \epsilon }$ of the dual problem, which corresponds to a low regularization of the primal problem.
Dependence on the regularization hyperparameter $\lambda$ . Let $\mathcal { L } _ { \lambda } ^ { G P }$ and $\mathcal { L } _ { \lambda } ^ { L P }$ denote the infimums of the regularized losses over a class of (differentiable) critic functions $f$ from Equation (6) (WGANGP) and Equation (8) (WGAN-LP) respectively. For the comparison of these optimal losses we have the following result (proof in Appendix C.4).
# Proposition 3.
$$\begin{array} { r } { \mathcal { L } _ { \lambda } ^ { L P } \le \mathcal { L } _ { \lambda } ^ { G P } \le \mathcal { L } _ { \lambda } ^ { L P } + \lambda } \end{array}$$
In particular, for small $\lambda$ the optimal scores approximately agree. On the other hand, increasing $\lambda$ strengthens the soft constraints, which means that the theoretical observations from Section 4 become more pertinent with growing $\lambda$ . Our experiments show exactly the behavior that WGANLP and WGAN-GP perform very similarly for small $\lambda$ , while WGAN-LP performs much better for larger values of $\lambda$ and its performance is much less dependent on the choice of hyperparameter $\lambda$ .
A more general view. The Kantorovich duality theorem holds in a quite general setting. For example, a different metric can be substituted for the Euclidean distance $| | \cdot | | _ { 2 }$ . Taking $| | \cdot | | _ { 2 } ^ { \bar { p } }$ for a different natural number $p$ for example leads to the minimization of the Wasserstein distance of order $p$ (i.e., the Wasserstein- $p$ distance). Based on the dual problem to the computation of the Wasserstein distance of order $p$ (as given by the Kantorovich duality theorem) we still need to maximize Equation (5) with the only difference that 1-Lipschitz-continuity is now measured with respect to $| | \cdot | | _ { 2 } ^ { p }$ . For our training method this entails that the only modification to make is to use the regularization term given by (7), where the Euclidean distance is replaced by the metric of interest. We provide experimental results for the Wasserstein-2 distance in Appendix D.5.
Recently, by Bellemare et al. (2017), the Wasserstein distance was replaced by the energy distance 5. For the training of Cramer GANs, the authors apply the GP-penalty term proposed by Gulrajani et al. (2017). We expect that using the LP-penalty term instead is also beneficial for Cramer GANs.
# 6 EXPERIMENTS
We perform several experiments on three toy data sets, 8Gaussians, 25Gaussians, and Swiss Roll 6, to compare the effect of different regularization terms. More specifically, we compare the performance of WGAN-GP and WGAN-LP as described in Equations (6) and (8) respectively, where the penalty was applied to points randomly sampled on the line between the training sample $x$ and the generated sample $y$ . Other sampling methods are discussed in Appendix D.4.
Both, the generator network and the critic network, are simple feed-forward NNs with three hidden Leaky ReLU layers, each containing 512 neurons, and one linear output layer. The dimensionality of the latent variables of the generator network was set to two. During training, 10 critic updates are performed for every generator update, except for the first 25 generator updates, where the critic is updated 100 times for each generator update in order to get closer to the optimal critic in the beginning of training. Both networks were trained using RMSprop (Tijmen & Hinton, 2012) with learning rate $5 \cdot 1 0 ^ { - 5 }$ and a batch size of 256.
To see whether our findings on toy data sets can be transferred to real world settings, we trained bigger WGAN-GPs and WGAN-LPs on CIFAR-10 as it is described below. Code for the reproduction of our results is available under https://github.com/lukovnikov/improved_wgan_ training .
Level sets of the critic. A qualitative way to evaluate the learned critic function for a twodimensional data set is by displaying its level sets, as it was done by Gulrajani et al. (2017) and Kodali et al. (2017). The level sets after 10, 50, 100 and 1000 training iterations of a WGAN trained with the GP and LP penalty on the Swiss Roll data set are shown in Figure 3. Similar experimental results for the 8Gaussians and 25Gaussian data sets can be found in Appendix D.1.
It becomes clear that with a penalty weight of $\lambda = 1 0$ , which corresponds to the hyperparameter value suggested by Gulrajani et al. (2017), the WGAN-GP does neither learn a good critic function nor a good model of the data generating distribution. With a smaller regularization parameter, $\lambda = 1$ , learning is stabilized. However, with the LP-penalty a good critic is learned even with a high penalty weight in only a few iterations and the level sets show higher regularity. Training a WGAN-LP with lower penalty weight led to equivalent observations (results not shown). We also experimented with much higher values for $\lambda$ , which led to almost the same results as for $\lambda = 1 0$ , which emphasizes that LP-penalty based training is less sensitive to the choice of $\lambda$ .
Evolution of the critic loss. To yield a fair comparison of methods applying different regularization terms, we display values of the critic’s loss functions without the regularization term throughout training. Results for WGAN-GPs and WGAN-LPs are shown in Figure 4.
The optimization of the critic with the GP-penalty and $\lambda = 5$ is very unstable: the loss is oscillating heavily around 0. When we use the LP-penalty instead, the critic’s loss smoothly reduces to zero, which is what we expect when the generative distribution $\nu$ steadily converges to the empirical distribution $\mu$ . Also note that we would expect the negative of the critic’s loss to be slightly positive, as a good critic function assigns higher values to real data points $x \sim \mu$ and lower values to generated points $y \sim \nu$ . This is exactly what we observe when using the LP-penalty Interestingly, when using the LP-penalty in combination with a very high penalty weight, like $\lambda = 1 0 0$ , we obtain the same results, indicating that the constraint is always fulfilled for $\lambda = 1 0$ already. Using $\lambda = 1$ in combination with the GP-penalty on the other hand stabilized training but still results in fluctuations in the beginning of the training (results shown in Appendix D.2).
 Figure 3: Level sets of the critic $f$ of WGANs during training, after 10, 50, 100, 500, and 1000 iterations. Yellow corresponds to high, purple to low values of $f$ . Training samples are indicated in red, generated samples in blue. Top: GP-penalty with $\lambda = 1 0$ . Middle: GP-penalty with $\lambda = 1$ . Bottom: LP-penalty with $\lambda = 1 0$ .
 Figure 4: Evolution of the negative of WGAN critic’s loss (without the regularization term) for $\lambda = 5$ . Median results over the 20 runs (blue area indicates quantiles, green dots outliers). Left: For the GP-penalty. Right: For the LP-penalty.
Estimating the Wasserstein distance. In order to estimate how the actual Wasserstein distance between the real and generated distribution evolves during training, we compute the cost of minimum assignment based on Euclidean distance between sets of samples from the real and generated distributions, using the Kuhn-Munkres algorithm (Kuhn, 1955). We use a sample set size of 500 to maintain reasonable computation time and estimate the distance every 10th iteration over the course of 500 iterations. All experiments were repeated 10 times for different random seeds. From the results for WGAN-GP and WGAN-LP with $\lambda = 5$ shown in Figure 5, we conclude that the proposed LP-penalty leads to smaller estimated Wasserstein distance and less fluctuations during training.
Table 1: Inception Score on CIFAR-10. Reported are the maximal mean values reached during training. Means are computed over 10 image sets, variances given in parenthesis.
<table><tr><td>PENALTYWEIGHT</td><td>WGAN-GP</td><td>WGAN-LP</td></tr><tr><td></td><td></td><td></td></tr><tr><td>0.1</td><td>7.781 (± 0.104)</td><td>8.017(± 0.075)</td></tr><tr><td>5</td><td>7.817 (± 0.095)</td><td>7.859 (± 0.085)</td></tr><tr><td>10</td><td>7.840 (± 0.066)</td><td>7.989 (± 0.119)</td></tr><tr><td>100</td><td>7.548 (± 0.102)</td><td>7.815 (± 0.038)</td></tr><tr><td>200</td><td>7.472 (± 0.070)</td><td>7.721 (± 0.105)</td></tr></table>
When training WGAN-GPs with a regularization parameter of $\lambda = 1$ , training is stabilized as well (see Appendix D.3), indicating that the effect of using a GP-penalty is highly dependent on the right choice of $\lambda$ .
 Figure 5: Evolution of the approximated Wasserstein-1 distance during training of WGANs $\lambda = 5$ , median results over 10 runs). Left: For the GP-penalty. Right: For the LP-penalty.
Sample quality on CIFAR-10. We trained WGANs with the same ResNet generator and discriminator and the same hyperparameters as Gulrajani et al. (2017) and computed the Inception score (Salimans et al., 2016) throughout training (plots can be found in Appendix D.6). The maximal scores reached in 100000 training iterations with different regularization parameters are reported in Table 1. WGAN-LP reaches the similar or slightly better Inception score as WGAN-GP with small penalty weight $( \lambda \leq 1 0 )$ , while being more stable to other choices of this hyperparameter. This is especially interesting in the light of a recent large scale study, which also reported a strong dependence of sample quality on $\lambda$ for WGAN-GP (see, Figure 8 and 9 in Lucic et al., 2017). Another interesting observation can be made by monitoring the value of the regularization term during training, as in Figure 6), where contributions to the penalty from $| | \nabla f ( \hat { x } ) \bar { | | } > 1$ are shown in the upper and contributions $| | \nabla f ( \hat { x } ) | | < 1$ (only existing for WGAN-GP) are shown in the lower half plane. While the values of the one-sided regularization of WGAN-LP are only slightly larger for larger $\lambda$ (100 compared to 5) the regularization of WGAN-GP shows a strong dependence on the choice of the regularization parameter. For $\lambda = 5$ the penalty contributions from gradient norms smaller than one almost vanished (we found this getting even more severe for even smaller regularization parameters). That is, in a setting where WGAN-GP is performing fine it actually acts similar to WGAN-LP.
Related penalties We tested the effects of using the regularization terms given by Equation (7) and Equation (9) instead of the the proposed regularization given in Equation (8). Both lead to good performance on toy data but to considerably worse results on CIFAR-10, where training was very unstable. Results are shown in Appendix D.7
 Figure 6: Comparison of the magnitude of the gradient penalty during training on CIFAR, showing $< 1$ and $> 1$ contributions (i.e. $\mathbf { \dot { m } } \mathrm { i n } ( 0 , | | \nabla f ( \mathbf { \dot { \hat { x } } } ) | | - 1 ) ^ { \mathbf { \dot { 2 } } }$ resp. $\operatorname* { m a x } ( \bar { 0 } , | | \nabla f ( \bar { { \boldsymbol x } } ) | | - 1 ) ^ { 2 } )$ ). Left: for regularization parameter $\lambda = 5$ . Right: for regularization parameter $\lambda = 1 0 0$ . The (one-sided) gradient penalty of WGAN-LP is depicted in blue (solid), the gradient penalty of WGAN-GP in red (dashed). All the values for every iteration (one mini-batch) are shown in light blue and red. Dark blue and red lines show the mean over a sliding window of size 500. The figure shows that the part of the gradient penalty of WGAN-GP penalizing a gradient $\leq 1$ almost vanishes for a small regularization parameter, bringing it close to WGAN-LP. For larger values of the regularization parameter, the total penalty of WGAN-GP and its contributing parts are larger than the penalty of WGAN-LP, however, the performance of WGAN-GP suffers more.
# 7 CONCLUSION
For stable training of Wasserstein GANs, we propose to use the following penalty term to enforce the Lipschitz constraint that appears in the objective function:
$$\mathbb { E } _ { \hat { x } \sim \tau } [ ( \operatorname* { m a x } \left\{ 0 , \vert \vert \nabla f ( \hat { x } ) \vert \vert - 1 \right\} ) ^ { 2 } ] \tau .$$
We presented theoretical and empirical evidence that this gradient penalty performs better than the previously considered approaches of clipping weights and of applying the stronger gradient penalty given by $\mathbb { E } _ { \hat { x } \sim \tau } [ ( | | \nabla f ( \bar { x } ) | | _ { 2 } - 1 ) ^ { 2 } ]$ . In addition to more stable learning behavior, the proposed regularization term leads to lower sensitivity to the value of the penalty weight $\lambda$ (demonstrating smooth convergence and well-behaved critic scores throughout the whole training process for different values of $\lambda$ ).
# ACKNOWLEDGMENTS
This work is supported in part by the European Union under the Horizon 2020 Framework Program for the project WDAqua (GA 642795).
The authors thank the anonymous reviewers for their valuable suggestions.
# REFERENCES
Mart´ın Arjovsky and Leon Bottou. Towards principled methods for training generative adversarial ´ networks. arXiv e-print, arXiv:1701.04862, 2017. Mart´ın Arjovsky, Soumith Chintala, and Leon Bottou. Wasserstein generative adversarial networks. ´ In Proceedings of the 34th International Conference on Machine Learning, ICML 2017, Sydney, NSW, Australia, pp. 214–223, 2017. Marc G. Bellemare, Ivo Danihelka, Will Dabney, Shakir Mohamed, Balaji Lakshminarayanan, Stephan Hoyer, and Remi Munos. The Cramer distance as a solution to biased Wasserstein gra- ´ dients. arXiv e-print, arXiv:1705.10743, 2017. Mathieu Blondel, Vivien Seguy, and Antoine Rolet. Smooth and sparse optimal transport. arXiv e-prints, arXiv:1710.06276, 2017. Xi Chen, Yan Duan, Rein Houthooft, John Schulman, Ilya Sutskever, and Pieter Abbeel. Infogan: Interpretable representation learning by information maximizing generative adversarial nets. In Advances in Neural Information Processing Systems 29, pp. 2172–2180, 2016. Marco Cuturi. Sinkhorn distances: Lightspeed computation of optimal transport. In Advances in Neural Information Processing Systems 26, pp. 2292–2300, 2013. Arnaud Dessein, Nicolas Papadakis, and Jean-Luc Rouas. Regularized optimal transport and the rot mover’s distance. arXiv e-prints, arXiv:1610.06447, 2016. David A. Edwards. On the Kantorovich–Rubinstein theorem. Expositiones Mathematicae, 29(4): 387 – 398, 2011. 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 27, pp. 2672–2680, 2014. Ishaan Gulrajani, Faruk Ahmed, Mart´ın Arjovsky, Vincent Dumoulin, and Aaron C. Courville. Improved training of Wasserstein GANs. arXiv e-prints, arXiv:1704.00028, 2017. Naveen Kodali, Jacob D. Abernethy, James Hays, and Zsolt Kira. How to train your DRAGAN. arXiv e-prints, arXiv:1705.07215v3, 2017. Harold W. Kuhn. The Hungarian method for the assignment problem. Naval Research Logistics Quarterly, 2:83–97, 1955. Mario Lucic, Karol Kurach, Marcin Michalski, Sylvain Gelly, and Olivier Bousquet. Are GANs created equal? A large-scale study. arXiv e-prints, arXiv:1711.10337, 2017. Sebastian Nowozin, Botond Cseke, and Ryota Tomioka. f-gan: Training generative neural samplers using variational divergence minimization. In Advances in Neural Information Processing Systems 29, pp. 271–279. 2016. Alec Radford, Luke Metz, and Soumith Chintala. Unsupervised representation learning with deep convolutional generative adversarial networks. arXiv e-prints, arXiv:1511.06434, 2015. Tim Salimans, Ian Goodfellow, Wojciech Zaremba, Vicki Cheung, Alec Radford, Xi Chen, and Xi Chen. Improved techniques for training gans. In Advances in Neural Information Processing Systems 29, pp. 2234–2242. 2016. Gabor J Sz ´ ekely and Maria L Rizzo. Energy statistics: A class of statistics based on distances. ´ Journal of statistical planning and inference, 143(8):1249–1272, 2013. Tieleman Tijmen and Geoffrey Hinton. Lecture 6.5—RmsProp: Divide the gradient by a running average of its recent magnitude. COURSERA: Neural Networks for Machine Learning, 2012. Ilya Tolstikhin, Sylvain Gelly, Olivier Bousquet, Carl-Johann Simon-Gabriel, and Bernhard Scholkopf. Adagan: Boosting generative models. ¨ arXiv e-prints, arXiv:1701.02386, 2017. Cedric Villani. ´ Optimal Transport: Old and New. Grundlehren der mathematischen Wissenschaften. Springer Berlin Heidelberg, 2008. ISBN 9783540710509.
# A PROPERTIES OF AN OPTIMAL CRITIC FUNCTION OF WGANS
An issue of the original GAN discriminator was that it outputs zero every time it is certain to see generated data, independent on how far away a generated data point lies from the real distribution. As a consequence, locally, there is no incentive for the generator to rather generate a value closer to (but still off) the real data; GAN critic’s optimal value is zero in either case. The WGAN’s optimal critic function measures this distance which helps for the generated distribution to converge, but the interpretation of the absolute value as indicating real (close to 1) and fake data (close to 0) is lost. And worse, there is even no guarantee that the relative values of the optimal critic function help to decide what is real and what is fake. Although this does not seem to cause major problems for the iterative training procedure in practice, we still consider it worthwhile to give a specific example justifying the following observation.
Observation 4. The WGAN generator could learn wrong things, basing its decision on the values of the optimal critic function, i.e., if it generates at locations of high critic function values.
Consider the following setting, where the X’s represent generated and the O’s represent real data points.
 Figure 7: Values of the WGAN critic function for some generated data points can be higher than the critic’s values for some real data points. Thus, fake and real points can not be distinguished based on the critics values alone. Real data points are represented by O, generated by X.
An optimal coupling in this example is quite obvious: We connect the left-most O with the X on the left, and then extend by an arbitrary matching of the other O’s with the other X’s. It is then not hard to verify that the indicated critic function with slope 1 or $- 1$ almost everywhere leads to an equality in the Kantorovich duality and hence is optimal. The value of the critic function at the left-most X is higher than the value at the right-most O, suggesting to generate images at the wrong position. This issue might be fixed by the alternating updates of generator and critic at a later stage of training when less X’s are generated so far on the right side of the O’s. The critic function will then flatten the peak, eventually assigning a lower value to an $\mathrm { X }$ on the left than to any of the O’s.
Remark 1. The same holds (with only a slight change of the critic function $f$ ) if the $X$ ’s and $O _ { s }$ denote the centers of Gaussians. This can be shown with similar arguments as those in the proofs in Appendix C.3.
# A.1 PROVING OPTIMALITY OF CERTAIN COMBINATIONS OF COUPLING AND CRITIC FUNCTION
We show here that the coupling and critic function indicated in Figure 1 are indeed optimal.
In the one-dimensional example on the left, $\begin{array} { r } { \int _ { \mathbb { R } \times \mathbb { R } } | x - y | d \pi ^ { * } ( x , y ) = \frac { 1 } { 7 } ( 1 + 1 + 1 + 1 + 1 + 1 + 1 ) = } \end{array}$ $\begin{array} { r } { \int _ { \mathbb { R } } f ^ { * } ( x ) d \mu ( x ) - \int _ { \mathbb { R } } f ^ { * } ( x ) d \nu ( x ) } \end{array}$ and thus $\pi ^ { * }$ and $f ^ { * }$ are indeed optimal.
In the two-dimensional example on the right, the coupling indicated in red and the critic function (described by its function values in blue) are optimal, since with this choice we have
$\begin{array} { r } { \int _ { \mathbb { R } ^ { n } \times \mathbb { R } ^ { n } } | | x - y | | _ { 2 } \ d \pi ^ { * } ( x , y ) \ = \ \frac { 1 } { 2 } ( 1 + 1 ) \ = \ 1 } \end{array}$ and $\begin{array} { r } { \int _ { \mathbb { R } ^ { n } } f ^ { * } ( y ) \ d \nu ( y ) \ - \ \int _ { \mathbb { R } ^ { n } } f ^ { * } ( x ) \ d \mu ( x ) \ = } \end{array}$ $\textstyle { \frac { 1 } { 2 } } ( 1 + a + 1 ) - { \frac { 1 } { 2 } } ( 0 + a ) = 1$ . Equality of the left hand side and right hand side of the equation proves optimality on both sides.
# B THE ISSUE WITH THE WEIGHT CLIPPING APPROACH
The critic function of WGAN is given by a neural network, which raises the question on how to enforce the 1-Lipschitz constraint in the maximization problem of the objective in Equation (5). As Arjovsky et al. (2017) point out, it does not matter whether to maximize over 1-Lipschitz or $\alpha$ - Lipschitz continuous functions, since we can equivalently optimize $\alpha \cdot W ( \mu , \nu )$ instead of $W ( \mu , \nu )$ . An easy consideration leads to the following lemma.
Lemma 1. The optimal critic function $f ^ { * }$ (leading to the maximum in Eq. (4)) exhausts the Lipschitz constraint for given $\alpha$ in the sense that there is a pair of points $( x , y )$ such that $f ^ { * } ( x ) - f ^ { * } ( y ) =$ $\alpha | | x - y | | _ { 2 }$ .
Proof. If supx6=y n f ∗(y)−f ∗(x)||x−y|| o = c < α , then g = 1c f ∗ generates a contradiction to the optimality of $f ^ { * }$ . (Alternatively, in the case $\alpha = 1$ , it follows directly from Theorem 1, (ii), that the transport is optimal if and only if the Lipschitz constraint of one is exhausted for any two points of the coupling.) □
Observation 5. Weight clipping is not a good strategy to enforce the Lipschitz constraint for the critic function.
First note that by clipping the weights we enforce a common Lipschitz constraint, where the common Lipschitz constant $\bar { \alpha }$ is defined as the minimal $\alpha \in \mathbb { R }$ such that ${ \overline { { f ( x ) - f ( y ) } } } \leq \alpha \| x - y \| _ { 2 }$ for all $x , y$ and all functions $f$ that can be generated by the network under weight clipping. The actual value of $\bar { \alpha }$ does not follow directly from the weight clipping constant $c _ { \mathrm { m a x } }$ but can be computed from the structure of the network. From Lemma 1 we know that an optimal $f ^ { * }$ exhausts the Lipschitz constraint. We will now show exemplarily for deep NN with rectified linear unit (ReLU) activation functions that there is an extremely limited number of functions generated by the NN using weight clipping that do exhaust the implicitly given common Lipschitz constraint $\bar { \alpha }$ . It follows that, in almost all cases, the optimal $f ^ { * }$ is not in the class of functions that can be generated by the network under the weight clipping constraint.
Proposition 4. Consider a (deep) NN with ReLU activation functions and linear output layer. A function generated by the NN under constraining each weight in absolute value by $c _ { m a x }$ exhausts the common Lipschitz constraint if and only if
(a) The weight matrix of the first layer consists of constant columns with value $c _ { m a x } o r - c _ { m a x } .$
$( b )$ The weights of all other layers are given by a matrix $C ^ { m a x }$ with every entry equal to $c _ { m a x }$
Proof. We need to determine every function $f ^ { * }$ generated by the neural network, such that we can find points $x ^ { * } \neq y ^ { * }$ with $f ^ { * } ( y ^ { * } ) - f ^ { * } ( x ^ { * } ) = \bar { \alpha } | | x ^ { * } - y ^ { * } | | _ { 2 }$ . Recall that $\bar { \alpha }$ is defined as the minimal $\alpha$ satisfying $f ( y ) - f ( x ) \leq \alpha \vert \vert x - y \vert \vert _ { 2 }$ for all functions $f$ generated by the neural network and all points $x , y$ .
In the following, we will denote by $\alpha ( f )$ the Lipschitz constant of $f$ , i.e., the smallest $\alpha \in \mathbb { R }$ such that $f ( x ) - f ( y ) \leq \alpha \vert \vert x - y \vert \vert _ { 2 }$ for all $x , y$ .
Every function generated by the neural net is a composition of functions
$$f = f _ { n } \circ { \mathrm { r e l u } } \circ f _ { n - 1 } \circ . . . \circ { \mathrm { r e l u } } \circ f _ { 1 } . $$
with linear functions $f _ { i }$ and relu denoting a layer of activation functions with rectifier linear units. Since each linear function $f _ { i }$ is Lipschitz continuous with Lipschitz constant $\alpha ( f _ { i } )$ and relu is Lipschitz continuous with $\alpha ( \mathrm { r e l u } ) = 1$ , it follows that $f$ is Lipschitz continuous with $\begin{array} { r } { \dot { \alpha } ( f ) \le \prod _ { i } \alpha ( \bar { f } _ { i } ) } \end{array}$ . Moreover, equality holds if there is a pair of points $( x , y )$ such that the consecutive images witness the maximal Lipschitz constant $\alpha ( f _ { i } )$ and $\alpha ( \mathrm { { r e l u } ) }$ for each of the individual functions making up the composition of $f$ . More formally, equality holds if and only if there is a tuple of pairs of points $( \boldsymbol { x } ^ { ( i ) } , \boldsymbol { y } ^ { ( \bar { i } ) } )$ , $1 \leq i \leq n - 1$ , such that for all $1 \leq i \leq n$ ,
(i) $\boldsymbol { x } ^ { ( i ) } \neq \boldsymbol { y } ^ { ( i ) }$
$$| f _ { i } ( x ^ { ( i ) } ) - f _ { i } ( y ^ { ( i ) } ) | = \alpha ( f _ { i } ) | | x ^ { ( i ) } - y ^ { ( i ) } | | _ { 2 }$$
(iv) All entries of $f _ { i } ( x ^ { ( i ) } )$ and $f _ { i } ( y ^ { ( i ) } )$ are larger or equal to zero. This is equivalent to the condition that
$$\begin{array} { r } { | \mathrm { r e l u } ( f _ { i } ( x ^ { ( i ) } ) ) - \mathrm { r e l u } ( f _ { i } ( y ^ { ( i ) } ) ) | = \alpha ( \mathrm { r e l u } ) | | f _ { i } ( x ^ { ( i ) } ) - f _ { i } ( y ^ { ( i ) } ) | | _ { 2 } \ . } \end{array}$$
It follows that to determine $f ^ { * }$ we need to maximize $\alpha ( f _ { i } )$ for the linear layers with weight constraint $c _ { \mathrm { m a x } }$ and find a sequence of points $( x ^ { ( i ) } , y ^ { ( i ) } )$ that satisfy (i)-(iv). The existence of the sequence of points shows that $\begin{array} { r } { \bar { \alpha } ( f ^ { * } ) = \bar { \prod } _ { i = 1 } ^ { n } \alpha ( f _ { i } ) } \end{array}$ and maximizing each $\alpha ( f _ { i } )$ then shows that
$$\alpha ( f ^ { * } ) = \prod _ { i = 1 } ^ { n } \alpha ( f _ { i } ) = \bar { \alpha } .$$
Since, as we will show, the conditions in (a) and (b) maximize the Lipschitz constraint of each layer individually, the existence of suitable $( x ^ { ( i ) } , y ^ { ( i ) } )$ proves the if-direction of the proposition.
For the only-if direction, we will see that the ability to find the sequence of points gives restrictions on how to maximize $\alpha ( f _ { i } )$ of an individual layer, leading to the more restrictive condition of (b) for all but the first layer (cf. (a)).
So let us first maximize the Lipschitz constraint of each linear layer and then make sure that we can find the corresponding points. We write the linear layer as a matrix multiplication $f _ { i } ( x ) = A ^ { ( i ) } x$ . Using linearity,
$$\alpha ( f _ { i } ) = \operatorname* { m a x } _ { | | z | | _ { 2 } = 1 } | | A ^ { ( i ) } z | | _ { 2 } \ ,$$
and our goal can be reformulated to finding the matrix $A ^ { ( i ) }$ maximizing $\alpha ( f _ { i } )$
For any fixed $z$ , $| | A ^ { ( i ) } z | | _ { 2 }$ is maximized exactly when each vector entry is maximized in absolute value. Now, with $A ^ { ( i ) } = ( a _ { j , k } ^ { ( i ) } ) _ { j , k }$ and $\operatorname { s g n } ( { \mathord { \cdot } } )$ denoting the sign function,
$$| ( A ^ { ( i ) } z ) _ { j } | = \left| \sum _ { k } a _ { j , k } ^ { ( i ) } z _ { k } \right| \leq \sum _ { k } | a _ { j , k } ^ { ( i ) } | | z _ { k } | \leq \sum _ { k } c _ { \operatorname* { m a x } } | z _ { k } | \mathrm { ( b y ~ t h e ~ w e i g h t ~ c o n s t r a i n t ) }$$
$$= \sum _ { k } ( c _ { \mathrm { m a x } } \cdot \mathrm { s g n } ( z _ { k } ) ) \cdot z _ { k }$$
and equality holds if and only if $A ^ { ( i ) }$ or $- A ^ { ( i ) }$ consists of columns of constant entry with the value $c _ { \mathrm { m a x } } \cdot \mathrm { s g n } ( z _ { k } )$ in column $k$ . It follows that
$$\alpha ( f _ { i } ) = \operatorname* { m a x } _ { | | z | | _ { 2 } = 1 } | | A ^ { ( i ) } z | | _ { 2 } = \operatorname* { m a x } _ { | | z | | _ { 2 } = 1 } c _ { \operatorname* { m a x } } \cdot | | z | | _ { 1 }$$
$$= c _ { \operatorname* { m a x } } \sqrt { d i m ( z ) }$$
with equality if and only if $\begin{array} { r } { z _ { k } = \pm \frac { 1 } { \sqrt { d i m ( z ) } } } \end{array}$ for all $k$ .
Hence, for the first linear layer we need to choose a matrix $A ^ { ( 1 ) }$ satisfying (a) of the statement of the proposition.
Now, we find a pair $( x ^ { ( 1 ) } , y ^ { ( 1 ) } )$ with
$$x ^ { ( 1 ) } - y ^ { ( 1 ) } = a \cdot ( \pm 1 , \pm 1 , \ldots , \pm 1 ) { \mathrm { f o r ~ s o m e ~ } } a \neq 0$$
such that
$$\mathtt { s g n } ( x _ { k } ^ { ( 1 ) } ) = \mathtt { s g n } ( y _ { k } ^ { ( 1 ) } ) = \mathtt { s g n } ( x _ { k } ^ { ( 1 ) } - y _ { k } ^ { ( 1 ) } ) = \mathtt { t h e ~ s i g n ~ o f ~ c o l u m n } k \mathrm { ~ o f ~ } A ^ { ( 1 ) } .$$
This is the only possibility to ensure (iii) and (iv) of the conditions above. Note that also (i) holds for $( x ^ { ( 1 ) } , y ^ { ( 1 ) } )$ , and (ii) (together with (iv)) determines $( x ^ { ( 2 ) } , y ^ { ( 2 ) } )$ uniquely from $( x ^ { ( 1 ) } , y ^ { ( 1 ) } )$ as
$$\begin{array} { r } { x ^ { ( 2 ) } = A ^ { ( 1 ) } x ^ { ( 1 ) } = c _ { \operatorname* { m a x } } \cdot \vert \vert x ^ { ( 1 ) } \vert \vert _ { 1 } \cdot ( 1 , 1 , . . . , 1 ) } \\ { \& } \end{array} .$$
We may assume that $| | x ^ { ( 1 ) } | | _ { 1 } ~ > ~ | | y ^ { ( 1 ) } | | _ { 1 }$ . (Otherwise, switch the roles of $x$ and $y$ . In the case of equality, we need to choose a different pair for $( x ^ { ( 1 ) } , y ^ { ( 1 ) } )$ not to violate (i) for $( x ^ { ( 2 ) } , y ^ { ( 2 ) } )$ .) Then we have that $x ^ { ( 2 ) } \neq y ^ { ( 2 ) }$ ,
$$+ 1 = \mathrm { s g n } ( x _ { k } ^ { ( 2 ) } ) = \mathrm { s g n } ( y _ { k } ^ { ( 2 ) } ) = \mathrm { s g n } ( x _ { k } ^ { ( 2 ) } - y _ { k } ^ { ( 2 ) } ) \mathrm { f o r } \mathrm { a l l } k .$$
Using the same arguments as above, it follows that for such $( x ^ { ( 2 ) } , y ^ { ( 2 ) } )$ , to maximize the Lipschitz constant of $f _ { 2 }$ (and to guarantee that the maximum is reached at $( x ^ { ( 2 ) } , y ^ { ( 2 ) } ) )$ , we need to have $A ^ { ( 2 ) }$ equal to a matrix with $c _ { \mathrm { m a x } }$ at each position.
Now (i)-(iv) also hold for the second layer and one may now proceed by induction to show that for $i \geq 2$ , $A ^ { ( i ) }$ contains only $c _ { \mathrm { m a x } }$ for each of its entries. This is the only way to maximize the Lipschitz constraint for functions generated by the neural net, and it does indeed hold $| | f ^ { * } ( x ^ { * } ) - f ^ { * } ( y ^ { * } ) | | _ { 2 } =$ ${ \bar { \alpha } } | | x - y | | _ { 2 }$ with $x ^ { * } = x ^ { ( 1 ) } , y ^ { * } = y ^ { ( 1 ) }$ and
$$( x ^ { ( i ) } , y ^ { ( i ) } ) = ( f _ { i } \circ \mathsf { r e l u } \circ f _ { i - 1 } \circ \dots \circ \mathsf { r e l u } \circ f _ { 1 } ( x ^ { * } ) , f _ { i } \circ \mathsf { r e l u } \circ f _ { i - 1 } \circ \dots \circ \mathsf { r e l u } \circ f _ { 1 } ( y ^ { * } ) ) .$$
# C PROOFS
# C.1 PROOF OF THEOREM 1
Proof. We provide the arguments how to derive our version from Theorem 5.10 of Villani (2008).
With $c ( x , y ) = | | x - y | | _ { 2 }$ , our assumptions imply (with $c _ { \mathcal { X } } = c _ { \mathcal { Y } } = | | \cdot | | _ { 2 } )$ that all conclusions of Theorem 5. $1 0 \ ( i ) - ( i i i )$ hold. Moreover, 5.4 of Villani (2008) shows that in this case $\psi = \psi ^ { c }$ (in the notation of Villani (2008)) and $c$ -convexity is the same as 1-Lipschitz continuity. This leads to our formulation in (i) and the existence of an optimal coupling $\pi ^ { * }$ and an optimal critic function $f ^ { * }$ by part (iii).
If we let
$$\Gamma _ { f } = \{ ( x , y ) \in \mathbb { R } ^ { n } \times \mathbb { R } ^ { n } \mid f ( x ) - f ( y ) = | | x - y | | _ { 2 } \}$$
then it follows from the proof of Theorem 5.10 that the set $\Gamma$ in part 5.10 (iii) is given by $\Gamma =$ Tf∗∈Lip optimal Γf∗ , where f ∗ being optimal means that it leads to a maximum on the RHS of equation (1).
To prove our part $( i i )$ from 5.10, let $\pi ^ { * }$ be optimal. Then, by 5.10 (iii), $\pi ^ { * } ( \Gamma ) = 1$ . Hence, in particular, $\pi ^ { * } ( \Gamma _ { f ^ { * } } ) = 1$ for all optimal $f ^ { * } \in \mathcal { L } i p _ { 1 }$ . This shows that (a) implies (b). For the other direction, we use that if $\pi ^ { * } ( \Gamma _ { f ^ { * } } ) = 1$ for all optimal $f ^ { * }$ , then $\pi ^ { * } ( \Gamma ) = 1$ , which by Theorem 5.10 (iii) is equivalent to $\pi ^ { * }$ being optimal. □
# C.2 PROOF OF PROPOSITION 1
Proof. It follows from Theorem 1 (ii) that for all $( x , y )$ in the support of $\pi ^ { * }$ we have $\left| f ^ { * } ( y ) - \right.$ $f ^ { * } ( { \dot { x } } ) | = | | x - y | | _ { 2 }$ . Considering the line between $x$ and $y$ , the 1-Lipschitz constraint implies that the values of $f ^ { * }$ have to follow a linear function (since assuming that the slope was smaller than one at some point would imply that the differentiable function must have a slope larger than one somewhere else between $x$ and $y$ , which contradicts the 1-Lipschitz constraint). It follows that at each point on the line, the partial derivative has norm equal to one into the direction pointing from the real data point $x$ to the generated one $y$ (which are coupled by the corresponding optimal coupling). Since, by the 1-Lipschitz constraint, the maximal norm of a partial derivative at any point into any direction is one, the given direction is the direction of maximal descent, i.e. equals the gradient.
# C.3 PROOF OF PROPOSITION 2
To prove Proposition 2, we first prove that $\phi ^ { * } ( x ) = - | x |$ is the optimal critic function for certain distributions with non-overlapping support, and then reduce the example with Gaussian functions to this simplified setting.
Proposition 5. Let $f$ and $g$ be two continuous functions on the real line that satisfy the following conditions:
• $f$ and $g$ are symmetric with respect to the y-axis. • $f ( x ) \geq 0$ and $g ( x ) \geq 0$ for all $x$ . • If $s u p p _ { \circ } ( h ) = \{ x \in \mathbb { R } \mid h ( x ) > 0 \}$ denotes the open support of a continuous function $h$ , then $s u p p _ { \circ } ( f ) \cap s u p p _ { \circ } ( g ) = \emptyset$ . • $f$ has connected support (this implies that $f$ is centered around 0 because of the symmetry). • $\begin{array} { r } { \int _ { \mathbb { R } } f ( x ) d x = \int _ { \mathbb { R } } g ( x ) d x . } \end{array}$
Then the maximum of $\begin{array} { r } { \int _ { \mathbb { R } } \phi ( x ) ( f ( x ) - g ( x ) ) d x } \end{array}$ over $\phi \in \mathcal { L } i p _ { 1 }$ is maximized for $\phi ^ { * } ( x ) = - | x |$ .
Proof. Before going into the technical details, we wish to point out the simple idea of the proof, which is to transport the left/right half of the distribution given by $g$ to the left/right half of the distribution given by $f$ respectively.
We first multiply both $f$ and $g$ by a constant number $c$ such that
$$\int _ { \mathbb { R } } c \cdot f ( x ) d x = \int _ { \mathbb { R } } c \cdot g ( x ) d x = 1 .$$
Then $c \cdot f$ and $c \cdot g$ define probability density functions. A function $\phi \in \mathcal { L } i p _ { 1 }$ maximizes $\begin{array} { r } { \int _ { \mathbb { R } } \phi ( x ) ( c \cdot } \end{array}$ $f ( x ) - c \cdot g ( x ) ) d x$ if and only if it maximizes $\begin{array} { r } { \int _ { \mathbb { R } } \phi ( x ) ( f ( x ) - g ( x ) ) d x } \end{array}$ . We therefore may assume from now on that
$$\int _ { \mathbb { R } } f ( x ) d x = \int _ { \mathbb { R } } g ( x ) d x = 1 .$$
Now it suffices to find a coupling $\pi$ of the probability distributions defined by $f$ and $g$ (that is itself defined by a probability density function $\pi : \mathbb { R } \times \mathbb { R } \to \mathbb { R }$ ) such that for $\phi ( x ) = - | x |$ we get
$$\int _ { \mathbb { R } \times \mathbb { R } } | x - y | \cdot \pi ( x , y ) d x d y = \int _ { \mathbb { R } } \phi ( x ) ( f ( x ) - g ( x ) ) d x .$$
The proof then follows from the Kantorovich duality theorem 1, because the right hand side is always smaller or equal to the left hand side for arbitrary coupling $\pi$ and function $\phi \in \mathcal { L } i p _ { 1 }$ and is consequently maximized when equality holds. By the assumption of symmetry, we may write $g = g _ { 1 } + g _ { 2 }$ where the support $\operatorname { s u p p } ( g _ { 1 } ) { \overset { \cdot } { \subseteq } } \{ x \mid x { \overset { \cdot } { < } } 0 \}$ and $g _ { 2 } \bar { ( } x ) = g _ { 1 } \bar { ( } - x )$ for all $x$ . The area under $g _ { 1 } ( x )$ equals half the area under $f ( x )$ , or put differently,
$$\int _ { \mathbb { R } } g _ { 1 } ( x ) d x = \int _ { \mathbb { R } } f ( x ) \delta _ { ( - \infty , 0 ] } ( x ) d x = \frac { 1 } { 2 } .$$
We now consider the probability density function $\pi _ { 1 } : \mathbb { R } \times \mathbb { R } \to \mathbb { R }$ given by
$$\pi _ { 1 } ( x , y ) = 2 g _ { 1 } ( x ) \cdot 2 f ( y ) \cdot \delta _ { ( - \infty , 0 ] } ( y ) ,$$
which defines a coupling between the two distributions given by the probability density functions $2 g _ { 1 }$ and $2 f \cdot \delta _ { ( - \infty , 0 ] }$ . For later use we note that
$$\int _ { x \in \mathbb { R } } \pi _ { 1 } ( x , y ) d x = 2 \cdot f ( y ) \cdot \delta _ { ( - \infty , 0 ] } ( y ) { \mathrm { ~ a n d ~ } } \int _ { y \in \mathbb { R } } \pi _ { 1 } ( x , y ) d y = 2 \cdot g _ { 1 } ( x ) .$$
We define $\pi _ { 2 } ( x , y ) = \pi _ { 1 } ( - x , - y )$ for $y \ne 0$ and $\pi _ { 2 } ( x , 0 ) = 0$ . Further, we let $\pi = { \textstyle { \frac { 1 } { 2 } } } \pi _ { 1 } + { \textstyle { \frac { 1 } { 2 } } } \pi _ { 2 }$ Then $\pi$ defines a coupling between $g$ and $f$ as can be seen by computing
$$\int _ { x \in \mathbb { R } } \pi ( x , y ) d x = \frac { 1 } { 2 } \int _ { x \in \mathbb { R } } \pi _ { 1 } ( x , y ) d x + \frac { 1 } { 2 } \int _ { x \in \mathbb { R } } \pi _ { 2 } ( x , y ) d x$$
$$= \frac { 1 } { 2 } \int _ { x \in \mathbb { R } } \pi _ { 1 } ( x , y ) d x + \frac { 1 } { 2 } \int _ { x \in \mathbb { R } } \pi _ { 1 } ( - x , - y ) \delta _ { \{ y \neq 0 \} } ( y ) d x$$
$$= f ( y ) \delta _ { ( - \infty , 0 ] } ( y ) + f ( y ) \delta _ { ( 0 , \infty ) } ( y ) = f ( y )$$
and
$$\int _ { y \in \mathbb { R } } \pi ( x , y ) d y = \frac { 1 } { 2 } \int _ { y \in \mathbb { R } } \pi _ { 1 } ( x , y ) d y + \frac { 1 } { 2 } \int _ { y \in \mathbb { R } } \pi _ { 2 } ( x , y ) d y$$
$$\frac { 1 } { 2 } \int _ { y \in \mathbb { R } } { \pi } _ { 1 } ( x , y ) d y + \frac { 1 } { 2 } \int _ { y \in \mathbb { R } } { \pi } _ { 1 } ( - x , - y ) \delta _ { \{ y \neq 0 \} } ( y ) d y$$
$$= g _ { 1 } ( x ) + g _ { 1 } ( - x ) = g _ { 1 } ( x ) + g _ { 2 } ( x ) = g ( x )$$
We have established the existence of some coupling between $f$ and $g$ and we will now compute its transport costs. We will subsequently show that this equals $\begin{array} { r } { \int _ { \mathbb { R } } ( - | x | ) ( f ( x ) - g ( x ) ) d x } \end{array}$ , hence both $\pi$ and $\phi$ are optimal by realizing the Kantorovich duality.
We aim at showing $\begin{array} { r } { \int _ { \mathbb { R } \times \mathbb { R } } | x - y | \pi ( x , y ) d x d y = \int _ { \mathbb { R } } ( - | x | ) ( f ( x ) - g ( x ) ) d x . } \end{array}$
$$\int _ { \mathbb { R } \times \mathbb { R } } | x - y | \pi ( x , y ) d x d y \overset { s y m m e t r y } { = } \int _ { \mathbb { R } \times \mathbb { R } } | x - y | \pi _ { 1 } ( x , y ) d x d y$$
$$= \int _ { \mathbb { R } \times \mathbb { R } } ( y - x ) \pi _ { 1 } ( x , y ) d x d y .$$
The latter equation holds because for $( x , y )$ in the support of $\pi _ { 1 }$ we have $x \leq y$ . (To see this, note that support of $\pi _ { 1 }$ is a subset of the support of $g _ { 1 } \times \left( f \cdot \delta _ { ( - \infty , 0 ] } \right) .$ .) Let
$$x _ { 0 } = \frac { \int _ { \mathbb { R } } x \cdot g _ { 1 } ( x ) d x } { \int _ { \mathbb { R } } g _ { 1 } ( x ) d x } , \mathrm { ~ a n d ~ } y _ { 0 } = \frac { \int _ { \mathbb { R } } y \cdot f ( y ) \cdot \delta _ { ( - \infty , 0 ) } ( y ) d y } { \int _ { \mathbb { R } } f ( y ) \cdot \delta _ { ( - \infty , 0 ) } ( y ) d y } .$$
Then
$$\int _ { \mathbb { R } } ( x - x _ { 0 } ) \cdot g _ { 1 } ( x ) d x = 0 { \mathrm { ~ a n d ~ } } \int _ { \mathbb { R } } ( y - y _ { 0 } ) \cdot f ( y ) \cdot \delta _ { ( - \infty , 0 ] } ( y ) d y = 0 .$$
Now, it follows that
$$\int _ { \mathbb { R } \times \mathbb { R } } ( y - x ) \pi _ { 1 } ( x , y ) d x d y = \int _ { \mathbb { R } \times \mathbb { R } } ( y - y _ { 0 } + y _ { 0 } - x ) \pi _ { 1 } ( x , y ) d x d y$$
$$= \int _ { x } \int _ { y } ( y - y _ { 0 } ) \pi _ { 1 } ( x , y ) d x d y + \int _ { x } \int _ { y } ( y _ { 0 } - x ) \pi _ { 1 } ( x , y ) d x d y$$
$$= \int _ { y } ( y - y _ { 0 } ) \int _ { x } \pi _ { 1 } ( x , y ) d x d y + \int _ { x } \int _ { y } ( y _ { 0 } - x ) \pi _ { 1 } ( x , y ) d x d y$$
$$= 2 \underbrace { \int _ { y } ( y - y _ { 0 } ) \cdot f ( y ) \cdot \delta _ { ( - \infty , 0 ] } ( y ) d y } _ { = 0 } + \int _ { x } \int _ { y } ( y _ { 0 } - x _ { 0 } + x _ { 0 } - x ) \pi _ { 1 } ( x , y ) d x d y$$
$$= ( y _ { 0 } - x _ { 0 } ) \int _ { x } \int _ { y } \pi _ { 1 } ( x , y ) d x d y + \int _ { x } ( x _ { 0 } - x ) \underbrace { \int _ { y } \pi _ { 1 } ( x , y ) d y } _ { = 2 g _ { 1 } ( x ) } d x$$
Hence,
$$\int _ { { \mathbb R } \times { \mathbb R } } | x - y | \pi ( x , y ) d x d y = ( y _ { 0 } - x _ { 0 } ) = \frac { \int _ { { \mathbb R } } y \cdot f ( y ) \cdot \delta _ { ( - \infty , 0 ) } ( y ) d y } { \frac { 1 } { 2 } } - \frac { \int _ { { \mathbb R } } x \cdot g _ { 1 } ( x ) d x } { \frac { 1 } { 2 } } .$$
$$\begin{array} { l } { { \displaystyle = 2 \int _ { \mathbb R } x \cdot ( f ( x ) \cdot \delta _ { ( - \infty , 0 ) } ( x ) - g _ { 1 } ( x ) ) d x } } \\ { { \displaystyle \quad = 2 \int _ { - \infty } ^ { 0 } x \cdot ( f ( x ) - g ( x ) ) d x } } \\ { { \displaystyle \quad = 2 \int _ { - \infty } ^ { 0 } ( - | x | ) \cdot ( f ( x ) - g ( x ) ) d x } } \\ { { \displaystyle \quad \it { s y m m e t r y } \int _ { \mathbb R } ( - | x | ) \cdot ( f ( x ) - g ( x ) ) d x } } \end{array}$$
We are now able to proof Proposition 2
Proof to Proposition 2. Let $f$ denote the probability density function of $\mathcal { N } ( 0 , 1 )$ and $\begin{array} { r } { g = \frac { 1 } { 2 } g _ { - 1 } + } \end{array}$ $\textstyle { \frac { 1 } { 2 } } g _ { 1 }$ denote the sum of half the probability density functions $g _ { - 1 }$ of $\mathcal { N } ( - 1 , 1 )$ and $g _ { 1 }$ of $\mathcal { N } ( 1 , 1 )$ . Let
$$\tilde { f } ( x ) = \operatorname* { m a x } \left\{ 0 , \left( f ( x ) - g ( x ) \right) \right\} \mathrm { ~ a n d ~ } \tilde { g } ( x ) = \operatorname* { m a x } \left\{ 0 , \left( g ( x ) - f ( x ) \right) \right\} ,$$
i.e. $\tilde { f }$ and $\tilde { g }$ are the positive and the negative part of $( f - g )$ . Then $\tilde { f }$ and $\tilde { g }$ satisfy the hypothesis of Proposition 5 and the maximum
$$\operatorname* { m a x } _ { \phi \in \mathcal { L } i p _ { 1 } } \int _ { \mathbb { R } } \phi ( x ) ( f ( x ) - g ( x ) ) d x = \operatorname* { m a x } _ { \phi \in \mathcal { L } i p _ { 1 } } \int _ { \mathbb { R } } \phi ( x ) ( \tilde { f } ( x ) - \tilde { g } ( x ) ) d x$$
is obtained for $\phi ^ { * } ( x ) = - | x |$ .
# C.4 PROOF OF PROPOSITION 3
Proof. For any fixed function $f$ and $\lambda > 0$ , the two regularized losses of the critic function $f$ are of the form
$$\mathcal { L } _ { \lambda } ^ { L P } ( f ) = c + \lambda \int \operatorname* { m a x } \{ 0 , ( h ( z ) - 1 ) \} ^ { 2 } ) \mathrm { d } \tau ( z ) \mathrm { a n d } \mathcal { L } _ { \lambda } ^ { G P } ( f ) = c + \lambda \int ( h ( z ) - 1 ) ^ { 2 } ) \mathrm { d } \tau ( z )$$
for some real number $c$ , a function $h$ with with $h ( z ) \geq 0$ for all $z$ and a probability distribution $\tau$ Since for any real number $0 \leq a$ we have that
$$\operatorname* { m a x } \{ 0 , ( a - 1 ) \} ^ { 2 } \leq ( a - 1 ) ^ { 2 } \leq \operatorname* { m a x } \{ 0 , ( a - 1 ) \} ^ { 2 } + 1$$
it follows that
$$\begin{array} { r } { \mathcal { L } _ { \lambda } ^ { L P } ( f ) \leq \mathcal { L } _ { \lambda } ^ { G P } ( f ) \leq \mathcal { L } _ { \lambda } ^ { L P } ( f ) + \lambda . } \end{array}$$
Therefore the inequalities also hold for the infimum over a class of functions, hence
$$\begin{array} { r } { \mathcal { L } _ { \lambda } ^ { L P } \leq \mathcal { L } _ { \lambda } ^ { G P } \leq \mathcal { L } _ { \lambda } ^ { L P } + \lambda . } \end{array}$$
# C.5 THE ARGUMENTS SUPPORTING OBSERVATION 3
For the coupled pairs $( x , y )$ and $( x , y ^ { \prime } )$ we have that the partial derivatives at $x$ into the directions of $y$ and $y ^ { \prime }$ respectively have an absolute value of one. If there are two such directions and $f ^ { * }$ is differentiable, then the norm of its gradient must be larger than one, contradicting the 1-Lipschitz constraint. Indeed, recall that, considering $f$ as a function on the line $\{ x + \lambda \cdot v \mid \lambda \in \mathbb { R } \}$ with $v$ of unit length, the slope of $f$ at $x$ is given by $\nabla f ( x ) \cdot v = D _ { v } ( f ( x ) )$ . Now
$$\nabla f ( \boldsymbol { x } ) \cdot \boldsymbol { v } = | | \nabla f ( \boldsymbol { x } ) | | _ { 2 } \cdot \cos ( \theta _ { v } )$$
with $\theta _ { v }$ being the angle between the vector $\nabla f ( x )$ and the unit vector $v$ . Equation (10) with $\cos ( \theta _ { v } ) = 1$ has a unique solution for $v$ with $\begin{array} { r } { v \ = \ \frac { \nabla f ( x ) } { | | \nabla f ( x ) | | _ { 2 } } } \end{array}$ . It follows that, if for two different directions $v , v ^ { \prime }$ we have $D _ { v } ( f ( x ) ) = D _ { v ^ { \prime } } ( f ( x ) ) \ { = } \ 1$ , then $\cos ( \theta _ { v } ) \ = \ \cos ( \theta _ { v ^ { \prime } } ) \ < \ 1$ and $| | \nabla f ( x ) | | _ { 2 } > 1$ .
# D ADDITIONAL EXPERIMENTAL RESULTS
# D.1 LEVEL SETS OF THE CRITIC
 Figure 8: Level sets of the critic (yellow corresponds to high, purple to low values) of WGANs during training (after 10, 50, 100, 500, and 1000 iterations) on the 8Gaussian data set. Top: GPpenalty $\lambda = 1 0$ ). Middle: GP-penalty $\lambda = 1$ ). Bottom: LP-penalty $\lambda = 1 0$ ).
 Figure 9: Level sets of the critic (yellow corresponds to high, purple to low values) of WGANs during training (after 10, 50, 100, 500, and 1000 iterations) on the 25Gaussian data set. Top: GPpenalty $\lambda = 1 0$ ). Middle: GP-penalty $\lambda = 1$ ). Bottom: LP-penalty $\lambda = 1 0$ ).
 Figure 10: Evolution of the WGAN-GP critics loss without the regularization term $\lambda = 1$ ). Left: Median results over the 20 runs (blue area indicates quantiles, green dots outliers). Right: Single runs.
D.3 EVOLUTION OF THE EM DISTANCE
 Figure 11: Evolution of the approximated EM distance during training WGAN-GPs with $\lambda = 1$ . Left: Median results over the 10 runs. Right: Single runs.
# D.4 DIFFERENT SAMPLING METHODS
We analyzed the effect of the GP- and the LP-penalty using different sampling procedures. In particular, we compared the sampling procedure proposed by Gulrajani et al. (2017) with variants, which generate the samples used for the regularization term by adding random noise either onto training points or onto both training and generated samples. We refer to this as “local perturbation” in the following.7 The evolution of the critics loss when using this local perturbation can be seen in Figure 12. Results are qualitatively similar to those when using the sampling procedure proposed by Gulrajani et al. (2017). Interestingly, WGAN-GP training is stabilized at a later stage if one only adds noise to training examples and not to generated examples. This indicates that enforcing the GP-penalty close to the data manifold is less harmful. However, the critic’s loss is still much more fluctuating than when training a WGAN-LP.
The evolution of the approximated EM distance when using local perturbation (by adding noise to the training examples only) is shown in Figure 13. Training with the GP-penalty leads to larger fluctuations of the approximated Wasserstein-1 distance than training with the LP-penalty. However, fluctuations are less severe compared to the setting when the GP-penalty is used in combination with the sampling procedure proposed by Gulrajani et al. (2017).
 Figure 12: Evolution of the WGAN critic’s negative loss with local sampling (without the regularization term). Left: Median results over the 20 runs. Right: Single runs. Top: GP-penalty when generating samples by perturbing training samples only. Middle: For GP-penalty, perturbing training and generated samples. Bottom: LP-penalty, perturbing training and generated samples (very similar to perturbing only training samples)
 Figure 13: Evolution of the approximated EM distance during training of WGANs with local perturbation $\lambda = 5$ ). Left: Median results over the 10 runs. Right: Single runs. Top: For the GP-penalty. Bottom: For the LP-penalty
# D.5 OPTIMIZING THE WASSERSTEIN-2 DISTANCE
We trained a WGAN with the objective of minimizing the Wasserstein-2 distance8, that is, with the regularization term given by
$$\operatorname* { m a x } \left( \left\{ 0 , { \frac { | f ( x ) - f ( y ) | } { | | x - y | | _ { 2 } ^ { 2 } } } - 1 \right\} \right) ^ { 2 } \ ,$$
and penalty weight $\lambda = 1 0$ . Results for the evolution of the critics loss and the approximated EM distance during training on the Swiss Roll data set are shown in Figure 14. Both critic loss and EM reduce smoothly, which makes the Wasserstein-2 distance (in combination with its theoretical properties) an interesting candidate to further investigations.
 Figure 14: Evolution of the WGAN critics loss (Left) and the approximated EM distance (Right) for a WGAN-LP trained to minimize the Wasserstein-2 distance $\lambda = 1 0$ ). Shown are the medians over 5 runs.
# D.6 EXPERIMENTAL RESULTS ON CIFAR
Inception score. The inception score was proposed by Salimans et al. (2016) to evaluate the quality of images $x$ sampled from a generative model $\nu$ based on the Inception model. Let $p ( y | x )$ be the conditional probability of label $y$ for image $x$ under the Inception model and $\begin{array} { r } { p ( y ) = \int p ( y | x ) \nu ( x ) d x } \end{array}$ the marginal probability of labels $y$ with respect to samples generated from $\nu$ . Then the Inception score is given by
$$\exp \left( \mathbb { E } _ { x \sim \nu } [ K L ( p ( y | x ) , p ( y ) ] ) \right) \ .$$
Intuitively, a good generative model should produce samples for which the conditional label distribution has low entropy, while the variability over samples and thus the entropy of the marginal label distribution should be high. Therefore, a higher Inception score indicates a better performance of the generative model.
The maximal Inception scores reported in Table 1 are representative for the general evolution of the scores for WGAN-LP and WGAN-GP during training. As an example we show the evolution of the Inception score for penalty weights of $\lambda = 5$ and $\lambda = 1 0 0$ in Figure 15. It becomes clear that WGAN-GP performs similar to WGAN-LP for small values of the regularization parameter but much worse for larger values (this was consistently observed in all experiments). In Figure 16 we compare the performance of WGAN-LP and WGAN-GP in terms of the critics loss on a separate validation set, which again demonstrates a more stable behavior for WGAN-LP with respect to the choice of lambda.
 Figure 15: Evolution of Inception score on CIFAR for WGAN-LP in blue (solid) and WGAN-GP in red (dotted). Left: for regularization parameter $\lambda = 5$ . Right: for regularization parameter $\lambda = 1 0 0$ .
We also trained WGAN-GP and WGAN-LP with a conditional model (making use of the label information of CIFAR10) with $\lambda = 1 0$ and found a similar performance for both, i.e. $8 . 5 3 7 \pm 0 . 1 3 3$ and $8 . 4 6 2 \pm 0 . 1 1 5$ for WGAN-GP and WGAN-LP, respectively.
 Figure 16: Evolution of validation loss on CIFAR. Black/purple curves indicate the total loss, blue curves the loss without regularization term, and red the regularization term only. Light colored curves indicate the true values, dark solid lines the average over a window of 5 iterations. Left: WGAN-GP. Right: WGAN-LP. Top: with $\lambda = 5$ . Bottom: with $\lambda = 1 0 0$ .
# D.7 RELATED PENALTIES
Level sets for WGANs trained with the regularization terms given by Equation (7) and (9) and penalty weight 10 are shown in Figure 17. As the evolution of the level sets and the sampled points indicate, training properly converges. However, on CIFAR-10, the same penalties did not lead to good results. As shown in Figure 18, using (7) for regularization initially lead to improving Inception scores but then quickly started to diverge, while using (9) lead to even greater instability.
 Figure 17: Level sets of the critic $f$ of WGANs during training, after 10, 50, 100, 500, and 1000 iterations. Yellow corresponds to high, purple to low values of $f$ . Training samples are indicated in red, generated samples in blue. Top: With the regularization term given in Equation (7) and $\lambda = 1 0$ . Bottom: With the regularization term given in Equation (9) and $\lambda = 1 0$ .
 Figure 18: Inception scores for regularization Equation (7) for penalty weights 100 (red) and 5 (blue), shown on the left, and Inception scores for training with the regularization Equation (9) for penalty weights 100 (red) and 5 (blue), shown on the right.123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346# FEW-SHOT LEARNING WITH GRAPH NEURAL NETWORKS
Victor Garcia∗ Amsterdam Machine Learning Lab University of Amsterdam Amsterdam, 1098 XH, NL v.garciasatorras@uva.nl
Joan Bruna Courant Institute of Mathematical Sciences New York University New York City, NY, 10010, USA bruna@cims.nyu.edu
# ABSTRACT
We propose to study the problem of few-shot learning with the prism of inference on a partially observed graphical model, constructed from a collection of input images whose label can be either observed or not. By assimilating generic message-passing inference algorithms with their neural-network counterparts, we define a graph neural network architecture that generalizes several of the recently proposed few-shot learning models. Besides providing improved numerical performance, our framework is easily extended to variants of few-shot learning, such as semi-supervised or active learning, demonstrating the ability of graph-based models to operate well on ‘relational’ tasks.
# 1 INTRODUCTION
Supervised end-to-end learning has been extremely successful in computer vision, speech, or machine translation tasks, thanks to improvements in optimization technology, larger datasets and streamlined designs of deep convolutional or recurrent architectures. Despite these successes, this learning setup does not cover many aspects where learning is nonetheless possible and desirable.
One such instance is the ability to learn from few examples, in the so-called few-shot learning tasks. Rather than relying on regularization to compensate for the lack of data, researchers have explored ways to leverage a distribution of similar tasks, inspired by human learning Lake et al. (2015). This defines a new supervised learning setup (also called ‘meta-learning’) in which the input-output pairs are no longer given by iid samples of images and their associated labels, but by iid samples of collections of images and their associated label similarity.
A recent and highly-successful research program has exploited this meta-learning paradigm on the few-shot image classification task Lake et al. (2015); Koch et al. (2015); Vinyals et al. (2016); Mishra et al. (2017); Snell et al. (2017). In essence, these works learn a contextual, task-specific similarity measure, that first embeds input images using a CNN, and then learns how to combine the embedded images in the collection to propagate the label information towards the target image.
In particular, Vinyals et al. (2016) cast the few-shot learning problem as a supervised classification task mapping a support set of images into the desired label, and developed an end-to-end architecture accepting those support sets as input via attention mechanisms. In this work, we build upon this line of work, and argue that this task is naturally expressed as a supervised interpolation problem on a graph, where nodes are associated with the images in the collection, and edges are given by a trainable similarity kernels. Leveraging recent progress on representation learning for graphstructured data Bronstein et al. (2017); Gilmer et al. (2017), we thus propose a simple graph-based few-shot learning model that implements a task-driven message passing algorithm. The resulting architecture is trained end-to-end, captures the invariances of the task, such as permutations within the input collections, and offers a good tradeoff between simplicity, generality, performance and sample complexity.
Besides few-shot learning, a related task is the ability to learn from a mixture of labeled and unlabeled examples — semi-supervised learning, as well as active learning, in which the learner has the option to request those missing labels that will be most helpful for the prediction task. Our graphbased architecture is naturally extended to these setups with minimal changes in the training design. We validate experimentally the model on few-shot image classification, matching state-of-the-art performance with considerably fewer parameters, and demonstrate applications to semi-supervised and active learning setups.
Our contributions are summarized as follows:
• We cast few-shot learning as a supervised message passing task which is trained end-to-end using graph neural networks. • We match state-of-the-art performance on Omniglot and Mini-Imagenet tasks with fewer parameters. • We extend the model in the semi-supervised and active learning regimes.
The rest of the paper is structured as follows. Section 2 describes related work, Sections 3, 4 and 5 present the problem setup, our graph neural network model and the training, and Section 6 reports numerical experiments.
# 2 RELATED WORK
One-shot learning was first introduced by Fei-Fei et al. (2006), they assumed that currently learned classes can help to make predictions on new ones when just one or few labels are available. More recently, Lake et al. (2015) presented a Hierarchical Bayesian model that reached human level error on few-shot learning alphabet recongition tasks.
Since then, great progress has been done in one-shot learning. Koch et al. (2015) presented a deeplearning model based on computing the pair-wise distance between samples using Siamese Networks, then, this learned distance can be used to solve one-shot problems by $\mathbf { k }$ -nearest neighbors classification. Vinyals et al. (2016) Presented an end-to-end trainable $\mathbf { k }$ -nearest neighbors using the cosine distance, they also introduced a contextual mechanism using an attention LSTM model that takes into account all the samples of the subset $\tau$ when computing the pair-wise distance between samples. Snell et al. (2017) extended the work from Vinyals et al. (2016), by using euclidean distance instead of cosine which provided significant improvements, they also build a prototype representation of each class for the few-shot learning scenario. Mehrotra & Dukkipati (2017) trained a deep residual network together with a generative model to approximate the pair-wise distance between samples.
A new line of meta-learners for one-shot learning is rising lately: Ravi & Larochelle (2016) introduced a meta-learning method where an LSTM updates the weights of a classifier for a given episode. Munkhdalai & Yu (2017) also presented a meta-learning architecture that learns meta-level knowledge across tasks, and it changes its inductive bias via fast parametrization. Finn et al. (2017) is using a model agnostic meta-learner based on gradient descent, the goal is to train a classification model such that given a new task, a small amount of gradient steps with few data will be enough to generalize. Lately, Mishra et al. (2017) used Temporal Convolutions which are deep recurrent networks based on dilated convolutions, this method also exploits contextual information from the subset $\tau$ providing very good results.
Another related area of research concerns deep learning architectures on graph-structured data. The GNN was first proposed in Gori et al. (2005); Scarselli et al. (2009), as a trainable recurrent messagepassing whose fixed points could be adjusted discriminatively. Subsequent works Li et al. (2015); Sukhbaatar et al. (2016) have relaxed the model by untying the recurrent layer weights and proposed several nonlinear updates through gating mechanisms. Graph neural networks are in fact natural generalizations of convolutional networks to non-Euclidean graphs. Bruna et al. (2013); Henaff et al. (2015) proposed to learn smooth spectral multipliers of the graph Laplacian, albeit with high computational cost, and Defferrard et al. (2016); Kipf & Welling (2016) resolved the computational bottleneck by learning polynomials of the graph Laplacian, thus avoiding the computation of eigenvectors and completing the connection with GNNs. In particular, Kipf & Welling (2016) was the first to propose the use of GNNs on semi-supervised classification problems. We refer the reader to Bronstein et al. (2017) for an exhaustive literature review on the topic. GNNs and the analogous Neural Message Passing Models are finding application in many different domains. Battaglia et al.
(2016); Chang et al. (2016) develop graph interaction networks that learn pairwise particle interactions and apply them to discrete particle physical dynamics. Duvenaud et al. (2015); Kearnes et al. (2016) study molecular fingerprints using variants of the GNN architecture, and Gilmer et al. (2017) further develop the model by combining it with set representations Vinyals et al. (2015), showing state-of-the-art results on molecular prediction.
# 3 PROBLEM SET-UP
We describe first the general setup and notations, and then particularize it to the case of few-shot learning, semi-supervised learning and active learning.
We consider input-output pairs $( \mathcal { T } _ { i } , Y _ { i } ) _ { i }$ drawn iid from a distribution $P$ of partially-labeled image collections
$$\begin{array} { r c l } { { { \cal T } } } & { { = } } & { { \{ \{ ( x _ { 1 } , l _ { 1 } ) , \dots ( x _ { s } , l _ { s } ) \} , \{ \tilde { x } _ { 1 } , \dots , \tilde { x } _ { r } \} , \{ \bar { x } _ { 1 } , \dots , \bar { x } _ { t } \} ; l _ { i } \in \{ 1 , K \} , x _ { i } , \tilde { x } _ { j } , \bar { x } _ { j } \sim \{ \mathcal { P } _ { l } ( \mathbb { R } ^ { N } ) \} \} , } } \\ { { { \cal Y } } } & { { = } } & { { ( y _ { 1 } , \dots , y _ { t } ) \in \{ 1 , K \} ^ { t } , } } \\ { { } } & { { } } & { { ( 1 ) } } \end{array}$$
for arbitrary values of $s , r , t$ and $K$ . Where $s$ is the number of labeled samples, $r$ is the number of unlabeled samples $r > 0$ for the semi-supervised and active learning scenarios) and $t$ is the number of samples to classify. $K$ is the number of classes. We will focus in the case $t = 1$ where we just classify one sample per task $\tau$ . $\mathcal { P } _ { l } ( \mathbb { R } ^ { N } )$ denotes a class-specific image distribution over $\mathbb { R } ^ { N }$ . In our context, the targets $Y _ { i }$ are associated with image categories of designated images $\bar { x } _ { 1 } , \ldots , \bar { x } _ { t } \in \mathcal { T } _ { i }$ with no observed label. Given a training set $\{ ( \mathcal { T } _ { i } , Y _ { i } ) _ { i } \} _ { i \leq L }$ , we consider the standard supervised learning objective
$$\operatorname* { m i n } _ { \Theta } \frac { 1 } { L } \sum _ { i \leq L } \ell ( \Phi ( \mathcal { T } _ { i } ; \Theta ) , Y _ { i } ) + \mathcal { R } ( \Theta ) ,$$
using the model $\Phi ( { \mathcal { T } } ; \Theta ) = p ( Y \mid { \mathcal { T } } )$ specified in Section 4 and $\mathcal { R }$ is a standard regularization objective.
Few-Shot Learning When $r = 0$ , $t = 1$ and $s = q K$ , there is a single image in the collection with unknown label. If moreover each label appears exactly $q$ times, this setting is referred as the $q$ -shot, $K$ -way learning.
Semi-Supervised Learning When $r > 0$ and $t = 1$ , the input collection contains auxiliary images $\tilde { x } _ { 1 } , \ldots , \tilde { x } _ { r }$ that the model can use to improve the prediction accuracy, by leveraging the fact that these samples are drawn from common distributions as those determining the output.
Active Learning In the active learning setting, the learner has the ability to request labels from the sub-collection $\{ \tilde { x } _ { 1 } , \ldots , \tilde { x } _ { r } \}$ . We are interested in studying to what extent this active learning can improve the performance with respect to the previous semi-supervised setup, and match the performance of the one-shot learning setting with $s _ { 0 }$ known labels when $s + r = s _ { 0 }$ , $s \ll s _ { 0 }$ .
# 4 MODEL
This section presents our approach, based on a simple end-to-end graph neural network architecture. We first explain how the input context is mapped into a graphical representation, then detail the architecture, and next show how this model generalizes a number of previously published few-shot learning architectures.
# 4.1 SET AND GRAPH INPUT REPRESENTATIONS
The input $\tau$ contains a collection of images, both labeled and unlabeled. The goal of few-shot learning is to propagate label information from labeled samples towards the unlabeled query image. This propagation of information can be formalized as a posterior inference over a graphical model determined by the input images and labels.
Following several recent works that cast posterior inference using message passing with neural networks defined over graphs Scarselli et al. (2009); Duvenaud et al. (2015); Gilmer et al. (2017), we associate $\tau$ with a fully-connected graph $G _ { \mathcal { T } } = ( V , E )$ where nodes $v _ { a } \in V$ correspond to the images present in $\tau$ (both labeled and unlabeled). In this context, the setup does not specify a fixed similarity $e _ { a , a ^ { \prime } }$ between images $x _ { a }$ and $x _ { a ^ { \prime } }$ , suggesting an approach where this similarity measure is learnt in a discriminative fashion with a parametric model similarly as in Gilmer et al. (2017), such as a siamese neural architecture. This framework is closely related to the set representation from Vinyals et al. (2016), but extends the inference mechanism using the graph neural network formalism that we detail next.
 Figure 1: Visual representation of One-Shot Learning setting.
# 4.2 GRAPH NEURAL NETWORKS
Graph Neural Networks, introduced in Gori et al. (2005); Scarselli et al. (2009) and further simplified in Li et al. (2015); Duvenaud et al. (2015); Sukhbaatar et al. (2016) are neural networks based on local operators of a graph $G = ( V , E )$ , offering a powerful balance between expressivity and sample complexity; see Bronstein et al. (2017) for a recent survey on models and applications of deep learning on graphs.
In its simplest incarnation, given an input signal $F \in \mathbb { R } ^ { V \times d }$ on the vertices of a weighted graph $G$ , we consider a family $\mathcal { A }$ of graph intrinsic linear operators that act locally on this signal. The simplest is the adjacency operator $\mathsf { \bar { A } } : \mathsf { F } \mapsto A ( F )$ where $\begin{array} { r } { ( A F ) _ { i } : = \sum _ { j \sim i } w _ { i , j } \mathbf { \bar { F } } _ { j } } \end{array}$ , with $i \sim j$ iff $( i , j ) \in E$ and $w _ { i , j }$ its associated weight. A GNN layer $\operatorname { G c } ( \cdot )$ receives as input a signal $\mathbf { x } ^ { ( k ) } \in \mathbb { R } ^ { V \times d _ { k } }$ and produces $\mathbf { x } ^ { ( k + 1 ) } \in \mathbb { R } ^ { V \times d _ { k + 1 } }$ as
$${ \bf x } _ { l } ^ { ( k + 1 ) } = { \bf G } { \bf c } ( { \bf x } ^ { ( k ) } ) = \rho \left( \sum _ { B \in \mathcal { A } } B { \bf x } ^ { ( k ) } \theta _ { B , l } ^ { ( k ) } \right) \mathrm { ~ , ~ } l = d _ { 1 } \mathrm { ~ . ~ . ~ } d _ { k + 1 } \mathrm { ~ , ~ }$$
where $\Theta = \{ \theta _ { 1 } ^ { ( k ) } , \dots , \theta _ { | \mathcal { A } | } ^ { ( k ) } \} _ { k }$ , ${ \boldsymbol { \theta } _ { B } ^ { ( k ) } \in \mathbb { R } ^ { d _ { k } \times d _ { k + 1 } } }$ , are trainable parameters and $\rho ( \cdot )$ is a point-wise non-linearity, chosen in this work to be a ‘leaky’ ReLU et al. (2015).
Authors have explored several modeling variants from this basic formulation, by replacing the pointwise nonlinearity with gating operations Duvenaud et al. (2015), or by generalizing the generator family to Laplacian polynomials Defferrard et al. (2016); Kipf & Welling (2016); Bruna et al. (2013), or including $2 ^ { J }$ -th powers of $A$ to $\mathcal { A }$ , $A _ { J } = \operatorname* { m i n } ( 1 , A ^ { 2 ^ { J } } )$ to encode $2 ^ { J }$ -hop neighborhoods of each node Bruna & Li (2017). Cascaded operations in the form (2) are able to approximate a wide range of graph inference tasks. In particular, inspired by message-passing algorithms, Kearnes et al. (2016); Gilmer et al. (2017) generalized the GNN to also learn edge features $\tilde { A } ^ { ( k ) }$ from the current node hidden representation:
$$\tilde { A } _ { i , j } ^ { ( k ) } = \varphi _ { \tilde { \theta } } ( \mathbf { x } _ { i } ^ { ( k ) } , \mathbf { x } _ { j } ^ { ( k ) } ) ,$$
 Figure 2: Graph Neural Network ilustration. The Adjacency matrix is computed before every Convolutional Layer.
where $\varphi$ is a symmetric function parametrized with e.g. a neural network. In this work, we consider a Multilayer Perceptron stacked after the absolute difference between two vector nodes. See eq. 4:
$$\varphi _ { \tilde { \theta } } ( \mathbf { x } _ { i } ^ { ( k ) } , \mathbf { x } _ { j } ^ { ( k ) } ) = \mathbf { M L P } _ { \tilde { \theta } } ( a b s ( \mathbf { x } _ { i } ^ { ( k ) } - \mathbf { x } _ { j } ^ { ( k ) } ) )$$
Then $\varphi$ is a metric, which is learned by doing a non-linear combination of the absolute difference between the individual features of two nodes. Using this architecture the distance property Symmetry $\varphi _ { \tilde { \theta } } ( a , b ) = \varphi _ { \tilde { \theta } } ( b , a )$ is fulfilled by construction and the distance property Identity $\varphi _ { \tilde { \theta } } ( a , a ) = 0$ is easily learned.
The trainable adjacency is then normalized to a stochastic kernel by using a softmax along each row. The resulting update rules for node features are obtained by adding the edge feature kernel $\tilde { A } ^ { ( k ) }$ into the generator family $\mathcal { A } = \{ \tilde { A } ^ { ( k ) } , \mathbf { 1 } \}$ and applying (2). Adjacency learning is particularly important in applications where the input set is believed to have some geometric structure, but the metric is not known a priori, such as is our case.
In general graphs, the network depth is chosen to be of the order of the graph diameter, so that all nodes obtain information from the entire graph. In our context, however, since the graph is densely connected, the depth is interpreted simply as giving the model more expressive power.
Construction of Initial Node Features The input collection $\tau$ is mapped into node features as follows. For images $x _ { i } \in \mathcal T$ with known label $l _ { i }$ , the one-hot encoding of the label is concatenated with the embedding features of the image at the input of the GNN.
$$\mathbf { x } _ { i } ^ { ( 0 ) } = \left( \phi ( { x } _ { i } ) , h ( l _ { i } ) \right) ,$$
where $\phi$ is a Convolutional neural network and $h ( l ) \ \in \ \mathbb { R } _ { + } ^ { K }$ is a one-hot encoding of the label. Architectural details for $\phi$ are detailed in Section 6.1.1 and 6.1.2. For images $\tilde { x } _ { j } , \bar { x } _ { j ^ { \prime } }$ with unknown label $l _ { i }$ , we modify the previous construction to account for full uncertainty about the label variable by replacing $h ( l )$ with the uniform distribution over the $K$ -simplex: $V _ { j } \doteq ( \phi ( \tilde { x } _ { j } ) , K ^ { - 1 } \mathbf { 1 } _ { K } )$ , and analogously for $\bar { x }$ .
# 4.3 RELATIONSHIP WITH EXISTING MODELS
The graph neural network formulation of few-shot learning generalizes a number of recent models proposed in the literature.
Siamese Networks Siamese Networks Koch et al. (2015) can be interpreted as a single layer message-passing iteration of our model, and using the same initial node embedding (5) $\mathbf { x } _ { i } ^ { ( 0 ) } =$ $( \phi ( x _ { i } ) , h _ { i } )$ , using a non-trainable edge feature
$$\varphi ( \mathbf { x } _ { i } , \mathbf { x } _ { j } ) = \lVert \phi ( x _ { i } ) - \phi ( x _ { j } ) \rVert , \tilde { A } ^ { ( 0 ) } = \mathrm { s o f t m a x } ( - \varphi ) ,$$
and resulting label estimation
$$\hat { Y } _ { * } = \sum _ { j } \tilde { A } _ { * , j } ^ { ( 0 ) } \langle \mathbf { x } _ { j } ^ { ( 0 ) } , u \rangle ,$$
with $u$ selecting the label field from $\mathbf { x }$ . In this model, the learning is reduced to learning image embeddings $\phi ( x _ { i } )$ whose euclidean metric is consistent with the label similarities.
Prototypical Networks Prototypical networks Snell et al. (2017) evolve Siamese networks by aggregating information within each cluster determined by nodes with the same label. This operation can also be accomplished with a gnn as follows. we consider
$$\tilde { A } _ { i , j } ^ { ( 0 ) } = \left\{ \begin{array} { c c } { q ^ { - 1 } } & { \mathrm { i f } l _ { i } = l _ { j } } \\ { 0 } & { \mathrm { o t h e r w i s e . } } \end{array} \right.$$
where $q$ is the number of examples per class, and
$$\mathbf { x } _ { i } ^ { ( 1 ) } = \sum _ { j } \tilde { A } _ { i , j } ^ { ( 0 ) } \mathbf { x } _ { j } ^ { ( 0 ) } ,$$
where $\mathbf { x } ^ { ( 0 ) }$ is defined as in the Siamese Networks. We finally apply the previous kernel $\tilde { A } ^ { ( 1 ) } =$ softmax $\left( \varphi \right)$ applied to $\mathbf { x } ^ { ( 1 ) }$ to yield class prototypes:
$$\hat { Y } _ { * } = \sum _ { j } \tilde { A } _ { * , j } ^ { ( 1 ) } \langle \mathbf { x } _ { j } ^ { ( 1 ) } , u \rangle .$$
Matching Networks Matching networks Vinyals et al. (2016) use a set representation for the ensemble of images in $\tau$ , similarly as our proposed graph neural network model, but with two important differences. First, the attention mechanism considered in this set representation is akin to the edge feature learning, with the difference that the mechanism attends always to the same node embeddings, as opposed to our stacked adjacency learning, which is closer to Vaswani et al. (2017). In other words, instead of the attention kernel in (3), matching networks consider attention mechanisms of the form A˜(k)∗,j $\tilde { A } _ { * , j } ^ { ( k ) } = \varphi ( \mathbf { x } _ { * } ^ { ( k ) } , \mathbf { x } _ { j } ^ { ( T ) } )$ , where $\underset { - } { \mathbf { x } _ { j } ^ { ( T ) } }$ is the encoding function for the elements of the support set, obtained with bidirectional LSTMs. In that case, the support set encoding is thus computed independently of the target image. Second, the label and image fields are treated separately throughout the model, with a final step that aggregates linearly the labels using a trained kernel. This may prevent the model to leverage complex dependencies between labels and images at intermediate stages.
# 5 TRAINING
We describe next how to train the parameters of the GNN in the different setups we consider: fewshot learning, semi-supervised learning and active learning.
# 5.1 FEW-SHOT AND SEMI-SUPERVISED LEARNING
In this setup, the model is asked only to predict the label $Y$ corresponding to the image to classify $\bar { x } \in \tau$ , associated with node $^ *$ in the graph. The final layer of the GNN is thus a softmax mapping the node features to the $K$ -simplex. We then consider the Cross-entropy loss evaluated at node $^ *$ :
$$\ell ( \Phi ( \mathcal { T } ; \Theta ) , Y ) = - \sum _ { k } y _ { k } \log P ( Y _ { * } = y _ { k } \mid \mathcal { T } ) .$$
The semi-supervised setting is trained identically — the only difference is that the initial label fields of the node will be filled with the uniform distribution on nodes corresponding to $\tilde { x } _ { j }$ .
# 5.2 ACTIVE LEARNING
In the Active Learning setup, the model has the intrinsic ability to query for one of the labels from $\{ \tilde { x } _ { 1 } , \ldots , \tilde { x } _ { r } \}$ . The network will learn to ask for the most informative label in order to classify the sample $\bar { x } \in \mathcal { T }$ . The querying is done after the first layer of the GNN by using a Softmax attention over the unlabeled nodes of the graph. For this we apply a function $g ( \mathbf { x } _ { i } ^ { ( 1 ) } ) \in \mathbb { R } ^ { 1 }$ that maps each unlabeled vector node to a scalar value. Function $g$ is parametrized by a two layers neural network. A Softmax is applied over the $\{ 1 , \ldots , r \}$ scalar values obtained after applying $g$ :
$$\mathrm { A t t e n t i o n } = \mathrm { S o f t m a x } ( g ( \mathbf { x } _ { \{ 1 , \dots , r \} } ^ { ( 1 ) } ) )$$
In order to query only one sample, we set all elements from the $A t t e n t i o n \in \mathbb { R } ^ { r }$ vector to 0 except for one. At test time we keep the maximum value, at train time we randomly sample one value based on its multinomial probability. Then we multiply this sampled attention by the label vectors:
$$w \cdot h ( l _ { i ^ { * } } ) = \langle \mathrm { A t t e n t i o n } ^ { \prime } , h ( l _ { \{ 1 , \dots , r \} } ) \rangle$$
The label of the queried vector $h ( l _ { i ^ { * } } )$ is obtained, scaled by the weight $w \in ( 0 , 1 )$ . This value is then summed to the current representation $\mathbf { x } _ { i ^ { * } } ^ { ( 1 ) }$ , since we are using dense connections in our GNN model we can sum this $w \cdot h ( l _ { i ^ { * } } )$ value directly to where the uniform label distribution was concatenated
$$\mathbf { x } _ { i ^ { * } } ^ { ( 1 ) } = [ \mathbf { G c } ( \mathbf { x } _ { i ^ { * } } ^ { ( 0 ) } ) , \mathbf { x } _ { i ^ { * } } ^ { ( 0 ) } ] = [ \mathbf { G c } ( \mathbf { x } _ { i ^ { * } } ^ { ( 0 ) } ) , ( \phi ( x _ { i ^ { * } } ) , h ( l _ { i ^ { * } } ) ) ]$$
After the label has been summed to the current node, the information is forward propagated. This attention part is trained end-to-end with the rest of the network by backpropagating the loss from the output of the GNN.
# 6 EXPERIMENTS
For the few-shot, semi-supervised and active learning experiments we used the Omniglot dataset presented by Lake et al. (2015) and Mini-Imagenet dataset introduced by Vinyals et al. (2016) which is a small version of ILSVRC-12 Krizhevsky et al. (2012). All experiments are based on the $q$ -shot, $K$ -way setting. For all experiments we used the same values $q$ -shot and $K$ -way for both training and testing.
Code available at: https://github.com/vgsatorras/few-shot-gnn
# 6.1 DATASETS AND IMPLEMENTATION
# 6.1.1 OMNIGLOT
Dataset: Omniglot is a dataset of 1623 characters from 50 different alphabets, each character/class has been drawn by 20 different people. Following Vinyals et al. (2016) implementation we split the dataset into 1200 classes for training and the remaining 423 for testing. We augmented the dataset by multiples of 90 degrees as proposed by Santoro et al. (2016).
Architectures: Inspired by the embedding architecture from Vinyals et al. (2016), following Mishra et al. (2017), a CNN was used as an embedding $\phi$ function consisting of four stacked blocks of $\{ 3 \times 3$ -convolutional layer with 64 filters, batch-normalization, $2 \times 2$ max-pooling, leaky-relu} the output is passed through a fully connected layer resulting in a 64-dimensional embedding. For the GNN we used 3 blocks each of them composed by 1) a module that computes the adjacency matrix and 2) a graph convolutional layer. A more detailed description of each block can be found at Figure 3.
# 6.1.2 MINI-IMAGENET
Dataset: Mini-Imagenet is a more challenging dataset for one-shot learning proposed by Vinyals et al. (2016) derived from the original ILSVRC-12 dataset Krizhevsky et al. (2012). It consists of $8 4 \times 8 4$ RGB images from 100 different classes with 600 samples per class. It was created with the purpose of increasing the complexity for one-shot tasks while keeping the simplicity of a light size dataset, that makes it suitable for fast prototyping. We used the splits proposed by Ravi & Larochelle (2016) of 64 classes for training, 16 for validation and 20 for testing. Using 64 classes for training, and the 16 validation classes only for early stopping and parameter tuning.
Architecture: The embedding architecture used for Mini-Imagenet is formed by 4 convolutional layers followed by a fully-connected layer resulting in a 128 dimensional embedding. This light architecture is useful for fast prototyping:
$1 \times \{ 3 \times 3$ -conv. layer (64 filters), batch normalization, max pool $( 2 , 2 )$ , leaky relu $\}$ , $1 \times \{ 3 \times 3$ -conv. layer (96 filters), batch normalization, max $\mathrm { p o o l } ( 2 , 2 )$ , leaky relu}, $1 \times \{ 3 \times 3$ -conv. layer (128 filters), batch normalization, max $\mathrm { p o o l } ( 2 , 2 )$ , leaky relu, dropout $\left( 0 . 5 \right) \}$ , $1 \times \{ 3 \times 3$ -conv. layer (256 filters), batch normalization, max $\mathrm { p o o l } ( 2 , 2 )$ , leaky relu, dropout $\left( 0 . 5 \right) \}$ , $1 \times \left\{ \begin{array} { r l } \end{array} \right.$ fc-layer (128 filters), batch normalization}.
The two dropout layers are useful to avoid overfitting the GNN in Mini-Imagenet dataset. The GNN architecture is similar than for Omniglot, it is formed by 3 blocks, each block is described at Figure 3.
# 6.2 FEW-SHOT
Few-shot learning experiments for Omniglot and Mini-Imagenet are presented at Table 1 and Table 2 respectively.
We evaluate our model by performing different ${ \bf q }$ -shot, K-way experiments on both datasets. For every few-shot task $\tau$ , we sample $K$ random classes from the dataset, and from each class we sample $q$ random samples. An extra sample to classify is chosen from one of that $K$ classes.
Omniglot: The GNN method is providing competitive results while still remaining simpler than other methods. State of the art results are reached in the 5-Way and 20-way 1-shot experiments. In the 20-Way 1-shot setting the GNN is providing slightly better results than Munkhdalai & Yu (2017) while still being a more simple approach. The TCML approach from Mishra et al. (2017) is in the same confidence interval for 3 out of 4 experiments, but it is slightly better for the 20-Way 5-shot, although the number of parameters is reduced from ${ \sim } 5 \mathbf { M }$ (TCML) to $\sim 3 0 0 \mathrm { K }$ (3 layers GNN).
At Mini-Imagenet table we are also presenting a baseline ”Our metric learning $\mathbf { \chi } + K N N ^ { \prime }$ where no information has been aggregated among nodes, it is a K-nearest neighbors applied on top of the pair-wise learnable metric $\bar { \varphi _ { \theta } } ( \mathbf { x } _ { i } ^ { ( 0 ) } , \mathbf { x } _ { j } ^ { ( 0 ) } )$ and trained end-to-end, this learnable metric is competitive by itself compared to other state of the art methods. Even so, a significant improvement (from $6 4 . 0 2 \%$ to $6 6 . 4 1 \%$ ) can be seen for the 5-shot 5-Way Mini-Imagenet setting when aggregating information among nodes by using the full GNN architecture. A variety of embedding functions $\phi$ are used among the different papers for Mini-Imagenet experiments, in our case we are using a simple network of 4 conv. layers followed by a fully connected layer (Section 6.1.2) which served us to compare between Our GNN and Our metric learning $+ ~ K N N$ and it is useful for fast prototyping. More complex embeddings have proven to produce better results, at Mishra et al. (2017) a deep residual network is used as embedding network $\phi$ increasing the accuracy considerably. Regarding the TCML architecture in Mini-Imagenet, the number of parameters is reduced from ${ \sim } 1 1 \mathbf { M }$ (TCML) to ${ \sim } 4 0 0 \mathrm { K }$ (3 layers GNN).
<table><tr><td rowspan="2"></td><td colspan="2"> 5-Way</td><td colspan="2">20-Way</td></tr><tr><td>1-shot</td><td>5-shot</td><td>1-shot</td><td>5-shot</td></tr><tr><td>Model Pixels Vinyals et al. (2016)</td><td>41.7%</td><td>63.2%</td><td>26.7%</td><td>42.6%</td></tr><tr><td>Siamese Net Koch et al. (2015)</td><td>97.3%</td><td>98.4%</td><td>88.2%</td><td>97.0%</td></tr><tr><td>Matching Networks Vinyals et al. (2016)</td><td>98.1%</td><td>98.9%</td><td>93.8%</td><td>98.5%</td></tr><tr><td>N.Statistician Edwards & Storkey (2016)</td><td>98.1%</td><td>99.5%</td><td>93.2%</td><td>98.1%</td></tr><tr><td>Res.Pair-Wise Mehrotra & Dukkipati (2017)</td><td>-</td><td>-</td><td>94.8%</td><td>-</td></tr><tr><td>Prototypical Networks Snellet al. (2017)</td><td>97.4%</td><td>99.3%</td><td>95.4%</td><td>98.8%</td></tr><tr><td>ConvNet with Memory Kaiser et al. (2017)</td><td>98.4%</td><td>99.6%</td><td>95.0%</td><td>98.6%</td></tr><tr><td>Agnostic Meta-learner Finn et al. (2017)</td><td>98.7 ±0.4%</td><td>99.9 ±0.3%</td><td>95.8 ±0.3%</td><td>98.9 ±0.2%</td></tr><tr><td>MetaNetworks Munkhdalai& Yu (2017)</td><td>98.9%</td><td>=</td><td>97.0%</td><td></td></tr><tr><td>TCML Mishra et al. (2017)</td><td></td><td>98.96% ±0.20% 99.75% ±0.11% 97.64% ±0.30% 99.36% ±0.18%</td><td></td><td></td></tr><tr><td>Our GNN</td><td>99.2%</td><td>99.7%</td><td>97.4%</td><td>99.0%</td></tr></table>
Table 1: Few-Shot Learning — Omniglot accuracies. Siamese Net results are extracted from Vinyals et al. (2016) reimplementation.
Table 2: Few-shot learning — Mini-Imagenet average accuracies with $9 5 \%$ confidence intervals.
<table><tr><td rowspan="2">Model</td><td colspan="2">5-Way</td></tr><tr><td>1-shot</td><td>5-shot</td></tr><tr><td>Matching Networks Vinyals et al. (2016)</td><td>43.6%</td><td>55.3%</td></tr><tr><td>Prototypical Networks Snel et al. (2017)</td><td>46.61% ±0.78%</td><td>65.77% ±0.70%</td></tr><tr><td>Model Agnostic Meta-learner Finn et al. (2017)</td><td>48.70% ±1.84%</td><td>63.1% ±0.92%</td></tr><tr><td>Meta Networks Munkhdalai & Yu (2017)</td><td>49.21% ±0.96</td><td></td></tr><tr><td>Ravi &Larochelle Ravi & Larochelle (2016)</td><td>43.4% ±0.77%</td><td>60.2% ±0.71%</td></tr><tr><td>TCML Mishra et al. (2017)</td><td>55.71% ±0.99%</td><td>68.88% ±0.92%</td></tr><tr><td>Our metric learning + KNN</td><td>49.44% ±0.28%</td><td>64.02% ±0.51%</td></tr><tr><td>Our GNN</td><td>50.33% ±0.36%</td><td>66.41% ±0.63%</td></tr></table>
# 6.3 SEMI-SUPERVISED
Semi-supervised experiments are performed on the 5-way 5-shot setting. Different results are presented when $20 \%$ and $40 \%$ of the samples are labeled. The labeled samples are balanced among classes in all experiments, in other words, all the classes have the same amount of labeled and unlabeled samples.
Two strategies can be seen at Tables 3 and 4. ”GNN - Trained only with labeled” is equivalent to the supervised few-shot setting, for example, in the 5-Way 5-shot $20 \%$ -labeled setting, this method is equivalent to the 5-way 1-shot learning setting since it is ignoring the unlabeled samples. ”GNN - Semi supervised” is the actual semi-supervised method, for example, in the 5-Way 5-shot $20 \%$ - labeled setting, the GNN receives as input 1 labeled sample per class and 4 unlabeled samples per class.
Omniglot results are presented at Table 3, for this scenario we observe that the accuracy improvement is similar when adding images than when adding labels. The GNN is able to extract information from the input distribution of unlabeled samples such that only using $20 \%$ of the labels in a 5-shot semi-supervised environment we get same results as in the $40 \%$ supervised setting.
In Mini-Imagenet experiments, Table 4, we also notice an improvement when using semi-supervised data although it is not as significant as in Omniglot. The distribution of Mini-Imagenet images is more complex than for Omniglot. In spite of it, the GNN manages to improve by ${ \sim } 2 \%$ in the $20 \%$ and $40 \%$ settings.
Table 3: Semi-Supervised Learning — Omniglot accuracies.
<table><tr><td></td><td colspan="3">5-Way 5-shot</td></tr><tr><td>Model</td><td>20%-labeled</td><td>40%-labeled</td><td>100 %-labeled</td></tr><tr><td>GNN - Trained only with labeled</td><td>99.18%</td><td>99.59%</td><td>99.71%</td></tr><tr><td>GNN -Semi supervised</td><td>99.59%</td><td>99.63%</td><td>99.71%</td></tr></table>
Table 4: Semi-Supervised Learning — Mini-Imagenet average accuracies with $9 5 \%$ confidence intervals.
<table><tr><td></td><td colspan="3">5-Way 5-shot</td></tr><tr><td>Model</td><td>20%-labeled</td><td>40%-labeled</td><td>100 %-labeled</td></tr><tr><td>GNN - Trainedonlywithlabeled</td><td>50.33% ±0.36%</td><td>56.91% ±0.42%</td><td>66.41% ±0.63%</td></tr><tr><td>GNN - Semi supervised</td><td>52.45% ±0.88%</td><td>58.76% ±0.86%</td><td>66.41% ±0.63%</td></tr></table>
# 6.4 ACTIVE LEARNING
We performed Active Learning experiments on the 5-Way 5-shot set-up when $20 \%$ of the samples are labeled. In this scenario our network will query for the label of one sample from the unlabeled ones. The results are compared with the Random baseline where the network chooses a random sample to be labeled instead of one that maximally reduces the loss of the classification task $\tau$ .
Results are shown at Table 5. The results of the GNN-Random criterion are close to the Semisupervised results for $20 \%$ -labeled samples from Tables 3 and 4. It means that selecting one random label practically does not improve the accuracy at all. When using the GNN-AL learned criterion, we notice an improvement of $\sim 3 . 4 \%$ for Mini-Imagenet, it means that the GNN manages to correctly choose a more informative sample than a random one. In Omniglot the improvement is smaller since the accuracy is almost saturated and the improving margin is less.
<table><tr><td>Method</td><td>5-Way 5-shot20%-labeled</td><td>Method</td><td>5-Way 5-shot 20%-labeled</td></tr><tr><td>GNN - AL</td><td>99.62%</td><td>GNN - AL</td><td>55.99% ±1.35%</td></tr><tr><td>GNN - Random</td><td>99.59%</td><td>GNN - Random</td><td>52.56% ±1.18%</td></tr></table>
Table 5: Omniglot (left) and Mini-Imagneet (right), average accuracies are shown at both tables, the GNN-AL is the learned criterion that performs Active Learning by selecting the sample that will maximally reduce the loss of the current classification. The GNN - Random is also selecting one sample, but in this case a random one. Mini-Imagenet results are presented with $9 5 \%$ confidence intervals.
# 7 CONCLUSIONS
This paper explored graph neural representations for few-shot, semi-supervised and active learning. From the meta-learning perspective, these tasks become supervised learning problems where the input is given by a collection or set of elements, whose relational structure can be leveraged with neural message passing models. In particular, stacked node and edge features generalize the contextual similarity learning underpinning previous few-shot learning models.
The graph formulation is helpful to unify several training setups (few-shot, active, semi-supervised) under the same framework, a necessary step towards the goal of having a single learner which is able to operate simultaneously in different regimes (stream of labels with few examples per class, or stream of examples with few labels). This general goal requires scaling up graph models to millions of nodes, motivating graph hierarchical and coarsening approaches Defferrard et al. (2016).
Another future direction is to generalize the scope of Active Learning, to include e.g. the ability to ask questions Rothe et al. (2017), or in reinforcement learning setups, where few-shot learning is critical to adapt to non-stationary environments.
# ACKNOWLEDGMENTS
This work was partly supported by Samsung Electronics (Improving Deep Learning using Latent Structure).
# REFERENCES
Peter Battaglia, Razvan Pascanu, Matthew Lai, Danilo Jimenez Rezende, et al. Interaction networks for learning about objects, relations and physics. In Advances in Neural Information Processing Systems, pp. 4502–4510, 2016.
Michael M Bronstein, Joan Bruna, Yann LeCun, Arthur Szlam, and Pierre Vandergheynst. Geometric deep learning: going beyond euclidean data. IEEE Signal Processing Magazine, 34(4):18–42, 2017.
Joan Bruna and Xiang Li. Community detection with graph neural networks. arXiv preprint arXiv:1705.08415, 2017.
Joan Bruna, Wojciech Zaremba, Arthur Szlam, and Yann LeCun. Spectral networks and locally connected networks on graphs. Proc. ICLR, 2013.
Michael B. Chang, Tomer Ullman, Antonio Torralba, and Joshua B. Tenenbaum. A compositional object-based approach to learning physical dynamics. ICLR, 2016.
Michael Defferrard, Xavier Bresson, and Pierre Vandergheynst. Convolutional neural networks¨ on graphs with fast localized spectral filtering. In Advances in Neural Information Processing Systems, pp. 3837–3845, 2016.
David Duvenaud, Dougal Maclaurin, Jorge Aguilera-Iparraguirre, Rafael Gomez-Bombarelli, Tim- ´ othy Hirzel, Alan Aspuru-Guzik, and Ryan P Adams. Convolutional networks on graphs for ´ learning molecular fingerprints. In Neural Information Processing Systems, 2015.
Harrison Edwards and Amos Storkey. Towards a neural statistician. arXiv preprint arXiv:1606.02185, 2016.
Li Fei-Fei, Rob Fergus, and Pietro Perona. One-shot learning of object categories. IEEE transactions on pattern analysis and machine intelligence, 28(4):594–611, 2006.
Chelsea Finn, Pieter Abbeel, and Sergey Levine. Model-agnostic meta-learning for fast adaptation of deep networks. arXiv preprint arXiv:1703.03400, 2017.
Justin Gilmer, Samuel S Schoenholz, Patrick F Riley, Oriol Vinyals, and George E Dahl. Neural message passing for quantum chemistry. arXiv preprint arXiv:1704.01212, 2017.
M. Gori, G. Monfardini, and F. Scarselli. A new model for learning in graph domains. In Proc. IJCNN, 2005.
M. Henaff, J. Bruna, and Y. LeCun. Deep convolutional networks on graph-structured data. arXiv:1506.05163, 2015.
Łukasz Kaiser, Ofir Nachum, Aurko Roy, and Samy Bengio. Learning to remember rare events. arXiv preprint arXiv:1703.03129, 2017.
Steven Kearnes, Kevin McCloskey, Marc Berndl, Vijay Pande, and Patrick Riley. Molecular graph convolutions: moving beyond fingerprints. Journal of computer-aided molecular design, 30(8): 595–608, 2016.
Thomas N Kipf and Max Welling. Semi-supervised classification with graph convolutional networks. arXiv preprint arXiv:1609.02907, 2016.
Gregory Koch, Richard Zemel, and Ruslan Salakhutdinov. Siamese neural networks for one-shot image recognition. In ICML Deep Learning Workshop, volume 2, 2015.
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.
Brenden M Lake, Ruslan Salakhutdinov, and Joshua B Tenenbaum. Human-level concept learning through probabilistic program induction. Science, 350(6266):1332–1338, 2015.
Yujia Li, Daniel Tarlow, Marc Brockschmidt, and Richard Zemel. Gated graph sequence neural networks. arXiv preprint arXiv:1511.05493, 2015.
Akshay Mehrotra and Ambedkar Dukkipati. Generative adversarial residual pairwise networks for one shot learning. arXiv preprint arXiv:1703.08033, 2017.
Nikhil Mishra, Mostafa Rohaninejad, Xi Chen, and Pieter Abbeel. Meta-learning with temporal convolutions. arXiv preprint arXiv:1707.03141, 2017.
Tsendsuren Munkhdalai and Hong Yu. Meta networks. arXiv preprint arXiv:1703.00837, 2017.
Sachin Ravi and Hugo Larochelle. Optimization as a model for few-shot learning. ICLR, 2016.
Anselm Rothe, Brenden Lake, and Todd Gureckis. Question asking as program generation. NIPS, 2017.
Adam Santoro, Sergey Bartunov, Matthew Botvinick, Daan Wierstra, and Timothy Lillicrap. Metalearning with memory-augmented neural networks. In International conference on machine learning, pp. 1842–1850, 2016.
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. Jake Snell, Kevin Swersky, and Richard S Zemel. Prototypical networks for few-shot learning. arXiv preprint arXiv:1703.05175, 2017. Sainbayar Sukhbaatar, Rob Fergus, et al. Learning multiagent communication with backpropagation. In Advances in Neural Information Processing Systems, pp. 2244–2252, 2016. Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N Gomez, Lukasz Kaiser, and Illia Polosukhin. Attention is all you need. arXiv preprint arXiv:1706.03762, 2017. Oriol Vinyals, Samy Bengio, and Manjunath Kudlur. Order matters: Sequence to sequence for sets. arXiv preprint arXiv:1511.06391, 2015. Oriol Vinyals, Charles Blundell, Tim Lillicrap, Daan Wierstra, et al. Matching networks for one shot learning. In Advances in Neural Information Processing Systems, pp. 3630–3638, 2016. Bing Xu, Naiyan Wang, Tianqi Chen, and Mu Li. Empirical evaluation of rectified activations in convolutional network. arXiv preprint arXiv:1505.00853, 2015.
# APPENDIX
 Figure 3: GNN model. Three blue blocks are used for Omniglot and Mini-Imagenet. $( \mathrm { n f } { = } 9 6 ) ,$ ).123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266# STABILIZING DARTS WITH AMENDED GRADIENT ESTIMATION ON ARCHITECTURAL PARAMETERS
Anonymous authors Paper under double-blind review
# ABSTRACT
Differentiable neural architecture search has been a popular methodology of exploring architectures for deep learning. Despite the great advantage of search efficiency, it often suffers weak stability, which hinders it from being applied to a large search space or being flexibly adjusted to different scenarios. This paper investigates DARTS, the currently most popular differentiable search algorithm, and points out an important factor of instability, which lies in its approximation on the gradients of architectural parameters. In the current status, the optimization algorithm can converge to another point which results in dramatic inaccuracy in the re-training process. Based on this analysis, we propose an amending term for computing architectural gradients by making use of a direct property of the optimality of network parameter optimization. Our approach mathematically guarantees that gradient estimation follows a roughly correct direction, which leads the search stage to converge on reasonable architectures. In practice, our algorithm is easily implemented and added to DARTS-based approaches efficiently. Experiments on CIFAR and ImageNet demonstrate that our approach enjoys accuracy gain and, more importantly, enables DARTS-based approaches to explore much larger search spaces that have not been studied before.
# 1 INTRODUCTION
Neural architecture search (NAS) has been an important topic in the research area of automated machine learning (AutoML). The idea is to replace the manual way of designing neural network architectures with an automatic algorithm, by which deep learning methods become more flexible in fitting complex data distributions, e.g., large-scale image datasets. Early efforts of NAS involved using heuristic search methods such as reinforcement learning (Zoph & Le, 2017; Zoph et al., 2018) and evolutionary algorithms (Real et al., 2017; Xie & Yuille, 2017) to sample networks from a large search space, and optimizing each sampled network individually to evaluate its quality. Despite notable successes obtained by this methodology, it often requires a vast amount of computation, which obstacles its applications in the scenarios of limited resources. Inspired by the idea of reusing and sharing parameters among trained networks, DARTS (Liu et al., 2019b) was designed as a ‘one-shot’ solution of NAS. The major difference from the aforementioned methods is a differentiable formulation of architecture search and an end-to-end mechanism which optimizes model weights (such as convolution) and architectural weights simultaneously. Recently, improvements upon DARTS were made in various aspects (Chen et al., 2019; Xu et al., 2019; Liang et al., 2019), making it a reasonable tradeoff between search cost and performance.
Despite its broad applications, the current pipeline of DARTS (or, generally speaking, differentiable NAS approaches) suffers a critical weakness known as instability. Researchers reported (Liang et al., 2019) that DARTS-based algorithms can sometimes generate weird architectures that produce considerably worse accuracy than those generated in other individual runs, or even significantly worse than randomly generated architectures. There indeed exist tricks designed by human expertise (Chen et al., 2019; Nayman et al., 2019; Liang et al., 2019) to alleviate this issue, but we point out that these approaches violated the ideology of NAS, which is to maximally prevent human interventions. Moreover, even with such add-ons, a dramatic property of DARTS persists and has not been studied carefully in prior work. When DARTS, as well as its variants, gets trained for a longer time, e.g., from the default number of 50 epochs to 200 epochs, we surprisingly observe that all these approaches converge to very similar architectures, in which almost all edges are occupied by skip-connect (a.k.a., identity). These architectures, with fewer trainable parameters, are often far from producing high accuracy in particular on large datasets like ImageNet, but they somehow produce sufficiently high validation accuracy in the search stage. In other words, convergence in search often leads to bad performance in re-training. This is why some previous DARTS-based approaches advocated for early termination (Liang et al., 2019), a practical but non-essential solution. Also, we conjecture that early termination also contributes to the lack of stability and, more importantly, trustfulness, of DARTS-based approaches.
This paper delves deep into the inconsistency between convergence and performance. We show that the devil lies in optimizing the loss function of the super-network, $\mathcal { L } _ { \mathrm { v a l } } ( \bar { \omega } ^ { \star } ( \alpha ) , \alpha )$ ( $\omega$ and $_ { \pmb { \alpha } }$ denote network and architectural parameters, respectively, and $\omega ^ { \star } ( \alpha )$ is the global optimum of $\omega$ given $_ \alpha$ ), in which ω and α get updated alternately. Following the chain rule, ∇αLval(ω?(α) , α)|α=αt equals to $\nabla _ { \alpha } \mathcal { L } _ { \mathrm { v a l } } ( \omega , \alpha ) | _ { \omega = \omega ^ { \star } ( \alpha _ { t } ) , \alpha = \alpha _ { t } } + \left. \nabla _ { \alpha } \omega ^ { \star } ( \alpha ) \right| _ { \alpha = \alpha _ { t } }$ · $\nabla _ { \omega } \mathcal { L } _ { \mathrm { v a l } } ( \omega , \alpha ) | _ { \omega = \omega ^ { \star } ( \alpha _ { t } ) , \alpha = \alpha _ { t } }$ , in which the first term is easy to compute while the second term is not, mainly because $\omega ^ { \star } ( \alpha )$ is difficult to estimate, and so is the term of ∇αω?(α)|α=αt . DARTS-based approaches performed inaccurate approximation for this purpose, in which the first-order version of DARTS directly discarded the second term – but this term is often numerically significant, and the second-order version of DARTS applied an approximation to this term which is not mathematically guaranteed (see Section 3.4). Consequently, the accuracy of $\nabla _ { \alpha } \mathcal { L } _ { \mathrm { v a l } } \big ( \omega ^ { \star } ( \alpha ) , \alpha \big ) | _ { \alpha = \alpha _ { t } }$ cannot be guaranteed, and hence the update of $_ { \pmb { \alpha } }$ can be problematic. To the best of our knowledge, this issue is not studied by existing DARTS-based approaches.
To deal with this problem, we propose an alternative way of computing $\nabla _ { \alpha } \omega ^ { \star } ( \alpha ) | _ { \alpha = \alpha _ { t } }$ . We make use of an important property, i.e., $\nabla _ { \omega } \mathcal { L } _ { \mathrm { t r a i n } } ( \omega , \alpha ) | _ { \omega = \omega ^ { \star } ( \alpha ^ { \dagger } ) , \alpha = \alpha ^ { \dagger } } \ \equiv \ \mathbf { 0 }$ holds for any $\alpha ^ { \dagger }$ , which directly comes from the optimality of $\omega ^ { \star } ( \alpha )$ . Differentiating both sides with respect to $\alpha ^ { \dagger }$ , we obtain a new equality which enables computing derives $\nabla _ { \alpha } \omega ^ { \star } ( \alpha ) | _ { \alpha = \alpha _ { t } }$ with the inverse of the Hesse matrix, $\nabla _ { \omega } ^ { 2 } \mathcal { L } _ { \mathrm { t r a i n } } ( \omega , \alpha ) \big | _ { \omega = \omega ^ { \star } ( \alpha ) , \alpha = \alpha _ { t } }$ . This idea enables us to achieve a more accurate approximation on $\nabla _ { \alpha } \mathcal { L } _ { \mathrm { v a l } } \big ( \omega ^ { \star } ( \alpha ) , \alpha \big ) | _ { \alpha = \alpha _ { t } }$ when $\omega ^ { \star } ( \alpha )$ is not available. Mathematically, we prove that when we have $\omega ^ { \mathrm { e s t } } \approx \omega ^ { \star } ( \alpha _ { t } )$ , the inner angle between the second term and our approximate term is smaller than 90 degrees. Note that this property does not hold in existing DARTS-based algorithms. Our final solution involves using the amended second term of ∇αLval(ω?(α) , α)|α=αt meanwhile keeping the first term unchanged, which goes one step further in optimizing the supernetwork, which reflects in a higher validation accuracy in the search stage.
Our approach is very easily implemented. The overall computational overhead is comparable to the second-order version of DARTS. Experiments are performed on image classification, with popular datasets including CIFAR and ImageNet being used. In all experiments, we allow the search stage to come to a complete convergence and report competitive accuracy among current state-of-thearts. The stability of our approach also enables us to close the gap between hyper-parameters of search and evaluation, as well as explore more complex search spaces, which are believed to be correct directions of NAS but existing DARTS-based approaches would mostly fail. Therefore, we believe our algorithm can expand the application scenario of differentiable NAS methods in particular DARTS-based approaches.
The remainder of this paper is organized as follows. We briefly review related work in Section 2, and illustrate our approach of amending architectural gradients in Section 3. After experiments are shown in Section 4, we conclude this work in Section 5.
# 2 RELATED WORK
With the era of big data and powerful computational resources, deep learning (LeCun et al., 2015), in particular, deep neural networks (Krizhevsky et al., 2012), have rapidly grown up to be the standard tool for learning representations in a complicated feature space. Recent years have witnessed the trend of using deeper (He et al., 2016) and denser (Huang et al., 2017) networks to boost recognition performance, while there is no justification that whether these manually designed architectures are best for each specific task, e.g., image classification. To advance, researchers started considering the possibility of learning network architectures automatically from data, which led to the appearance of neural architecture search (NAS) (Zoph & Le, 2017), which is now popular and known as a sub research field in automated machine learning (AutoML).
The common pipeline of NAS starts with a pre-defined space of network operators. Since the search space is often large (e.g., containing $1 0 ^ { 1 0 }$ or even more possible architectures), it is unlikely that exhaustive search is tractable, and thus heuristic search methods are widely applied for speedup. Typical examples include reinforcement learning (Zoph & Le, 2017; Zoph et al., 2018; Liu et al., 2018a) and evolutionary algorithms (Real et al., 2017; Xie & Yuille, 2017; Real et al., 2019). These approaches followed a general pipeline that samples a set of architectures from a learnable distribution, evaluates them and learns from rewards by updating the distribution. In an early age, each sampled architecture underwent an individual training process from scratch and thus the overall computational overhead is large, e.g., hundreds of even thousands of GPU-days. To alleviate the burden, researchers started to share computation among training sampled architectures, with the key lying in reusing network weights trained previously (Cai et al., 2018) or starting from a well-trained super-network (Pham et al., 2018). These efforts shed light on the so-called one-shot architecture search methods, which required training the super-network only once and thus ran more efficiently, e.g., two or three orders of magnitude faster than conventional approaches.
Within the scope of one-shot architecture search, an elegant solution lies in jointly formulating architecture search and approximation, so that it is possible to apply end-to-end optimization for training network and architectural parameters simultaneously. This methodology is known today as differentiable NAS, and a typical example is DARTS (Liu et al., 2019b), which constructed a super-network with all possible operators contained and decoupled, and the goal is to determine the weights of these architectural parameters, followed by pruning and re-training stages. This kind of approach allowed more flexible search space to be constructed, unlike conventional approaches with either reinforcement or evolutionary learning, which suffer from the computational burden and thus must constrain search within a relatively small search space (Tan & Le, 2019).
Despite the inspirations brought by differentiable NAS, these approaches still suffer a few critical issues that narrow down their applications in practice. One significant drawback lies in the lack of stability, which reflects in the way that results of differentiable search can be impacted by very small perturbations, e.g., initialization of architectural weights, training hyper-parameters, and even randomness in the training process. Existing solutions include running search for several individual times and choosing the best one in validation (Liu et al., 2019b), or using other kinds of techniques such as decoupling modules (Cai et al., 2019; Guo et al., 2019), adjusting search space during optimization (Noy et al., 2019; Chen et al., 2019; Nayman et al., 2019), regularization $\mathrm { { X u } }$ et al., 2019), early termination (Liang et al., 2019), etc., however, these approaches seemed to develop heuristic remedies rather than analyze it from the mathematical fundamentals, e.g., how instability happens in mathematics.
In this paper, we investigate the stability issue in mathematics and show that the results produced by the current approaches are much less reliable than people used to think. Then, we fix this issue by amending optimization of the architectural parameters, so that each step of the update gets closer to the correct direction. We show great improvement on stability in a fundamental task, image classification, while we believe our approach can be applied to a wide range of tasks including object detection (Ghiasi et al., 2019), semantic segmentation (Liu et al., 2019a), hyper-parameter learning (Cubuk et al., 2019), etc.
# 3 STABILIZING DARTS WITH AMENDED GRADIENTS
In this section, we first show that DARTS can fail dramatically when it gets trained till convergence, and then we mathematically analyze how this problem is related to inaccurate approximation in optimization, following which we present our solution to amend this error and thus stabilize DARTS.
# 3.1 PRELIMINARIES: DIFFERENTIABLE NEURAL ARCHITECTURE SEARCH
Differentiable NAS approaches start with defining a super-network, which is constrained in a search space with a pre-defined number of layers and a limited set of neural operators. The core idea is to introduce a ‘soft’ way operator selection (i.e., using a weighted sum over the outputs of a few operators instead of taking the output of only one), so that optimization can be done in an end-toend manner. Mathematically, the super-network is a function $\mathbf { f } \left( \mathbf { x } ; \omega , \alpha \right)$ , with $\mathbf { x }$ being input, and parameterized by network parameters $\omega$ (e.g., convolutional kernels) and architectural parameters $_ { \pmb { \alpha } }$ (e.g., indicating the importance of each operator between each pair of layers). $\mathbf { f } \left( \mathbf { x } ; \omega , \alpha \right)$ is differentiable to both $\omega$ and $_ { \pmb { \alpha } }$ , so that gradient-based approaches can be applied for optimization.
 Figure 1: Left: a typical search process of the first-order DARTS, in which 200 search epochs are used. Red, green and blue lines indicate the average weight of none, the ratio of dominant skipconnect operators (over 14 normal edges) and the re-training accuracy, with respect to the number of search epochs, respectively. Right: the normal cell obtained after 200 search epochs, in which all preserved operators are skip-connect. We executed both first-order and second-order DARTS for several times, and such failure consistently happens in each individual run.
In the example of DARTS, $\mathbf { f } \left( \mathbf { x } ; \omega , \alpha \right)$ is composed of a few cells, each of which contains $N$ nodes, and there is a pre-defined set, $\mathcal { E }$ , denoting which pairs of nodes are connected. For each connected node pair $( i , j ) , i < j$ , node $j$ takes the output of node $i$ , $\mathbf { x } _ { i }$ , as a part of its input, and propagate it through a pre-defined operator set, $\mathcal { O }$ , with all outputs summed up:
$$\mathbf { y } ^ { ( i , j ) } \left( \mathbf { x } _ { i } \right) = \sum _ { o \in \mathcal { O } } \frac { \exp ( \alpha _ { o } ^ { ( i , j ) } ) } { \sum _ { o ^ { \prime } \in \mathcal { O } } \exp ( \alpha _ { o } ^ { ( i , j ) } ) } \cdot o ( \mathbf { x } _ { i } ) .$$
Here, a softmax term is computed by architectural weights to normalize outputs. Within each unit of the search process, $\omega$ and $_ { \pmb { \alpha } }$ get optimized alternately. After search, the operator $o$ with the maximal value of $\alpha _ { o } ^ { ( i , j ) }$ is preserved for each edge $( i , j )$ . All network parameters $\omega$ are discarded and the obtained architecture is re-trained from scratch1.
# 3.2 DARTS FAILS: THE CONTRADICTORY BETWEEN CONVERGENCE AND PERFORMANCE
Our research is motivated by an observation that DARTS, at the end of a regular training process with, say, 50 epochs (Liu et al., 2019b), has not yet arrived at or even got close to convergence, yet the weight of the none (a.k.a., zero) operator is consistently the largest on each edge of the normal cell. To verify this, we increase the length of each training stage by 4 times, i.e., from 50 to 200 epochs. Two weird phenomena are observed, both of which are shown in the left part of Figure 1. First, the weight of the none operator monotonically goes up – at 200 epochs, the weight has achieved 0.97 on each edge of the normal cells, however, this operator is not considered in the final architecture. Second, almost all preserved operators are skip-connect (a.k.a., identity), a parameter-free operator that contributes little to feature learning – and surprisingly, it occupies $3 0 \%$ to $7 0 \%$ of the weight remained by none. Such a network has much fewer parameters than a well-designed one, and thus it usually reports unsatisfying performance at the re-training stage. This indicates that, in the context of DARTS, there exists a contradictory between search convergence and re-training accuracy.
We point out that this is a critical issue, which suggests that when using DARTS-based approaches, one does not hope the search process to achieve convergence as it implies bad performance. In other words, each ‘successful’ architecture comes from an early-terminated search process. Consequently, the initialization of parameters $\scriptstyle { \mathbf { \alpha } } _ { \alpha }$ and $\omega$ ), the hyper-parameters of search (e.g., learning rate) and the time of terminating search become important and thus need to be determined by experience (Liang et al., 2019). This weakens the stability as well as explainability of search and, more importantly, violates the fundamental ideology of AutoML, i.e., maximally reducing human interference and determining the best architecture by training data.
# 3.3 DELVING DEEP INTO MATHEMATICS: PROBLEM AND SOLUTION
We point out that the reason lies in inaccurate estimation of the gradient with respect to $_ { \pmb { \alpha } }$ , namely, $\nabla _ { \alpha } \bar { \mathcal { L } } _ { \mathrm { v a l } } \big ( \omega ^ { \star } ( \alpha ) , \alpha \big ) | _ { \alpha = \alpha _ { t } }$ . Following the chain rule of gradients, this quantity equals to
$$\nabla _ { \alpha } \mathcal { L } _ { \mathrm { v a l } } ( \omega , \alpha ) | _ { \omega = \omega ^ { \star } ( \alpha _ { t } ) , \alpha = \alpha _ { t } } + \nabla _ { \alpha } \omega ^ { \star } ( \alpha ) | _ { \alpha = \alpha _ { t } } \cdot \nabla _ { \omega } \mathcal { L } _ { \mathrm { v a l } } ( \omega , \alpha ) | _ { \omega = \omega ^ { \star } ( \alpha _ { t } ) , \alpha = \alpha _ { t } } ,$$
in which the first term is relatively easy to compute (as is done by the first-order version of DARTS), while the second term, in particular $\mathrm { \nabla } \nabla _ { \alpha } \omega ^ { \star } ( \bar { \alpha } ) | _ { \alpha = \alpha _ { t } }$ , is not. The first-order version of DARTS directly discarded this term, but it often has significant numerical values which are not negligible. The second-order version of DARTS indeed proposed an approximation to this term, but, as we shall see in the next subsection, can incur a large approximation error (the inner-product between the correct and estimated directions can be smaller than 0). Consequently, there can be a significant gap between the estimated and true values of $\nabla _ { \alpha } \mathcal { L } _ { \mathrm { v a l } } \big ( \omega ^ { \star } ( \alpha ) , \alpha \big ) | _ { \alpha = \alpha _ { t } }$ . Such inaccuracy accumulates with every update on $_ { \pmb { \alpha } }$ , and gradually causes $_ { \pmb { \alpha } }$ to converge to weird solutions that are far from optimum, e.g., the entire super-network is dominated by none and skip-connect operators. We name this phenomenon as the gradient trap during optimization.
To estimate $\nabla _ { \alpha } \omega ^ { \star } ( \alpha ) | _ { \alpha = \alpha _ { t } }$ , we first make a reasonable assumption that $\nabla _ { \alpha } \omega ^ { \star } ( \alpha ) | _ { \alpha = \alpha _ { t } }$ has finite values. Then, we make use of an important property, i.e., $\nabla _ { \omega } \mathcal { L } _ { \mathrm { t r a i n } } ( \omega , \alpha ) | _ { \omega = \omega ^ { \star } ( \alpha ^ { \dagger } ) , \alpha = \alpha ^ { \dagger } } \ \equiv \ \mathbf { 0 }$ holds for any $\alpha ^ { \dagger }$ . This is property directly comes from the optimality of $\omega ^ { \star } ( \alpha )$ , but it has never been used by existing approaches. Applying differentiation with respect to any $\alpha ^ { \dagger }$ to both sides of this equality, we have $\bar { \nabla _ { \alpha ^ { \dagger } } } \left( \nabla _ { \omega } \mathcal { L } _ { \mathrm { t r a i n } } ( \omega , \bar { \alpha } ) | _ { \omega = \omega ^ { \star } ( \alpha ^ { \dagger } ) , \alpha = \alpha ^ { \dagger } } \right) \equiv \mathbf { 0 }$ . When $ { \alpha } ^ { \dagger } = { \alpha } _ { t }$ , it becomes:
$$\nabla _ { \alpha ^ { \dagger } } \left. \left( \nabla _ { \omega } \mathcal { L } _ { \mathrm { t r a i n } } ( \omega , \alpha ) \vert _ { \omega = \omega ^ { \star } ( \alpha ^ { \dagger } ) , \alpha = \alpha ^ { \dagger } } \right) \right. _ { \alpha ^ { \dagger } = \alpha _ { t } } = 0 .$$
Again, applying the chain rule to the left-hand side gives:
$$\nabla _ { \alpha , \omega } ^ { 2 } \mathcal { L } _ { \mathrm { t r a i n } } ( \omega , \alpha ) \big | _ { \omega = \omega ^ { * } ( \alpha _ { t } ) , \alpha = \alpha _ { t } } + \nabla _ { \alpha } \omega ^ { \star } ( \alpha ) \big | _ { \alpha = \alpha _ { t } } \cdot \left. \nabla _ { \omega } ^ { 2 } \mathcal { L } _ { \mathrm { t r a i n } } ( \omega , \alpha ) \right| _ { \omega = \omega ^ { * } ( \alpha _ { t } ) , \alpha = \alpha _ { t } } = \mathbf { 0 } ,$$
where we use the notation $\nabla _ { { \boldsymbol { \alpha } } , \omega } ^ { 2 } ( \cdot ) ~ \equiv ~ \nabla _ { { \boldsymbol { \alpha } } } ( \nabla _ { \omega } ( \cdot ) )$ throughout the remaining part of this paper. Here, ∇2ωLtrain(ω, α)ω=ω?(α ),α=α is the Hesse matrix corresponding to the optimum $\omega ^ { \star } ( \alpha _ { t } )$ , which is symmetric and positive-definite, and thus invertible. This gives us an estimation that $\nabla _ { \alpha } \omega ^ { \star } ( \alpha ) | _ { \alpha = \alpha _ { t } } = - \left. \nabla _ { \alpha , \omega } ^ { 2 } \mathcal { L } _ { \mathrm { t r a i n } } ( \omega , \alpha ) \right| _ { \omega = \omega ^ { \star } ( \alpha _ { t } ) , \alpha = \alpha _ { t } } \cdot \mathbf { H } ^ { - 1 } .$ . Substituting it into Equation 2 gives:
$$\begin{array} { r l r } & { } & { \nabla _ { \alpha } \mathcal { L } _ { \mathrm { v a l } } ( \omega ^ { \star } ( \alpha ) , \alpha ) | _ { \alpha = \alpha _ { t } } = \nabla _ { \alpha } \mathcal { L } _ { \mathrm { v a l } } ( \omega , \alpha ) | _ { \omega = \omega ^ { \star } ( \alpha _ { t } ) , \alpha = \alpha _ { t } } - } \\ & { } & { \nabla _ { \alpha , \omega } ^ { 2 } \mathcal { L } _ { \mathrm { t r a i n } } ( \omega , \alpha ) | _ { \omega = \omega ^ { \star } ( \alpha _ { t } ) , \alpha = \alpha _ { t } } \cdot \mathbf { H } ^ { - 1 } \cdot \nabla _ { \omega } \mathcal { L } _ { \mathrm { v a l } } ( \omega , \alpha ) | _ { \omega = \omega ^ { \star } ( \alpha _ { t } ) , \alpha = \alpha _ { t } } . } \end{array}$$
Note that Equation 5 does not involve any approximation. The only issue comes from the term of ${ \bf H } ^ { - 1 }$ , which is computationally intractable due to the large dimensionality of $\mathbf { H }$ (it is related to the number of network parameters, which often exceeds one million in a typical super-network).
# 3.4 APPROXIMATIONS IN COMPUTING THE INVERSE HESSE MATRIX
Let us denote Equation 5 in an abbreviated form of $\mathbf { g } = \mathbf { g } _ { 1 } + \mathbf { g } _ { 2 }$ , in which $\mathbf { g } _ { 1 }$ , the first-order term of DARTS, is easily computed, while $\mathbf { g } _ { 2 }$ is not due to the computation of ${ \bf H } ^ { - 1 }$ . Here, we propose an alternative solution which constructs an approximation term $\mathbf { g } _ { 2 } ^ { \prime }$ :
$$\begin{array} { r } { \mathbf { g } _ { 2 } ^ { \prime } = - \eta \cdot \left. \nabla _ { \alpha , \omega } ^ { 2 } \mathcal { L } _ { \mathrm { t r a i n } } ( \omega , \alpha ) \right| _ { \omega = \omega ^ { * } ( \alpha _ { t } ) , \alpha = \alpha _ { t } } \cdot \mathbf { H } \cdot \left. \nabla _ { \omega } \mathcal { L } _ { \mathrm { v a l } } ( \omega , \alpha ) \right| _ { \omega = \omega ^ { * } ( \alpha _ { t } ) , \alpha = \alpha _ { t } } , } \end{array}$$
where $\eta > 0$ is named the amending coefficient. In what follows, we show that $\mathbf { g } _ { 2 } ^ { \prime }$ is indeed a reasonable approximation of $\mathbf { g } _ { 2 }$ . Since
$$\begin{array} { r l } & { \langle \mathbf { g } _ { 2 } ^ { \prime } , \mathbf { g } _ { 2 } \rangle = \boldsymbol { \eta } \cdot \left. \nabla _ { \omega } \mathcal { L } _ { \mathrm { v a l } } ( \omega , \alpha ) \right| _ { \omega = \omega ^ { \star } ( \alpha _ { t } ) , \alpha = \alpha _ { t } } \boldsymbol { \mathsf { T } } \cdot \left. \mathbf { H } ^ { - 1 } \cdot \nabla _ { \omega , \alpha } ^ { 2 } \mathcal { L } _ { \mathrm { t r a i n } } ( \omega , \alpha ) \right| _ { \omega = \omega ^ { \star } ( \alpha _ { t } ) , \alpha = \alpha _ { t } } \cdot } \\ & { \qquad \nabla _ { \alpha , \omega } ^ { 2 } \mathcal { L } _ { \mathrm { t r a i n } } ( \omega , \alpha ) \big | _ { \omega = \omega ^ { \star } ( \alpha _ { t } ) , \alpha = \alpha _ { t } } \cdot \mathbf { H } \cdot \nabla _ { \omega } \mathcal { L } _ { \mathrm { v a l } } ( \omega , \alpha ) \big | _ { \omega = \omega ^ { \star } ( \alpha _ { t } ) , \alpha = \alpha _ { t } } , } \end{array}$$
the product of the two terms between ${ \bf H } ^ { - 1 }$ and $\mathbf { H }$ is a semi-positive-definite matrix, and so is the matrix after similarity transformation, which directly gives $\left. \mathbf { g } _ { 2 } ^ { \prime } , \mathbf { g } _ { 2 } \right. \geqslant 0$ .
In summary, we decompose the gradient of architectural parameters into two terms, $\mathbf { g } _ { 1 }$ and $\mathbf { g } _ { 2 }$ , compute $\mathbf { g } _ { 1 }$ directly and use an approximation to $\mathbf { g } _ { 2 }$ so that the angle between the accurate and approximated terms is smaller than 90 degrees. In comparison, existing DARTS-based approaches either discarded $\mathbf { g } _ { 2 }$ entirely or used a mathematically non-explainable approximation $\mathbf { \bar { g } } _ { 2 } ^ { \prime \prime } = \mathbf { \bar { \nu } } \eta \cdot \nabla _ { \alpha , \omega } ^ { 2 } \mathcal { L } _ { \mathrm { t r a i n } } ( \omega , \mathbf { \bar { \alpha } } ) | _ { \omega = \omega ^ { * } ( \alpha _ { t } ) , \alpha = \alpha _ { t } } \cdot \mathbf { I } \cdot \nabla _ { \omega } \mathcal { L } _ { \mathrm { v a l } } ( \omega , \mathbf { \bar { \alpha } } ) | _ { \omega = \omega ^ { * } ( \alpha _ { t } ) , \alpha = \alpha _ { t } } .$ . None of them are reasonable because $\mathbf { g } _ { 2 }$ can be large, yet there is no guarantee that $\left. \mathbf { g } _ { 2 } ^ { \prime \prime } , \mathbf { g } _ { 2 } \right. \geqslant 0$ , i.e., the secondorder DARTS can lead the algorithm to a wrong direction.
The rationality of our approach is also verified by the validation process, i.e., in updating architectural parameters. The first-order DARTS, by directly discarding $\mathbf { g } _ { 2 }$ , reported an average validation accuracy of $9 0 . 5 \%$ in search space $S _ { 1 }$ (see Section 4.1.3) on the CIFAR10 dataset. The second-order DARTS added $\mathbf { g } _ { 2 } ^ { \prime \prime }$ , which has no guarantee that $\left. { { \bf { g } } _ { 2 } ^ { \prime \prime } , { \bf { g } } _ { 2 } } \right. \mathrm { ~ \ \ \geqslant ~ 0 ~ }$ , and thus resulted in a reduced validation accuracy. Our approach, by adding $\mathbf { g } _ { 2 } ^ { \prime }$ , achieves a validation accuracy of $9 1 . 5 \%$ , implying that our optimization works better than DARTS. This eventually results in the advantage of searched architectures, which will be verified in Section 4.1.2.
The remainder part of computing $\mathbf { g } _ { 2 } ^ { \prime }$ simply follows conventions, which we replace $\omega ^ { \star } ( \alpha )$ with the current $\omega ^ { \mathrm { e s t } }$ as the most accurate approximation we can get2. Computing ${ \bf g } _ { 2 } ^ { \bar { \prime } }$ with Equation 6 requires both ∇2α,ωLtrain(ω, α)ω=ω?(αt),α=αt and $\nabla _ { \omega } \mathcal { L } _ { \mathrm { v a l } } ( \omega , \alpha ) | _ { \omega = \omega ^ { \star } ( \alpha _ { t } ) , \alpha = \alpha _ { t } }$ , while DARTS needs the former one with $\omega ^ { \star } ( \alpha _ { t } )$ estimated in two steps. Therefore, computing Equation 6 requires similar computational overhead compared to the second-order version of DARTS. In experiments, each search epoch requires around 0.02 GPU-days on the standard 8-cell space on CIFAR10.
# 3.5 DISCUSSIONS AND RELATIONSHIP TO PRIOR WORK
The core benefit brought by our approach is the consistency between search and evaluation. This is indeed a fundamental idea of NAS, but it was ignored by existing approaches since they have been perplexed by a more significant error caused by inaccurate optimization. After the error, we point out a few prior conventions that need to be adjusted accordingly, including using different depths (e.g., DARTS used 8 cells in search and 20 cells in evaluation) and widths (e.g., DARTS used a basic channel number of 16 in search and 36 in evaluation) during search and evaluation, as well as using different training strategies (e.g., during re-training, a few regularization techniques including Cutout (DeVries & Taylor, 2017), Dropout (Srivastava et al., 2014) and auxiliary loss were used, but none of them appeared in search). More importantly, the search process was followed by edge removal (8 out of 14 connections were preserved) which caused a significant difference between the network architectures of search and evaluation. Our approach provides the opportunity to bridge the gap between search and evaluation, which we will show in Section 4.1.2 that unifying these hyper-parameters leads to better performance.
A few prior differentiable search approaches noticed the issue of instability, but they chose to solve it in different manners. For example, P-DARTS (Chen et al., 2019) fixed the number of preserved skip-connect operators, PC-DARTS (Xu et al., 2019) used edge normalization to eliminate the none operator, while XNAS (Nayman et al., 2019) and DARTS $^ { + }$ (Liang et al., 2019) introduced a few human expertise to stabilize search. However, we point out that (i) either P-DARTS or PC-DARTS, with carefully designed methods or tricks, can also fail in a sufficiently long search process (more than 200 epochs); and that (ii) XNAS and DART $\vdots +$ , by adding human expertise, somewhat violated the design nature of AutoML, in which one is expected to avoid introducing too many hand-designed rules.
Another line of NAS, besides differentiable methods, is to use either reinforcement learning or an evolutionary algorithm as a controller of heuristic search and train each sampled network to get some kind of rewards, e.g., validation accuracy. In the viewpoint of optimization, this pipeline mainly differs from the differentiable one in that optimizing $_ { \pmb { \alpha } }$ is decoupled from optimizing $\omega$ , so that it does not require $\omega$ to arrive at $\omega ^ { \ast }$ , but only need a reasonable approximation of $\omega ^ { \ast }$ to predict model performance – this is an important reason that such algorithms often produce stable results. Our approach sheds light on introducing a similar property, i.e., robustness to approximated $\omega ^ { \star }$ , which helps in stabilizing differentiable search approaches.
# 4 EXPERIMENTS
# 4.1 RESULTS ON CIFAR10
The CIFAR10 dataset (Krizhevsky & Hinton, 2009) has 50,000 training and 10,000 testing images, sized $3 2 \times 3 2$ , and equally distributed over 10 classes. We mainly use this dataset to evaluate the stability of our approach, as well as analyze the impacts of different search options and parameters.
# 4.1.1 IMPACT OF THE AMENDING COEFFICIENT
We first investigate how the amending coefficient, $\eta$ , defined in Equation 6, impacts architecture search. We search and re-train similarly as DARTS. During the search, all operators are assigned equal weights on each edge. We use a base channel number of 16, and a batch size of 96. An Adam optimizer is used to update architectural parameters, with a learning rate of 0.0003, a weight decay of 0.001 and a momentum of (0.5, 0.999). The number of epochs is to be discussed later. During re-training, the base channel number is increased to 36. An SGD optimizer is used with an initial learning rate of 0.025, decaying following the cosine annealing rule and arriving at 0 after 600 epochs. The weight decay is set to be 0.0003, and the momentum is 0.9.
To arrive at convergence, we run the search stage for 500 epochs. We evaluate different $\eta$ values from 0 to 1, and the architectures corresponding to $\eta = 0$ (equivalent to DARTS), $\eta = 0 . 1$ and $\eta = 1$ are summarized in Figure 2. We can see that $\eta = 0 . 1$ converges, after 500, into a reasonable architecture that achieves an error rate of $3 . 0 8 \%$ on CIFAR10. We emphasize that, even with more search epochs, this architecture is not likely to change, as the preserved operator on each edge has a weight not smaller than 0.5, and most of these weights are still growing gradually.
When $\eta$ is very small, e.g., $\eta = 0 . 0 0 1$ or $\eta = 0 . 0 1$ , the change brought by this amending term to architecture search is ignorable, and our approach shows almost the same behavior as the first-order version of DARTS, i.e., $\eta = 0$ . In addition, when $\eta$ grows up, e.g., from 0.001 to 0.01, although the search process eventually runs into an architecture with all skip-connect operators, the number of epochs needed for a complete failure is significantly postponed, which verifies that the amending term indeed pulls architecture search away from the gradient trap.
 Figure 2: Normal (left) and reduction (right) cells (the standard DARTS space) obtained by different amending coefficients, namely, $\eta = 0$ (top), $\eta = 0 . 1$ (middle) and $\eta = 1$ (bottom).
On the other hand, if we use a sufficiently large $\eta$ value, e.g., $\eta = 1$ , the amending term, $\mathbf { g } _ { 2 } ^ { \prime }$ , can dominate optimization, so that the first term, i.e., the gradient of architectural parameters, has limited effects in updating $_ \alpha$ . Note that the amending term is closely related to network regularization, therefore, in the scenarios of a large $\eta$ , the network significantly prefers avg-pooling to other operators, as avg-pooling can smooth feature maps and avoid over-fitting. However, avg-pooling is also a parameter-free operator, so the performance of such architectures is also below satisfaction.
Following these analyses, we simply use $\eta = 0 . 1$ for all later experiments. We do not tune $\eta$ very carefully, though it is possible to determine $\eta$ automatically using a held-out validation set. Besides, we find that the best architecture barely changes after 100 search epochs, which we fix the total length to be 100 epochs in all remaining experiments.
# 4.1.2 CONSISTENCY BETWEEN SEARCH AND EVALUATION
As discussed in Section 3.5, it is important to alleviate the difference between search and evaluation. We make the following modifications, listed from most to least important. First, to avoid edge removal, we fix the edges in each cell, so that each node $i$ is connected to node $i - 1$ and the least indexed node (denoted by $c _ { k - 2 }$ in most conventions), resulting in 8 edges in each cell. Note that our approach also works well with all 14 edges preserved, but we have used 8 edges to be computationally fair to DARTS. Second, we unify the width (the number of basic channels) as 36 for both search and evaluation. Third, we add normalization techniques, including Cutout (DeVries & Taylor, 2017), Dropout (Srivastava et al., 2014) and an auxiliary loss tower, into the search stage.
We use the amending coefficient $\eta = 0 . 1$ learned from previous experiments, i.e., without modification, the searched architecture, denoted by $\mathbb { A } _ { \mathrm { o r i g } }$ , is shown in the middle column of Figure 2. After modification, the obtained architecture, denoted by $\mathbb { A } _ { \mathrm { n e w } }$ , is shown in Figure 3. We re-train both networks on CIFAR10, with or without the option that stacking duplicate cells to make the network deeper (with 20 cells). With a standard re-training process, $\mathbb { A } _ { \mathrm { o r i g } }$ reports a $3 . 6 7 \%$ error with 8 cells, and a $3 . 0 8 \%$ error with 20 cells; and the corresponding numbers are $3 . 2 0 \%$ and $2 . 8 1 \%$ for $\mathbb { A } _ { \mathrm { n e w } }$ . We find that $\mathbb { A } _ { \mathrm { n e w } }$ is consistently better than $\mathbb { A } _ { \mathrm { o r i g } }$ , which suggests that alleviating the gap indeed helps. This also reminds us of the significant depth gap (Chen et al., 2019) between search and re-training (the network has 8 cells in search, but 20 cells in re-training), and this gap also obstructs our approach from achieving better performance. We will investigate this issue in the following part.
# 4.1.3 EXPLORING MORE COMPLEX SEARCH SPACES
We note tremendous efforts made by existing approaches to alleviate the depth gap, while our solution is a direct one, thanks to the stability of our approach which enables us to directly explore larger search spaces. Here, we denote the original search space used in DARTS as $S _ { 1 }$ , which has six normal cells and two reduction cells, and all normal cells share the same set of architectural parameters and so do the reduction cells. Note that we have fixed the edges in this space, resulting in the total number of possible architectures to reduce from $1 . 1 \times 1 0 ^ { 1 8 }$ to $3 . 3 \times 1 0 ^ { 1 \bar { 3 } }$ . We also explore a more complex search space, denoted by $S _ { 2 }$ , in which we relax the constraint that either normal cells or reduction cells should be the same, and also the number of cells increases from 8 to 20, to be applied in re-training. Here, limited by GPU memory, we cannot support all seven operators to be searched, so we only choose two, namely skip-connect and sep-conv- $3 x 3$ , which have very different properties. This setting allows a total of $1 . 5 \times 1 0 ^ { 4 8 }$ architectures to appear, much larger than $S _ { 1 }$ .
Results are listed in Table 1. In $S _ { 1 }$ , our approach achieves a moderate error rate of $2 . 8 1 \%$ , mainly because the assumption of consistency between search and re-training does not hold. In $S _ { 2 }$ , with directly searching in deep architectures, our result is significantly boosted (an error rate of $2 . 6 0 \%$ , the architecture is shown in the middle row of Figure 3). Again, we emphasize that we report retraining results based on an converged architecture, which stands out from existing DARTS-based approaches which required early termination.
In $S _ { 2 }$ , we compare our approach against both DARTS (no amending term) and random search. We observe that DARTS produces weird architectures (the bottom row of Figure 3), that high-layer cells are mostly occupied by skip-connect, which is not likely to fully utilize the ability of the supernetwork. Regarding random search, we follow DARTS by randomly sampling 20 valid architectures from each of $S _ { 1 }$ and $S _ { 2 }$ , and using a small validation dataset to choose the best two architectures for re-training. Given a fixed number of probes, it becomes more and more difficult to sufficiently explore a large space. The deficits of DARTS and random search on CIFAR10 are $0 . 2 5 \%$ and $0 . { \bar { 2 } } 9 \%$ , respectively, which do not seem to be very large arguably because CIFAR10 is relatively easy and our edge-fixed search space guarantees sufficient depth. However, when we transfer these architectures to ImageNet, the deficits become much larger, i.e., with $1 . 7 \%$ and $0 . 8 \%$ top-1 accuracy drops, respectively (DARTS produces inferior performance to random search). These results remind us of prior work (Xie et al., 2019) which claimed that random search works sufficiently well in large search spaces. Here, we leave a comment on this debate, demonstrating that a large space indeed raises challenges to architecture search, but a stabilized search algorithm still has the ability of to find more powerful architectures.
 Figure 3: Top: normal and reduction cells found in $ { \boldsymbol { S } } _ { 1 }$ . Middle & Bottom: the overall architecture found in $S _ { 2 }$ by DARTS, with and without the amended term, in which red and blue edges indicate skip-connect and sep-conv- $. 3 x 3$ operators, respectively.
# 4.1.4 COMPARISON TO THE STATE-OF-THE-ARTS
Finally, we compare our approach with recent approaches, in particular, differentiable ones. Result are shown in Table 1. Our approach produces competitive results among state-of-the-arts, although it does not seem to beat others. We note that existing approaches often used additional tricks, e.g., PDARTS assumed a fixed number of skip-connect operators, which shrinks the search space (so as to guarantee stability). More importantly, all these differentiable search approaches must be terminated in an early stage, which makes them less convincing as search has not arrived at convergence. These tricks somewhat violate the ideology of neural architecture search; in comparison, our research, though not producing the best performance, seems going along a correct and promising direction.
<table><tr><td rowspan="2">Architecture</td><td>Test Err.</td><td>Params</td><td>Search Cost</td><td rowspan="2">Search Method</td></tr><tr><td>(%)</td><td>(M)</td><td>(GPU-days)</td></tr><tr><td>DenseNet-BC (Huang et al.,2017)</td><td>3.46</td><td>25.6</td><td>-</td><td>manual</td></tr><tr><td>ENAS (Pham et al.,2018) w/ Cutout</td><td>2.89</td><td>4.6</td><td>0.5</td><td>RL</td></tr><tr><td>NASNet-A (Zoph et al.,2018) w/Cutout</td><td>2.65</td><td>3.3</td><td>1800</td><td>RL</td></tr><tr><td>NAONet-WS (Luo et al.,2018)</td><td>3.53</td><td>3.1</td><td>0.4</td><td>NAO</td></tr><tr><td>Hireachical Evolution (Liu et al.,2018b)</td><td>3.75±0.12</td><td>15.7</td><td>300</td><td>evolution</td></tr><tr><td>AmoebaNet-B (Real et al.,2019) w/ Cutout</td><td>2.55±0.05</td><td>2.8</td><td>3150</td><td>evolution</td></tr><tr><td>PNAS (Liu et al., 2018a)</td><td>3.41±0.09</td><td>3.2</td><td>225</td><td>SMBO</td></tr><tr><td>DARTS (first-order) (Liu et al.,2019b) w/ Cutout</td><td>3.00±0.14</td><td>3.3</td><td>0.4</td><td>gradient-based</td></tr><tr><td>DARTS (second-order) (Liu et al.,20i9b) w/Cutout</td><td>2.76±0.09</td><td>3.3</td><td>1.0</td><td>gradient-based</td></tr><tr><td>SNAS (moderate) (Xie etal.,2018) w/ Cutout</td><td>2.85±0.02</td><td>2.8</td><td>1.5</td><td>gradient-based</td></tr><tr><td>ProxylessNAS (Cai et al.,2019) w/Cutout</td><td>2.08</td><td>-</td><td>4.0</td><td>gradient-based</td></tr><tr><td>P-DARTS (Chen et al.,2019) w/ Cutout</td><td>2.50</td><td>3.4</td><td>0.3</td><td>gradient-based</td></tr><tr><td>BayesNAS (Zhou et al.,2019) w/ Cutout</td><td>2.81±0.04</td><td>3.4</td><td>0.2</td><td>gradient-based</td></tr><tr><td>PC-DARTS (Xu et al.,2019) w/ Cutout</td><td>2.57±0.07</td><td>3.6</td><td>0.1</td><td>gradient-based</td></tr><tr><td>Amended-DARTS,S1,w/Cutout</td><td>2.81±0.21</td><td>3.5</td><td>1.0</td><td>gradient-based</td></tr><tr><td>Amended-DARTS,S2,w/Cutout</td><td>2.60±0.15</td><td>3.6</td><td>1.1</td><td>gradient-based</td></tr></table>
Table 1: Comparison with state-of-the-art network architectures on CIFAR10.
<table><tr><td rowspan="2">Architecture</td><td colspan="2">Test Err. (%)</td><td rowspan="2">Params (M)</td><td rowspan="2">×+ (M)</td><td rowspan="2">Search Cost (GPU-days)</td><td rowspan="2">Search Method</td></tr><tr><td>top-1</td><td>top-5</td></tr><tr><td>Inception-v1 (Szegedy et al.,2015)</td><td>30.2</td><td>10.1</td><td>6.6</td><td>1448</td><td>-</td><td>manual</td></tr><tr><td>MobileNet (Howard etal.,2017)</td><td>29.4</td><td>10.5</td><td>4.2</td><td>569</td><td></td><td>manual</td></tr><tr><td>ShuffleNet 2× (v1) (Zhang et al.,2018)</td><td>26.4</td><td>10.2</td><td>~5</td><td>524</td><td></td><td>manual</td></tr><tr><td>ShuffleNet 2× (v2) (Ma et al.,2018)</td><td>25.1</td><td>-</td><td>~5</td><td>591</td><td>-</td><td>manual</td></tr><tr><td>NASNet-A (Zoph et al., 2018)</td><td>26.0</td><td>8.4</td><td>5.3</td><td>564</td><td>1800</td><td>RL</td></tr><tr><td>MnasNet-92 (Tan et al.,2019)</td><td>25.2</td><td>8.0</td><td>4.4</td><td>388</td><td>-</td><td>RL</td></tr><tr><td>PNAS (Liu et al., 2018a)</td><td>25.8</td><td>8.1</td><td>5.1</td><td>588</td><td>225</td><td>SMBO</td></tr><tr><td>AmoebaNet-C (Real et al.,2019)</td><td>24.3</td><td>7.6</td><td>6.4</td><td>570</td><td>3150</td><td>evolution</td></tr><tr><td>DARTS (second-order) (Liu et al.,2019b)</td><td>26.7</td><td>8.7</td><td>4.7</td><td>574</td><td>4.0</td><td>gradient-based</td></tr><tr><td>SNAS (mild) (Xie et al., 2018)</td><td>27.3</td><td>9.2</td><td>4.3</td><td>522</td><td>1.5</td><td>gradient-based</td></tr><tr><td>BayesNAS (Zhou et al.,2019)</td><td>26.5</td><td>8.9</td><td>3.9</td><td>-</td><td>0.2</td><td>gradient-based</td></tr><tr><td>P-DARTS (CIFAR10) (Chen et al.,2019)</td><td>24.4</td><td>7.4</td><td>4.9</td><td>557</td><td>0.3</td><td>gradient-based</td></tr><tr><td>ProxylessNAS (GPU) (Cai et al., 2019)</td><td>24.9</td><td>7.5</td><td>7.1</td><td>465</td><td>8.3</td><td>gradient-based</td></tr><tr><td>PC-DARTS (Xu et al., 2019)‡</td><td>24.2</td><td>7.3</td><td>5.3</td><td>597</td><td>3.8</td><td>gradient-based</td></tr><tr><td>DARTS+ (Liang et al., 2019)‡</td><td>23.9</td><td>7.4</td><td>5.1</td><td>582</td><td>6.8</td><td>gradient-based</td></tr><tr><td>Amended-DARTS, S2</td><td>24.3</td><td>7.4</td><td>5.5</td><td>590</td><td>1.1</td><td>gradient-based</td></tr></table>
Table 2: Comparison with state-of-the-art architectures on ILSVRC2012. All searched architectures are fit into the mobile setting. ‡ indicates architectures searched on ImageNet.
# 4.2 RESULTS ON ILSVRC2012
ILSVRC2012 (Russakovsky et al., 2015) is the most commonly used subset of ImageNet (Deng et al., 2009). It contains 1.3M training images and 50K testing images, which are almost evenly distributed over all 1,000 categories. We directly use the $S _ { 2 }$ architecture obtained from CIFAR10 experiments and enlarge it with a basic number of channels of 42, so that the FLOPs of our model is 590M, i.e., fitting the mobile setting. During re-training, there are a total of 250 epochs. We use an SGD optimizer with an initial learning rate of 0.5 (decaying linearly after each epoch), a momentum of 0.9 and a weight decay of $3 \times 1 0 ^ { - 5 }$ . On NVIDIA Tesla V100 GPUs, the entire re-training process takes around 24 GPU-days.
The comparison of our approach to existing approaches is shown in Table 2. Our approach achieves a top-1 error rate of $2 4 . { \bar { 3 } } \bar { \% }$ without any common optimization tricks such as AutoAugment (Cubuk et al., 2019) and Squeeze-and-Excitation modules (Hu et al., 2018). This result is competitive among state-of-the-arts, and it is obtained after convergence is achieved in the search stage. On the other hand, without the amending term, DARTS converges to a solution that skip-connected and sep-conv$3 x 3$ are largely separated, on which the re-training performance is even inferior to random search.
# 5 CONCLUSIONS
In this paper, we present an effective approach for stabilizing differentiable neural architecture search. Our motivation comes from that DARTS-based approaches mostly generate all-skip-connect architectures when they are executed for a sufficient number of epochs. We analyze this weird phenomenon mathematically and find the reason to lie in the dramatic inaccuracy in estimating gradients of architectural parameters. With an alternative approximation based on the optimality of network parameters, we guarantee the update of architectural parameters to be in a correct direction. In DARTS-based search spaces on CIFAR10 and ImageNet, our approach shows improved stability, in particular in large search spaces, as well as improved performance in the re-training stage.
Our research sheds light on future research on NAS in several aspects. First, we reveal that previous differentiable approaches were mostly built upon a dangerous pipeline, and mostly introduced heavy human expertise to avoid failure. By fixing the ‘system error’ of this pipeline, we provide a platform that NAS approaches can compete in the ability of NAS. Second, our approach enables researchers to explore even bigger search spaces that have not been studied before (due to search instability).
REFERENCES H. Cai, T. Chen, W. Zhang, Y. Yu, and J. Wang. Efficient architecture search by network transformation. In AAAI Conference on Artificial Intelligence, 2018. H. Cai, L. Zhu, and S. Han. Proxylessnas: Direct neural architecture search on target task and hardware. 2019. X. Chen, L. Xie, J. Wu, and Q. Tian. Progressive differentiable architecture search: Bridging the depth gap between search and evaluation. In International Conference on Computer Vision, 2019. E. D. Cubuk, B. Zoph, D. Mane, V. Vasudevan, and Q. V. Le. Autoaugment: Learning augmentation policies from data. In Computer Vision and Pattern Recognition, 2019. J. Deng, W. Dong, R. Socher, L. J. Li, K. Li, and L. Fei-Fei. Imagenet: A large-scale hierarchical image database. In Computer Vision and Pattern Recognition, 2009. T. DeVries and G. W. Taylor. Improved regularization of convolutional neural networks with cutout. arXiv preprint arXiv:1708.04552, 2017. G. Ghiasi, T. Y. Lin, and Q. V. Le. Nas-fpn: Learning scalable feature pyramid architecture for object detection. In Computer Vision and Pattern Recognition, 2019. Z. Guo, X. Zhang, H. Mu, W. Heng, Z. Liu, Y. Wei, and J. Sun. Single path one-shot neural architecture search with uniform sampling. arXiv preprint arXiv:1904.00420, 2019. K. He, X. Zhang, S. Ren, and J. Sun. Deep residual learning for image recognition. In Computer Vision and Pattern Recognition, 2016. A. G. Howard, M. Zhu, B. Chen, D. Kalenichenko, W. Wang, T. Weyand, M. Andreetto, and H. Adam. Mobilenets: Efficient convolutional neural networks for mobile vision applications. arXiv preprint arXiv:1704.04861, 2017. J. Hu, L. Shen, and G. Sun. Squeeze-and-excitation networks. In Computer Vision and Pattern Recognition, 2018. G. Huang, Z. Liu, L. Van Der Maaten, and K. Q. Weinberger. Densely connected convolutional networks. In Computer Vision and Pattern Recognition, 2017. A. Krizhevsky, I. Sutskever, and G. E. Hinton. Imagenet classification with deep convolutional neural networks. In Advances in Neural Information Processing Systems, 2012. Alex Krizhevsky and Geoffrey Hinton. Learning multiple layers of features from tiny images. Technical report, 2009. Y. LeCun, Y. Bengio, and G. E. Hinton. Deep learning. Nature, 521(7553):436, 2015. H. Liang, S. Zhang, J. Sun, X. He, W. Huang, K. Zhuang, and Z. Li. Darts+: Improved differentiable architecture search with early stopping. arXiv preprint arXiv:1909.06035, 2019. C. Liu, B. Zoph, M. Neumann, J. Shlens, W. Hua, L. J. Li, L. Fei-Fei, A. L. Yuille, J. Huang, and K. Murphy. Progressive neural architecture search. In European Conference on Computer Vision, 2018a. C. Liu, L. C. Chen, F. Schroff, H. Adam, W. Hua, A. L. Yuille, and L. Fei-Fei. Auto-deeplab: Hierarchical neural architecture search for semantic image segmentation. In Computer Vision and Pattern Recognition, 2019a. H. Liu, K. Simonyan, O. Vinyals, C. Fernando, and K. Kavukcuoglu. Hierarchical representations for efficient architecture search. In International Conference on Learning Representations, 2018b. H. Liu, K. Simonyan, and Y. Yang. Darts: Differentiable architecture search. In International Conference on Learning Representations, 2019b. R. Luo, F. Tian, T. Qin, E. Chen, and T. Y. Liu. Neural architecture optimization. In Advances in Neural Information Processing Systems, 2018. N. Ma, X. Zhang, H. T. Zheng, and J. Sun. Shufflenet v2: Practical guidelines for efficient cnn architecture design. In European Conference on Computer Vision, 2018. N. Nayman, A. Noy, T. Ridnik, I. Friedman, R. Jin, and L. Zelnik-Manor. Xnas: Neural architecture search with expert advice. arXiv preprint arXiv:1906.08031, 2019. A. Noy, N. Nayman, T. Ridnik, N. Zamir, S. Doveh, I. Friedman, R. Giryes, and L. Zelnik-Manor. Asap: Architecture search, anneal and prune. arXiv preprint arXiv:1904.04123, 2019. H. Pham, M. Guan, B. Zoph, Q. V. Le, and J. Dean. Efficient neural architecture search via parameter sharing. In International Conference on Machine Learning, 2018. E. Real, S. Moore, A. Selle, S. Saxena, Y. L. Suematsu, J. Tan, Q. V. Le, and A. Kurakin. Large-scale evolution of image classifiers. In International Conference on Machine Learning, 2017. E. Real, A. Aggarwal, Y. Huang, and Q. V. Le. Regularized evolution for image classifier architecture search. In AAAI Conference on Artificial Intelligence, 2019. O. Russakovsky, J. Deng, H. Su, J. Krause, S. Satheesh, S. Ma, Z. Huang, A. Karpathy, A. Khosla, M. Bernstein, et al. Imagenet large scale visual recognition challenge. International Journal of Computer Vision, 115(3):211–252, 2015. N. Srivastava, G. E. Hinton, A. Krizhevsky, I. Sutskever, and R. Salakhutdinov. Dropout: a simple way to prevent neural networks from overfitting. Journal of Machine Learning Research, 15(1): 1929–1958, 2014. C. Szegedy, W. Liu, Y. Jia, P. Sermanet, S. Reed, D. Anguelov, D. Erhan, V. Vanhoucke, and A. Rabinovich. Going deeper with convolutions. In Computer Vision and Pattern Recognition, 2015. M. Tan and Q. V. Le. Efficientnet: Rethinking model scaling for convolutional neural networks. In International Conference on Machine Learning, 2019. M. Tan, B. Chen, R. Pang, V. Vasudevan, M. Sandler, A. Howard, and Q. V. Le. Mnasnet: Platformaware neural architecture search for mobile. In Computer Vision and Pattern Recognition, 2019. L. Xie and A. L. Yuille. Genetic CNN. In International Conference on Computer Vision, 2017. S. Xie, H. Zheng, C. Liu, and L. Lin. SNAS: Stochastic neural architecture search. arXiv preprint arXiv:1812.09926, 2018. S. Xie, A. Kirillov, R. Girshick, and K. He. Exploring randomly wired neural networks for image recognition. In International Conference on Computer Vision, 2019. Y. Xu, L. Xie, X. Zhang, X. Chen, G. J. Qi, Q. Tian, and H. Xiong. Pc-darts: Partial channel connections for memory-efficient differentiable architecture search. arXiv preprint arXiv:1907.05737, 2019. X. Zhang, X. Zhou, M. Lin, and J. Sun. Shufflenet: An extremely efficient convolutional neural network for mobile devices. In Computer Vision and Pattern Recognition, 2018. H. Zhou, M. Yang, J. Wang, and W. Pan. Bayesnas: A bayesian approach for neural architecture search. arXiv preprint arXiv:1905.04919, 2019. B. Zoph and Q. V. Le. Neural architecture search with reinforcement learning. In International Conference on Learning Representations, 2017. B. Zoph, V. Vasudevan, J. Shlens, and Q. V. Le. Learning transferable architectures for scalable image recognition. In Computer Vision and Pattern Recognition, 2018.
# A APPENDIX
# A.1 A TOY EXAMPLE TO SHOW THE IMPORTANCE OF $\mathbf { g } _ { 2 }$
Let the loss function be $\begin{array} { l l l } { { \mathcal L } \left( \omega , \alpha ; x \right) } & { = } & { \left( \omega x - \alpha \right) ^ { 2 } } \end{array}$ . Then, the only difference between $\mathcal { L } _ { \mathrm { t r a i n } } \left( \omega , \alpha \right) = \mathcal { L } \left( \omega , \alpha ; x _ { \mathrm { t r a i n } } \right)$ and $\mathcal { L } _ { \mathrm { v a l i d } } \left( \omega , \alpha \right) = \mathcal { L } \left( \omega , \alpha ; x _ { \mathrm { v a l i d } } \right)$ lies in the input, $_ { \textbf { \em x } }$ . Assume the input of training data is ${ x } _ { \mathrm { t r a i n } } = 1$ and the input validation data is $\pmb { x } _ { \mathrm { v a l i d } } = 2$ . It is easy to derive that the local optimum of $\mathcal { L } _ { \mathrm { t r a i n } } \left( \omega , \alpha \right)$ is $\omega ^ { \ast } \left( \alpha \right) = \alpha$ . Substituting $\pmb { x } _ { \mathrm { v a l i d } } = 2$ into $\mathcal { L } _ { \mathrm { v a l i d } } \left( \omega , \alpha \right)$ yields ${ \mathcal { L } } _ { \mathrm { v a l i d } } \left( \omega , \alpha \right) = \left( 2 \omega - \alpha \right) ^ { 2 }$ . When $\mathbf { \alpha } _ { \alpha } = \mathbf { \alpha } _ { \mathbf { \alpha } _ { \mathbf { t } } }$ , $\omega$ arrives at $\omega ^ { \ast } \left( \alpha _ { \mathrm { t } } \right)$ , so $\mathbf { g } _ { 1 } = 2 \left( \alpha _ { \mathrm { t } } - 2 \alpha _ { \mathrm { t } } \right) = - 2 \alpha _ { \mathrm { t } }$ and $\mathbf { g } _ { 2 } = 4 \alpha _ { \mathrm { t } }$ . When $\omega$ arrives at ${ { \omega } ^ { * } } \left( \alpha \right) , { { \mathcal { L } } _ { v a l i d } } \left( { { \omega } ^ { * } } \left( \alpha \right) , \alpha \right) = { { \alpha } ^ { 2 } }$ , $\mathbf { g } \left( \alpha _ { \mathrm { t } } \right) = 2 \alpha _ { \mathrm { t } } = \mathbf { g } _ { 1 } + \mathbf { g } _ { 2 }$ . In summary, both $\mathbf { g } _ { 1 }$ and $\mathbf { g } _ { 2 }$ are important, but DARTS chose to ignore $\mathbf { g } _ { 2 }$ which can cause a dramatic error in approximation.
# A.2 THE COMPLEXITY OF $\mathbf { g } _ { 2 } ^ { ' }$ CAN BE SUBSTANTIALLY REDUCED USING THE FINITEDIFFERENCE APPROXIMATION
We use the finite difference approximation just like DARTS. Let $\epsilon$ be a small scalar, $\omega _ { 1 } \ = \ \omega + \epsilon \nabla _ { \omega } \mathcal { L } _ { \mathrm { v a l } } ( \omega , \alpha )$ , $\omega _ { 2 } ~ = ~ \omega - \epsilon \nabla _ { \omega } \mathcal { L } _ { \mathrm { v a l } } ( \omega , \alpha )$ . Then: $\begin{array} { r l } { \mathbf { H } \cdot \nabla _ { \omega } \mathcal { L } _ { \mathrm { v a l } } ( \omega , \alpha ) } & { = } \end{array}$ $\frac { \nabla _ { \omega } \mathcal { L } _ { \mathrm { t r a i n } } ( \omega _ { 1 } , \alpha ) - \nabla _ { \omega } \mathcal { L } _ { \mathrm { t r a i n } } ( \omega _ { 2 } , \alpha ) } { \mathrm { . } }$ . $\begin{array} { r l r } { \omega _ { 3 } } & { { } = } & { \omega \ + \ \frac { \nabla _ { \omega } \mathcal { L } _ { \mathrm { t r a i n } } ( \omega _ { 1 } , \alpha ) - \nabla _ { \omega } \mathcal { L } _ { \mathrm { t r a i n } } ( \omega _ { 2 } , \alpha ) } { 2 } } \end{array}$ , $\omega _ { 4 } = \omega - \frac { } { }$ 2 . Then: $\frac { \nabla _ { \omega } \mathcal { L } _ { \mathrm { t r a i n } } ( \omega _ { 1 } , \alpha ) ^ { - \infty } \nabla _ { \omega } \mathcal { L } _ { \mathrm { t r a i n } } ( \omega _ { 2 } , \alpha ) } { 2 }$ $\begin{array} { r } { \mathbf { g } _ { 2 } ^ { \prime } = - \pmb { \eta } \times \frac { \nabla _ { \omega } \mathcal { L } _ { \mathrm { v a l } } ( \omega _ { 3 } , \alpha ) - \bar { \nabla _ { \omega } } \mathcal { L } _ { \mathrm { v a l } } ( \omega _ { 4 } , \alpha ) } { 2 \epsilon } } \end{array}$
# A.3 A TOY EXAMPLE TO SHOW THE IMPORTANCE OF THE “GRADIENT TRAP”
We have a small toy case to show the influence of the “gradient trap”. We searched for a small super-network in the DARTS’s search space, which only has two cells(we searched for 600 epochs).
When we train the super-network in the “training sets in search phase” and validate in the “validation sets in search phase”, the test error using $\mathbf { g } _ { 2 } ^ { ' }$ is $1 0 . 5 \%$ while the test error without ${ \bf g } _ { 2 } ^ { ' }$ is $1 2 . 8 \%$ .
When we train the super-network in the training sets and validate in the validation sets, the test error using ${ \bf g } _ { 2 } ^ { ' }$ is $5 . 4 \%$ while the test error without $\mathbf { g } _ { 2 } ^ { ' }$ is $7 . 4 \%$ .
When we generalize and train the network in the training sets and validate in the validation sets, the test error using ${ \bf g } _ { 2 } ^ { ' }$ is $6 . 2 \%$ while the test error without $\mathbf { g } _ { 2 } ^ { \prime }$ is $7 . 4 \%$ .
In this case the “gradient trap” will cause a dramatic accuracy drop of the super-network.
# A.4 SEARCH WITH DIFFERENT SEEDS
We ran our search algorithms with different seeds for 5 times in $S _ { 2 }$ and evaluated each discovered architecture for 3 times. The lowest test error is $2 . 5 7 { \pm } 0 . 1 1 \%$ and the highest is $2 . 6 3 { \pm } 0 . 1 3 \%$ . We did the same thing on $S _ { 1 }$ and the lowest and the highest test errors are $2 . 7 1 \pm 0 . 1 5 \%$ and $2 . 9 2 \pm 0 . 0 9 \%$ , respectively.
As we expected, the results in $S _ { 1 }$ are less robust than those in $S _ { 2 }$ . The main reason is the difference between search and evaluation, including the different depths of search and evaluation networks and the the discretization stage of the standard DARTS method.
More importantly, our approach survives after 500 (and even more) epochs, while DARTS degenerates to an all-skip-connect architecture in all $( 1 0 + )$ individual runs.
A.5 THEORETICAL ANALYSIS OF SEMI-POSITIVE-DEFINITE MATRIX AFTER SIMILARITY TRANSFORMATION
$\mathbf { A } = \mathbf { C } ^ { T } \cdot \mathbf { C } .$ , A is a semi-positive-definite matrix. In this case, the number of different eigenvalues is far less than the dimension of A(hundreds compared to millions). $\mathbf { H }$ is a real symmetric positivedefinite matrix.
Let $\big \{ \alpha _ { \mathrm { i } } \big \}$ be a set of eigenvectors w.r.t $\mathbf { A } ( \alpha _ { \mathrm { i } } ^ { T } \cdot \alpha _ { \mathrm { i } } = 1 )$ ), then $\{ \mathbf { H } \cdot \mathbf { \boldsymbol { \alpha } } _ { \mathrm { i } } \}$ is a set of eigenvectors w.r.t $\mathbf { H } \cdot \dot { \mathbf { A } } \cdot \dot { \mathbf { H } } ^ { - 1 }$ , $\{ \mathbf { H } ^ { - 1 } \cdot \mathbf { \bar { \alpha } } _ { \mathrm { i } } \}$ is a set of eigenvectors w.r.t $\mathbf { H } ^ { - 1 } \cdot \mathbf { A } \cdot \mathbf { H }$ , and $\{ \lambda _ { \mathrm { i } } \}$ is a set of eigenvectors shared by them.
Let $\beta$ be an eigenvector $\begin{array} { r } { \mathbf { \operatorname { p f } } \mathbf { H } { \cdot } \mathbf { A } { \cdot } \mathbf { H } ^ { - 1 } + \mathbf { H } ^ { - 1 } { \cdot } \mathbf { A } { \cdot } \mathbf { H } , \beta = \sum _ { \mathrm { i } = 1 } ^ { \mathrm { n } } a _ { \mathrm { i } } \times \mathbf { H } \cdot \alpha _ { \mathrm { i } } = \sum _ { \mathrm { i } = 1 } ^ { \mathrm { n } } b _ { \mathrm { i } } \times \mathbf { H } ^ { - 1 } \cdot \alpha _ { \mathrm { i } } . } \end{array}$ $\begin{array} { r l } & { \qquad \mathrm { E } : = \dots \qquad \mathrm { A } : \mathrm { H } ^ { - 1 } + \mathrm { H } ^ { - 1 } \cdot \mathrm { A } \cdot \mathrm { H } \cdot \mathrm { \Lambda } \mathrm { H } \cdot \mathrm { \Lambda } \beta = \mathrm { \Lambda } \lambda \beta , \quad \mathrm { ~ a } : = 1 \times \mathrm { H } \cdot \mathrm { \Lambda } \alpha _ { \mathrm { i } } + \sum _ { \mathrm { i } = 1 } ^ { \mathrm { n } } b _ { \mathrm { i } } \lambda _ { \mathrm { i } } \times \mathrm { H } ^ { - 1 } \cdot \alpha _ { \mathrm { i } } = } \\ & { \underset { \mathrm { - i } = 1 } { \sum } a _ { \mathrm { i } } \lambda \times \mathrm { H } \cdot \alpha _ { \mathrm { i } } = \sum _ { \mathrm { i } = 1 } ^ { \mathrm { n } } b _ { \mathrm { i } } \lambda \times \mathrm { H } ^ { - 1 } \cdot \alpha _ { \mathrm { i } } . } \\ & { \underset { \mathrm { - i } = 1 } { \sum } \left( \lambda _ { \mathrm { i } } - \lambda \right) a _ { \mathrm { i } } b _ { \mathrm { i } } = - \sum _ { \mathrm { i } = 1 } ^ { \mathrm { n } } \left( \lambda _ { \mathrm { i } } - \lambda \right) b _ { \mathrm { i } } \alpha _ { \mathrm { i } } ^ { T } \cdot \mathrm { H } ^ { - 1 } \cdot \sum _ { \mathrm { i } = 1 } ^ { \mathrm { n } } \left( \lambda _ { \mathrm { i } } - \lambda \right) b _ { \mathrm { i } } \mathrm { H } ^ { - 1 } \cdot \alpha _ { \mathrm { i } } \le 0 } \end{array}$
A is a real symmetric matrix, so we have many sets of $\big \{ \alpha _ { \mathrm { i } } \big \}$ that is orthogonal to each other. $\beta ^ { T } \cdot \beta =$ $\textstyle \sum _ { \mathrm { i } = 1 } ^ { \mathrm { n } } a _ { \mathrm { i } } b _ { \mathrm { i } } \geq 0$ , For every eigenvalue, the dimension of the subspace will be very high in the case of neural architecture search, so we assume that we can choose a set of $\big \{ \alpha _ { \mathrm { i } } \big \}$ orthogonal to each other from the subspace satisfying Pni+1j=ni $\sum _ { \mathrm { j = n _ { i } } } ^ { \mathrm { n _ { i + 1 } - 1 } } a _ { \mathrm { j } } b _ { \mathrm { j } } \geq 0$ in most cases $\mathrm { { \acute { n } _ { i } } }$ is the id of the first eigenvector w.r.t $\lambda _ { \mathrm { i } }$ ).
$\begin{array} { r } { \sum _ { \mathrm { i = 1 } } ^ { \mathrm { n } } \left( \lambda _ { \mathrm { i } } - \lambda \right) a _ { \mathrm { i } } b _ { \mathrm { i } } = \sum _ { \mathrm { i = 1 } } ^ { \mathrm { n } } \left( \lambda _ { \mathrm { i } } - \lambda \right) \sum _ { \mathrm { j = n _ { i } } } ^ { \mathrm { n _ { i + 1 } - 1 } } a _ { \mathrm { j } } b _ { \mathrm { j } } \le 0 } \end{array}$ so $\boldsymbol { \lambda }$ cannot be smaller than zero.
All of the eigenvalues w.r.t real symmetric matrix $\mathbf { H } \cdot \mathbf { A } \cdot \mathbf { H } ^ { - 1 } + \mathbf { H } ^ { - 1 } \cdot \mathbf { A } \cdot \mathbf { H }$ is not smaller than zero, so it is semi-positive-definite. Then we get that $\mathbf { H } ^ { - 1 } \cdot \mathbf { A } \cdot \mathbf { H }$ is semi-positive-definite.123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381# FEATURE INTERACTION INTERPRETABILITY: A CASE FOR EXPLAINING AD-RECOMMENDATION SYSTEMS VIA NEURAL INTERACTION DETECTION
Michael Tsang1, Dehua Cheng2, Hanpeng $\mathbf { L i u } ^ { 1 }$ , Xue Feng2, Eric Zhou2, and Yan Liu1
1Department of Computer Science, University of Southern California {tsangm,hanpengl,yanliu.cs}@usc.edu 2Facebook AI {dehuacheng,xfeng,hanningz}@fb.com
# ABSTRACT
Recommendation is a prevalent application of machine learning that affects many users; therefore, it is important for recommender models to be accurate and interpretable. In this work, we propose a method to both interpret and augment the predictions of black-box recommender systems. In particular, we propose to interpret feature interactions from a source recommender model and explicitly encode these interactions in a target recommender model, where both source and target models are black-boxes. By not assuming the structure of the recommender system, our approach can be used in general settings. In our experiments, we focus on a prominent use of machine learning recommendation: ad-click prediction. We found that our interaction interpretations are both informative and predictive, e.g., significantly outperforming existing recommender models. What’s more, the same approach to interpret interactions can provide new insights into domains even beyond recommendation, such as text and image classification.
# 1 INTRODUCTION
Despite their impact on users, state-of-the-art recommender systems are becoming increasingly inscrutable. For example, the models that predict if a user will click on an online advertisement are often based on function approximators that contain complex components in order to achieve optimal recommendation accuracy. The complex components come in the form of modules for better learning relationships among features, such as interactions between user and ad features (Cheng et al., 2016; Guo et al., 2017; Wang et al., 2017; Lian et al., 2018; Song et al., 2018). Although efforts have been made to understand the feature relationships, there is still no method that can interpret the feature interactions learned by a generic recommender system, nor is there a strong commercial incentive to do so.
In this work, we identify and leverage feature interactions that represent how a recommender system generally behaves. We propose a novel approach, Global Interaction Detection and Encoding for Recommendation (GLIDER), which detects feature interactions that span globally across multiple data-instances from a source recommender model, then explicitly encodes the interactions in a target recommender model, both of which can be black-boxes. GLIDER achieves this by first utilizing our ongoing work on Neural Interaction Detection (NID) (Tsang et al., 2017) with a data-instance perturbation method called LIME (Ribeiro et al., 2016) over a batch of data samples. GLIDER then explicitly encodes the collected global interactions into a target model via sparse feature crossing.
In our experiments on ad-click recommendation, we found that the interpretations generated by GLIDER are illuminating, and the detected global interactions can significantly improve the target model’s prediction performance. Because our interaction interpretation method is very general, we also show that the interpretations are informative in other domains: text, image, graph, and dna modeling.
 Figure 1: A simplified overview of GLIDER. $\textcircled{1}$ GLIDER utilizes Neural Interaction Detection and LIME together to interpret feature interactions learned by a source black-box model at a data instance, denoted by the large green plus sign. $\textcircled{2}$ GLIDER identifies interactions that consistently appear over multiple data samples, then explicitly encodes these interactions in a target black-box recommender model $f _ { r e c }$ .
Our contributions are as follows:
1. We propose feature interaction interpretations of general prediction models via interaction detection. 2. Based on this approach, we propose GLIDER to detect and explicitly encode global feature interactions in black-box recommender systems. This process is a form of automatic feature engineering. 3. Through experiments, we demonstrate the overall interpretability of detected feature interactions on a variety of domains and show that the interactions can be leveraged to improve recommendation accuracy.
# 2 NOTATIONS AND BACKGROUND
Notations: Vectors are represented by boldface lowercase letters, such as $\mathbf { x }$ or $\mathbf { z }$ . The $i$ -th entry of a vector $\mathbf { x }$ is denoted by $x _ { i }$ . For a set $s$ , its cardinality is denoted by $| S |$ .
Let $d$ be the number of features in a dataset. An interaction, $\mathcal { T }$ , is a subset of feature indices: ${ \mathcal { T } } \subseteq \{ 1 , 2 , \ldots , d \}$ , where $| \mathcal { T } |$ is always $\geq 2$ . A higher-order interaction always has $| \mathcal { T } | \geq 3$ . For a vector $\mathbf { x } \in \mathbb { R } ^ { d }$ , let $\mathbf { x } _ { \mathcal { I } } \in \mathbb { R } ^ { | \mathcal { I } | }$ be restricted to the dimensions of $\mathbf { x }$ specified by $\mathcal { T }$ .
Let a black-box model be $f ( \cdot ) : \mathbb { R } ^ { p } \mathbb { R }$ . A black-box recommender model uses tabular feature types, as discussed later in this section. In classification tasks, we assume $f$ is a class logit. $p$ and $d$ may be different depending on feature transformations.
Feature Interactions: By definition, a model $f$ learns a statistical (non-additive) feature interaction $\mathcal { T }$ if and only if $f$ cannot be decomposed into a sum of $| \mathcal { T } |$ arbitrary subfunctions $f _ { i }$ , each excluding a corresponding interaction variable (Friedman et al., 2008; Sorokina et al., 2008; Tsang et al., 2017), i.e., $\begin{array} { r } { f ( \mathbf { x } ) \neq \bar { \sum } _ { i \in \mathcal { T } } f _ { i } ( \mathbf { x } _ { \{ 1 , 2 , \ldots , d \} \backslash i } ) } \end{array}$ .
For example, a multiplication between two features, $x _ { 1 }$ and $x _ { 2 }$ , is a feature interaction because it cannot be represented as an addition of univariate functions, i.e., $x _ { 1 } x _ { 2 } \neq f _ { 1 } ( x _ { 2 } ) + f _ { 2 } ( x _ { 1 } )$ .
Recommendation Systems: A recommender system, $f _ { r e c } ( \cdot )$ , is a model of two feature types: dense numerical features and sparse categorical features. Since the one-hot encoding of categorical feature $x _ { c }$ can be high-dimensional, it is commonly represented in a low-dimensional embedding $\scriptstyle \mathbf { e } _ { c } \ =$ $o n e \mathbf { \mathcal { - } } h o t ( x _ { c } ) \mathbf { V } _ { c }$ via embedding matrix $\mathbf { V } _ { c }$ .
# 3 FEATURE INTERACTIONS IN BLACK-BOX MODELS
We start by explaining how to obtain a data-instance level (local) interpretation of feature interactions by utilizing interaction detection on feature perturbations.
# 3.1 FEATURE PERTURBATION AND INFERENCE
Given a data instance $\mathbf { x } \in \mathbb { R } ^ { p }$ , LIME proposed to perturb the data instance by sampling a separate binary representation $\tilde { \mathbf { x } } \in \{ 0 , 1 \} ^ { d }$ of the same data instance. Let $\xi : \{ 0 , 1 \} ^ { d } \overset { \cdot } { } \mathbb { R } ^ { p }$ be the map from the binary representation to the perturbed data instance. Starting from a binary vector of all ones that map to the original features values in the data instance, LIME uniformly samples the number of random features to switch to 0 or the “off” state. In the data instance, “off” could correspond to a 0 embedding vector for categorical features or mean value over a batch for numerical features. It is possible for $d < p$ by grouping features in the data instance to correspond to single binary features in $\tilde { \bf x }$ . An important step is getting black-box predictions of the perturbed data instances to create a dataset with binary inputs and prediction targets: $\mathcal { D } = \{ ( \tilde { \mathbf { x } } _ { i } , y _ { i } ) ~ | ~ y _ { i } = f ( \xi ( \tilde { \mathbf { x } } _ { i } ) ) , \tilde { \mathbf { x } } _ { i } \in \{ 0 , 1 \} ^ { d } \}$ . Though we use LIME’s approach, the next section is agnostic to the instance perturbation method.
# 3.2 FEATURE INTERACTION DETECTION
Feature interaction detection is concerned with identifying feature interactions in a dataset (Bien et al., 2013; Purushotham et al., 2014; Lou et al., 2013; Friedman et al., 2008). Typically, proper interaction detection requires a pre-processing step to remove correlated features that adversely affect detection performance (Sorokina et al., 2008). As long as features in dataset $\mathcal { D }$ are generated in an uncorrelated fashion, e.g., through random sampling, we can directly use $\mathcal { D }$ to detect feature interactions from black-box model $f$ at data instance x.
# 3.2.1 NEURAL INTERACTION DETECTION
$f$ can be an arbitrary function and can generate highly nonlinear targets in $\mathcal { D }$ , so we focus on detecting interactions that could have generic forms. In light of this, we leverage our method, Neural Interaction Detection (NID) (Tsang et al., 2017), which accurately and efficiently detects generic non-additive and arbitrary-order statistical feature interactions. NID detects these interactions by training a lasso-regularized multilayer perceptron (MLP) on a dataset, then identifying the features that have high-magnitude weights to common hidden units. NID is efficient by greedily testing the top-interaction candidates of every order at each of $h$ first-layer hidden units, enabling arbitraryorder interaction detection in $O ( h d )$ tests within one MLP.
# 3.2.2 GRADIENT-BASED NEURAL INTERACTION DETECTION
Besides the non-additive definition of statistical interaction, a gradient definition also exists based on mixed partial derivatives (Friedman et al., 2008), i.e., a function $F ( \cdot )$ exhibits statistical interaction $\mathcal { T }$ among features $z _ { i }$ indexed by $i _ { 1 } , i _ { 2 } , \dotsc , i _ { | \mathcal { T } | } \in \mathcal { T }$ if
$$E _ { \mathbf { z } } \left[ \frac { \partial ^ { | \mathcal { T } | } F ( \mathbf { z } ) } { \partial z _ { i _ { 1 } } \partial z _ { i _ { 2 } } \dots \partial z _ { i _ { | \mathcal { T } | } } } \right] ^ { 2 } > 0 .$$
The advantage of this definition is that it allows exact interaction detection from model gradients (Ai & Norton, 2003); however, this definition contains a computationally expensive expectation, and typical neural networks with ReLU activation functions do not permit mixed partial derivatives. For the task of local interpretation, we only examine a single data instance $\mathbf { x }$ , which avoids the expectation. We turn $F$ into an MLP $g ( \cdot )$ with smooth, infinitely-differentiable activation functions such as softplus, which closely follows ReLU (Glorot et al., 2011). We then train the MLP with the same purpose as $\ S 3 . 2 . 1$ to faithfully capture interactions in perturbation dataset $\mathcal { D }$ . Given these conditions, we define an alternate gradient-based neural interaction detector (GradientNID) as:
$$\omega ( \mathcal { T } ) = \left( \frac { \partial ^ { | \mathcal { T } | } g ( \tilde { \mathbf { x } } ) } { \partial \tilde { x } _ { i _ { 1 } } \partial \tilde { x } _ { i _ { 2 } } \hdots \partial \tilde { x } _ { i _ { | \mathcal { T } | } } } \right) ^ { 2 } ,$$
where $\omega$ is the strength of the interaction $\mathcal { T }$ , $\tilde { \mathbf { x } }$ is the representation of $\mathbf { x }$ , and the MLP $g$ is trained on $\mathcal { D }$ . While GradientNID exactly detects interactions from the explainer MLP, it needs to compute interaction strengths $\omega$ for feature combinations that grow exponentially in number as $| \mathcal { T } |$ increases. We recommend restricting GradientNID to low-order interactions.
Algorithm 1 Global Interaction Detection in GLIDER
<table><tr><td>Input: dataset B, recommender model frec Output: G = {(Ii,ci)}: global interactions Ii and their counts ci over the dataset</td></tr><tr><td>1:G ← initialize occurrence dictionary for global interactions</td></tr><tr><td>2:for each data sample x within dataset B do</td></tr><tr><td>3: S ← MADEX(frec, X)</td></tr><tr><td>4: G ← increment the occurrence count of Ij ∈ S, ∀j = 1,2,...,|S|</td></tr><tr><td>5: sort G by most frequently occurring interactions</td></tr><tr><td>6:[optional prune subset interactions in G within a target number of interactions K</td></tr></table>
# 3.3 SCOPE
Based on $\ S 3 . 1$ and $\ S 3 . 2$ , we define a function, $\mathtt { M A D E X } ( f , \mathbf { x } )$ , that takes as inputs black-box $f$ and data instance $\mathbf { x }$ , and outputs ${ \cal { S } } = \{ { \cal { T } } _ { i } \} _ { i = 1 } ^ { k }$ , a set of top- $k$ detected feature interactions. MADEX stands for “Model-Agnostic Dependency Explainer”.
In some cases, it is necessary to identify a $k$ threshold. Because of the importance of speed for local interpretations, we simply use a linear regression with additional multiplicative terms to approximate the gains given by interactions in $s$ , where $k$ starts at 0 and is incremented until the linear model’s predictions stop improving.
# 4 GLIDER: GLOBAL INTERACTION DETECTION AND ENCODING FOR RECOMMENDATION
We now discuss the different components of GLIDER: detecting global interactions in $\ S 4 . 1$ , then encoding these interactions in recommender systems in $\ S 4 . 2$ . Recommender systems are interesting because they have pervasive application in real-world systems, and their features are often very sparse. By sparse features, we mean features with many categories, e.g., millions of user IDs. The sparsity makes interaction detection challenging especially when applied directly on raw data because the one-hot encoding of sparse features creates an extremely large space of potential feature combinations (Fan et al., 2015).
# 4.1 GLOBAL INTERACTION DETECTION
In this section, we explain the first step of GLIDER. As defined in $\ S 3 . 3$ , MADEX takes as input a blackbox model $f$ and data instance $\mathbf { x }$ . In the context of this section, MADEX inputs a source recommender system $f _ { r e c }$ and data instance $\mathbf { x } = [ x _ { 1 } , x _ { 2 } , \ldots , x _ { p } ]$ . $x _ { i }$ is the $i$ -th feature field and is either a dense or sparse feature. $p$ is both the total number of feature fields and the number of perturbation variables $( p = d )$ ). We define global interaction detection as repeatedly running MADEX over a batch of data instances, then counting the occurrences of the same detected interactions, shown in Algorithm 1. The occurrence counts are not only a useful way to rank global interaction detections, but also a sanity check to rule out the chance that the detected feature combinations are random selections.
One potential concern with Alg. 1 is that it could be slow depending on the speed of MADEX. In our experiments, the entire process took less than one hour when run in parallel over a batch of 1000 samples with $\sim 4 0$ features on a 32-CPU server with 2 GPUs. This algorithm only needs to be run once to obtain the summary of global interactions.
# 4.2 TRUNCATED FEATURE CROSSES
The global interaction $\mathcal { T } _ { i }$ , outputted by Alg. 1, is used to create a synthetic feature $x _ { \mathcal { T } _ { i } }$ for a target recommender system. The synthetic feature $x _ { \mathcal { T } _ { i } }$ is created by explicitly crossing sparse features indexed in $\mathcal { T } _ { i }$ . If interaction $\mathcal { T } _ { i }$ involves dense features, we bucketize the dense features before crossing them. The synthetic feature is sometimes called a cross feature (Wang et al., 2017; Luo et al., 2019) or conjunction feature (Rosales et al., 2012; Chapelle et al., 2015).
In this context, a cross feature is an $n$ -ary Cartesian product among $n$ sparse features. If we denote $\mathcal { X } _ { 1 } , \mathcal { X } _ { 2 } , \ldots , \mathcal { X } _ { n }$ as the set of IDs for each respective feature $x _ { 1 } , x _ { 2 } , \ldots , x _ { n }$ , then their cross feature $x _ { \{ 1 , . . . , n \} }$ takes on all possible values in
$$\mathcal { X } _ { 1 } \times \dots \times \mathcal { X } _ { n } = \{ ( x _ { 1 } , \dots , x _ { n } ) ~ | ~ x _ { i } \in \mathcal { X } _ { i } , \forall i = 1 , \dots , n \}$$
Accordingly, the cardinality of this cross feature is $\left| { \mathcal { X } } _ { 1 } \right| \times \cdots \times \left| { \mathcal { X } } _ { n } \right|$ and can be extremely large, yet many combinations of values in the cross feature are likely unseen in the training data. Therefore, we generate a truncated form of the cross feature with only seen combinations of values, $\mathbf { x } _ { \mathcal { T } } ^ { ( j ) }$ , where $j$ is a sample index in the training data, and $\mathbf { x } _ { \mathcal { T } } ^ { ( j ) }$ is represented as a sparse ID in the cross feature $x \tau$ . We further reduce the cardinality by requiring the same cross feature ID to occur more than times in a batch of samples, or set to a default ID otherwise. These truncation steps significantly reduce the embedding sizes of each cross feature while maintaining their representation power. Once cross features $\{ x _ { \mathbb { Z } _ { i } } \bar \} _ { i }$ are included in a target recommender system, it can be trained as per usual.
# 4.3 MODEL DISTILLATION VS. ENHANCEMENT
There are dual perspectives of GLIDER: as a method for model distillation or model enhancement. If a strong source model is used to detect global interactions which are then encoded in more resourceconstrained target models, then GLIDER adopts a teacher-student type distillation process. If interaction encoding augments the same model where the interactions were detected from, then GLIDER tries to enhance the model’s ability to represent the interactions.
# 5 RELATED WORKS
Interaction Interpretations: A variety of methods exist to detect feature interactions learned in specific models but not black-box models. For example, RuleFit (Friedman et al., 2008), Additive Groves (Sorokina et al., 2008), and Tree-Shap (Lundberg et al., 2018) detect interactions specifically in trees; likewise PaD2 (Gevrey et al., 2006) and NID (Tsang et al., 2017) detect interactions in multilayer perceptrons. Some methods have attempted to interpret feature groups in black-box models, such as Anchors (Ribeiro et al., 2018), Agglomerative Contextual Decomposition (Singh et al., 2019), and Context-Aware methods (Singla et al., 2019); however, these methods were not intended to identify feature interactions.
Explicit Interaction Representation: There are increasingly methods for explicitly representing interactions in models. Cheng et al. (2016), Guo et al. (2017), Wang et al. (2017), and Lian et al. (2018) directly incorporate multiplicative cross terms in neural network architectures and Song et al. (2018) use attention as an interaction module, all of which are intended to improve the neural network’s function approximation. This line of work found that predictive performance can improve with dedicated interaction modeling. Luo et al. (2019) followed up by proposing feature sets from data then explicitly encoding them via feature crossing, but this method’s proposals are limited by beam search. Our work approaches this problem from a model interpretation standpoint.
Black-Box Local vs. Global Interpretations: Data-instance level local interpretation methods are more flexible at explaining general black-box models; however, global interpretations, which cover multiple data instances, have become increasingly desirable to summarize model behavior. Locally Interpretable Model-Agnostic Explanations (LIME) (Ribeiro et al., 2016) and Integrated Gradients (Sundararajan et al., 2017) are some of the most used methods to locally interpret any classifier and neural predictor respectively. There are some methods for global black-box interpretations, such as shuffle-based feature importance (Fisher et al., 2018), submodular pick (Ribeiro et al., 2016), and visual concept extraction (Kim et al., 2018). Our work offers a new tooling option.
# 6 EXPERIMENTS
# 6.1 SETUP
In our experiments, we study interaction interpretation and encoding on real-world data. The hyperparameters in MADEX are as follows. For all experiments, our perturbation datasets $\mathcal { D }$ contain 5000 training samples and 500 samples for each validation and testing. Our usage of NID or GradientNID as the interaction detector (§3.2) depends on the experimental setting. For all experiments that only examine single data instances, we use GradientNID for its exactness and pairwise interaction detection; otherwise, we use NID for its higher-order interaction detection. The MLPs for NID and GradientNID have architectures of 256-128-64 first-to-last hidden layer sizes, and they are trained with learning rate of $\mathrm { 1 e - 2 }$ , batchsize of 100, and the ADAM optimizer. NID uses ReLU activations and an $\ell _ { 1 }$ regularization of $\lambda _ { 1 } = 1 \mathrm { e } { - 4 }$ , whereas GradientNID uses softplus activations and a structural regularizer as MLP+linear regression, which we found offers strong test performance. In general, models are trained with early stopping on validation sets.
For LIME perturbations, we need to establish what a binary 0 maps to via $\xi$ in the raw data instance (§3.1). In domains involving embeddings, i.e., sparse features and word embeddings, the 0 (“off”) state is the zeroed embedding vector. For dense features, it is the mean feature value over a batch; for images, the mean superpixel RGB of the image. For our DNA experiment, we use a random nucleotide other than the original one. These settings correspond to what is used in literature (Ribeiro et al., 2016; 2018). In our graph experiment, the nodes within the neighborhood of a test node are perturbed, where each node is zeroed during perturbation.
# 6.2 EXPERIMENTS ON CTR RECOMMENDATION
In this section, we provide experiments with GLIDER on models trained for clickthrough-rate (CTR) prediction. The recommender models we study include commonly reported baselines, which all use neural networks: Wide&Deep (Cheng et al., 2016), DeepFM (Guo et al., 2017), Deep&Cross (Wang et al., 2017), xDeepFM (Lian et al., 2018), and AutoInt (Song et al., 2018).
Table 1: CTR dataset statistics
<table><tr><td>Dataset</td><td>#Samples</td><td>#Features</td><td>Total # Sparse IDs</td></tr><tr><td>Criteo</td><td>45,840,617</td><td>39</td><td>998,960</td></tr><tr><td>Avazu</td><td>40,428,967</td><td>23</td><td>1,544,428</td></tr></table>
AutoInt is the reported state-of-the-art in academic literature, so we use the model settings and data splits provided by AutoInt’s official public repository1. For all other recommender models, we use public implementations2 with the same original architectures reported in literature, set all embedding sizes to 16, and tune the learning rate and optimizer to reach or surpass the test logloss reported by the AutoInt paper (on AutoInt’s data splits). From tuning, we use the Adagrad optimizer (Duchi et al., 2011) with learning rate of 0.01. All models use early stopping on validation sets.
The datasets we use are benchmark CTR datasets with the largest number of features: Criteo3 and Avazu4, whose data statistics are shown in Table 1. Criteo and Avazu both contain $4 0 +$ millions of user records on clicking ads, with Criteo being the primary benchmark in CTR research (Cheng et al., 2016; Guo et al., 2017; Wang et al., 2017; Lian et al., 2018; Song et al., 2018; Luo et al., 2019).
# 6.2.1 GLOBAL INTERACTION DETECTION
 Figure 2: Occurrence counts (Total: 1000) vs. rank of detected interactions from AutoInt on Criteo and Avazu datasets. \* indicates a higher-order interaction (details in
For each dataset, we train a source AutoInt model, $f _ { r e c }$ , then run global interaction detection via Algorithm 1 on a batch of 1000 samples from the validation set. A full global detection experiment finishes in less than one hour when run in parallel on either Criteo or Avazu datasets in a 32-CPU Intel Xeon E5-2640 v2 $\textcircled { a } \ 2 . 0 0 \mathrm { G H z }$ server with 2 Nvidia 1080 Ti GPUs. The detection results across datasets are shown in Figure 2 Appendix G). as plots of detection counts versus rank. Because the Avazu dataset contains non-anonymized features, we directly show its top-10 detected global interactions in Table 2a.
Table 2: Understanding feature interactions: top global feature interactions for (a) an ad targeting system via Algorithm 1 and (b) a text sentiment analyzer via $\ S 6 . 3 . 2$ (later). The tables are juxtaposed to assist in understanding feature interactions, i.e., nuanced changes among interacting variables lead to significant changes in prediction probabilities. The prediction outcomes are ad-clicks by users for (a) and text sentiment for (b). (a) Explanation of an ad targeting system
<table><tr><td>Count (Total:1000)</td><td>Interaction</td></tr><tr><td>525</td><td>{device_ip,hour}</td></tr><tr><td>235</td><td>{device_id,device_ip,hour}</td></tr><tr><td>217</td><td>{device_id,app-id}</td></tr><tr><td>203</td><td>{device_ip,device_model, hour}</td></tr><tr><td>194</td><td>{site_id, site_domain}</td></tr><tr><td>190</td><td>{site_id, hour}</td></tr><tr><td>187</td><td>{device_ip,site_id,hour}</td></tr><tr><td>183</td><td>{site_id,site_domain,hour}</td></tr><tr><td>179</td><td>{device_id,hour}</td></tr><tr><td>179</td><td>{device_id,device_ip,device_model,hour}</td></tr></table>
(b) Explanation of a sentiment analyzer
<table><tr><td>Count (Total:40)</td><td>Interaction (ordered)</td></tr><tr><td>36</td><td>never, fails</td></tr><tr><td>30</td><td>suspend,disbelief</td></tr><tr><td>30</td><td>too, bad</td></tr><tr><td>29</td><td>very, funny</td></tr><tr><td>29</td><td>neither, nor</td></tr><tr><td>28</td><td>not, miss</td></tr><tr><td>27</td><td>recent, memory</td></tr><tr><td>27</td><td>not, good</td></tr><tr><td>26</td><td>no,denying</td></tr><tr><td>25</td><td>not, bad</td></tr></table>
From Figure 2, we see that the same interactions are detected very frequently across data instances, and many of the interactions are higher-order interactions. The interaction counts are very significant. For example, any top-1 occurrence count $> 2 5$ is significant for the Criteo dataset $( p < 0 . 0 5 ) $ , and likewise $> 7 1$ for the Avazu dataset, assuming a conservative search space of only up to 3-way interactions ( $| \mathcal { I } | \le 3 )$ . Our top-1 occurrence counts are 691 $\left( \gg 2 5 \right)$ ) for Criteo and 525 $( \gg 7 1 )$ ) for Avazu.
In Table 2a, the top-interactions are explainable. For example, the interaction between “device ip” and “hour” (in UTC time) makes sense because users - here identified by IP addresses - have ad-click behaviors dependent on their time zones. This is a general theme with many of the top-interactions5. As another example, the interaction between “device id” and “app id” makes sense because ads are targeted to users based on the app they’re in.
# 6.2.2 INTERACTION ENCODING
Based on our results from the previous section $( \ S 6 . 2 . 1 )$ , we turn our attention to explicitly encoding the detected global interactions in target baseline models via truncated feature crosses (detailed in $\ S 4 . 2 )$ . In order to generate valid cross feature IDs, we bucketize dense features into a maximum of 100 bins before crossing them and require that final cross feature IDs occur more than $T = 1 0 0$ times over a training batch of one million samples.
We take AutoInt’s top- $K$ global interactions on each dataset from $\ S 6 . 2 . 1$ with subset interactions excluded (Algorithm 1, line 6) and encode the interactions in each baseline model including AutoInt itself. $K$ is tuned on valiation sets, and model hyperparameters are the same between a baseline and one with encoded interactions. We set $K = 4 0$ for Criteo and $K = 1 0$ for Avazu.
In Table 3, we found that GLIDER often obtains significant gains in performance based on standard deviation, and GLIDER often reaches or exceeds a desired 0.001 improvement for the Criteo dataset (Cheng et al., 2016; Guo et al., 2017; Wang et al., 2017; Song et al., 2018). The improvements are especially visible with DeepFM on Criteo. We show how this model’s test performance varies with different $K$ in Figure 3. All performance gains are obtained at limited cost of extra model parameters (Table 4) thanks to the truncations applied to our cross features. To avoid extra parameters entirely, we recommend feature selection on the new and existing features.
One one hand, the evidence that AutoInt’s detected interactions can improve other baselines’ performance suggests the viability of interaction distillation. On the other hand, evidence that AutoInt’s performance on Criteo can improve using its own detected interactions suggests that AutoInt may benefit from learning interactions more explicitly. In either model distillation or enhancement settings, we found that GLIDER performs especially well on industry production models trained on large private datasets with thousands of features.
Table 3: Test prediction performance by encoding top- $K$ global interactions in baseline recommender systems on the Criteo and Avazu datasets (5 trials). $K$ are 40 and 10 for Criteo and Avazu respectively. $^ { 6 6 } +$ GLIDER” means the inclusion of detected global interactions to corresponding baselines. The “Setting” column is labeled relative to the source of detected interactions: AutoInt. \* scores by Song et al. (2018).
<table><tr><td rowspan="2">Setting</td><td rowspan="2">Model</td><td colspan="2">Criteo</td><td colspan="2">Avazu</td></tr><tr><td>AUC</td><td>logloss</td><td>AUC</td><td>logloss</td></tr><tr><td rowspan="7">Distillation</td><td>Wide&Deep +GLIDER</td><td>0.8069 ± 5e-4</td><td>0.4446 ± 4e-4</td><td>0.7794± 3e-4</td><td>0.3804 ± 2e-4</td></tr><tr><td>DeepFM</td><td>0.8080±3e-4 0.8079 ± 3e-4</td><td>0.4436 ± 3e-4 0.4436± 2e-4</td><td>0.7795 ± 1e-4 0.7792 ± 3e-4</td><td>0.3802 ± 9e-5 0.3804±9e-5</td></tr><tr><td>+ GLIDER</td><td>0.8097± 2e-4</td><td>0.4420±2e-4</td><td>0.7795 ± 2e-4</td><td>0.3802 ± 2e-4</td></tr><tr><td>Deep&Cross</td><td>0.8076 ± 2e-4</td><td>0.4438± 2e-4</td><td>0.7791 ± 2e-4</td><td>0.3805± 1e-4</td></tr><tr><td>+ GLIDER</td><td>0.8086±3e-4</td><td>0.4428± 2e-4</td><td>0.7792 ± 2e-4</td><td>0.3803 ± 9e-5</td></tr><tr><td>xDeepFM</td><td>0.8084± 2e-4</td><td>0.4433 ± 2e-4</td><td>0.7785± 3e-4</td><td>0.3808 ± 2e-4</td></tr><tr><td>+ GLIDER</td><td>0.8097±3e-4</td><td>0.4421± 3e-4</td><td>0.7787 ± 4e-4</td><td>0.3806± 1e-4</td></tr><tr><td rowspan="2">Enhancement</td><td>AutoInt *</td><td>0.8083</td><td>0.4434</td><td>0.7774</td><td></td></tr><tr><td></td><td></td><td></td><td></td><td>0.3811</td></tr><tr><td></td><td>+ GLIDER</td><td>0.8090±2e-4</td><td>0.4426± 2e-4</td><td>0.7773 ± 1e-4</td><td>0.3811 ± 5e-5</td></tr></table>
Table 4: # parameters of the models in Table 3. M denotes million.
<table><tr><td>Model</td><td>Criteo</td><td>Avazu</td></tr><tr><td>Wide&Deep</td><td>18.1M</td><td>27.3M</td></tr><tr><td>+ GLIDER</td><td>19.3M (+6.8%)</td><td>27.6M (+1.0%)</td></tr><tr><td>DeepFM + GLIDER</td><td>17.5M</td><td>26.7M</td></tr><tr><td></td><td>18.3M (+4.8%)</td><td>26.9M(+0.6%)</td></tr><tr><td>Deep&Cross + GLIDER</td><td>17.5M 18.7M (+6.9%)</td><td>26.1M 26.4M (+1.0%)</td></tr><tr><td>xDeepFM</td><td></td><td></td></tr><tr><td>+ GLIDER</td><td>18.5M 21.7M(+17.2%)</td><td>27.6M 28.3M (+2.5%)</td></tr><tr><td></td><td></td><td></td></tr><tr><td>AutoInt</td><td>16.4M</td><td>25.1M</td></tr><tr><td>+ GLIDER</td><td>17.3M (+5.1%)</td><td>25.2M(+0.6%)</td></tr></table>
 Figure 3: Test logloss vs. $K$ of DeepFM on the Criteo dataset (5 trials).
# 6.3 INTERPRETATIONS ON OTHER DOMAINS
Since the proposed interaction interpretations are not entirely limited to recommender systems, we demonstrate interpretations on more general black-box models. Specifically, we experiment with the function MADEX $( \cdot )$ defined in $\ S 3 . 3$ , which inputs a black-box $f$ , data-instance x, and outputs a set of top- $k$ interactions. The models we use are trained on very different tasks, i.e., ResNet152: an image classifier pretrained on ImageNet ‘14 (Russakovsky et al., 2015; He et al., 2016), Sentiment-LSTM: a 2-layer bi-directional long short-term memory network (LSTM) trained on the Stanford Sentiment Treebank (SST) (Socher et al., 2013; Tai et al., 2015), DNA-CNN: a 2-layer 1D convolutional neural network (CNN) trained on MYC-DNA binding data6 (Mordelet et al., 2013; Yang et al., 2013; Alipanahi et al., 2015; Zeng et al., 2016; Wang et al., 2018; Barrett et al., 2012), and GCN: a 3-layer Graph Convolutional Network trained on the Cora dataset (Kipf & Welling, 2016; Sen et al., 2008). In order to make informative comparisons to the linear LIME baseline, we use LIME’s sample weighting strategy and kernel size (0.25) in this section. We first provide quantitative validation for the detected interactions of all four models in $\ S 6 . 3 . 1$ , followed by qualitative results for ResNet152, Sentiment-LSTM, and DNA-CNN in $\ S 6 . 3 . 2$ .
# 6.3.1 QUANTITATIVE
To quantitatively validate our interaction interpretations of general black-box models, we measure the local explanation fidelity of the interactions via prediction performance. As suggested in $\ S 3 . 3$ and $\ S 4 . 2$ , encoding feature interactions is a way to increase a model’s function representation, but this also means that prediction performance gains over simpler first-order models (e.g., linear regression) is a way to test the significance of the detected interactions. In this section, we use neural network function approximators for each top-interaction from the ranking $\{ \mathcal { T } _ { i } \}$ given by MADEX’s interaction detector (in this case NID). Similar to the $k$ -thresholding description in $\ S 3 . 3$ , we start at $k = 0$ , which is a linear regression, then increment $k$ with added MLPs for each $\mathcal { T } _ { i }$ among $\{ \mathcal { T } _ { i } \} _ { i = 1 } ^ { k }$ until validation performance stops improving, denoted at $k = L$ . The MLPs all have architectures of 64-32-16 first-to-last hidden layer sizes and use the binary perturbation dataset $\mathcal { D }$ (from $\ S 3 . 1 \rrangle$ .
Table 5: Prediction performance (mean-squared error; lower is better) with $( k > 0 )$ ) and without $( k \ = \ 0$ ) interactions for random data instances in the test sets of respective black-box models. $k = L$ corresponds to the interaction at a rank threshold. $2 \le k < L$ are excluded because not all instances have 2 or more interactions. Only results with detected interactions are shown. At least $9 4 \%$ $\left( \geq 1 8 8 \right)$ of the data instances had interactions across 5 trials for each model and score statistic.
<table><tr><td></td><td>k</td><td>DNA-CNN</td><td>Sentiment-LSTM</td><td>ResNet152</td><td>GCN</td></tr><tr><td>linear LIME</td><td>0</td><td>10e-3±le-3</td><td>8.0e-2±6e-3</td><td>1.9 ±0.1</td><td>7.1e3±7e2</td></tr><tr><td>MADEX (ours)</td><td>1</td><td>8e-3±2e-3</td><td>3.8e-2±6e-3</td><td>1.7 ± 0.1</td><td>5.7e3± 7e2</td></tr><tr><td>MADEX (ours)</td><td>L</td><td>5.0e-3±8e-4</td><td>0.4e-2±3e-3</td><td>0.9± 0.2</td><td>2e3±1e3</td></tr></table>
Test prediction performances are shown in Table 5 for $k \in \{ 0 , 1 , L \}$ . The average number of features of $\mathcal { D }$ among the black-box models ranges from 18 to 112. Our quantitative validation shows that adding feature interactions for DNA-CNN, SentimentLSTM, and ResNet152, and adding node interactions for GCN result in significant performance gains when averaged over 40 randomly selected data instances in the test set.
# 6.3.2 QUALITATIVE
For our qualitative analysis, we provide interaction interpretations via MADEX $( \cdot )$ of ResNet152, SentimentLSTM, and DNA-CNN on test samples. The interpretations are given by $\stackrel { \cdot } { S } = \{ { \cal T } _ { i } \} _ { i = 1 } ^ { k }$ , a set of $k$ detected interactions, which are shown in Figure 4 for ResNet152 and SentimentLSTM. For reference, we also show the top “main effects” by LIME’s original linear regression, which select the top-5 features that attribute towards the predicted class7.
In Figure 4a, the “interaction” columns show selected features from MADEX’s interactions between Quickshift superpixels (Vedaldi & Soatto, 2008; Ribeiro et al., 2016). To reduce the number of interactions per image, we merged interactions that have overlap coefficient $\geq ~ 0 . 5$ (Vijaymeena & Kavitha, 2016). From (a) ResNet152 interpretations
 top prediction: trolleybus, trolley coach, trackless trolley Figure 4: Qualitative examples (more in Appendix D & E)
<table><tr><td rowspan="2">Original sentence</td><td rowspan="2">Predi- ction</td><td rowspan="2">Main effects</td><td colspan="2">Interactions (ours)</td></tr><tr><td>I</td><td>I</td></tr><tr><td>It never fails to engage us.</td><td>pos.</td><td>never, us</td><td>never, fails</td><td></td></tr><tr><td>The movie makes absolutely no sense.</td><td>neg.</td><td>no, sense</td><td>absolutely, no</td><td>no, sense</td></tr><tr><td>The central story lacks punch.</td><td>neg.</td><td>lacks</td><td>story, lacks</td><td>lacks, punch</td></tr></table>
the figure, we see that the interactions form a single region or multiple regions of the image. They also tend to be complementary to LIME’s main effects and are sometimes more informative. For example, the interpretations of the “shark” classification show that interaction detection finds the shark fin whereas main effects do not. Interpretations of Sentiment-LSTM are shown in Figure 4b, excluding common stop words (Appendix C). We again see the value of MADEX’s interactions, which show salient combinations of words, such as “never, fails”, “absolutely, no”, and “lacks, punch”.
In our experiments on DNA-CNN, we consistently detected the interaction between “CACGTG” nucleotides, which form a canonical DNA sequence (Staiger et al., 1989). The interaction was detected $9 7 . 3 \%$ out of 187 CACGTG appearances in the test set.
In order to run consistency experiments now on Sentiment-LSTM, word interactions need to be detected consistently across different sentences, which na¨ıvely would require an exorbitant amount of sentences. Instead, we initially collect interaction candidates by running MADEX over all sentences in the SST test set, then select the word interactions that appear multiple times. We assume that word interactions are ordered but not necessarily adjacent or positionally bound, e.g., (not, good) $\ne ( \mathrm { g o o d }$ , not), but their exact positions don’t matter. We use the larger IMDB dataset (Maas et al., 2011) to collect different sets of sentences that contain the same ordered words as each interaction candidate (but the sentences are otherwise random). The ranked detection counts of the target interactions on their individual sets of sentences are shown in Table 2b. The average sentence length is 33 words, and interaction occurrences are separated by 2 words on average.
# 7 CONCLUSION
We proposed a way to interpret feature interactions in general prediction models, and we proposed GLIDER to detect and encode these interactions in black-box recommender systems. In our experiments on recommendation, we found that our detected global interactions are explainable and that explicitly encoding them can improve predictions. We further validated our interaction interpretations on image, text, graph, and dna models. We hope the interpretations encourage investigation into the complex behaviors of prediction models, especially models with large societal impact. Some opportunities for future work are generating correct attributions for interaction interpretations, preventing false-positive interactions from out-of-distribution feature perturbations, and performing interaction distillation from multiple models rather than just one.
# ACKNOWLEDGMENTS
We would like to sincerely thank everyone who has provided their generous feedback for this work. Thank you Youbang Sun, Dongxu Ren, and Beibei Xin for offering early-stage brainstorming and prolonged discussions. Thank you Yuping Luo for providing advice on theoretical analysis of model interpretation. Thank you Rich Caruana for your support and insight. Thank you Artem Volkhin, Levent Ertoz, Ellie Wen, Long Jin, Dario Garcia, and the rest of the Facebook personalization team for your feedback on the paper content. Last but not least, thank you anonymous reviewers for your thorough comments and suggestions. This work was supported by National Science Foundation Awards IIS-1254206 and IIS-1539608, granted to co-author Yan Liu in her academic role at the University of Southern California.
# REFERENCES
Chunrong Ai and Edward C Norton. Interaction terms in logit and probit models. Economics letters, 80(1):123–129, 2003.
Babak Alipanahi, Andrew Delong, Matthew T Weirauch, and Brendan J Frey. Predicting the sequence specificities of dna-and rna-binding proteins by deep learning. Nature biotechnology, 33 (8):831, 2015.
Tanya Barrett, Stephen E Wilhite, Pierre Ledoux, Carlos Evangelista, Irene F Kim, Maxim Tomashevsky, Kimberly A Marshall, Katherine H Phillippy, Patti M Sherman, Michelle Holko, et al. Ncbi geo: archive for functional genomics data sets—update. Nucleic acids research, 41(D1): D991–D995, 2012.
Jacob Bien, Jonathan Taylor, and Robert Tibshirani. A lasso for hierarchical interactions. Annals of statistics, 41(3):1111, 2013.
Olivier Chapelle, Eren Manavoglu, and Romer Rosales. Simple and scalable response prediction for display advertising. ACM Transactions on Intelligent Systems and Technology (TIST), 5(4): 61, 2015.
Tianqi Chen and Carlos Guestrin. Xgboost: A scalable tree boosting system. In Proceedings of the 22nd acm sigkdd international conference on knowledge discovery and data mining, pp. 785–794. ACM, 2016.
Heng-Tze Cheng, Levent Koc, Jeremiah Harmsen, Tal Shaked, Tushar Chandra, Hrishi Aradhye, Glen Anderson, Greg Corrado, Wei Chai, Mustafa Ispir, et al. Wide & deep learning for recommender systems. In Proceedings of the 1st workshop on deep learning for recommender systems, pp. 7–10. ACM, 2016.
John Duchi, Elad Hazan, and Yoram Singer. Adaptive subgradient methods for online learning and stochastic optimization. Journal of Machine Learning Research, 12(Jul):2121–2159, 2011.
Yingying Fan, Yinfei Kong, Daoji Li, Zemin Zheng, et al. Innovated interaction screening for highdimensional nonlinear classification. The Annals of Statistics, 43(3):1243–1272, 2015.
Aaron Fisher, Cynthia Rudin, and Francesca Dominici. Model class reliance: Variable importance measures for any machine learning model class, from the “rashomon” perspective. arXiv preprint arXiv:1801.01489, 2018.
Jerome H Friedman, Bogdan E Popescu, et al. Predictive learning via rule ensembles. The Annals of Applied Statistics, 2(3):916–954, 2008.
Muriel Gevrey, Ioannis Dimopoulos, and Sovan Lek. Two-way interaction of input variables in the sensitivity analysis of neural network models. Ecological modelling, 195(1-2):43–50, 2006.
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.
Huifeng Guo, Ruiming Tang, Yunming Ye, Zhenguo Li, and Xiuqiang He. Deepfm: a factorizationmachine based neural network for ctr prediction. In Proceedings of the 26th International Joint Conference on Artificial Intelligence, pp. 1725–1731. AAAI Press, 2017.
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.
Sepp Hochreiter and Jurgen Schmidhuber. Long short-term memory. ¨ Neural computation, 9(8): 1735–1780, 1997.
Giles Hooker. Discovering additive structure in black box functions. In Proceedings of the tenth ACM SIGKDD international conference on Knowledge discovery and data mining, pp. 575–580. ACM, 2004.
Been Kim, Martin Wattenberg, Justin Gilmer, Carrie Cai, James Wexler, Fernanda Viegas, et al. Interpretability beyond feature attribution: Quantitative testing with concept activation vectors (tcav). In International Conference on Machine Learning, pp. 2673–2682, 2018.
Thomas N Kipf and Max Welling. Semi-supervised classification with graph convolutional networks. arXiv preprint arXiv:1609.02907, 2016.
Jianxun Lian, Xiaohuan Zhou, Fuzheng Zhang, Zhongxia Chen, Xing Xie, and Guangzhong Sun. xdeepfm: Combining explicit and implicit feature interactions for recommender systems. In Proceedings of the 24th ACM SIGKDD International Conference on Knowledge Discovery & Data Mining, pp. 1754–1763. ACM, 2018.
Yin Lou, Rich Caruana, Johannes Gehrke, and Giles Hooker. Accurate intelligible models with pairwise interactions. In Proceedings of the 19th ACM SIGKDD international conference on Knowledge discovery and data mining, pp. 623–631. ACM, 2013.
Scott M Lundberg, Gabriel G Erion, and Su-In Lee. Consistent individualized feature attribution for tree ensembles. arXiv preprint arXiv:1802.03888, 2018.
Yuanfei Luo, Mengshuo Wang, Hao Zhou, Quanming Yao, Wei-Wei Tu, Yuqiang Chen, Wenyuan Dai, and Qiang Yang. Autocross: Automatic feature crossing for tabular data in real-world applications. In Proceedings of the 25th ACM SIGKDD International Conference on Knowledge Discovery & Data Mining, 2019.
Andrew L. Maas, Raymond E. Daly, Peter T. Pham, Dan Huang, Andrew Y. Ng, and Christopher Potts. Learning word vectors for sentiment analysis. In Proceedings of the 49th Annual Meeting of the Association for Computational Linguistics: Human Language Technologies, pp. 142–150, Portland, Oregon, USA, June 2011. Association for Computational Linguistics. URL http: //www.aclweb.org/anthology/P11-1015.
Christopher D. Manning, Prabhakar Raghavan, and Hinrich Schutze. ¨ Introduction to Information Retrieval. Cambridge University Press, New York, NY, USA, 2008. ISBN 0521865719, 9780521865715.
Fantine Mordelet, John Horton, Alexander J Hartemink, Barbara E Engelhardt, and Raluca Gordan.ˆ Stability selection for regression-based models of transcription factor–dna binding specificity. Bioinformatics, 29(13):i117–i125, 2013.
W James Murdoch, Peter J Liu, and Bin Yu. Beyond word importance: Contextual decomposition to extract interactions from lstms. International Conference on Learning Representations, 2018.
Sanjay Purushotham, Martin Renqiang Min, C-C Jay Kuo, and Rachel Ostroff. Factorized sparse learning models with interpretable high order feature interactions. In Proceedings of the 20th ACM SIGKDD international conference on Knowledge discovery and data mining, pp. 552–561. ACM, 2014.
Marco Tulio Ribeiro, Sameer Singh, and Carlos Guestrin. Why should i trust you?: Explaining the predictions of any classifier. In Proceedings of the 22nd ACM SIGKDD international conference on knowledge discovery and data mining, pp. 1135–1144. ACM, 2016.
Marco Tulio Ribeiro, Sameer Singh, and Carlos Guestrin. Anchors: High-precision model-agnostic explanations. In AAAI Conference on Artificial Intelligence, 2018.
Romer Rosales, Haibin Cheng, and Eren Manavoglu. Post-click conversion modeling and analysis ´ for non-guaranteed delivery display advertising. In Proceedings of the fifth ACM international conference on Web search and data mining, pp. 293–302. ACM, 2012.
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.
Victor Sanh, Lysandre Debut, Julien Chaumond, and Thomas Wolf. Distilbert, a distilled version of bert: smaller, faster, cheaper and lighter. arXiv preprint arXiv:1910.01108, 2019.
Prithviraj Sen, Galileo Namata, Mustafa Bilgic, Lise Getoor, Brian Galligher, and Tina Eliassi-Rad. Collective classification in network data. AI magazine, 29(3):93–93, 2008.
Chandan Singh, W James Murdoch, and Bin Yu. Hierarchical interpretations for neural network predictions. International Conference on Learning Representations, 2019.
Sahil Singla, Eric Wallace, Shi Feng, and Soheil Feizi. Understanding impacts of high-order loss approximations and features in deep learning interpretation. arXiv preprint arXiv:1902.00407, 2019.
Richard Socher, Alex Perelygin, Jean Wu, Jason Chuang, Christopher D Manning, Andrew $\mathrm { N g }$ , and Christopher Potts. Recursive deep models for semantic compositionality over a sentiment treebank. In Proceedings of the 2013 conference on empirical methods in natural language processing, pp. 1631–1642, 2013.
Weiping Song, Chence Shi, Zhiping Xiao, Zhijian Duan, Yewen Xu, Ming Zhang, and Jian Tang. Autoint: Automatic feature interaction learning via self-attentive neural networks. arXiv preprint arXiv:1810.11921, 2018.
Daria Sorokina, Rich Caruana, Mirek Riedewald, and Daniel Fink. Detecting statistical interactions with additive groves of trees. In Proceedings of the 25th international conference on Machine learning, pp. 1000–1007. ACM, 2008.
Dorothee Staiger, Hildegard Kaulen, and Jeff Schell. A cacgtg motif of the antirrhinum majus chalcone synthase promoter is recognized by an evolutionarily conserved nuclear protein. Proceedings of the National Academy of Sciences, 86(18):6930–6934, 1989.
Mukund Sundararajan, Ankur Taly, and Qiqi Yan. Axiomatic attribution for deep networks. In Proceedings of the 34th International Conference on Machine Learning-Volume 70, pp. 3319– 3328. JMLR. org, 2017.
Kai Sheng Tai, Richard Socher, and Christopher D Manning. Improved semantic representations from tree-structured long short-term memory networks. arXiv preprint arXiv:1503.00075, 2015.
Michael Tsang, Dehua Cheng, and Yan Liu. Detecting statistical interactions from neural network weights. arXiv preprint arXiv:1705.04977, 2017.
Andrea Vedaldi and Stefano Soatto. Quick shift and kernel methods for mode seeking. In European Conference on Computer Vision, pp. 705–718. Springer, 2008.
MK Vijaymeena and K Kavitha. A survey on similarity measures in text mining. Machine Learning and Applications: An International Journal, 3(2):19–28, 2016.
Meng Wang, Cheng Tai, Weinan E, and Liping Wei. Define: deep convolutional neural networks accurately quantify intensities of transcription factor-dna binding and facilitate evaluation of functional non-coding variants. Nucleic acids research, 46(11):e69–e69, 2018.
Ruoxi Wang, Bin Fu, Gang Fu, and Mingliang Wang. Deep & cross network for ad click predictions. In Proceedings of the ADKDD’17, pp. 12. ACM, 2017.
Lin Yang, Tianyin Zhou, Iris Dror, Anthony Mathelier, Wyeth W Wasserman, Raluca Gordan, and ˆ Remo Rohs. Tfbsshape: a motif database for dna shape features of transcription factor binding sites. Nucleic acids research, 42(D1):D148–D155, 2013.
Haoyang Zeng, Matthew D Edwards, Ge Liu, and David K Gifford. Convolutional neural network architectures for predicting dna–protein binding. Bioinformatics, 32(12):i121–i127, 2016.
# A EFFECT OF EXTRA PARAMETERS BY INTERACTION ENCODINGS VS. ENLARGED EMBEDDINGS
In this section, we study whether increasing embedding size can obtain similar prediction performance gains as explicitly encoding interactions via GLIDER. We increase the embedding dimension sizes of every sparse feature in baseline recommender models to match the total number of model parameters of baseline $^ +$ GLIDER as close as possible. The embedding sizes we used to obtain similar parameter counts are shown in Table 6. For the Avazu dataset, all of the embedding sizes remain unchanged because they were already the target size. The corresponding prediction performances of all models are shown in Table 7. We observed that directly increasing embedding size / parameter counts generally did not give the same level of performance gains that GLIDER provided.
Table 6: Comparison of # model parameters between baseline models with enlarged embeddings and original baselines $^ +$ GLIDER (from Tables 3 and 4). The models with enlarged embeddings are denoted by the asterick $( ^ { * } )$ . The embedding dimension of sparse features is denoted by “emb. size”. Percent differences are relative to baseline\* models. M denotes million, and the ditto mark (”) means no change in the above line.
<table><tr><td rowspan="2">Model</td><td colspan="2">Criteo</td><td colspan="2">Avazu</td></tr><tr><td>emb. size</td><td># params</td><td>emb. size</td><td># params</td></tr><tr><td>Wide&Deep*</td><td>17</td><td>19.1M</td><td>16</td><td>27.3M</td></tr><tr><td>Wide&Deep</td><td>16</td><td>18.1M</td><td>16</td><td>;</td></tr><tr><td>+ GLIDER</td><td>16</td><td>19.3M (+1.1%)</td><td>16</td><td>27.6M (+1.0%)</td></tr><tr><td>DeepFM*</td><td>17</td><td>18.5M</td><td>16</td><td>26.7M</td></tr><tr><td>DeepFM</td><td>16</td><td>17.5M</td><td>16</td><td>;</td></tr><tr><td>+GLIDER</td><td>16</td><td>18.3M(-0.9%)</td><td>16</td><td>26.9M (+0.6%)</td></tr><tr><td>Deep&Cross*</td><td>17</td><td>18.5M</td><td>16</td><td>26.1M</td></tr><tr><td>Deep&Cross</td><td>16</td><td>17.5M</td><td>16</td><td>;</td></tr><tr><td>+ GLIDER</td><td>16</td><td>18.7M(+1.0%)</td><td>16</td><td>26.4M (+1.0%)</td></tr><tr><td>xDeepFM*</td><td>19</td><td>21.5M</td><td>16</td><td>27.6M</td></tr><tr><td>xDeepFM</td><td>16</td><td>18.5M</td><td>16</td><td>;</td></tr><tr><td>+GLIDER</td><td>16</td><td>21.7M (+0.7%)</td><td>16</td><td>28.3M (+2.5%)</td></tr><tr><td>AutoInt*</td><td>17</td><td>17.4M</td><td>16</td><td>25.1M</td></tr><tr><td>AutoInt</td><td>16</td><td>16.4M</td><td>16</td><td>;</td></tr><tr><td>+ GLIDER</td><td>16</td><td>17.3M(-1.0%)</td><td>16</td><td>25.2M (+0.6%)</td></tr></table>
Table 7: Test prediction performance corresponding to the models shown in Table 6
<table><tr><td rowspan="2">Model</td><td colspan="2">Criteo</td><td colspan="2">Avazu</td></tr><tr><td>AUC</td><td>logloss</td><td>AUC</td><td>logloss</td></tr><tr><td>Wide&Deep*</td><td>0.8072 ± 3e-4</td><td>0.4443 ± 2e-4</td><td>0.7794±3e-4</td><td>0.3804± 2e-4</td></tr><tr><td>Wide&Deep</td><td>0.8069± 5e-4</td><td>0.4446± 4e-4</td><td>;</td><td>;</td></tr><tr><td>+ GLIDER</td><td>0.8080 ±3e-4</td><td>0.4436 ± 3e-4</td><td>0.7795± 1e-4</td><td>0.3802 ± 9e-5</td></tr><tr><td>DeepFM*</td><td>0.8080±4e-4</td><td>0.4435 ± 4e-4</td><td>0.7792 ± 3e-4</td><td>0.3804 ± 9e-5</td></tr><tr><td>DeepFM</td><td>0.8079±3e-4</td><td>0.4436± 2e-4</td><td>;</td><td>;</td></tr><tr><td>+GLIDER</td><td>0.8097± 2e-4</td><td>0.4420± 2e-4</td><td>0.7795± 2e-4</td><td>0.3802 ± 2e-4</td></tr><tr><td>Deep&Cross*</td><td>0.8081±2e-4</td><td>0.4434±2e-4</td><td>0.7791± 2e-4</td><td>0.3805 ±1e-4</td></tr><tr><td>Deep&Cross + GLIDER</td><td>0.8076±2e-4</td><td>0.4438 ± 2e-4</td><td>;</td><td>;</td></tr><tr><td></td><td>0.8086 ±3e-4</td><td>0.4428 ± 2e-4</td><td>0.7792 ± 2e-4</td><td>0.3803 ± 9e-5</td></tr><tr><td>xDeepFM* xDeepFM</td><td>0.8088±1e-4</td><td>0.4429 ±1e-4</td><td>0.7785±3e-4 ”</td><td>0.3808± 2e-4</td></tr><tr><td>+ GLIDER</td><td>0.8084± 2e-4</td><td>0.4433 ± 2e-4</td><td></td><td>”</td></tr><tr><td>AutoInt*</td><td>0.8097 ± 3e-4</td><td>0.4421± 3e-4</td><td>0.7787± 4e-4</td><td>0.3806 ± 1e-4</td></tr><tr><td>AutoInt</td><td>0.8087±2e-4</td><td>0.4431± 1e-4</td><td>0.7774±1e-4</td><td>0.3811 ± 8e-5</td></tr><tr><td></td><td>0.8083</td><td>0.4434</td><td>”</td><td>;</td></tr><tr><td>+ GLIDER</td><td>0.8090 ± 2e-4</td><td>0.4426± 2e-4</td><td>0.7773±1e-4</td><td>0.3811 ± 5e-5</td></tr></table>
# B EFFECT OF DENSE FEATURE BUCKETIZATION
We examine the effect of dense feature bucketization on cross feature parameter efficiency for the Criteo dataset, which contains 13 dense features. Figure 5 shows the effects of varying the number of dense buckets on the embedding sizes of the cross features involving dense features. Both the effects on the average and individual embedding size are shown. 14 out of 40 of the cross features involved a dense feature. Different cross features show different parameter patterns as the number of buckets increases (Figure 5b). One one hand, the parameter count sometimes increases then asymptotes. Our requirement that a valid cross feature ID occurs more than $T$ times (§4.2) restricts the growth in parameters. On the other hand, the parameter count sometimes decreases, which happens when the dense bucket size becomes too small to satisfy the $T$ occurrence restriction. In all cases, the parameter counts are kept limited, which is important for overall parameter efficiency.
 Figure 5: The effects of varying the number of buckets on (a) on the average embedding size of cross features involving dense features and (b) the individual embedding sizes of the same cross features.
# C STOP WORDS
For all qualitative interpretations on text (in $\ S 6 . 3 . 2$ and Appendix D), we preprocessed sentences to remove stop words. We use the same stop words suggested by Manning et al. (2008), i.e., $\{ \mathbf { a } ,$ , an, and, are, as, at, be, by, for, from, has, he, in, is, it, its, of, on, that, the, to, was, were, will, with $\}$ .
# D QUALITATIVE RESULTS ON SENTIMENT-LSTM VS. BERT
In this section, we compare the word interactions discovered by MADEX on Sentiment-LSTM versus BERT. These models perform with accuracies of $8 7 \%$ and $9 2 \%$ respectively on the SST test set. We use a public pre-trained BERT, i.e., DistilBERT (Sanh et al., 2019), which is available online8. The interaction detector we use is GradientNID $( \ S 3 . 2 . 2 )$ , and sample weighting is disabled for this comparison. The top-2 interactions for each model are shown in Table 8 on random sentences from the SST test set.
Table 8: Top-ranked word interactions $\mathcal { T } _ { i }$ from Sentiment-LSTM and BERT on randomly selected sentences in the SST test set.
<table><tr><td rowspan="2">Original sentence</td><td colspan="2">Sentiment-LSTM</td><td colspan="2">BERT</td></tr><tr><td>I</td><td>I</td><td>I</td><td>I</td></tr><tr><td>An intelligent, earnest, intimate film that drops the ball only when it pauses for blunt exposition to make sure you're getting its metaphysical point.</td><td>intelligent, metaphysical</td><td>metaphysical, point</td><td>intelligent, earnest</td><td>drops, ball</td></tr><tr><td>It's not so much enjoyable to watch as it is enlightening to listen to new sides of a previous reality,and to visit with some of the people who were able to make an impact in the theater world.</td><td>not, enjoyable</td><td>not, so</td><td>not, much</td><td>not, enlightening</td></tr><tr><td>Uneasy mishmash of styles and genres.</td><td>uneasy, mishmash</td><td>mishmash, genres</td><td>uneasy, mishmash</td><td>uneasy, styles</td></tr><tr><td>You're better off staying home and watching the X-Files.</td><td>x, files</td><td>off, x</td><td>better, off</td><td>you, off</td></tr><tr><td>If this is the Danish idea of a good time, prospective tourists might want to consider a different destination-some jolly country embroiled ina bloody civil war,perhaps.</td><td>if, this</td><td>if, good</td><td>if, jolly</td><td> jolly, country</td></tr><tr><td>We can see the wheels turning,and we might resent it sometimes,but this is still a nice little picture,made by bright and friendly souls with a lot of good cheer.</td><td>resent, nice</td><td>we,resent</td><td>nice, good</td><td>nice,made</td></tr><tr><td>One of the greatest family-oriented, fantasy-adventure movies ever.</td><td>family, oriented</td><td>greatest, family</td><td>greatest, family</td><td>adventure, movies</td></tr><tr><td>It's so full of wrong choices that all you can do is shake your head in disbelief- and worry about what classic Oliver Parker intends to mangle next time.</td><td>so,wrong</td><td>full, wrong</td><td>so, wrong</td><td>so, full</td></tr><tr><td>Itsmysteries are transparentlyobvious,and it's too slowly paced to be a thriller.</td><td>mysteries, transparently</td><td>paced, thriller</td><td>too, thriller</td><td>too, paced</td></tr><tr><td>This miserable excuse of a movie runs on empty,believing flatbush machismo will get it through.</td><td>miserable, runs</td><td>excuse,get</td><td>runs,empty</td><td>miserable, runs</td></tr></table>
# E ADDITIONAL QUALITATIVE RESULTS FOR RESNET152
 Figure 6: Additional qualitative results, following Figure 4a, on random test images in ImageNet. Interactions are denoted by $\mathcal { T } _ { i }$ and are unordered. Overlapping interactions with overlap coefficient $\geq 0 . 5$ are merged to reduce $| \{ \mathcal { T } _ { i } \} |$ per test image.
# F DETECTION PERFORMANCE OF MADEX VS. BASELINES
We compare the detection performances between MADEX and baselines on identifying feature interactions learned by complex models, i.e., XGBoost (Chen & Guestrin, 2016), Multilayer Perceptron (MLP), and Long Short-Term Memory Network (LSTM) (Hochreiter & Schmidhuber, 1997). The baselines are Tree-Shap: a method to identify interactions in tree-based models like XGBoost (Lundberg et al., 2018), MLP-ACD+: a modified version of ACD (Singh et al., 2019; Murdoch et al., 2018) to search all pairs of features in MLP to find the best interaction candidate, and LSTM-ACD+: the same as MLP-ACD $^ +$ but for LSTMs. All baselines are local interpretation methods. For MADEX, we sample continuous features from a truncated normal distribution $\mathcal { N } ( \mathbf { x } , \sigma ^ { 2 } \mathbf { I } )$ centered at a specified data instance $\mathbf { x }$ and truncated at $\sigma$ . Our MADEX experiments consist of two methods, NID and GradNID (shorthand for GradientNID).
Table 9: Data generating functions with interactions
<table><tr><td>F1(x)=</td><td>10x1x2+</td></tr><tr><td>F2(x)=</td><td>x102+∑3i 10</td></tr><tr><td>F3(x)=</td><td></td></tr><tr><td>F4(x)=</td><td></td></tr></table>
We evaluate interaction detection performance by using synthetic data where ground truth interactions are known (Hooker, 2004; Sorokina et al., 2008). We generate 10e3 samples of synthetic data using functions $F _ { 1 } - F _ { 4 }$ (Table 9) with continuous features uniformly distributed between $- 1$ to 1. Next, we train complex models (XGBoost, MLP, and LSTM) on this data. Lastly, we run MADEX and the baselines on 10 trials of 20 data instances at randomly sampled locations on the synthetic function domain. Between trials, the complex models are trained with different random initialization to test the stability of each interpretation method. Interaction detection performance is computed by the average R-precision (Manning et al., $2 0 0 8 ) ^ { 9 }$ of interaction rankings across the sampled data instances.
Results are shown in Table 10. MADEX (NID and GradNID) performs well compared to the baselines. On the tree-based model, MADEX can compete with the tree-specific baseline Tree-Shap, which only detects pairwise interactions. On MLP and LSTM, MADEX performs significantly better than $\mathbf { A C D + }$ . The performance gain is especially large in the LSTM setting. Comparing NID and GradNID, NID tends to perform better in this experiment because it takes its entire sampling region into account whereas GradNID examines a single data instance.
Table 10: Detection Performance in R-Precision (higher the better). $\sigma = 0 . 6$ (max: 3.2). “Tree” is XGBoost. \*Does not detect higher-order interactions. $\dagger$ Requires an exhaustive search of all feature combinations.
<table><tr><td></td><td colspan="3">Tree</td><td colspan="3">MLP</td><td colspan="3">LSTM</td></tr><tr><td></td><td>Tree-Shap</td><td>NID</td><td>GradNID</td><td>MLP-ACD+</td><td>NID</td><td>GradNID</td><td>LSTM-ACD+</td><td>NID</td><td>GradNID</td></tr><tr><td>F1(x)</td><td>1±0</td><td>1±0</td><td>0.96± 0.04</td><td>0.63±0.08</td><td>1±0</td><td>1±0</td><td>0.3±0.2</td><td>1±0</td><td>1±0</td></tr><tr><td>F(x)</td><td>1±0</td><td>0.3± 0.4</td><td>0.6±0.4</td><td>0.41 ± 0.06</td><td>1±0</td><td>0.95 ± 0.04</td><td>0.01±0.02</td><td>0.99 ±0.02</td><td>0.95±0.04</td></tr><tr><td>F(x)</td><td>1±0</td><td>1±0</td><td>1±0</td><td>0.3±0.2</td><td>1±0</td><td>1±0</td><td>0.05±0.08</td><td>1±0</td><td>1±0</td></tr><tr><td>F4(x)</td><td>*</td><td>1±0</td><td>+</td><td>+</td><td>1±0</td><td>+</td><td>+</td><td>1±0</td><td>+</td></tr></table>
# G HIGHER-ORDER INTERACTIONS
This section shows how often different orders of higher-order interactions are identified by GLIDER / MADEX. Figure 7 plots the occurrence counts of global interactions detected in AutoInt for the Criteo and Avazu dataset, which correspond to the results in Figure 2. Here we show the occurrence counts of higher-order interactions, where the exact interaction cardinality is annotated besides each data point. 3-way interactions are the most common type, followed by 4-, then 5-way interactions.
Figure 8 plots histograms of interaction cardinalities for all interactions detected from ResNet152 and Sentiment-LSTM across 1000 random samples in their test sets. The average number of features are 66 and 18 for ResNet152 and Sentiment-LSTM respectively. Higher-order interactions are common in both models.
 Figure 7: Occurrence counts (total: 1000) vs. rank of interactions detected from AutoInt on (a) Criteo and (b) Avazu datasets. Each higher-order interaction is annotated with its interaction cardinality.
 Figure 8: Histograms of interaction sizes for interactions detected in (a) ResNet152 and (b) Sentiment-LSTM across 1000 random samples in respective test sets.123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580# STRUCTURED ADVERSARIAL ATTACK: TOWARDS GENERAL IMPLEMENTATION AND BETTER INTERPRETABILITY
Kaidi $\mathbf { X } \mathbf { u } ^ { 1 * }$ Sijia $\mathbf { L i u ^ { 2 * } }$ Pu Zhao1 Pin-Yu Chen2 Huan Zhang3 Quanfu Fan2 Deniz Erdogmus1 Yanzhi Wang1 Xue Lin1 1Northeastern University, USA 2MIT-IBM Watson AI Lab, IBM Research, USA 3University of California, Los Angeles, USA
# ABSTRACT
When generating adversarial examples to attack deep neural networks (DNNs), $\ell _ { p }$ norm of the added perturbation is usually used to measure the similarity between original image and adversarial example. However, such adversarial attacks perturbing the raw input spaces may fail to capture structural information hidden in the input. This work develops a more general attack model, i.e., the structured attack (StrAttack), which explores group sparsity in adversarial perturbations by sliding a mask through images aiming for extracting key spatial structures. An ADMM (alternating direction method of multipliers)-based framework is proposed that can split the original problem into a sequence of analytically solvable subproblems and can be generalized to implement other attacking methods. Strong group sparsity is achieved in adversarial perturbations even with the same level of $\ell _ { p }$ -norm distortion $( p \in \{ 1 , 2 , \infty \} )$ as the stateof-the-art attacks. We demonstrate the effectiveness of StrAttack by extensive experimental results on MNIST, CIFAR-10 and ImageNet. We also show that StrAttack provides better interpretability (i.e., better correspondence with discriminative image regions) through adversarial saliency map (Papernot et al., 2016b) and class activation map (Zhou et al., 2016). Our code is available at https://github.com/KaidiXu/StrAttack.
# 1 INTRODUCTION
Deep learning achieves exceptional successes in domains such as image recognition (He et al., 2016; Geifman & ElYaniv, 2017), natural language processing (Hinton et al., 2012; Harwath et al., 2016), medical diagnostics (Chen et al., 2016; Shi et al., 2018) and advanced control (Silver et al., 2016; Fu et al., 2017). Recent studies (Szegedy et al., 2013; Goodfellow et al., 2014; Nguyen et al., 2015; Kurakin et al., 2016; Carlini & Wagner, 2017) show that DNNs are vulnerable to adversarial attacks implemented by generating adversarial examples, i.e., adding well-designed perturbations to original legal inputs. Delicately crafted adversarial examples can mislead a DNN to recognize them as any target image label, while the perturbations appears unnoticeable to human eyes. Adversarial attacks against
 Figure 1: Group sparsity demonstrated in adversarial perturbations obtained by C&W attack and our StrAttack, where ‘ostrich’ is the original label, and ‘unicycle’ is the misclassified label. Here each group is a region of $1 3 \times 1 3 \times 3$ pixels and the strength of adversarial perturbations (through their $\ell _ { 2 }$ norm) at each group is represented by heatmap. C&W attack perturbs almost all groups, while StrAttack yields strong group sparsity, with more semantic structure: the perturbed image region matches the feature of the target object, namely, the frame of the unicycle.
DNNs not only exist in theoretical models
but also pose potential security threats to the real world (Kurakin et al., 2016; Evtimov et al., 2017; Papernot et al., 2017). Several explanations are proposed to illustrate why there exist adversarial examples to DNNs based on hypotheses such as model linearity and data manifold (Goodfellow et al., 2014; Gilmer et al., 2018). However, little is known to their origins, and convincing explanations remain to be explored.
Besides achieving the goal of (targeted) mis-classification, an adversarial example should be as “similar” to the original legal input as possible to be stealthy. Currently, the similarity is measured by the $\ell _ { p }$ norm $( p = 0 , 1 , 2 , \infty )$ of the added perturbation (Szegedy et al., 2013; Carlini & Wagner, 2017; Chen et al., 2017b;a), i.e., $\ell _ { p }$ norm is being minimized when generating adversarial example. However, measuring the similarity between the original image and its adversarial example by $\ell _ { p }$ norm is neither necessary nor sufficient (Sharif et al., 2018). Besides, no single measure can be perfect for human perceptual similarity (Carlini & Wagner, 2017) and such adversarial attacks may fail to capture key information hidden in the input such as spatial structure or distribution. Spurred by that, this work implements a new attack model i.e., structured attack (StrAttack) that imposes group sparsity on adversarial perturbations by extracting structures from the inputs. As shown in Fig. 1, we find that StrAttack identifies minimally sufficient regions that make attacks successful, but without incurring extra pixel-level perturbation power. The major contributions are summarized as below.
• (Structure-driven attack) This work is the first attempt towards exploring group-wise sparse structures when implementing adversarial attacks, but without losing $\ell _ { p }$ distortion performance when compared to state-of-the-art attacking methods. (Generality) We show that the proposed attack model covers many norm-ball based attacks such as C&W (Carlini & Wagner, 2017) and EAD (Chen et al., 2017a). (Efficient implementation) We develop an efficient algorithm to generate structured adversarial perturbations by leveraging the alternating direction method of multipliers (ADMM). We show that ADMM splits the original complex problem into subproblems, each of which can be solved analytically. Besides, we show that ADMM can further be used to refine an arbitrary adversarial attack under the fixed sparse structure. (Interpretability) The generated adversarial perturbations demonstrate clear correlations and interpretations between original and target images. With the aid of adversarial saliency map (Papernot et al., 2016b) and class activation map (Zhou et al., 2016), we show that the obtained group-sparse adversarial patterns better shed light on the mechanisms of adversarial perturbations to fool DNNs.
Related work Many works studied norm-ball constrained adversarial attacks. For example, FGM (Goodfellow et al., 2014) and IFGSM (Kurakin et al., 2017) attack methods were proposed to maximize the classification error subject to $\ell _ { \infty }$ -norm based distortion constraints. Moreover, L-BFGS (Szegedy et al., 2013) and C&W (Carlini & Wagner, 2017) attacks found an adversarial example by minimizing its $\ell _ { 2 }$ -norm distortion. By contrast, JSMA (Papernot et al., 2016b) and one-pixel (Su et al., 2017) attacks attempted to generate adversarial examples by perturbing the minimum number of pixels, namely, minimizing the $\ell _ { 0 }$ norm of adversarial perturbations. Different from the above norm-ball constrained attacks, some works (Karmon et al., 2018; Brown et al., 2017) crafted adversarial examples by adding noise patches. However, the resulting adversarial perturbations are no longer imperceptible to humans. Here we argue that imperceptibility could be important since it helps us to understand how/why DNNs are vulnerable to adversarial attacks while perturbing natural examples just by indistinguished adversarial noise.
In the aforementioned norm-ball constrained adversarial attacks, two extremely opposite principles have been applied: C&W attack (or $\ell _ { \infty }$ attacks) seeks the minimum image-level distortion but allows to modify all pixels; one-pixel attack only perturbs a few pixels but suffers a high pixel-level distortion. Both attacking principles might lead to a high noise visibility due to perturbing too many pixels or perturbing a few pixels too much. In this work, we wonder if there exists a more effective attack that can be as successful as existing attacks but achieves a tradeoff between the perturbation power and the number of perturbed pixels. We will show that the proposed StrAttack is able to identify sparse perturbed regions that make attacks successful, but without incurring extra pixel-level perturbations. It is also worth mentioning that one-pixel attack has much lower attack success rate on ImageNet than C&W attack and StrAttack.
In addition to adversarial attacks, many defense works have been proposed. Examples include defensive distillation (Papernot et al., 2016c) that distills the original DNN and introduces temperature into the softmax layer, random mask (Anonymous, 2019) that modifies the DNN structures by randomly removing certain neurons before training, adversarial training through enlarging the training dataset with adversarial examples, and robust adversarial training (Madry et al., 2017; Sinha et al., 2018) through the min-max optimization. It is commonly known that the robust adversarial training method ensures the strongest defense performance against adversarial attacks on MNIST and CIFAR-10. In this work, we will evaluate the effectiveness of StrAttack to three defense methods, a) defensive distillation (Papernot et al., 2016c), b) adversarial training via data augmentation (Tramèr et al., 2018) and c) robust adversarial training (Madry et al., 2017).
Although the adversarial attack and defense have attracted an increasing amount of attention, the visual explanation on adversarial perturbations is less explored since the distortion power is minimized and the resulting adversarial effects become imperceptible to humans. The work (Dong et al., 2017) attempted to understand how the internal representations of DNNs are affected by adversarial examples. However, only an ensemble-based attack was considered, which fails to distinguish the effectiveness of different norm-ball constrained adversarial attacks. Unlike (Dong et al., 2017), we employ the interpretability tools, adversarial saliency map (ASM) (Papernot et al., 2016b) and class activation map (CAM) (Zhou et al., 2016) to measure the effectiveness of different attacks in terms of their interpretability. Here ASM provides sensitivity analysis for pixel-level perturbation’s impact on label classification, and CAM localizes class-specific image discriminative regions (Xiao et al., 2018). We will show that the sparse adversarial pattern obtained by StrAttack offers a great interpretability through ASM and CAM compared with other norm-ball constrained attacks.
# 2 STRUCTURED ATTACK: EXPLORE GROUP STRUCTURES FROM IMAGES
In the section, we introduce the concept of StrAttack, motivated by the question: ‘what possible structures could adversarial perturbations have to fool DNNs?’ Our idea is to divide an image into sub-groups of pixels and then penalize the corresponding group-wise sparsity. The resulting sparse groups encode minimally sufficient adversarial effects on local structures of natural images.
Let $\pmb { \Delta } \in \mathbb { R } ^ { W \times H \times C }$ be an adversarial perturbation added to an original image $\mathbf { X } _ { 0 }$ , where $W \times H$ gives the spatial region, and $C$ is the depth, e.g., $C = 3$ for RGB images. To characterize the local structures of $\pmb { \Delta }$ , we introduce a sliding mask $\mathcal { M }$ with stride $S$ and size $r \times r \times C$ . When $S = 1$ , the mask moves one pixel at a time; When $S = 2$ , the mask jumps 2 pixels at a time while sliding. By adjusting the stride $S$ and the mask size $r$ , different group splitting schemes can be obtained. If $S \ < \ r$ , the resulting groups will contain overlapping pixels. By contrast, groups will become non-overlapped when $S = r$ .
A sliding mask $\mathcal { M }$ finally divides $\pmb { \Delta }$ into a set of groups $\{ \Delta _ { { \mathcal G } _ { p , q } } \}$ for $p \in [ P ]$ and $q \in [ Q ]$ , where $P = ( W - r ) / S + 1$ , $Q = ( H - r ) / S + 1$ , and $[ n ]$ denotes the integer set $\{ 1 , 2 , \ldots , n \}$ . Given the groups $\{ \Delta _ { { \mathcal G } _ { p , q } } \}$ , the group sparsity can be characterized through the following sparsity-inducing function (Yuan $\&$ Lin, 2006; Bach et al., 2012; Liu et al., 2015), motivated by the problem of group Lasso (Yuan & Lin, 2006):
$$\begin{array} { r } { g ( \Delta ) = \sum _ { p = 1 } ^ { P } \sum _ { q = 1 } ^ { Q } \| \Delta { \mathcal { G } } _ { p , q } \| _ { 2 } , } \end{array}$$
where $\Delta _ { { \mathcal G } _ { p , q } }$ denotes the set of pixels of $\pmb { \Delta }$ indexed by $\mathcal { G } _ { p , q }$ , and $\| \cdot \| _ { 2 }$ is the $\ell _ { 2 }$ norm. We refer readers to Fig. A1 for an illustrative example of our concepts on groups and group sparsity.
# 3 STRUCTURED ADVERSARIAL ATTACK WITH ADMM
In this section, we start by proposing a general framework to generate prediction-evasive adversarial examples, where the adversary relies only on gradients of the loss function with respect to inputs of DNNs. Our model takes into account both commonly-used adversarial distortion metrics and the proposed group-sparsity regularization that encodes spatial structures in attacks. We show that the process of generating structured adversarial examples leads to an optimization problem that is difficult to solve using the existing optimizers Adam (for C&W attack) and FISTA (for EAD attack) (Carlini & Wagner, 2017; Chen et al., 2017a). To circumvent this challenge, we develop an efficient optimization method via alternating direction method of multipliers (ADMM).
Given an original image $\mathbf { x } _ { 0 } \in \mathbb { R } ^ { n }$ , we aim to design the optimal adversarial perturbation $\pmb { \delta } \in \mathbb { R } ^ { n }$ so that the adversarial example $( \mathbf { x } _ { 0 } + \pmb { \delta } )$ misleads DNNs trained on natural images. Throughout this paper, we use vector representations of the adversarial perturbation $\pmb { \Delta }$ and the original image $\mathbf { X } _ { 0 }$ without loss of generality. A well designed perturbation $\pmb { \delta }$ can be obtained by solving optimization problems of the following form,
$$\begin{array} { r l } { \underset { \delta } { \mathrm { m i n i m i z e } } } & { \ f ( \mathbf { x } _ { 0 } + \pmb { \delta } , t ) + \gamma D ( \pmb { \delta } ) + \tau g ( \pmb { \delta } ) } \\ { \mathrm { s u b j e c t ~ t o } } & { \ ( \mathbf { x } _ { 0 } + \pmb { \delta } ) \in [ 0 , 1 ] ^ { n } , \ \lVert \pmb { \delta } \rVert _ { \infty } \leq \epsilon , } \end{array}$$
where $f ( \mathbf { x } , t )$ denotes the loss function for crafting adversarial example given a target class $t$ , $D ( \delta )$ is a distortion function that controls the perceptual similarity between a natural image and a perturbed image, $\begin{array} { r } { g ( \delta ) = \sum _ { p = 1 } ^ { P } \sum _ { q = 1 } ^ { Q } \| \delta _ { { \mathcal G } _ { p , q } } \| _ { 2 } } \end{array}$ is given by (1), and $\| \cdot \| _ { p }$ signifies the $\ell _ { p }$ norm. In problem (2), the ‘hard’ constraints ensure the validness of created adversarial examples with $\epsilon$ - tolerant perturbed pixel values. And the non-negative regularization parameters $\gamma$ and $\tau$ place our emphasis on the distortion of an adversarial example (to an original image) and group sparsity of adversarial perturbation. Tuning the regularization parameters will be discussed in Appendix F.
Problem (2) gives a quite general formulation for design of adversarial examples. If we remove the group-sparsity regularizer $g ( \delta )$ and the $\ell _ { \infty }$ constraint, problem (2) becomes the same as the C&W attack (Carlini & Wagner, 2017). More specifically, if we further set the distortion function $D ( \delta )$ to the form of $\ell _ { 0 }$ , $\ell _ { 2 }$ or $\ell _ { \infty }$ norm, then we obtain C&W $\ell _ { 0 }$ , $\ell _ { 2 }$ or $\ell _ { \infty }$ attack. If $D ( \delta )$ is specified by the elastic-net regularizer, then problem (2) becomes the formulation of EAD attack (Chen et al., 2017a).
In this paper, we specify the loss function of problem (2) as below, which yields the best known performance of adversaries (Carlini & Wagner, 2017),
$$f ( \mathbf { x } _ { 0 } + \pmb { \delta } , t ) = c \cdot \operatorname* { m a x } \{ \operatorname* { m a x } _ { j \neq t } Z ( \mathbf { x } _ { 0 } + \pmb { \delta } ) _ { j } - Z ( \mathbf { x } _ { 0 } + \pmb { \delta } ) _ { t } , - \kappa \} ,$$
where $Z ( \mathbf { x } ) _ { j }$ is the $j$ th element of logits $Z ( \mathbf { x } )$ , representing the output before the last softmax layer in DNNs, and $\kappa$ is a confidence parameter that is usually set to zero if the attack transferability is not much cared. We choose $D ( \delta ) \overset { \cdot } { = } \lVert \delta \rVert _ { 2 } ^ { 2 }$ for a fair comparison with the $\mathrm { C } \& \mathbf { W } \ \ell _ { 2 }$ adversarial attack. In this section, we assume that $\{ \mathcal { G } _ { p , q } \}$ are non-overlapping groups, i.e., $\mathcal { G } _ { p , q } \cap \mathcal { G } _ { p ^ { \prime } , q ^ { \prime } } = \emptyset$ for $q \neq q ^ { \prime }$ or $p \neq p ^ { \prime }$ . The overlapping case will be studied in the next section.
The presence of multiple non-smooth regularizers and ‘hard’ constraints make the existing optimizers Adam and FISTA (Carlini & Wagner, 2017; Chen et al., $2 0 1 7 \mathrm { a }$ ; Kingma & Ba, 2015; Beck & Teboulle, 2009) inefficient for solving problem (2). First, the subgradient of the objective function of problem (2) is difficult to obtain especially when $\{ \mathcal { G } _ { p , q } \}$ are overlapping groups. Second, it is impossible to compute the proximal operations required for FISTA with respect to all non-smooth regularizers and ‘hard’ constraints. Different from the existing work, we show that ADMM, a firstorder operator splitting method, helps us to split the original complex problem (2) into a sequence of subproblems, each of which can be solved analytically.
We reformulate problem (2) in a way that lends itself to the application of ADMM,
$$\begin{array} { r l } { \underset { \delta , { \mathbf z } , { \mathbf w } , { \mathbf y } } { \mathrm { m i n i m i z e } } } & { \ f ( \mathbf z + \mathbf x _ { 0 } ) + \gamma D ( \delta ) + \tau \sum _ { i = 1 } ^ { P Q } \| \mathbf y _ { \mathcal D _ { i } } \| _ { 2 } + h ( \mathbf w ) } \\ { \mathrm { s u b j e c t ~ t o } } & { \ \mathbf z = \delta , \ \mathbf z = \mathbf y , \ \mathbf z = \mathbf w , } \end{array}$$
where $\mathbf { z } , \mathbf { y }$ and w are newly introduced variables, for ease of notation let $\mathcal { D } _ { ( q - 1 ) P + p } = \mathcal { G } _ { p , q }$ , and $h ( \mathbf { w } )$ is an indicator function with respect to the constraints of problem (2),
$$h ( \mathbf { w } ) = { \left\{ \begin{array} { l l } { 0 } & { { \mathrm { ~ i f ~ } } ( \mathbf { x } _ { 0 } + \mathbf { w } ) \in [ 0 , 1 ] ^ { n } , \ \| \mathbf { w } \| _ { \infty } \leq \epsilon , } \\ { \infty } & { { \mathrm { ~ o t h e r w i s e . } } } \end{array} \right. }$$
ADMM is performed by minimizing the augmented Lagrangian of problem (4),
$$\begin{array} { r l r } & { } & { L ( { \bf z } , \delta , { \bf y } , { \bf w } , { \bf u } , { \bf v } , { \bf s } ) = f ( { \bf z } + { \bf x } _ { 0 } ) + \gamma D ( \delta ) + \tau \sum _ { i = 1 } ^ { P Q } \| { \bf y } { \boldsymbol { \pi } } _ { i } \| _ { 2 } + h ( { \bf w } ) + { \bf u } ^ { T } ( \delta - { \bf z } ) } \\ & { } & { + { \bf v } ^ { T } ( { \bf y } - { \bf z } ) + { \bf s } ^ { T } ( { \bf w } - { \bf z } ) + \frac { \rho } { 2 } \| \delta - { \bf z } \| _ { 2 } ^ { 2 } + \frac { \rho } { 2 } \| { \bf y } - { \bf z } \| _ { 2 } ^ { 2 } + \frac { \rho } { 2 } \| { \bf w } - { \bf z } \| _ { 2 } ^ { 2 } , \quad } \end{array}$$
where u, v and s are Lagrangian multipliers, and $\rho > 0$ is a given penalty parameter. ADMM splits all of optimization variables into two blocks and adopts the following iterative scheme,
$$\begin{array} { r l } & { \{ \delta ^ { k + 1 } , \mathbf w ^ { k + 1 } , \mathbf y ^ { k + 1 } \} = \underset { \delta , \mathbf w , \mathbf y } { \operatorname* { a r g m i n } } L ( \delta , \mathbf z ^ { k } , \mathbf w , \mathbf y , \mathbf u ^ { k } , \mathbf v ^ { k } , \mathbf s ^ { k } ) , } \\ & { } \\ & { \mathbf z ^ { k + 1 } = \underset { \mathbf z } { \operatorname* { a r g m i n } } L ( \delta ^ { k + 1 } , \mathbf z , \mathbf w ^ { k + 1 } , \mathbf y ^ { k + 1 } , \mathbf u ^ { k } , \mathbf v ^ { k } , \mathbf s ^ { k } ) , } \\ & { \left\{ \begin{array} { l l } { \mathbf u ^ { k + 1 } = \mathbf u ^ { k } + \rho ( \delta ^ { k + 1 } - \mathbf z ^ { k + 1 } ) , } \\ { \mathbf v ^ { k + 1 } = \mathbf v ^ { k } + \rho ( \mathbf y ^ { k + 1 } - \mathbf z ^ { k + 1 } ) , } \\ { \mathbf s ^ { k + 1 } = \mathbf s ^ { k } + \rho ( \mathbf w ^ { k + 1 } - \mathbf z ^ { k + 1 } ) , } \end{array} \right. } \end{array}$$
where $k$ is the iteration index, steps (7)-(8) are used for updating primal variables, and the last step (9) is known as the dual update step. We emphasize that the crucial property of the proposed ADMM approach is that, as we demonstrate in Proposition 1, the solution to problem (7) can be found in parallel and exactly.
Proposition 1 When $D ( \delta ) = \| \delta \| _ { 2 } ^ { 2 }$ , the solution to problem (7) is given by
$$\begin{array} { r l } & { \delta ^ { k + 1 } = \frac { \rho } { \rho + 2 \gamma } \mathbf { a } , } \\ & { [ \mathbf { w } ^ { k + 1 } ] _ { i } = \left\{ \begin{array} { l l } { \operatorname* { m i n } \{ 1 - [ \mathbf { x } _ { 0 } ] _ { i } , \epsilon \} } & { b _ { i } > \operatorname* { m i n } \{ 1 - [ \mathbf { x } _ { 0 } ] _ { i } , \epsilon \} } \\ { \operatorname* { m a x } \{ - [ \mathbf { x } _ { 0 } ] _ { i } , - \epsilon \} } & { b _ { i } < \operatorname* { m a x } \{ - [ \mathbf { x } _ { 0 } ] _ { i } , - \epsilon \} \quad f o r \ i \in [ n ] , } \\ { b _ { i } } & { o t h e r w i s e , } \end{array} \right. } \\ & { [ \mathbf { y } ^ { k + 1 } ] _ { \mathcal { D } _ { i } } = \Big ( 1 - \frac { \tau } { \rho \| [ \mathbf { c } ] _ { \mathcal { D } _ { i } } \| _ { 2 } } \Big ) _ { + } [ \mathbf { c } ] _ { \mathcal { D } _ { i } } , \ i \in [ P Q ] , } \end{array}$$
where $\mathbf { a } : = \mathbf { z } ^ { k } - \mathbf { u } ^ { k } / \rho , \mathbf { b } : = \mathbf { z } ^ { k } - \mathbf { s } ^ { k } / \rho , \mathbf { c } : = \mathbf { z } ^ { k } - \mathbf { v } ^ { k } / \rho , ( x ) _ { + } = x$ if $x \geq 0$ and 0 otherwise, $[ \mathbf { x } ] _ { i }$ denotes the ith element of $\mathbf { x }$ , and $[ \mathbf { x } ] _ { \mathcal { D } _ { i } }$ denotes the sub-vector of $\mathbf { x }$ indexed by $\mathcal { D } _ { i }$ .
Proof: See Appendix B.
It is clear from Proposition 1 that introducing auxiliary variables does not increase the computational complexity of ADMM since (10)-(12) can be solved in parallel. Moreover, if another distortion metric (different from $D ( \delta ) = \lvert \lvert \delta \rvert \rvert _ { 2 } ^ { 2 } )$ is used, then ADMM only changes at the $\delta$ -step (10).
We next focus on the $\mathbf { z }$ -minimization step (8), which can be equivalently transformed into
$$\operatorname* { m i n i m i z e } _ { \mathbf { z } } \quad f ( \mathbf { x } _ { 0 } + \mathbf { z } ) + \frac { \rho } { 2 } \| \mathbf { z } - \mathbf { a } ^ { \prime } \| _ { 2 } ^ { 2 } + \frac { \rho } { 2 } \| \mathbf { z } - \mathbf { b } ^ { \prime } \| _ { 2 } ^ { 2 } + \frac { \rho } { 2 } \| \mathbf { z } - \mathbf { c } ^ { \prime } \| _ { 2 } ^ { 2 } ,$$
where $\mathbf { a } ^ { \prime } : = \delta ^ { k + 1 } + \mathbf { u } ^ { k } / \rho$ , $\mathbf b ^ { \prime } : = \mathbf w ^ { k + 1 } + \mathbf s ^ { k } / \rho$ , and $\mathbf { c } ^ { \prime } : = \mathbf { y } ^ { k + 1 } + \mathbf { v } ^ { k } / \rho$ . We recall that attacks studied in this paper belongs to ‘first-order’ adversaries (Madry et al., 2017), which only have access to gradients of the loss function $f$ . Spurred by that, we solve problem (13) via a linearization technique that is commonly used in stochastic/online ADMM (Ouyang et al., 2013; Suzuki, 2013; Liu et al., 2018) or linearized ADMM (Boyd et al., 2011; Liu et al., 2017). Specifically, we replace the function $f$ with its first-order Taylor expansion at the point $\mathbf { z } ^ { k }$ by adding a Bregman divergence term $( \eta _ { k } / 2 ) \lvert | \mathbf { z } - \mathbf { z } ^ { k } \rvert | _ { 2 } ^ { 2 }$ . As a result, problem (13) becomes
$$\begin{array} { r l } { \underset { \mathbf { z } } { \mathrm { m i n i m i z e } } } & { ( \nabla f ( \mathbf { z } ^ { k } + \mathbf { x } _ { 0 } ) ) ^ { T } ( \mathbf { z } - \mathbf { z } ^ { k } ) + \displaystyle \frac { \eta _ { k } } { 2 } \| \mathbf { z } - \mathbf { z } ^ { k } \| _ { 2 } ^ { 2 } + \displaystyle \frac { \rho } { 2 } \| \mathbf { z } - \mathbf { a } ^ { \prime } \| _ { 2 } ^ { 2 } } \\ & { + \displaystyle \frac { \rho } { 2 } \| \mathbf { z } - \mathbf { b } ^ { \prime } \| _ { 2 } ^ { 2 } + \displaystyle \frac { \rho } { 2 } \| \mathbf { z } - \mathbf { c } ^ { \prime } \| _ { 2 } ^ { 2 } , } \end{array}$$
where $1 / \eta _ { k } > 0$ is a given decaying parameter, e.g., $\eta _ { k } = \alpha \sqrt { k }$ for some $\alpha > 0$ , and the Bregman divergence term stabilizes the convergence of $\mathbf { z }$ -minimization step. It is clear that problem (14) yields a quadratic program with the closed-form solution
$$\begin{array} { r } { \mathbf { z } ^ { k + 1 } = \left( 1 / \left( \eta _ { k } + 3 \rho \right) \right) \left( \eta _ { k } \mathbf { z } ^ { k } + \rho \mathbf { a } + \rho \mathbf { b } + \rho \mathbf { c } - \nabla f ( \mathbf { z } ^ { k } + \mathbf { x } _ { 0 } ) \right) . } \end{array}$$
In summary, the proposed ADMM algorithm alternatively updates (7)-(9), which yield closed-form solutions given by (10)-(12) and (15). The convergence of linearized ADMM for nonconvex optimization was recently proved by (Liu et al., 2017), and thus provides theoretical validity of our approach. Compared to the existing solver for generation of adversarial examples (Carlini & Wagner, 2017; Papernot et al., 2016b), our algorithm offers two main benefits, efficiency and generality. That is, the computations for every update step are efficiently carried out, and our approach can be applicable to a wide class of attack formulations.
# 4 OVERLAPPING GROUP AND REFINED STRATTACK
In this section, we generalize our proposed ADMM solution framework to the case of generating adversarial perturbations with overlapping group structures. We then turn to an attack refining model under fixed sparse structures. We will show that both extensions can be unified under the ADMM framework. In particular, the refined approach will allow us to gain deeper insights on the structural effects on adversarial perturbations.
# 4.1 OVERLAPPING GROUP STRUCTURE
We recall that groups $\{ \mathcal { D } _ { i } \}$ (also denoted by $\{ \mathcal { G } _ { p , q } \} )$ studied in Sec. 3 could be overlapped with each other; see an example in Fig. A1. Therefore, $\{ \mathcal { D } _ { i } \}$ is in general a cover rather than a partition of $[ n ]$ . To address the challenge in coupled group variables, we introduce multiple copies of the variable y in problem (4), and achieve the following modification
$$\begin{array} { r l } { \underset { \delta , { \mathbf { z } } , { \mathbf { w } } , \{ { \mathbf { y } } _ { i } \} } { \mathrm { m i n i m i z e } } } & { \ f ( { \mathbf { z } } + { \mathbf { x } } _ { 0 } ) + \gamma D ( \delta ) + \tau \sum _ { i = 1 } ^ { P Q } \| \mathbf { y } _ { i , \mathcal { D } _ { i } } \| _ { 2 } + h ( \mathbf { w } ) } \\ { \mathrm { s u b j e c t ~ t o } } & { \ \mathbf { z } = \delta , \ \mathbf { z } = \mathbf { w } , \ \mathbf { z } = \mathbf { y } _ { i } , \quad i \in [ P Q ] , } \end{array}$$
where compared to problem (4), there exist $P Q$ variables $\mathbf { y } _ { i } \in \mathbb { R } ^ { n }$ for $i \in [ P Q ]$ , and ${ \bf y } _ { i , \mathcal { D } _ { i } }$ denotes the subvector of $\mathbf { y } _ { i }$ with indices given by $\mathcal { D } _ { i }$ . It is clear from (16) that groups $\{ \mathcal { D } _ { i } \}$ become nonoverlapped since each of them lies in a different copy $\mathbf { y } _ { i }$ . The ADMM algorithm for solving problem (16) maintains a similar procedure as (7)-(9) except $\mathbf { y }$ -step (12) and $\mathbf { z }$ -step (15); see Proposition 2.
Proposition 2 Given the same condition of Proposition $I$ , the ADMM solution to problem (16) involves the $\delta$ -step same as $( I O )$ , the w-step same as $( l I )$ , and two modified y- and $\mathbf { z }$ -steps,
$$\left\{ \begin{array} { l l } { \left[ \mathbf { y } _ { i } ^ { k + 1 } \right] _ { \mathcal { D } _ { i } } = \left( 1 - \frac { \tau } { \rho \| [ \mathbf { c } _ { i } ] _ { \mathcal { D } _ { i } } \| _ { 2 } } \right) _ { + } [ \mathbf { c } _ { i } ] _ { \mathcal { D } _ { i } } } \\ { \left[ \mathbf { y } _ { i } ^ { k + 1 } \right] _ { [ n ] / \mathcal { D } _ { i } } = [ \mathbf { c } _ { i } ] _ { [ n ] / \mathcal { D } _ { i } } } \\ { \mathbf { z } ^ { k + 1 } = \left( 1 / \left( \eta _ { k } + 2 \rho + P Q \rho \right) \right) \left( \eta _ { k } \mathbf { z } ^ { k } + \rho \mathbf { a } ^ { \prime } + \rho \mathbf { b } ^ { \prime } + \rho \sum _ { i = 1 } ^ { P Q } \mathbf { c } _ { i } ^ { \prime } - \nabla f ( \mathbf { z } ^ { k } + \mathbf { x } _ { 0 } ) \right) , } \end{array} \right.$$
where $\mathbf { c } _ { i } : = \mathbf { z } ^ { k } - \mathbf { v } _ { i } ^ { k } / \rho , \mathbf { v }$ $\mathbf { v } _ { i }$ is the Lagrangian multiplier associated with equality constraint $\mathbf { y } _ { i } = \mathbf { z }$ , similar to (9) we obtain $\mathbf v _ { i } ^ { k + 1 } = \mathbf v _ { i } ^ { k } + \rho ( \mathbf y ^ { k + 1 } - \mathbf z ^ { k + 1 } ) , [ \tau$ $[ n ] / \mathcal { D } _ { i }$ denotes the difference of sets $[ n ]$ and $\mathcal { D } _ { i } , \mathbf { a } ^ { \prime }$ and $\mathbf { b } ^ { \prime }$ have been defined in (13), and $\mathbf c _ { i } ^ { \prime } = \mathbf y _ { i } ^ { k + 1 } + \mathbf v _ { i } ^ { k } / \rho$ .
Proof: See Appendix C.
We note that updating $P Q$ variables $\left\{ \mathbf { y } _ { i } \right\}$ is decomposed as shown in (17). However, the side effect is the need of $P Q$ times more storage space than the $\mathbf { y }$ -step (12) when groups are non-overlapped.
# 4.2 REFINED STRATTACK UNDER FIXED SPARSE PATTERN
The approaches proposed in Sec. 3 and Sec. 4.1 help us to identify structured sparse patterns in adversarial perturbations. This section presents a method to refine structured attacks under fixed group sparse patterns. Let $\delta ^ { * }$ denote the solution to problem (2) solved by the proposed ADMM method. We define a $\sigma$ -sparse perturbation $\delta$ via $\delta ^ { * }$ ,
$$\delta _ { i } = 0 \mathrm { i f } \delta _ { i } ^ { * } \leq \sigma , \mathrm { f o r a n y } i \in [ n ] ,$$
where a hard thresholding operator is applied to $\delta ^ { * }$ with tolerance $\sigma$ . Our refined model imposes the fixed $\sigma$ -sparse structure (19) into problem (2). This leads to
$$\begin{array} { r l } { \underset { \delta } { \mathrm { m i n i m i z e } } } & { f ( \mathbf { x } _ { 0 } + \pmb { \delta } ) + \gamma D ( \pmb { \delta } ) } \\ { \mathrm { s u b j e c t ~ t o } } & { ( \mathbf { x } _ { 0 } + \pmb { \delta } ) \in [ 0 , 1 ] ^ { n } , \| \pmb { \delta } \| _ { \infty } \leq \epsilon } \\ & { \delta _ { i } = 0 , \mathrm { i f ~ } i \in S _ { \sigma } , } \end{array}$$
where $\scriptstyle { \mathcal { S } } _ { \sigma }$ is defined by (19), i.e., $S _ { \sigma } : = \left\{ j \vert \delta _ { j } ^ { * } \leq \sigma \right.$ , $j \in [ n ] \}$ . Compared to problem (2), the groupsparse penalty function is eliminated as it has been known as $a$ priori. With the priori knowledge of group sparsity, problem (20) is formulated to optimize and refine the non-zero groups, thus achieving better performance on highlighting and exploring the perturbation structure. Problem (20) can be solved using ADMM, and its solution is presented in Proposition 3.
Proposition 3 The ADMM solution to problem (20) is given by
$$\begin{array} { r } { [ \delta ^ { k + 1 } ] _ { i } = \left\{ \begin{array} { l l } { 0 } & { i \in \mathcal { S } _ { \sigma } } \\ { \operatorname* { m i n } \{ 1 - [ { \mathbf { x } } _ { 0 } ] _ { i } , \epsilon \} } & { \frac { \rho } { 2 \gamma + \rho } a _ { i } > \operatorname* { m i n } \{ 1 - [ { \mathbf { x } } _ { 0 } ] _ { i } , \epsilon \} , i \notin \mathcal { S } _ { \sigma } } \\ { \operatorname* { m a x } \{ - [ { \mathbf { x } } _ { 0 } ] _ { i } , - \epsilon \} } & { \frac { \rho } { 2 \gamma + \rho } a _ { i } < \operatorname* { m a x } \{ - [ { \mathbf { x } } _ { 0 } ] _ { i } , - \epsilon \} , i \notin \mathcal { S } _ { \sigma } } \\ { \frac { \rho } { 2 \gamma + \rho } a _ { i } } & { o t h e r w i s e , } \end{array} \right. } \\ { [ \mathbf { z } ^ { k + 1 } ] _ { i } = \left\{ \begin{array} { l l } { 0 } & { i \in \mathcal { S } _ { \sigma } } \\ { 1 / ( \eta _ { k } + \rho ) \left[ \eta _ { k } [ \mathbf { z } ^ { k } ] _ { i } + \rho [ \mathbf { a } ^ { \prime } ] _ { i } - [ \nabla f ( \mathbf { z } ^ { k } + { \mathbf { x } } _ { 0 } ) ] _ { i } \right] } & { i \notin \mathcal { S } _ { \sigma } , } \end{array} \right. } \end{array}$$
for $i \in \lceil n \rceil$ , where $\mathbf { z } = \delta$ is the introduced auxiliary variable similar to (4), $\mathbf { a } : = \delta ^ { k + 1 } - \mathbf { u } ^ { k } / \rho ,$ $\bar { \mathbf { a } } ^ { \prime } : = \delta ^ { k + 1 ^ { \prime } } + \mathbf { u } ^ { k } / \rho$ , $\mathbf { u } ^ { k + 1 } = \mathbf { u } ^ { k } + \rho ( \delta ^ { k + 1 } - \mathbf { z } ^ { k + 1 } ) ,$ , and $\rho$ and $\eta _ { k }$ have been defined in (6) and $( I 4 )$ . The ADMM iterations can be initialized by $\delta ^ { * }$ , the known solution to problem (2).
Proof: See Appendix D.
# 5 EMPIRICAL PERFORMANCE OF STRATTACK
We evaluate the performance of the proposed StrAttack on three image classification datasets, MNIST (Lecun et al., 1998), CIFAR-10 (Krizhevsky & Hinton, 2009) and ImageNet (Deng et al., 2009). To make fair comparison with the C&W $\ell _ { 2 }$ attack (Carlini & Wagner, 2017), we use $\ell _ { 2 }$ norm as the distortion function $D ( \delta ) = \| \delta \| _ { 2 } ^ { 2 }$ . And we also compare with FGM (Goodfellow et al., 2014) and IFGSM $\ell _ { 2 }$ attacks (Kurakin et al., 2017) as a reference. We evaluate attack success rate (ASR)1 as well as $\ell _ { p }$ distortion metrics for $p \in \{ 0 , 1 , 2 , \infty \}$ . The detailed experiment setup is presented in Appendix F. Our code is available at https://github.com/KaidiXu/StrAttack.
For each attack method on MNIST or CIFAR-10, we choose 1000 original images from the test dataset as source and each image has 9 target labels. So a total of 9000 adversarial examples are generated for each attack method. On ImageNet, each attack method tries to craft 900 adverdarial examples with 100 random images from the test dataset and 9 random target labels for each image.
Fig. 2 compares adversarial examples generated by StrAttack and C&W attack on each dataset. We observe that the perturbation of the C&W attack has poor group sparsity, i.e., many non-zeros groups with small magnitudes. However, the ASR of the C&W attack is quite sensitive to these small perturbations. As applying a threshold to have the same $\ell _ { 0 }$ norm as our attack, we find that only $6 . 7 \%$ of adversarial examples generated from C&W attack remain valid. By contrast, StrAttack is able to highlight the most important group structures (local regions) of adversarial perturbations without attacking other pixels. For example, StrAttack misclassifies a natural image (4 in MNIST) as an incorrect label 3. That is because the pixels that appears in the structure of 3 are more significantly perturbed by our attack; see the top right plots of Fig. 2. Furthermore, the ‘goose-sorrel’ example shows that misclassification occurs when we just perturb a small number of non-sparse group regions on goose’s head, which is more consistent with human perception. We refer readers to Appendix G for more results.
By quatitatively analysis, we report $\ell _ { p }$ norms and ASR in Table 1 for $p \in \{ 0 , 1 , 2 , \infty \}$ . We show that StrAttack perturbs much fewer pixels (smaller $\ell _ { 0 }$ norm), but it is comparable to or even better than other attacks in terms of $\ell _ { 1 } , \ell _ { 2 }$ , and $\ell _ { \infty }$ norms. Specifically, the FGM attack yields the worst performance in both ASR and $\ell _ { p }$ distortion. On MNIST and CIFAR-10, StrAttack outperforms other attacks in $\ell _ { 0 }$ , $\ell _ { 1 }$ and $\ell _ { \infty }$ distortion. On ImageNet, StrAttack outperforms C&W attack in $\ell _ { 0 }$ and $\ell _ { 1 }$ distortion. Since the C&W attacking loss directly penalizes the $\ell _ { 2 }$ norm, it often causes smaller $\ell _ { 2 }$ distortion than StrAttack. We also observe that the overlapping case leads to the adversarial perturbation of less sparsity (in terms of $\ell _ { 0 }$ norm) compared to the non-overlapping case. This is not surprising, since the sparsity of the overlapping region is controlled by at least two groups. However, compared to C&W attack, the use of overlapping groups in StrAttack still yields sparser perturbations. Unless specified otherwise, we focus on the case of non-overlapping groups to generate the most sparse adversarial perturbations. We highlight that although a so-called one-pixel attack (Su et al., 2017) also yields very small $\ell _ { 0 }$ norm, it is at the cost of very large $\ell _ { \infty }$ distortion. Unlike one-pixel attack, StrAttack achieves the sparsity without losing the performance of $\ell _ { \infty }$ , $\ell _ { 1 }$ and $\ell _ { 2 }$ distortion.
Furthermore, we compare the performance of StrAttack with the C&W $\ell _ { \infty }$ attack and IFGSM while attacking the robust model (Madry et al., 2017) on MNIST. We remark that all the considered attack methods are performed under the same $\ell _ { \infty }$ -norm based distortion constraint with an upper bound $\epsilon \in \{ 0 . 1 , 0 . 2 , 0 . 3 , 0 . 4 \}$ . Here we obtain a (refined) StrAttack subject to $\| \pmb { \delta } \| _ { \infty } \le \epsilon$ by solving problem (20) at $\gamma = 0$ . In Table 2, we demonstrate the ASR and the number of perturbed pixels for various attacks over 5000 (untargeted) adversarial examples. The ASR define as the proportion of the final perturbation results less than given $\epsilon \in \{ 0 . 1 , 0 . 2 , 0 . 3 , 0 . 4 \}$ bound over number of test images. Here an successful attack is defined by an attack that can fool DNNs and meets the $\ell _ { \infty }$ distortion constraint. As we can see, StrAttack can achieve the similar ASR compared to other attack methods, however, it perturbs a much less number of pixels. Next, we evaluate the performance of StrAttack against two defense mechanisms: defensive distillation (Papernot et al., 2016c) and adversarial training (Tramèr et al., 2018). We observe that StrAttack is able to break the two defense methods with $100 \%$ ASR. More details are provided in Appendix H.
 Figure 2: C&W attack vs StrAttack. Here each grid cell represents a $2 \times 2 , 2 \times 2$ , and $1 3 \times 1 3$ small region in MNIST, CIFAR-10 and ImageNet, respectively. The group sparsity of perturbation is represented by heatmap. The colors on heatmap represent average absolute value of distortion scale to [0, 255]. The left two columns correspond to results of using C&W attack. The right two columns show results of StrAttack.
Table 1: Adversarial attack success rate (ASR) and $\ell _ { p }$ distortion values for various attacks.
<table><tr><td rowspan="2">Data Set</td><td rowspan="2">Attack Method</td><td colspan="5">BestCase</td><td colspan="5">Average Case</td><td colspan="5">Worst Case</td></tr><tr><td>ASR</td><td>lo</td><td>l1</td><td>l2</td><td>lo</td><td>ASR</td><td>l</td><td>l1</td><td>l2</td><td>lo</td><td>ASR</td><td>lo</td><td>l1</td><td>l2</td><td>lo</td></tr><tr><td rowspan="5">MNIST</td><td>FGM</td><td>99.3</td><td>456.5 549.5</td><td>28.2</td><td>2.32</td><td>0.57</td><td>35.8</td><td>466</td><td>39.4</td><td>3.17</td><td>0.717</td><td>0</td><td>N.A</td><td>N.A.</td><td>N.A.</td><td>N.A.</td></tr><tr><td>IFGSM</td><td>100</td><td></td><td>18.3</td><td>1.57</td><td>0.4</td><td>100</td><td>588</td><td>30.9</td><td>2.41</td><td>0.566</td><td>99.8</td><td>640.4</td><td>50.98</td><td>3.742</td><td>0.784</td></tr><tr><td>C&W</td><td>100</td><td>479.8</td><td>13.3</td><td>1.35</td><td>0.397</td><td>100</td><td>493.4</td><td>21.3</td><td>1.9</td><td>0.528</td><td>99.7</td><td>524.3</td><td>29.9</td><td>2.45</td><td>0.664</td></tr><tr><td>StrAttack</td><td>100</td><td>73.2</td><td>10.9</td><td>1.51</td><td>0.384</td><td>100</td><td>119.4</td><td>18.05</td><td>2.16</td><td>0.47</td><td>100</td><td>182.0</td><td>26.9</td><td>2.81</td><td>0.5</td></tr><tr><td>+overlap</td><td>100</td><td>84.4</td><td>9.2</td><td>1.32</td><td>0.401</td><td>100</td><td>157.4</td><td>16.2</td><td>1.95</td><td>0.508</td><td>100</td><td>260.9</td><td>22.9</td><td>2.501</td><td>0.653</td></tr><tr><td rowspan="5">CIFAR-10</td><td>FGM</td><td>98.5</td><td>3049</td><td>12.9</td><td>0.389</td><td>0.046</td><td>44.1</td><td>3048</td><td>34.2</td><td>0.989</td><td>0.113</td><td>0.2</td><td>3071</td><td>61.3</td><td>1.76</td><td>0.194</td></tr><tr><td>IFGSM</td><td>100</td><td>3051</td><td>6.22</td><td>0.182</td><td>0.02</td><td>100</td><td>3051</td><td>13.7</td><td>0.391</td><td>0.0433</td><td>100</td><td>3060</td><td>22.9</td><td>0.655</td><td>0.075</td></tr><tr><td>C&W</td><td>100</td><td>2954</td><td>6.03</td><td>0.178</td><td>0.019</td><td>100</td><td>2956</td><td>12.1</td><td>0.347</td><td>0.0364</td><td>99.9</td><td>3070</td><td>16.8</td><td>0.481</td><td>0.0536</td></tr><tr><td>StrAttack</td><td>100</td><td>264</td><td>3.33</td><td>0.204</td><td>0.031</td><td>100</td><td>487</td><td>7.13</td><td>0.353</td><td>0.050</td><td>100</td><td>772</td><td>12.5</td><td>0.563</td><td>0.075</td></tr><tr><td>+overlap</td><td>100</td><td>295</td><td>3.35</td><td>0.169</td><td>0.029</td><td>100</td><td>562</td><td>7.05</td><td>0.328</td><td>0.047</td><td>100</td><td>920</td><td>12.9</td><td>0.502</td><td>0.063</td></tr><tr><td rowspan="4">ImageNet</td><td>FGM</td><td>12</td><td>264917</td><td>152</td><td>0.477</td><td>0.0157</td><td>2</td><td>263585</td><td>51.3</td><td>0.18</td><td>0.00614</td><td>0</td><td>N.A.</td><td>N.A.</td><td>N.A.</td><td>N.A.</td></tr><tr><td>IFGSM</td><td>100</td><td>267079</td><td>299.32</td><td>0.9086</td><td>0.02964</td><td>100</td><td>267293</td><td>723</td><td>2.2</td><td>0.0792</td><td>98</td><td>267581</td><td>1378</td><td>4.22</td><td>0.158</td></tr><tr><td>C&W</td><td>100</td><td>267916</td><td>127</td><td>0.471</td><td>0.016</td><td>100</td><td>263140</td><td>198</td><td>0.679</td><td>0.03</td><td>100</td><td>265212</td><td>268</td><td>0.852</td><td>0.041</td></tr><tr><td>StrAttack</td><td>100</td><td>14462</td><td>55.2</td><td>0.719</td><td>0.058</td><td>100</td><td>52328</td><td>152</td><td>1.06</td><td>0.075</td><td>100</td><td>80722</td><td>197</td><td>1.35</td><td>0.122</td></tr></table>
\* Please refer to Appendix F for the definition of best case, best case and worst case. \*\* N.A. means not available in the case of zero ASR, +overlap means structured attack with overlapping groups.
Lastly, we evaluate the transferability of StrAttack from Inception V3 (Szegedy et al., 2016) to other network models including Inception V2, Inception V4 (Szegedy et al., 2017), ResNet 50, ResNet 152 (He et al., 2016), DenseNet 121 and DenseNet 161 (Huang et al., 2017). For comparison, we also present the transferbility of IFGSM and C&W. This experiment is performed under 1000 (target) adversarial examples on ImageNet2. It can be seen from in Table 3 that StrAttack yields the largest attack success rate while transferring to almost every network model.
Table 2: Attack success rate (ASR) and $\ell _ { 0 }$ norm of adversarial perturbations for various attacks against robust adversarial training based defense on MNIST.
<table><tr><td></td><td>ASR at ε = 0.1</td><td>ASR at e = 0.2</td><td>ASR at e = 0.3</td><td>ASR at ε = 0.4</td><td>l</td></tr><tr><td>IFGSM</td><td>0.01</td><td>0.02</td><td>0.09</td><td>0.94</td><td>654</td></tr><tr><td>C&W loattack</td><td>0.01</td><td>0.02</td><td>0.10</td><td>0.96</td><td>723</td></tr><tr><td>StrAttack</td><td>0.01</td><td>0.02</td><td>0.10</td><td>0.99</td><td>279</td></tr></table>
Table 3: Comparison of transferability of different attacks over 6 ImageNet models.
<table><tr><td></td><td>Incept V2</td><td>Incept V4</td><td>ResNet50</td><td>ResNet152</td><td>DenseNet121</td><td>DenseNet161</td></tr><tr><td>IFGSM</td><td>0.27</td><td>0.22</td><td>0.27</td><td>0.19</td><td>0.16</td><td>0.19</td></tr><tr><td>C&W</td><td>0.25</td><td>0.24</td><td>0.23</td><td>0.23</td><td>0.15</td><td>0.15</td></tr><tr><td>StrAttack</td><td>0.28</td><td>0.27</td><td>0.25</td><td>0.25</td><td>0.26</td><td>0.25</td></tr></table>
# 6 STRATTACK OFFERS BETTER INTERPRETABILITY
In this section, we evaluate the effects of structured adversarial perturbations on image classification through adversarial saliency map (ASM) (Papernot et al., 2016b) and class activation map (CAM) (Zhou et al., 2016). Here we recall that ASM measures the impact of pixel-level perturbations on label classification, and CAM localizes class-specific image discriminative regions that we use to visually explain adversarial perturbations (Xiao et al., 2018). We will show that compared to C&W attack, StrAttack meets better interpretability in terms of (a) a higher ASM score and (b) a tighter connection with CAM, where the metric (a) implies interpretability at a micro-level, namely, perturbing pixels with largest impact on image classification, and the metric (b) demonstrates interpretability at a macro-level, namely, perturbations can be mapped to the most discriminative image regions localized by CAM.
Given an input image $\mathbf { x } _ { \mathrm { 0 } }$ and a target class $t$ , let $\mathrm { A S M } ( \mathbf { x } _ { 0 } , t ) \in \mathbb { R } ^ { d }$ denote ASM scores for every pixel of $\mathbf { x } _ { \mathrm { 0 } }$ corresponding to $t$ . We elaborate on the mathematical definition of ASM in Appendix E. Generally speaking, the ith element of $\mathrm { A S M } ( \mathbf { x } _ { 0 } , t )$ , denoted by $\mathrm { A S M } ( \mathbf { x } _ { 0 } , t ) [ i ]$ , measures how much the classification score with respect to the target label $t$ will increase and that with respect to the original label $t _ { 0 }$ will decrease if a perturbation is added to the pixel $i$ . With the aid of ASM, we then define a Boolean map $\mathbf { B } _ { \mathrm { A S M } } \in \mathbb { R } ^ { \bar { d } }$ to encode the regions of $\mathbf { x } _ { \mathrm { 0 } }$ most sensitive to targeted adversarial attacks, where $\begin{array} { r } { \mathbf { B } _ { \mathrm { A S \bar { M } } } ( i ) = 1 } \end{array}$ if $\mathrm { A S M } ( \mathbf { x } _ { 0 } , t ) > \nu$ , and 0 otherwise. Here $\nu$ is a given threshold to highlight the most sensitive pixels. we then define the interpretability score (IS) via ASM,
$$\mathrm { I S } ( \delta ) = \| \mathbf { B } _ { \mathrm { A S M } } \circ \pmb { \delta } \| _ { 2 } / \| \pmb { \delta } \| _ { 2 } ,$$
where $\circ$ is the element-wise product. The rationale behind (23) is that $\mathrm { I S } ( \delta ) 1$ if the sensitive region identified by ASM perfectly predicts the locations of adversarial perturbations. By contrast, if $\mathrm { \bar { I S } } ( \delta ) \to 0$ , then adversarial perturbations cannot be interpreted by ASM. In Fig. 3(a), we compare IS of our proposed attack with C&W attack versus the threshold $\nu$ , valued by different percentiles of ASM scores. We obsreve that our attack outperforms C&W attack in terms of IS, since the former is able to extract important local structures of images by penalizing the group sparsity of adversarial perturbations. It seems that our improvement is not significant. However, StrAttack just perturbs very few pixels to obtain this benefit, leading to perturbations with more semantic structure; see Fig. 3(b) for an illustrative example.
Besides ASM, we show that the effect of adversarial perturbations can be visually explained through the class-specific discriminative image regions localized by CAM (Zhou et al., 2016). In Fig. 3(c), we illustrate CAM and demonstrate the differences between our attack and C&W in terms of their connections to the most discriminative regions of $\mathbf { x } _ { \mathrm { 0 } }$ with label $t _ { 0 }$ . We observe that the mechanism of StrAttack can be better interpreted from CAM: only a few adversarial perturbations are needed to suppress the feature of the original image with the true label. By replacing ASM with CAM, we can similarly compute IS in (23) averaged over 500 examples on ImageNet, yielding 0.65 for C&W attack and 0.77 for our attack. More examples of ASM and CAM can be viewed in Appendix E.
To better interpret the mechanism of adversarial examples, we study adversarial attacks on some complex images, where the objects of the original and target labels exist simultaneously as shown in Fig. 4. It can be visualized from CAM that both C&W attack and StrAttack yields similar adversarial effects on natural images: Adversarial perturbations are used to suppress the most discriminative region with respect to the true label, and simultaneously promotes the discriminative region of the target label. The former principle is implied by the location of perturbed regions and $C ( \mathbf { x } _ { 0 } , t _ { 0 } )$ in Fig. 4, and the latter can be seen from $C ( \mathbf { x } _ { \mathrm { C W } } , t )$ or $\boldsymbol { C } ( \mathbf { x } _ { \mathrm { S t r } } , t )$ against $C ( \mathbf { x } _ { 0 } , t )$ . However, compared to C&W attack, StrAttack perturbs much less but ‘right’ pixels which have better correspondence with class-specific discriminative image regions localized by CAM.
 Figure 3: Interpretabilicy comparison of StrAttack and C&W attack. (a) ASM-based IS vs $\nu$ , given from the 30th percentile to the 90th percentile of ASM scores. (b) Overlay ASM and $\mathbf { B } _ { \mathrm { A S M } } \circ \delta$ on top of image with the true label ‘Tibetan Mastiff’ and the target label ‘streetcar’. From left to right: original image, ASM (darker color represents larger value of ASM score), $\mathbf { B } _ { \mathrm { A S M } } \circ \delta$ under StrAttack, and $\mathbf { B } _ { \mathrm { A S M } } \circ \delta$ under C&W attack. Here $\nu$ in $\mathbf { B } _ { \mathrm { A S M } }$ is set by the 90th percentile of ASM scores. (c) From left to right: original image with true label ‘stove’, CAM of ‘stove’, and perturbations with target label ‘water ouzel’ under StrAttack and C&W.
# 7 CONCLUSION
This work explores group-wise sparse structures when implementing adversarial attacks. Different from previous works that use $\ell _ { p }$ norm to measure the similarity between an original image and an adversarial example, this work incorporates group-sparsity regularization into the problem formulation of generating adversarial examples and achieves strong group sparsity in the obtained adversarial perturbations. Leveraging ADMM, we develop an efficient implementation to generate structured adversarial perturbations, which can be further used to refine an arbitrary adversarial attack under fixed group sparse structures. The proposed ADMM framewrok is general enough for implementing many state-of-the-art attacks. We perform extensive experiments using MNIST, CIFAR-10 and ImageNet datasets, showing that our structured adversarial attack (StrAttack) is much stronger than the existing attacks and its better interpretability from group sparse structures aids in uncovering the origins of adversarial examples.
# ACKNOWLEDGEMENT
This work is supported by Air Force Research Laboratory FA8750-18-2-0058, and U.S. Office of Naval Research. Sijia Liu, Pin-Yu Chen, Huan Zhang and Quanfu Fan were supported by the MITIBM Watson Ai Lab, IBM Research.
# REFERENCES
Anonymous. Random mask: Towards robust convolutional neural networks. In Submitted to International Conference on Learning Representations, 2019. URL https://openreview. net/forum?id ${ . } = { }$ SkgkJn05YX. under review.
F. Bach, R. Jenatton, J. Mairal, and G. Obozinski. Optimization with sparsity-inducing penalties. Foundations and Trends $\textsuperscript { \textregistered }$ in Machine Learning, 4(1):1–106, 2012.
A. Beck and M. Teboulle. A fast iterative shrinkage-thresholding algorithm for linear inverse problems. SIAM journal on imaging sciences, 2(1):183–202, 2009.
S. Boyd, N. Parikh, E. Chu, B. Peleato, J. Eckstein, et al. Distributed optimization and statistical learning via the alternating direction method of multipliers. Foundations and Trends $\textsuperscript { \textregistered }$ in Machine Learning, 3(1):1–122, 2011.

$t _ { 0 }$ : Bosto n bu ll, t : bucket $t _ { 0 }$ : holster, t : revo lver $t _ { 0 }$ : pug, t: street sign

 Figure 4: CAMs of adversarial examples generated by the C&W attack and StrAttack under the original label $\left( t _ { 0 } \right)$ and target label $\mathbf { \rho } ( t )$ . Here $\scriptstyle \mathbf { 1 } \mathbf { 2 } \mathbf { C } \mathbf { W }$ and ${ \pmb x } _ { \mathrm { S t r } }$ denote adversarial examples crafted by different attacks. At each row, the subplots from left to right represent the original image $\scriptstyle { \mathbf { 2 } } 0$ , perturbations generated by C&W attack, perturbations generated by StrAttack, and CAMs with respect to natural or adversarial example under $t _ { 0 }$ or $t$ . Here the class $c$ specified CAM with respect to image $\mathbf { x }$ is denoted by $C ( \mathbf { x } , c )$ .
Tom B Brown, Dandelion Mané, Aurko Roy, Martín Abadi, and Justin Gilmer. Adversarial patch. arXiv preprint arXiv:1712.09665, 2017.
N. Carlini and D. Wagner. Towards evaluating the robustness of neural networks. In Security and Privacy (SP), 2017 IEEE Symposium on, pp. 39–57. IEEE, 2017.
J. Chen, L. Yang, Y. Zhang, M. Alber, and D. Chen. Combining fully convolutional and recurrent neural networks for 3d biomedical image segmentation. In Advances in Neural Information Processing Systems, pp. 3036–3044, 2016.
P.-Y. Chen, Y. Sharma, H. Zhang, J. Yi, and C.-J. Hsieh. Ead: elastic-net attacks to deep neural networks via adversarial examples. arXiv preprint arXiv:1709.04114, 2017a.
P.-Y. Chen, H. Zhang, Y. Sharma, J. Yi, and C.-J. 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, pp. 15–26. ACM, 2017b.
J. Deng, W. Dong, R. Socher, L. Li, K. Li, and F.-F. Li. Imagenet: A large-scale hierarchical image database. In Computer Vision and Pattern Recognition, 2009. CVPR 2009. IEEE Conference on, pp. 248–255. IEEE, 2009.
Y. Dong, H. Su, J. Zhu, and F. Bao. Towards interpretable deep neural networks by leveraging adversarial examples. arXiv preprint arXiv:1708.05493, 2017.
I. Evtimov, K. Eykholt, E. Fernandes, T. Kohno, B. Li, A. Prakash, A. Rahmati, and D. Song. Robust physical-world attacks on machine learning models. arXiv preprint arXiv:1707.08945, 2017.
J. Fu, J. Co-Reyes, and S. Levine. Ex2: Exploration with exemplar models for deep reinforcement learning. In Advances in Neural Information Processing Systems, pp. 2574–2584, 2017.
Y. Geifman and R. El-Yaniv. Selective classification for deep neural networks. In Advances in neural information processing systems, pp. 4885–4894, 2017.
J. Gilmer, L. Metz, F. Faghri, S. Schoenholz, M. Raghu, M. Wattenberg, and I. Goodfellow. Adversarial spheres. arXiv preprint arXiv:1801.02774, 2018. I. Goodfellow, J. Shlens, and C. Szegedy. Explaining and harnessing adversarial examples. arXiv preprint arXiv:1412.6572, 2014. D. Harwath, A. Torralba, and J. Glass. Unsupervised learning of spoken language with visual context. In Advances in Neural Information Processing Systems, pp. 1858–1866, 2016. K. He, X. Zhang, S. Ren, and J. Sun. Deep residual learning for image recognition. In Proceedings of the IEEE conference on computer vision and pattern recognition, pp. 770–778, 2016. G. Hinton, L. Deng, D. Yu, G. Dahl, A.-r. Mohamed, N. Jaitly, A. Senior, V. Vanhoucke, P. Nguyen, T. Sainath, et al. Deep neural networks for acoustic modeling in speech recognition: The shared views of four research groups. IEEE Signal Processing Magazine, 29(6):82–97, 2012. Gao Huang, Zhuang Liu, Laurens Van Der Maaten, and Kilian Q Weinberger. Densely connected convolutional networks. In CVPR, volume 1, pp. 3, 2017. D. Karmon, D. Zoran, and Y. Goldberg. Lavan: Localized and visible adversarial noise. arXiv preprint arXiv:1801.02608, 2018. D. Kingma and J. Ba. Adam: A method for stochastic optimization. 2015 ICLR, arXiv preprint arXiv:1412.6980, 2015. URL http://arxiv.org/abs/1412.6980. A. Krizhevsky and G. Hinton. Learning multiple layers of features from tiny images. Master’s thesis, Department of Computer Science, University of Toronto, 2009. A. Kurakin, I. Goodfellow, and S. Bengio. Adversarial examples in the physical world. arXiv preprint arXiv:1607.02533, 2016. A. Kurakin, I. Goodfellow, and S. Bengio. Adversarial machine learning at scale. 2017 ICLR, arXiv preprint arXiv:1611.01236, 2017. URL http://arxiv.org/abs/1611.01236. Y. Lecun, L. Bottou, Y. Bengio, and P. Haffner. Gradient-based learning applied to document recognition. Proceedings of the IEEE, 86(11):2278–2324, Nov 1998. ISSN 0018-9219. doi: 10.1109/5.726791. Q. Liu, X. Shen, and Y. Gu. Linearized admm for non-convex non-smooth optimization with convergence analysis. arXiv preprint arXiv:1705.02502, 2017. S. Liu, S. Kar, M. Fardad, and P. K. Varshney. Sparsity-aware sensor collaboration for linear coherent estimation. IEEE Transactions on Signal Processing, 63(10):2582–2596, 2015. S. Liu, J. Chen, P.-Y. Chen, and A. O. Hero. Zeroth-order online admm: Convergence analysis and applications. In Proceedings of the Twenty-First International Conference on Artificial Intelligence and Statistics, volume 84, pp. 288–297, April 2018. A. Madry, A. Makelov, L. Schmidt, D. Tsipras, and A. Vladu. Towards deep learning models resistant to adversarial attacks. arXiv preprint arXiv:1706.06083, 2017. A. Nguyen, J. Yosinski, and J. 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, pp. 427–436, 2015. H. Ouyang, N. He, L. Tran, and A. Gray. Stochastic alternating direction method of multipliers. In International Conference on Machine Learning, pp. 80–88, 2013. N. Papernot, I. Goodfellow, R. Sheatsley, R. Feinman, and P. McDaniel. cleverhans v1.0.0: an adversarial machine learning library. arXiv preprint arXiv:1610.00768, 2016a. N. Papernot, P. McDaniel, S. Jha, M. Fredrikson, B. Celik, and A. Swami. The limitations of deep learning in adversarial settings. In Security and Privacy (EuroS&P), 2016 IEEE European Symposium on, pp. 372–387. IEEE, 2016b. N. Papernot, P. McDaniel, X. Wu, S. Jha, and A. Swami. Distillation as a defense to adversarial perturbations against deep neural networks. In Security and Privacy (SP), 2016 IEEE Symposium on, pp. 582–597. IEEE, 2016c. N. Papernot, P. McDaniel, I. Goodfellow, S. Jha, Z. Celik, and A. Swami. Practical black-box attacks against machine learning. In Proceedings of the 2017 ACM on Asia Conference on Computer and Communications Security, pp. 506–519. ACM, 2017. N. Parikh, S. Boyd, et al. Proximal algorithms. Foundations and Trends $\textsuperscript { \textregistered }$ in Optimization, 1(3): 127–239, 2014. M. Sharif, L. Bauer, and M. K. Reiter. On the suitability of lp-norms for creating and preventing adversarial examples. CoRR, abs/1802.09653, 2018. X. Shi, M. Sapkota, F. Xing, F. Liu, L. Cui, and L. Yang. Pairwise based deep ranking hashing for histopathology image classification and retrieval. Pattern Recognition, 81:14 – 22, 2018. ISSN 0031-3203. doi: https://doi.org/10.1016/j.patcog.2018.03.015. URL http: //www.sciencedirect.com/science/article/pii/S0031320318301055. D. Silver, A. Huang, C. Maddison, A. Guez, L. Sifre, G. Van Den Driessche, J. Schrittwieser, I. Antonoglou, V. Panneershelvam, M. Lanctot, et al. Mastering the game of go with deep neural networks and tree search. nature, 529(7587):484–489, 2016. A. Sinha, H. Namkoong, and J. Duchi. Certifying some distributional robustness with principled adversarial training. 2018. 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. arXiv preprint arXiv:1808.01688, 2018. J. Su, D. Vargas, and S. Kouichi. One pixel attack for fooling deep neural networks. arXiv preprint arXiv:1710.08864, 2017. T. Suzuki. Dual averaging and proximal gradient descent for online alternating direction multiplier method. In International Conference on Machine Learning, pp. 392–400, 2013. C. Szegedy, W. Zaremba, I. Sutskever, J. Bruna, D. Erhan, I. Goodfellow, and R. Fergus. Intriguing properties of neural networks. arXiv preprint arXiv:1312.6199, 2013. C. Szegedy, V. Vanhoucke, S. Ioffe, J. Shlens, and Z. Wojna. Rethinking the inception architecture for computer vision. 2016 IEEE Conference on Computer Vision and Pattern Recognition (CVPR), pp. 2818–2826, 2016. Christian Szegedy, Sergey Ioffe, Vincent Vanhoucke, and Alexander A Alemi. Inception-v4, inception-resnet and the impact of residual connections on learning. In AAAI, volume 4, pp. 12, 2017. F. Tramèr, A. Kurakin, N. Papernot, I. Goodfellow, D. Boneh, and P. McDaniel. Ensemble adversarial training: Attacks and defenses. 2018 ICLR, arXiv preprint arXiv:1705.07204, 2018. C. Xiao, J. Zhu, B. Li, W. He, M. Liu, and D. Song. Spatially transformed adversarial examples. CoRR, abs/1801.02612, 2018. URL http://arxiv.org/abs/1801.02612. M. Yuan and Y. Lin. Model selection and estimation in regression with grouped variables. Journal of the Royal Statistical Society: Series B (Statistical Methodology), 68(1):49–67, 2006. B. Zhou, A. Khosla, A. Lapedriza, A. Oliva, and A. Torralba. Learning deep features for discriminative localization. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pp. 2921–2929, 2016.
# APPENDIX
# A ILLUSTRATIVE EXAMPLE OF GROUP SPARSITY
 Figure A1: An example of $4 \times 4$ perturbation matrix under sliding masks with different strides. The values of matrix elements are represented by color’s intensity (white stands for 0). Left: Non-overlapping groups with $r = 2$ and $S = 2$ . Right: Overlapping groups with $r = 2$ and $S = 1$ . In both cases, two groups $\mathcal { G } _ { 1 , 1 }$ and $\mathcal { G } _ { 1 , 2 }$ are highlighted, where $\mathcal { G } _ { 1 , 1 }$ is non-sparse, and $\mathcal { G } _ { 1 , 2 }$ is sparse.
# B PROOF OF PROPOSITION 1
We recall that the augmented Lagrangian function $L ( \delta , \mathbf { z } , \mathbf { w } , \mathbf { y } , \mathbf { u } , \mathbf { v } , \mathbf { s } )$ is given by
$$\begin{array} { r l r } & { } & { L ( { \bf z } , \delta , { \bf y } , { \bf w } , { \bf u } , { \bf v } , { \bf s } ) = f ( { \bf z } + { \bf x } _ { 0 } ) + \gamma D ( \delta ) + \tau \sum _ { i = 1 } ^ { P Q } \| { \bf y } _ { \mathcal { D } _ { i } } \| _ { 2 } + h ( { \bf w } ) + { \bf u } ^ { T } ( \delta - { \bf z } ) } \\ & { } & { + { \bf v } ^ { T } ( { \bf y } - { \bf z } ) + { \bf s } ^ { T } ( { \bf w } - { \bf z } ) + \displaystyle \frac { \rho } { 2 } \| \delta - { \bf z } \| _ { 2 } ^ { 2 } + \displaystyle \frac { \rho } { 2 } \| { \bf y } - { \bf z } \| _ { 2 } ^ { 2 } + \displaystyle \frac { \rho } { 2 } \| { \bf w } - { \bf z } \| _ { 2 } ^ { 2 } . } \end{array}$$
Problem (7), to minimize $L ( \delta , \mathbf { z } ^ { k } , \mathbf { w } , \mathbf { y } , \mathbf { u } ^ { k } , \mathbf { v } ^ { k } , \mathbf { s } ^ { k } )$ , can be decomposed into three sub-problems:
$$\operatorname* { m i n i m i z e } _ { \delta } \gamma D ( \pmb { \delta } ) + \frac { \rho } { 2 } \| \pmb { \delta } - \mathbf { a } \| _ { 2 } ^ { 2 } ,$$
$$\operatorname* { m i n i m i z e } _ { \mathbf { w } } { h ( \mathbf { w } ) } + \frac { \rho } { 2 } \| \mathbf { w } - \mathbf { b } \| _ { 2 } ^ { 2 } ,$$
$$\underset { \mathbf { y } } { \mathrm { m i n i m i z e } } \ \tau \sum _ { i = 1 } ^ { P Q } \| \mathbf { y } _ { \mathcal { D } _ { i } } \| _ { 2 } + \frac { \rho } { 2 } \| \mathbf { y } - \mathbf { c } \| _ { 2 } ^ { 2 } ,$$
where $\mathbf { a } : = \mathbf { z } ^ { k } - \mathbf { u } ^ { k } / \rho , \mathbf { b } : = \mathbf { z } ^ { k } - \mathbf { s } ^ { k } / \rho$ , and $\mathbf { c } : = \mathbf { z } ^ { k } - \mathbf { v } ^ { k } / \rho .$ .
$\delta$ -step Suppose $D ( \delta ) = \| \delta \| _ { 2 } ^ { 2 }$ , then the solution to problem (25) is easily acquired as below
$$\delta ^ { k + 1 } = \frac { \rho } { \rho + 2 \gamma } \mathbf { a }$$
w-step Based on the definition of $h ( \mathbf { w } )$ , problem (26) becomes
$$\begin{array} { r l } { \underset { \mathbf { w } } { \mathrm { m i n i m i z e } } } & { \| \mathbf { w } - \mathbf { b } \| _ { 2 } ^ { 2 } } \\ { \mathrm { s u b j e c t ~ t o } } & { ( \mathbf { x } _ { 0 } + \mathbf { w } ) \in [ 0 , 1 ] ^ { n } , \ \| \mathbf { w } \| _ { \infty } \leq \epsilon . } \end{array}$$
Problem (29) is equivalent to
$$\begin{array} { r l } { \underset { w _ { i } } { \mathrm { m i n i m i z e } } } & { ( w _ { i } - a _ { i } ) _ { 2 } ^ { 2 } } \\ { \mathrm { s u b j e c t ~ t o } } & { - [ \mathbf { x } _ { 0 } ] _ { i } \leq w _ { i } \leq 1 - [ \mathbf { x } _ { 0 } ] _ { i } , | w _ { i } | \leq \epsilon } \end{array}$$
for $i \in [ n ]$ , where $x _ { i }$ or $[ \mathbf { x } ] _ { i }$ represents the $i$ th element of $\mathbf { x }$ , and $1 - [ { \bf x } _ { 0 } ] _ { i } > 0$ since $[ \mathbf { x } _ { 0 } ] _ { i } \in [ 0 , 1 ]$ . Problem (30) then yields the solution
$$[ \mathbf { w } ^ { k + 1 } ] _ { i } = \left\{ \begin{array} { l l } { \operatorname* { m i n } \{ 1 - [ \mathbf { x } _ { 0 } ] _ { i } , \epsilon \} } & { a _ { i } > \operatorname* { m i n } \{ 1 - [ \mathbf { x } _ { 0 } ] _ { i } , \epsilon \} } \\ { \operatorname* { m a x } \{ - [ \mathbf { x } _ { 0 } ] _ { i } , - \epsilon \} } & { a _ { i } < \operatorname* { m a x } \{ - [ \mathbf { x } _ { 0 } ] _ { i } , - \epsilon \} } \\ { a _ { i } } & { \mathrm { o t h e r w i s e } . } \end{array} \right.$$
y-step Problem (27) becomes
$$\underset { \mathbf { y } } { \mathrm { m i n i m i z e } } \sum _ { i = 1 } ^ { P Q } \| \mathbf { y } _ { \mathcal { D } _ { i } } \| _ { 2 } + \frac { \rho } { 2 \tau } \| \mathbf { y } - \mathbf { c } \| _ { 2 } ^ { 2 } ,$$
The solution is given by the proximal operator associated with the $\ell _ { 2 }$ norm with parameter $\tau / \rho$ (Parikh et al., 2014)
$$[ { \bf y } ^ { k + 1 } ] _ { \mathcal { D } _ { i } } = \left( 1 - \frac { \tau } { \rho \| [ { \bf c } ] _ { \mathcal { D } _ { i } } \| _ { 2 } } \right) _ { + } [ { \bf c } ] _ { \mathcal { D } _ { i } } , \ i \in [ P Q ] ,$$
where recall that $\cup _ { i \in [ P Q ] } { \mathcal { D } } _ { i } = [ n ]$ , and $\mathcal { D } _ { i } \cap \mathcal { D } _ { j } = \emptyset$ if $i \neq j$ .
# C PROOF OF PROPOSITION 2
The augmented Lagrangian of problem (16) is given by
$$\begin{array} { l } { { \displaystyle \langle { \bf z } , \delta , { \bf w } , \{ \bf y } _ { i } \rangle , { \bf u } , { \bf v } _ { i } , { \bf s } \rangle = f ( { \bf z } + { \bf x } _ { 0 } ) + \gamma D ( \delta ) + h ( { \bf w } ) + \tau \sum _ { i = 1 } ^ { P Q } \| { \bf y } _ { i } , { \mathcal D } _ { i } \| _ { 2 } + { \bf u } ^ { T } ( \delta - { \bf z } ) + { \bf s } ^ { T } ( { \bf w } - { \bf z } ) } \\ { { \displaystyle \qquad + \sum _ { i = 1 } ^ { P Q } { \bf v } _ { i } ^ { T } ( { \bf y } _ { i } - { \bf z } ) + \frac { \rho } { 2 } \| \delta - { \bf z } \| _ { 2 } ^ { 2 } + \frac { \rho } { 2 } \| { \bf w } - { \bf z } \| _ { 2 } ^ { 2 } + \frac { \rho } { 2 } \sum _ { i = 1 } ^ { P Q } \| { \bf y } _ { i } - { \bf z } \| _ { 2 } ^ { 2 } } , } \end{array}$$
where u, $\mathbf { v } _ { i }$ and s are the Lagrangian multipliers.
ADMM decomposes the optimization variables into two blocks and adopts the following iterative scheme,
$$\begin{array} { r l } & { \{ \delta ^ { k + 1 } , \mathbf w ^ { k + 1 } , \mathbf y _ { i } ^ { k + 1 } \} = \underset { \delta , \mathbf w , \{ \mathbf y _ { i } \} } { \arg \operatorname* { m i n } } L ( \mathbf z ^ { k } , \delta , \mathbf w , \mathbf y _ { i } , \mathbf u ^ { k } , \mathbf v _ { i } ^ { k } , \mathbf s ^ { k } ) , } \\ & { } \\ & { \mathbf z ^ { k + 1 } = \underset { \mathbf z } { \arg \operatorname* { m i n } } L ( \mathbf z , \delta ^ { k + 1 } , \mathbf w ^ { k + 1 } , \mathbf y _ { i } ^ { k + 1 } , \mathbf u ^ { k } , \mathbf v _ { i } ^ { k } , \mathbf s ^ { k } ) , } \\ & { \left\{ \begin{array} { l l } { \mathbf u ^ { k + 1 } = \mathbf u ^ { k } + \rho ( \delta ^ { k + 1 } - \mathbf z ^ { k + 1 } ) , } \\ { \mathbf v _ { i } ^ { k + 1 } = \mathbf v _ { i } ^ { k } + \rho ( \mathbf y _ { i } ^ { k + 1 } - \mathbf z ^ { k + 1 } ) , \mathrm { ~ f o r ~ } i \in [ P Q ] , } \\ { \mathbf s ^ { k + 1 } = \mathbf s ^ { k } + \rho ( \mathbf w ^ { k + 1 } - \mathbf z ^ { k + 1 } ) , } \end{array} \right. } \end{array}$$
where $k$ is the iteration index. Problem (35) can be split into three subproblems as shown below,
$$\operatorname* { m i n i m i z e } _ { \delta } \gamma D ( \pmb { \delta } ) + \frac { \rho } { 2 } \| \pmb { \delta } - \mathbf { a } \| _ { 2 } ^ { 2 } ,$$
$$\operatorname* { m i n i m i z e } _ { \mathbf { w } } ~ h ( \mathbf { w } ) + \frac { \rho } { 2 } \| \mathbf { w } - \mathbf { b } \| _ { 2 } ^ { 2 } ,$$
$$\operatorname* { m i n i m i z e } _ { \mathbf { y } _ { i } } { \tau } | | \mathbf { y } _ { i , \mathcal { D } _ { i } } | | _ { 2 } + \frac { \rho } { 2 } | | \mathbf { y } _ { i } - \mathbf { c } _ { i } | | _ { 2 } ^ { 2 } , \mathrm { f o r } i \in [ P Q ] .$$
where $\mathbf { a } = \mathbf { z } ^ { k } - \mathbf { u } ^ { k } / \rho$ , $\mathbf { b } = \mathbf { z } ^ { k } - \mathbf { s } ^ { k } / \rho$ and $\mathbf { c } _ { i } = \mathbf { z } ^ { k } - \mathbf { v } _ { i } ^ { k } / \rho$ . Each problem has a closed form solution. Note that the solutions to problem (38) and problem (39) are given (28) and (31).
$\mathbf { y } _ { i }$ -step Problem (40) can be rewritten as
$$\displaystyle \operatorname* { m i n i m i z e } _ { \mathbf { y } _ { i } } \ : \tau \| \mathbf { y } _ { i , \mathcal { D } _ { i } } \| _ { 2 } + \frac { \rho } { 2 } \| \mathbf { y } _ { i , \mathcal { D } _ { i } } - [ \mathbf { c } _ { i } ] _ { \mathcal { D } _ { i } } \| _ { 2 } ^ { 2 } + \frac { \rho } { 2 } \| \mathbf { y } _ { i , [ n ] / \mathcal { D } _ { i } } - [ \mathbf { c } _ { i } ] _ { [ n ] / \mathcal { D } _ { i } } \| _ { 2 } ^ { 2 } , \mathrm { ~ f o r ~ } i \in [ P Q ] ,$$
which can be decomposed into
$$\begin{array} { r l } & { \underset { { \bf y } _ { i , \mathcal { D } _ { i } } } { \mathrm { m i n i m i z e ~ } } \tau \| { \bf y } _ { i , \mathcal { D } _ { i } } \| _ { 2 } + \frac { \rho } { 2 } \| { \bf y } _ { i , \mathcal { D } _ { i } } - [ { \bf c } _ { i } ] _ { \mathcal { D } _ { i } } \| _ { 2 } ^ { 2 } , \mathrm { ~ f o r ~ } i \in [ P Q ] , } \end{array}$$
and
$$\mathop { \operatorname* { m i n i m i z e } } _ { \mathbf { y } _ { i , [ n ] / \mathcal { D } _ { i } } } ~ \| \mathbf { y } _ { i , [ n ] / \mathcal { D } _ { i } } - [ \mathbf { c } _ { i } ] _ { [ n ] / \mathcal { D } _ { i } } \| _ { 2 } ^ { 2 } , \mathrm { f o r } i \in [ P Q ] .$$
The solution to problem (42) can be obtained through the block soft thresholding operator (Parikh et al., 2014),
$$\big [ \mathbf { y } _ { i } ^ { k + 1 } \big ] _ { \mathcal { D } _ { i } } = \left( 1 - \frac { \tau } { \rho \| \big [ \mathbf { c } _ { i } \big ] _ { \mathcal { D } _ { i } } \| _ { 2 } } \right) _ { + } [ \mathbf { c } _ { i } ] _ { \mathcal { D } _ { i } } , \mathrm { f o r } i \in [ P Q ] ,$$
The solution to problem (43) is given by,
$$\begin{array} { r } { \left[ \mathbf { y } _ { i } ^ { k + 1 } \right] _ { [ n ] / \mathcal { D } _ { i } } = [ \mathbf { c } _ { i } ] _ { [ n ] / \mathcal { D } _ { i } } , \mathrm { f o r } i \in [ P Q ] . } \end{array}$$
z-step Problem (36) can be simplified to
$$\operatorname* { m i n i m i z e } _ { \mathbf { z } } \quad f ( \mathbf { x } _ { 0 } + \mathbf { z } ) + \frac { \rho } { 2 } \| \mathbf { z } - \mathbf { a } ^ { \prime } \| _ { 2 } ^ { 2 } + \frac { \rho } { 2 } \| \mathbf { z } - \mathbf { b } ^ { \prime } \| _ { 2 } ^ { 2 } + \frac { \rho } { 2 } \sum _ { i = 1 } ^ { P Q } \| \mathbf { z } - \mathbf { c } _ { i } ^ { \prime } \| _ { 2 } ^ { 2 } ,$$
where $\mathbf { a } ^ { \prime } : = \delta ^ { k + 1 } + \mathbf { u } ^ { k } / \rho$ , $\mathbf b ^ { \prime } : = \mathbf w ^ { k + 1 } + \mathbf s ^ { k } / \rho$ , and $\mathbf c _ { i } ^ { \prime } : = \mathbf y _ { i } ^ { k + 1 } + \mathbf v _ { i } ^ { k } / \rho$ . We solve problem (46) using the linearization technique (Suzuki, 2013; Liu et al., 2018; Boyd et al., 2011). More specifically, the function $f$ is replaced with its first-order Taylor expansion at the point $\mathbf { z } ^ { k }$ by adding a Bregman divergence term $( \eta _ { k } \mathbf { \dot { / } } 2 ) \lVert \mathbf { z } - \mathbf { z } ^ { k } \rVert _ { 2 } ^ { 2 }$ . As a result, problem (46) becomes
$$\begin{array} { r l } { \underset { \mathbf { z } } { \mathrm { m i n i m i z e } } } & { ( \nabla f ( \mathbf { z } ^ { k } + \mathbf { x } _ { 0 } ) ) ^ { T } ( \mathbf { z } - \mathbf { z } ^ { k } ) + \displaystyle \frac { \eta _ { k } } { 2 } \| \mathbf { z } - \mathbf { z } ^ { k } \| _ { 2 } ^ { 2 } + \displaystyle \frac { \rho } { 2 } \| \mathbf { z } - \mathbf { a } ^ { \prime } \| _ { 2 } ^ { 2 } } \\ & { + \displaystyle \frac { \rho } { 2 } \| \mathbf { z } - \mathbf { b } ^ { \prime } \| _ { 2 } ^ { 2 } + \displaystyle \frac { \rho } { 2 } \sum _ { i = 1 } ^ { P Q } \| \mathbf { z } - \mathbf { c } _ { i } ^ { \prime } \| _ { 2 } ^ { 2 } , } \end{array}$$
whose solution is given by
$$\mathbf { z } ^ { k + 1 } = \frac { \eta _ { k } \mathbf { z } ^ { k } + \rho \mathbf { a } ^ { \prime } + \rho \mathbf { b } ^ { \prime } + \rho \sum _ { i = 1 } ^ { P Q } \mathbf { c } _ { i } ^ { \prime } - \nabla f ( \mathbf { z } ^ { k } + \mathbf { x } _ { 0 } ) } { \eta _ { k } + ( 2 + P Q ) \rho } .$$
# D PROOF OF PROPOSITION 3
We start by converting problem (20) into the ADMM form
$$\begin{array} { r l } { \underset { \delta , \mathbf { z } } { \mathrm { m i n i m i z e } } } & { \ f ( \mathbf { x } _ { 0 } + \mathbf { z } ) + g ( \mathbf { z } ) + \gamma D ( \delta ) + h ( \delta ) + g ( \delta ) } \\ { \mathrm { s u b j e c t \ t o } } & { \ \delta = \mathbf { z } , } \end{array}$$
where $\mathbf { z }$ and $\delta$ are optimization variables, $g ( \delta )$ is an indicator function with respect to the constraint $\{ \delta _ { i } = 0$ , if $i \in \mathcal { S } _ { \sigma } \bar \}$ , and $h ( \delta )$ is the other indicator function with respect to the other constraints $( \mathbf { x } _ { 0 } + \pmb { \delta } ) \in [ 0 , 1 ] ^ { n }$ , $\| \pmb { \delta } \| _ { \infty } \le \epsilon$ .
The augmented Lagrangian of problem (20) is given by
$$L ( \boldsymbol { \delta } , \mathbf { z } , \mathbf { u } ) = f ( \mathbf { z } + \mathbf { x } _ { 0 } ) + g ( \mathbf { z } ) + \gamma D ( \boldsymbol { \delta } ) + h ( \boldsymbol { \delta } ) + g ( \boldsymbol { \delta } ) + \mathbf { u } ^ { T } ( \boldsymbol { \delta } - \mathbf { z } ) + \frac { \rho } { 2 } \| \boldsymbol { \delta } - \mathbf { z } \| _ { 2 } ^ { 2 } ,$$
where $\mathbf { u }$ is the Lagrangian multiplier.
ADMM yields the following alternating steps
$$\begin{array} { r l } & { \delta ^ { k + 1 } = \underset { \delta } { \arg \operatorname* { m i n } } L ( \delta , \mathbf { z } ^ { k } , \mathbf { u } ^ { k } ) } \\ & { \mathbf { z } ^ { k + 1 } = \underset { \mathbf { z } } { \arg \operatorname* { m i n } } L ( \delta ^ { k + 1 } , \mathbf { z } , \mathbf { u } ^ { k } ) } \\ & { \mathbf { u } ^ { k + 1 } = \mathbf { u } ^ { k } + \rho ( \delta ^ { k + 1 } - \mathbf { z } ^ { k + 1 } ) . } \end{array}$$
$\delta$ -step Suppose $D ( \delta ) = \| \delta \| _ { 2 } ^ { 2 }$ , problem (51) becomes
$$\begin{array} { r l } { \underset { \delta } { \mathrm { m i n i m i z e } } } & { \gamma \| \pmb { \delta } \| _ { 2 } ^ { 2 } + \frac { \rho } { 2 } \| \pmb { \delta } - \mathbf { a } \| _ { 2 } ^ { 2 } } \\ { \mathrm { s u b j e c t ~ t o } } & { ( \mathbf { x } _ { 0 } + \pmb { \delta } ) \in [ 0 , 1 ] ^ { n } , \| \pmb { \delta } \| _ { \infty } \leq \epsilon } \\ & { \delta _ { i } = 0 , \mathrm { i f ~ } i \in \mathcal { S } _ { \sigma } , } \end{array}$$
where $\mathbf { a } : = \mathbf { z } ^ { k } - \mathbf { u } ^ { k } / \rho$ . Problem (54) can be decomposed elementwise
$$\begin{array} { r l } { \underset { \delta _ { i } } { \mathrm { m i n i m i z e } } } & { \frac { 2 \gamma + \rho } { \rho } \delta _ { i } ^ { 2 } - 2 a _ { i } \delta _ { i } + a _ { i } ^ { 2 } = \frac { 2 \gamma + \rho } { \rho } \left( \delta _ { i } - \frac { \rho } { 2 \gamma + \rho } a _ { i } \right) ^ { 2 } } \\ { \mathrm { s u b j e c t \ t o } } & { \left( [ \mathbf { x } _ { 0 } ] _ { i } + \delta _ { i } \right) \in [ 0 , 1 ] , ~ | \delta _ { i } | \leq \epsilon } \\ & { \delta _ { i } = 0 , ~ \mathrm { i f } ~ i \in \mathcal { S } _ { \sigma } . } \end{array}$$
The solution to problem (55) is then given by
$$[ \delta ^ { k + 1 } ] _ { i } = \left\{ \begin{array} { l l } { 0 } & { i \in { \mathcal { S } } _ { \sigma } } \\ { \operatorname* { m i n } \{ 1 - [ { \mathbf { x } } _ { 0 } ] _ { i } , \epsilon \} } & { \frac { \rho } { 2 \gamma + \rho } a _ { i } > \operatorname* { m i n } \{ 1 - [ { \mathbf { x } } _ { 0 } ] _ { i } , \epsilon \} , i \notin { \mathcal { S } } _ { \sigma } } \\ { \operatorname* { m a x } \{ - [ { \mathbf { x } } _ { 0 } ] _ { i } , - \epsilon \} } & { \frac { \rho } { 2 \gamma + \rho } a _ { i } < \operatorname* { m a x } \{ - [ { \mathbf { x } } _ { 0 } ] _ { i } , - \epsilon \} , i \notin { \mathcal { S } } _ { \sigma } } \\ { \frac { \rho } { 2 \gamma + \rho } a _ { i } } & { \mathrm { o t h e r w i s e } . } \end{array} \right.$$
$\mathbf { z }$ -step Problem (52) yields
$$\begin{array} { r l } { \underset { \mathbf { z } } { \mathrm { m i n i m i z e } } } & { { } f ( \mathbf { x } _ { 0 } + \mathbf { z } ) + \displaystyle \frac { \rho } { 2 } \| \mathbf { z } - \mathbf { a } ^ { \prime } \| _ { 2 } ^ { 2 } } \\ { \mathrm { s u b j e c t ~ t o } } & { { } z _ { i } = 0 , \mathrm { ~ i f ~ } i \in \mathcal { S } _ { \sigma } , } \end{array}$$
where $\mathbf { a } ^ { \prime } = \delta ^ { k + 1 } + \mathbf { u } ^ { k } / \rho$ . We solve problem (57) using the linearization technique (Suzuki, 2013; Liu et al., 2018; Boyd et al., 2011),
$$\begin{array} { l l } { \mathrm { m i n i m i z e } } & { ( \nabla f ( \mathbf { x } _ { 0 } + \mathbf { z } ^ { k } ) ) ^ { T } ( \mathbf { z } - \mathbf { z } ^ { k } ) + \displaystyle \frac { \eta _ { k } } { 2 } \| \mathbf { z } - \mathbf { z } ^ { k } \| _ { 2 } ^ { 2 } + \displaystyle \frac { \rho } { 2 } \| \mathbf { z } - \mathbf { a } ^ { \prime } \| _ { 2 } ^ { 2 } } \\ { \mathrm { s u b j e c t ~ t o } } & { z _ { i } = 0 , \mathrm { ~ i f ~ } i \in \mathcal { S } _ { \sigma } , } \end{array}$$
where $\eta _ { k }$ is a decaying parameter associated with the Bregman divergence term $\| \mathbf { z } - \mathbf { z } ^ { k } \| _ { 2 } ^ { 2 }$ . In problems (57) and (58), only variables $\left\{ z _ { i } \right\}$ satisfying $i \notin S _ { \sigma }$ are unknown. The solution to problem (58) is then given by
$$\begin{array} { r } { [ \mathbf { z } ^ { k + 1 } ] _ { i } = \left\{ \begin{array} { l l } { 0 } & { i \in \mathcal { S } _ { \sigma } } \\ { \frac { \eta _ { k } [ \mathbf { z } ^ { k } ] _ { i } + \rho [ \mathbf { a } ^ { \prime } ] _ { i } - [ \nabla f ( \mathbf { z } ^ { k } + \mathbf { x } _ { 0 } ) ] _ { i } } { \eta _ { k } + \rho } } & { i \notin \mathcal { S } _ { \sigma } . } \end{array} \right. } \end{array}$$
# E ADVERSARIAL SALIENCY MAP (ASM) AND CLASS ACTIVATION MAPPING (CAM)
$\mathrm { A S M } ( \mathbf { x } , t ) \in \mathbb { R } ^ { d }$ is defined by the forward derivative of a neural network given the input sample $\mathbf { x }$ and the target label $t$ (Papernot et al., 2016b)
$$\begin{array} { r } { \mathrm { A S M } ( \mathbf { x } , t ) [ i ] = \left\{ \begin{array} { l l } { 0 } & { \mathrm { i f } \frac { \partial Z ( \mathbf { x } ) _ { t } } { \partial \mathbf { x } _ { i } } < 0 \mathrm { o r } \sum _ { j \neq t } \frac { \partial Z ( \mathbf { x } ) _ { j } } { \partial \mathbf { x } _ { i } } > 0 } \\ { \left( \frac { \partial Z ( \mathbf { x } ) _ { t } } { \partial \mathbf { x } _ { i } } \right) \left| \sum _ { j \neq t } \frac { \partial Z ( \mathbf { x } ) _ { j } } { \partial \mathbf { x } _ { i } } \right| } & { \mathrm { o t h e r w i s e } , } \end{array} \right. } \end{array}$$
where $Z ( \mathbf { x } ) _ { j }$ is the $j$ th element of logits $Z ( \mathbf { x } )$ , representing the output before the last softmax layer in DNNs. If there exist many classes in a dataset (e.g., 1000 classes in ImageNet), then computing $\textstyle \sum _ { j \neq t } { \frac { \partial Z ( \mathbf { x } ) _ { j } } { \partial \mathbf { x } _ { i } } }$ t ∂Z(x)j∂x is intensive. To circumvent the scalability issue of ASM, we focus on the logit change with respect to the true label $t _ { 0 }$ and the target label $t$ only. More specifically, we consider three quantities, $\begin{array} { r } { \frac { \partial Z ( \mathbf { x } ) _ { t } } { \partial \mathbf { x } _ { i } } , - \frac { \partial Z ( \mathbf { x } ) _ { 0 } } { \partial \mathbf { x } _ { i } } } \end{array}$ , and $\begin{array} { r } { \left( \frac { \partial Z ( \mathbf { x } ) _ { t } } { \partial \mathbf { x } _ { i } } \right) \left| \sum _ { j \neq t } \frac { \partial Z ( \mathbf { x } ) _ { j } } { \partial \mathbf { x } _ { i } } \right| , } \end{array}$ , which correspond to a) promotion of the score of the target label $t$ , b) suppression of the classification score of the true label $t _ { 0 }$ , and c) a dual role on suppression and promotion. As a result, we modify (60) as
$$\begin{array} { r } { \mathrm { A S M } ( \mathbf { x } , t ) [ i ] = \left\{ \begin{array} { l l } { 0 } & { \mathrm { ~ i f ~ } \frac { \partial Z ( \mathbf { x } ) _ { t } } { \partial \mathbf { x } _ { i } } < 0 \mathrm { ~ o r ~ } \frac { \partial Z ( \mathbf { x } ) _ { t _ { 0 } } } { \partial \mathbf { x } _ { i } } > 0 } \\ { \left( \frac { \partial Z ( \mathbf { x } ) _ { t } } { \partial \mathbf { x } _ { i } } \right) \left| \frac { \partial Z ( \mathbf { x } ) _ { t _ { 0 } } } { \partial \mathbf { x } _ { i } } \right| } & { \mathrm { ~ o t h e r w i s e } . } \end{array} \right. } \end{array}$$
CAM allows us to visualize the perturbation of adversaries on predicted class scores given any pair of image and object label, and highlights the discriminative object regions detected by CNNs (Zhou et al., 2016). In Fig. A2, we show ASM and the discriminative regions identified by CAM on several ImageNet samples.
 Figure A2: (a) Overlay ASM and $\mathbf { B } _ { \mathrm { A S M } } \circ \delta$ on top of image with the true and the target label. From left to right: original image, ASM (darker color represents larger value of ASM score), $\mathbf { B } _ { \mathrm { A S M } } \circ \delta$ under our attack, and $\mathbf { B } _ { \mathrm { A S M } } \circ \pmb { \delta }$ under C&W attack. Here $\nu$ in $\mathbf { B } _ { \mathrm { A S M } }$ is set by the 90th percentile of ASM scores. (b) From left to right: original image, CAM of original label, and perturbations with target label generated from the StrAttack and C&W attack, respectively.
# F EXPERIMENT SETUP AND PARAMETER SETTING
In this work, we consider targeted adversarial attacks since they are believed stronger than untargeted attacks. For targeted attacks, we have different methods to choose the target labels. The average case selects the target label randomly among all the labels that are not the correct label. The best case performs attacks using all incorrect labels, and report the target label that is the least difficult to attack. The worst case performs attacks using all incorrect labels, and report the target label which is the most difficult to attack.
In our experiments, two networks are trained for MNIST and CIFAR-10, respectively, and a pretrained network is utilized for ImageNet. The model architectures for MNIST and CIFAR-10 are the same, both with four convolutional layers, two max pooling layers, two fully connected layers and a softmax layer. It can achieve $9 9 . 5 \%$ and $80 \%$ accuracy on MNIST and CIFAR-10, respectively. For ImageNet, a pre-trained Inception v3 network (Szegedy et al., 2016) is applied which can achieve $96 \%$ top-5 accuracy. All experiments are conducted on machines with NVIDIA GTX 1080 TI GPUs.
The implementations of FGM and IFGM are based on the CleverHans package (Papernot et al., 2016a). The key distortion parameter $\epsilon$ is determined by a fine-grained grid search. For IFGM, we perform 10 FGM iterations and the distortion parameter $\epsilon ^ { \prime }$ is set to $\epsilon / 1 0$ for effectiveness as shown in Tramèr et al. (2018). The implementation of the C&W attack is based on the opensource code provided by Carlini & Wagner (2017). The maximum iteration number is set to 1000 and it has 9 binary search steps.
In the StrAttack, the group size for MNIST and CIFAR-10 is $2 \times 2$ and its stride is set to 2 if the non-overlapping mask is used, otherwise the group size is $3 \times 3$ and stride is 2. The group size for ImageNet is $1 3 \times 1 3$ and its stride is set to 13. In ADMM, the parameter $\rho$ achieves a trade-off between the convergence rate and the convergence value. A larger $\rho$ could make ADMM converging faster but usually leads to perturbations with larger $\ell _ { p }$ distortion values. A proper configuration of the parameters is suggested as follows: We set the penalty parameter $\rho = 1$ , decaying parameter in (14) $\eta _ { 1 } = 5$ , $\tau = 2$ and $\gamma = 1$ . Moreover, we set $c$ defined in (3) to 0.5 for MNIST, 0.25 for CIFAR-10, and 2.5 for ImageNet. Refined attack technique proposed in Sec. 4.2 is applied for all experiments, we set $\sigma$ is equal to $3 \%$ quantile value of non-zero perturbation in $\delta ^ { * }$ . We observe that $73 \%$ of $\delta ^ { * }$ can be retrained to a $\sigma$ -sparse perturbation successfully which proof the effective of our refined attack step.
# G SUPPLEMENTARY EXPERIMENTAL RESULTS
 Figure A3: C&W attack vs StrAttack on MNIST with grid size $2 \times 2$ .
Some random choice samples from MNIST (Fig. A3), CIFAR-10 (Fig. A4) and ImageNet (Fig. A5) compare StrAttack with C&W attack. For better sparse visual effect, we only show non-overlapping mask function results here. From these samples, we can discover a consistent phenomenon that our StrAttack is more interested in some particular regions, they usually appear on the objects or their edges in original images, distinctly seen in MNIST (Fig. A3) and ImageNet (Fig. A5).
# H STRATTACK AGAINST DEFENSIVE DISTILLATION AND ADVERSARIALTRAINING
In this section, we present the performance of the StrAttack against defensive distillation (Papernot et al., 2016c) and adversarial training (Tramèr et al., 2018). In defensive distillation, we evaluate the
 Figure A4: C&W attack vs StrAttack on CIFAR-10 with grid size $2 \times 2$ .
StrAttack for different temperature parameters on MNIST and CIFAR-10. We generate 9000 adversarial examples with 1000 randomly selected images from MNIST and CIFAR-10, respectively. The attack success rates of the StrAttack for different temperatures $T$ are all $100 \%$ . The reason is that distillation at temperature $T$ makes the logits approximately $T$ times larger but does not change the relative values of logits. The StrAttack which works on the relative values of logits does not fail.
We further use the StrAttack to break DNNs training on adversarial examples (Tramèr et al., 2018) with their correct labels on MNIST. The StrAttack is performed on three neural networks: the first network is unprotected, the second is obtained by retraining with $9 0 0 0 \mathrm { C } \& \mathrm { { W } }$ adversarial examples, and the third network is retained with 9000 adversarial examples crafted by the StrAttack. The success rate and distortions on the three networks are shown in Table A1. The StrAttack can break all three networks with $100 \%$ success rate. However, adversarial training shows certain defense effects as an increase on the $\ell _ { 1 }$ or $\ell _ { 2 }$ distortion on the latter two networks over the unprotected network is observed.
Table A1: StrAttack against adversarial training on MNIST
<table><tr><td rowspan="2">Adversarial training</td><td colspan="3">Best case</td><td colspan="3">Averagecase</td><td colspan="3">Worst case</td></tr><tr><td>ASR</td><td>l1</td><td>l2</td><td>ASR</td><td>l1</td><td>l2</td><td>ASR</td><td>l1</td><td>l2</td></tr><tr><td>None</td><td>100</td><td>10.9</td><td>1.51</td><td>100</td><td>18.05</td><td>2.16</td><td>100</td><td>26.9</td><td>2.81</td></tr><tr><td>C&W</td><td>100</td><td>16.1</td><td>1.87</td><td>100</td><td>25.1</td><td>2.58</td><td>100</td><td>34.2</td><td>3.26</td></tr><tr><td>structured</td><td>100</td><td>15.6</td><td>1.86</td><td>100</td><td>25.1</td><td>2.61</td><td>100</td><td>34.6</td><td>3.31</td></tr></table>
 Figure A5: C&W attack vs StrAttack on ImageNet with grid size $1 3 \times 1 3$ .123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368# CONDITIONAL GENERATION OF MOLECULES FROM DISENTANGLED REPRESENTATIONS
Anonymous authors Paper under double-blind review
# ABSTRACT
Though machine learning approaches have shown great success in estimating properties of small molecules, the inverse problem of generating molecules with desired properties remains challenging. This difficulty is in part because the set of molecules which have a given property is structurally very diverse. Treating this inverse problem as a conditional distribution estimation task, we draw upon work in learning disentangled representations to learn a conditional distribution over molecules given a desired property, where the molecular structure is encoded in a continuous latent random variable. By including property information as an input factor independent from the structure representation, one can perform conditional molecule generation via a “style transfer” process, in which we explicitly set the property to a desired value at generation time. In contrast to existing approaches, we disentangle the latent factors from the property factors using a regularization term which constrains the generated molecules to have the property provided to the generation network, no matter how the latent factor changes.
# 1 INTRODUCTION
Conditional molecule generation is far from being solved. The main challenge is the enormous and discrete nature of the molecules space and the fact that molecule properties are highly sensitive to molecular structure (Kirkpatrick & Ellis, 2004). Approaches to conditional generation are typically two-step, either using a model or genetic algorithm to generate candidates which are later filtered, or learning a continuous embedding of the discrete molecules and optimizing in a real-valued representation space. The former is computationally expensive, the latter performs conditional generation only very obliquely.
We propose a conditional generative model that produces candidate molecules which targeting a desired property in a single step. This approach builds on work in structured deep generative models (Kingma et al., 2014; Siddharth et al., 2017), which aim to learn a disentangled representation that factors into observed properties we want to control for, and latent factors that account for the remaining features which are either hard to annotate or irrelevant to the properties we wish to optimize.
We derive a regularizer for supervised variational autoencoders which exploits property information that we provide as supervision, ensuring that produced molecules adhere to target properties they are conditioned on. We demonstrate the ability of our model to perform accurate conditional molecule generation and a sort of “style transfer” on molecules, where a latent representation for a single molecule can have its target properties perturbed independently of its learnt structural characteristics, allowing direct and efficient generation of candidates for local optimization of molecules.
# 2 BACKGROUND
Molecule discovery tasks come in two flavors. Global optimization seeks to find molecules that have a particular target property. Local optimization starts from some initial molecule and searches for molecules which have a desired property while not straying too far from the prototype. There is some overlap in methods used in the two approaches.
# 2.1 DEEP GENERATIVE MODELS FOR MOLECULES
Virtual screening methods start from a large database of possible molecules and retain the promising ones (Eckert & Bajorath, 2007), as measured by some quality function $f ( \cdot )$ . Machine learning approaches expand on this by dynamically generating additional candidate molecules; Segler et al. (2017) uses a stacked LSTM to produce large numbers of novel molecules which have similar characteristics to an existing database.
For properties which are expensive to evaluate, generating large sets of candidate molecules is not particularly useful. More sample-efficient global search can be achieved using Bayesian optimization methods, which use a generative model with a latent space that functions as a continuous representation of molecules (Gomez-Bombarelli et al., 2016; Kusner et al., 2017). Optimization is then ´ carried out over this continuous representation space to find candidates which are expected to have the desired property. Local gradient-based search can also be applied on continuous latent spaces to optimize the latent representation with respect to a target property (Jin et al., 2018; Liu et al., 2018).
A challenge for these latent variable models is to reliably produce valid molecules. Character variational autoencoders (CVAEs) (Gomez-Bombarelli et al., 2016) generate molecules one character ´ at a time, and are prone to syntactic and semantic errors; the grammar-based variational autoencoder (GVAE) (Kusner et al., 2017) and syntax-directed variational autoencoder (SD-VAE) (Dai et al., 2018) instead operate in the space of context-free and attribute grammars, respectively, to ensure syntactic validity. Other work generative models that operates on graph representations (Simonovsky & Komodakis, 2018; De Cao & Kipf, 2018; Jin et al., 2018; You et al., 2018; Liu et al., 2018), largely improving the ability to generate valid molecules.
Suppose we are given a training set of pairs $\mathcal { D } = \{ ( \mathbf { x } _ { i } , \mathbf { y } _ { i } ) \} , i = 1 , \ldots , N .$ , where x corresponds to molecules and y represents a value of some properties of the molecule $\mathbf { x }$ . Assume the molecules represent an i.i.d. sample from some unknown distribution $\tilde { p } ( { \bf x } )$ , which assigns high probability to molecules believed to be useful for a given task. Aside from Segler et al. (2017), which has no latent space and thus directly trains via maximum likelihood, these latent variable models are trained by optimizing a standard ELBO objective for variational autoencoders (?). This entails learning a stochastic encoder $q _ { \phi } ( { \bf z } | { \bf x } )$ which maps molecules into a latent space, and a stochastic decoder $p _ { \boldsymbol { \theta } } ( \mathbf { x } | \mathbf { z } )$ for reconstructing molecules, by maximizing
$$\mathcal { L } ( \boldsymbol { \theta } , \boldsymbol { \phi } ) = \sum _ { i = 1 } ^ { N } \bigg \{ \mathbb { E } _ { q _ { \boldsymbol { \phi } } ( \mathbf { z } _ { i } | \mathbf { x } _ { i } ) } [ \log p _ { \boldsymbol { \theta } } ( \mathbf { x } _ { i } | \mathbf { z } _ { i } ) ] - D _ { K L } ( q _ { \boldsymbol { \phi } } ( \mathbf { z } _ { i } | \mathbf { x } _ { i } ) | | p ( \mathbf { z } _ { i } ) ) \bigg \} .$$
Notably, the objective is not a function of y: most existing generative models with latent variables do not perform direct conditional generation, and approaches for targeted molecule discovery are bolted on to the learnt model. Some, e.g. Kusner et al. (2017), are trained in an “unsupervised” manner, agnostic to any property which later may need to be optimized. Others, e.g. Gomez-Bombarelli ´ et al. (2016); Liu et al. (2018), train the autoencoder jointly alongside a function to predict y from z, hoping to guide the latent space to be also good for predicting the desired property. A recent exception is Assouel et al. (2018), which learns a deterministic autoencoder where the decoder takes the latent code and the desired property as input, using a mutual information term in training to steer the model towards generating molecules whose target properties match the input. Guimaraes et al. (2017); De Cao & Kipf (2018); You et al. (2018) instead learn generation models optimized towards specific metrics, such as drug-likeliness and solubility; the major downside is that these models must be retrained each time for a new property. In contrast, the autoencoder-based methods can be re-used to optimize towards any particular value of the property.
# 2.2 STYLE TRANSFER WITH SUPERVISED VAES
While the latent representations learned through standard VAE models perform well on the task of molecule reconstruction they do not necessarily provide interpretable factorised representations. A disentangled representation gives us additional control on the molecule generation process, allowing us to modify a single property leaving the remaining unaffected (Bengio et al., 2013a). In many cases important variation in the data is easy to annotate. For example in the case of molecule datasets we have access to different functional descriptors of the molecules obtained by chemoinformatics software such as RDKit (Landrum). Particularly useful to us here are supervised methods for learning disentangled representations (Kingma et al., 2014; Siddharth et al., 2017). These are distinct from unsupervised disentangling approaches such as InfoGAN (Chen et al., 2016) or $\beta$ -VAE (Higgins et al., 2017), which encourages the latent factor to learn a disentangled representation by modifying the objective to promote component independence.
We will learn representations that specifically disentangle molecular properties of interest which we may later want to modify. Kingma et al. (2014) demonstrates how disentangling can be used to take two MNIST images of different digits, written in different styles, and independently change the digit while holding the style constant. An analogous operation on molecules would involve holding the physical structure of a molecule (its “style”) relatively fixed while modifying a salient property. Unlike (say) the style transfer example for the MNIST digits, the conditional distribution of molecules with a particular value of properties might be very diverse; for example, the QED score attempts to measure the drug-likeness of a molecule, and the set of molecules generated at high values of this score would hopefully have high probability on a large, varied set of molecules. An essential challenge here is that the property only provides a very weak signal as to the overall structure of the molecule. To account for this diversity, we model the conditional distribution with a latent variable $\mathbf { z }$ , such that $\begin{array} { r } { p _ { \theta } ( \mathbf { x } | \mathbf { y } ) = \int p _ { \theta } ( \mathbf { x } | \mathbf { z } , \mathbf { y } ) p ( \mathbf { \bar { z } } ) d \mathbf { z } } \end{array}$ .
Disentangling the latent code $\mathbf { z }$ from the property y enables style transfer. This is done by taking an initial $\mathbf { x }$ , computing the posterior over the latent variable $\mathbf { z }$ , and then generating a new $\mathbf { x } ^ { \prime }$ with the property modified to have a target value $\mathbf { y } ^ { \prime }$ , with $p _ { \theta } ( \mathbf { x } ^ { \prime } | \mathbf { y } ^ { \prime } , \mathbf { x } ) =$ $\begin{array} { r } { \int p _ { \theta } ( \mathbf { x } ^ { \prime } | \mathbf { y } ^ { \prime } , \mathbf { z } ) p _ { \theta } ( \mathbf { z } | \mathbf { x } ) d \mathbf { z } } \end{array}$ .
 Figure 1: A demonstration of style transfer
Concretely, this involves fitting a joint generative model of the form $p _ { \boldsymbol { \theta } } ( \mathbf { x } , \mathbf { y } , \mathbf { z } ) = p _ { \boldsymbol { \theta } } ( \mathbf { x } | \mathbf { y } , \mathbf { z } ) p ( \mathbf { y } ) \bar { p ( \mathbf { z } ) }$ , in which $\mathbf { y }$ and $\mathbf { z }$ are independent under the prior, and we assume a unit multivariate normal prior $p ( \mathbf { z } )$ . To infer the latent variable $\mathbf { z }$ we will use a variational distribution $q _ { \phi } ( { \bf z } | { \bf x } )$ , which takes the form of a multivariate normal distribution with parameters a nonlinear function of $\mathbf { x }$ , to approximate the true posterior $p _ { \theta } ( \mathbf { z } | \mathbf { x } , \mathbf { y } )$ . This objective function
$$\mathcal { L } _ { E L B O } ( \theta , \phi ) = \sum _ { i = 1 } ^ { N } \left\{ \mathbb { E } _ { q _ { \phi } ( \mathbf { z } _ { i } | \mathbf { x } _ { i } ) } [ \log p _ { \theta } ( \mathbf { x } _ { i } | \mathbf { y } _ { i } , \mathbf { z } _ { i } ) ] - D _ { K L } ( q _ { \phi } ( \mathbf { z } _ { i } | \mathbf { x } _ { i } ) | | p ( \mathbf { z } _ { i } ) ) \right\}$$
corresponds to learning a supervised VAE (Kingma et al., 2014), and represents a fairly na¨ıve approach to modeling a conditional distribution.
# 3 CONDITIONAL GENERATION BY DISENTANGLING
Maximizing this conditional ELBO in Eq (2) will likely yield good reconstructions of molecules from an embedding $\mathbf { z }$ (alongside the true property y), but for properties which only weakly inform the generative model there is nothing to enforce that the variable $\mathbf { y }$ actually directly has an effect on the generative process. Since the value $\mathbf { y }$ is something we know is a derived property of the molecule $\mathbf { x }$ , it is completely possible for all information about y to also be encoded in the representation $\mathbf { z }$ , in which case there is no guarantee that the learnt likelihood $p _ { \theta } ( \mathbf { x } | \mathbf { y } , \mathbf { z } )$ actually takes into account the value of $\mathbf { y }$ — in fact, we know it is possible to fit variational autoencoders where the decoder simply has the form $p _ { \boldsymbol { \theta } } ( \mathbf { x } | \mathbf { z } )$ — and we are relying on the utility of $\mathbf { y }$ in reconstructions to see any sort of disentangling effect.
# 3.1 CONSTRAINED ELBO
In the case of conditional generation of molecules, we often have access to some oracle function $f$ (possibly non-differentiable) which for any given $\mathbf { x }$ outputs a property estimate $\mathbf { y }$ , for instance, the chemoinformatics software RDKit (Landrum). Since for conditional generation our ultimate goal is to generate a molecule $\mathbf { x }$ for any given target property $\mathbf { y } _ { 0 }$ , which then actually has $f ( \mathbf { x } ) = \bar { \mathbf { y } } _ { 0 }$ , we can reframe the problem by introducing hard constraints on the generated values, i.e. if restricting to values of $\mathbf { y }$ in the training set,
$$\begin{array} { r l } & { \underset { \theta , \phi } { \operatorname* { m a x } } \mathcal { L } _ { E L B O } ( \theta , \phi ) } \\ & { \mathrm { s u b j e c t ~ t o ~ } \mathbb { E } _ { \mathbf { x } \sim p ( \mathbf { x } \mid \mathbf { y } _ { i } ) } [ \mathbb { I } [ f ( \mathbf { x } ) = \mathbf { y } _ { i } ] ] = 1 } \end{array}$$
 Figure 2: Setting and modeling pipeline for conditional generation of molecules, with supervision provided via an external property prediction oracle. Red lines correspond to non-differentiable components, including both a potentially complex sampling process and the property prediction itself. The blue dashed line corresponds to the approximate property predictor, which aims to predict the expected value of the property from a continuous relaxation, marginalized over the sampling process.
for all $i = 1 , \ldots , N$ . This is an unreasonably hard constraint, unlikely to be satisfied by any distribution other than one which simply places a point mass on the single training $\mathbf { x } _ { i }$ associated with $\mathbf { y } _ { i }$ , but we can relax it by considering that (unlike the molecular space $\mathbf { x }$ ) the property space $\mathbf { y }$ is typically smooth, as many properties are continuous-valued and correspond to a human-interpretable scale. Following Ma et al. (2018) and Hu et al. (2017), we reframe the constraint as a soft penalty on the ELBO,
$$\mathcal { L } ( \theta , \phi ) = \mathcal { L } _ { E L B O } ( \theta , \phi ) - \frac { \lambda _ { 1 } } { 2 } \sum _ { i = 1 } ^ { N } \mathbb { E } _ { \hat { \mathbf { x } } \sim p _ { \theta } ( \mathbf { x } | \mathbf { y } _ { i } ) } \Vert f ( \hat { \mathbf { x } } ) - \mathbf { y } _ { i } \Vert ^ { 2 }$$
so that they are consistent with the property prediction, i.e., as we have an oracle function $f$ which enable us to access the property of any generated data, we can explicitly add a soft constraint to our loss function to provide explicit guidance for the generative model such that $f ( \hat { \mathbf x } ) = \mathbf y$ . This constraint is expected to hold for any pair $\displaystyle ( \mathbf { x } , \mathbf { y } )$ we may happen to come across, not just those in the training data. We also show optimizing the relaxed constraint is equivalent to maximizing mutual information with the target $\mathbf { y } _ { i }$ and generated molecule $\hat { \bf x }$ ; for details see appendix Section 6.1.
# 3.2 APPROXIMATING THE PROPERTY PREDICTOR
Introducing the regularizer as in Eq. (3) implicitly guides the reconstruction to take into account the property information, such that the reconstructed data should exhibit properties which match the input properties it is conditioned on. However, existing implementations of $f$ are often non-differentiable or CPU-bound, and $\hat { \bf x }$ are discrete samples from a categorical distribution, all of which means the gradient of the regularizer can’t flow back to the generator. This is outlined in Figure 2. To enable the gradient based methods on GPUs during training and avoid discrete sampling, one approach would be to first fit a differentiable approximation to $f$ , and then use either a Gumbel-softmax relaxation (Jang et al., 2016) or tricks like a “straight-through” estimator (Bengio et al., 2013b) as a continuous approximation for the discrete samples. Instead, we propose bypassing the discrete sampling step entirely and learning a function $f _ { \omega }$ that can map from a learned representation of the molecules directly to molecules property (Hu et al., 2017).
To do this, we take as input the last hidden layer of the decoder network which parameterizes $p _ { \theta } ( \mathbf { x } | \mathbf { z } , \mathbf { y } )$ , denoting this deterministic transformation as $g _ { \boldsymbol { \theta } } ( \mathbf { z } , \mathbf { y } )$ . For the grammar VAE and the syntax-directed VAE, this last layer $\mathbf { h } = g _ { \boldsymbol { \theta } } ( \mathbf { z } , \mathbf { y } )$ is the output of a recurrent layer that generates logits corresponding to unmasked and unnormalized log probabilities for each character at each position in the string; see Kusner et al. (2017) and Dai et al. (2018) for details on the implementation of the somewhat complex sampling process in the decoder. Ideally, $f _ { \omega }$ would estimate the property distribution obtained by marginalizing out the discrete sampling step, with
$$f _ { \omega } ( \mathbf { h } \equiv g _ { \theta } ( \mathbf { z } , \mathbf { y } _ { 0 } ) ) \approx \mathbb { E } _ { p _ { \theta } ( \mathbf { x } | \mathbf { z } , \mathbf { y } _ { 0 } ) } [ f ( \mathbf { x } ) ] ,$$
where we condition on $\mathbf { z }$ , and $\mathbf { y } _ { 0 }$ refers to an arbitrary input target property.
Assuming the approximation in Eq. (4), we have
$$\begin{array} { r } { \mathbb { E } _ { p _ { \theta } ( \hat { \mathbf { x } } | \mathbf { y } _ { i } ) } \| f ( \hat { \mathbf { x } } ) - \mathbf { y } _ { i } \| ^ { 2 } = \mathbb { E } _ { p ( \mathbf { z } ) } \left[ \mathbb { E } _ { p _ { \theta } ( \hat { \mathbf { x } } | \mathbf { y } _ { i } , \mathbf { z } ) } \| f ( \hat { \mathbf { x } } ) - \mathbf { y } _ { i } \| ^ { 2 } \right] \approx \mathbb { E } _ { p ( \mathbf { z } ) } \| f _ { \omega } ( g _ { \theta } ( \mathbf { z } , \mathbf { y } _ { i } ) ) - \mathbf { y } _ { i } \| ^ { 2 } , } \end{array}$$
an expectation over a real-valued variable which does not depend on any of the parameters we are estimating, meaning we can use a simple path estimate of the gradient with respect to $\theta , \omega$ by exchanging the gradient with the expectation. We thus define a regularization term
$$\mathcal { L } _ { d i s e n t } ( \theta , \omega ) = \frac { \lambda _ { 1 } } { 2 } \sum _ { i = 1 } ^ { N } \mathbb { E } _ { p ( \mathbf { z } ) } \| f _ { \omega } \big ( g _ { \theta } ( \mathbf { z } , \mathbf { y } _ { i } ) \big ) - \mathbf { y } _ { i } \| ^ { 2 }$$
which can be used as a drop-in replacement for the non-differentiable penalty term in Eq. (3), yielding a candidate objective function
$$\mathcal { L } ( \theta , \phi ) \approx \hat { \mathcal { L } } _ { \omega } ( \theta , \phi ) = \mathcal { L } _ { E L B O } ( \theta , \phi ) - \mathcal { L } _ { d i s e n t } ( \theta , \omega )$$
3.3 LEARNING THE PROPERTY ESTIMATOR JOINTLY WITH GENERATIVE MODEL
While one could imagine attempting to learn $f _ { \omega }$ jointly with $\phi , \theta$ by direct optimization of Eq. (6), in practice this is very unstable, as values of $g _ { \boldsymbol { \theta } } ( \mathbf { z } , \mathbf { y } _ { i } )$ early in training may correspond to very poor generated molecules $\hat { \mathbf { x } } _ { i }$ which may not have properties at all similar to $\mathbf { y } _ { i }$ . This can be sidestepped by training the property estimator jointly as part of an extended generative model on [x, y].
We note that the property estimator $f _ { \omega }$ parameterizes a probability distribution $p _ { \omega } ( f ( \mathbf { x } ) | \mathbf { z } , \mathbf { y } _ { 0 } )$ , where $\mathbf { x } \sim p _ { \theta } ( \mathbf { x } | \mathbf { z } , \mathbf { y } _ { 0 } )$ and f is the oracle function that $f ( \mathbf { x } ) = \mathbf { y }$ . With a Gaussian distribution over the error, we can consider
$$p _ { \omega } ( f ( \mathbf { x } ) \vert \mathbf { z } , \mathbf { y } _ { 0 } ) = \mathcal { N } ( f ( \mathbf { x } ) \vert f _ { \omega } ( g _ { \theta } ( \mathbf { z } , \mathbf { y } _ { 0 } ) ) , \lambda _ { 2 } ^ { - 1 } \mathbf { I } )$$
for small, fixed $\lambda _ { 2 }$ . Therefore, we propose defining a new ELBO based on a joint autoencoder for $\{ f ( \mathbf { x } _ { i } ) , \mathbf { y } _ { i } ) \}$ , albeit with a factorization such that the input $\mathbf { y } _ { i }$ bypasses the encoder and is passed directly into the decoder, with a joint likelihood
$$p _ { \{ \theta , \omega \} } ( \mathbf { x } _ { i } , f ( \mathbf { x } _ { i } ) | \mathbf { z } _ { i } , \mathbf { y } _ { i } ) = p _ { \omega } ( f ( \mathbf { x } _ { i } ) | \mathbf { z } _ { i } , \mathbf { y } _ { i } ) p _ { \theta } ( \mathbf { x } _ { i } | \mathbf { z } _ { i } , \mathbf { y } _ { i } ) .$$
This yields a joint ELBO for the training set of
$$\mathcal { L } _ { E L B O } ( \omega , \theta , \phi ) = \sum _ { i = 1 } ^ { N } \mathbb { E } _ { q _ { \phi } ( \mathbf { z } | \mathbf { x } _ { i } ) } \left[ \log \frac { p _ { \omega } ( f ( \mathbf { x } _ { i } ) | \mathbf { z } , \mathbf { y } _ { i } ) p _ { \theta } ( \mathbf { x } _ { i } | \mathbf { z } , \mathbf { y } _ { i } ) p ( \mathbf { z } ) } { q _ { \phi } ( \mathbf { z } | \mathbf { x } _ { i } ) } \right] .$$
Note that we can rewrite this ELBO as a function of the previous one, with
$$\mathcal { L } _ { E L B O } ( \boldsymbol { \omega } , \boldsymbol { \theta } , \boldsymbol { \phi } ) = \mathcal { L } _ { E L B O } ( \boldsymbol { \theta } , \boldsymbol { \phi } ) - \frac { \lambda _ { 2 } } { 2 } \sum _ { i = 1 } ^ { N } \mathbb { E } _ { \boldsymbol { q } _ { \boldsymbol { \phi } } ( \mathbf { z } | \mathbf { x } _ { i } ) } \| f _ { \boldsymbol { \omega } } \big ( g _ { \boldsymbol { \theta } } ( \mathbf { z } , \mathbf { y } _ { i } ) \big ) - \mathbf { y } _ { i } \| _ { 2 } ^ { 2 } ,$$
where we also see that $\mathcal { L } _ { E L B O } ( \omega , \theta , \phi ) \leq \mathcal { L } _ { E L B O } ( \theta , \phi )$ , allowing us to define an objective
$$\hat { \mathcal { L } } ( \omega , \theta , \phi ) = \mathcal { L } _ { E L B O } ( \omega , \theta , \phi ) - \mathcal { L } _ { d i s e n t } ( \theta , \omega ) ,$$
which is a lower bound on Eq. (6). Notice the two terms we have added to the original ELBO are quite similar, differing only in choice of distribution: for learning $f _ { \omega }$ , we wish to use values of $\mathbf { z }$ simulated form the approximate posterior $q _ { \phi } ( { \bf z } | { \bf x } )$ , whereas for enforcing a constraint across all possible generations we simulate $\mathbf { z }$ from the prior $p ( \mathbf { z } )$ .
# 3.4 GRADIENT ESTIMATION
As the regularizer $\mathcal { L } _ { d i s e n t } ( \theta , \omega )$ encourages disentangling by constraining the molecules generated from $\mathbf { y } _ { i }$ to have property $\mathbf { y } _ { i }$ no matter what value $\mathbf { z }$ takes, we found that it does not necessarily evaluate at meaningful values of $\mathbf { z }$ when sampled randomly from $p ( \mathbf { z } )$ . This roughly corresponds to the notion that not all combinations of “style” and property are physically attainable; ideally for style transfer we would like the generated molecule to stay “close” in structure to the original molecule that we intended to modify. When estimating (gradients of) the soft constraint term $\mathcal { L } _ { d i s e n t } ( \theta , \omega )$ , we found it advantageous to use samples of $\mathbf { z }$ which correspond to encodings of actual data points, as opposed to random samples from the prior. We approximate expectations with respect to $p ( \mathbf { x } )$ by looking at the so-called marginal posterior; we note that
Table 1: Reconstruction performance and generation quality (Valid, Unique, Novel).
<table><tr><td rowspan="2">Model</td><td colspan="3">QM9</td><td colspan="5">ZINC</td></tr><tr><td>Reconstruction %</td><td>Valid%</td><td>Unique %</td><td>Novel %</td><td>Reconstruction %</td><td>Valid%</td><td>Unique %</td><td>Novel %</td></tr><tr><td>CVAE Gómez-Bombarelli et al. (2016)</td><td>3.61</td><td>10.30</td><td>=</td><td>90.0</td><td>44.6</td><td>0.70</td><td>·</td><td>100</td></tr><tr><td>GVAE Kusner et al. (2017)</td><td>96.00</td><td>60.20</td><td>=</td><td>80.90</td><td>53.70</td><td>7.20</td><td>=</td><td>100</td></tr><tr><td>SD-VAE Dai et al.(2018)</td><td>97.84</td><td>98.40</td><td>99.28</td><td>91.97</td><td>76.20</td><td>43.50</td><td>-</td><td>-</td></tr><tr><td>Sup-VAE-1-GRU</td><td>97.53</td><td>93.66</td><td>91.30</td><td>92.05</td><td>74.12</td><td>32.84</td><td>94.61</td><td>100</td></tr><tr><td>CGD-VAE-1-GRU</td><td>99.27</td><td>95.61</td><td>93.65</td><td>87.87</td><td>88.64</td><td>29.00</td><td>99.24</td><td>100</td></tr><tr><td>Sup-VAE-3-GRU</td><td>97.81</td><td>97.90</td><td>95.09</td><td>89.47</td><td>82.40</td><td>36.16</td><td>86.26</td><td>100</td></tr><tr><td>CGD-VAE-3-GRU</td><td>99.31</td><td>97,80</td><td>98.77</td><td>96.21</td><td>81.80</td><td>37.78</td><td>98.75</td><td>100</td></tr></table>
$$p ( \mathbf { z } ) = \int p _ { \theta } ( \mathbf { z } | \mathbf { x } ) p _ { \theta } ( \mathbf { x } ) d \mathbf { x } \approx \frac { 1 } { N } \sum _ { j } p _ { \theta } ( \mathbf { z } | \mathbf { x } _ { j } ) \approx \frac { 1 } { N } \sum _ { j } q _ { \phi } ( \mathbf { z } | \mathbf { x } _ { j } ) ,$$
where the first approximation uses the empirical data distribution as an approximation to the model marginal $p _ { \theta } ( \mathbf { x } )$ , and the second uses our variational posterior approximation $q _ { \phi } ( { \bf z } | { \bf x } )$ . We define this quantity as $\begin{array} { r } { q ( \mathbf { z } ) = \frac { 1 } { N } \sum _ { j } q _ { \phi } ( \mathbf { z } | \mathbf { x } _ { j } ) } \end{array}$ , a mixture of Gaussians, which we can sample from by drawing random values from our dataset and then drawing from their encoding distributions.
When we use this in estimating gradients of the soft constraint, we can use samples from the same minibatch, exactly corresponding to a property transfer task. That is, for any particular $y _ { i }$ in the dataset, we can estimate
$$\begin{array} { r } { \mathbb { E } _ { p ( \mathbf { z } ) } \nabla _ { \theta , \omega } \| f _ { \omega } \big ( g _ { \theta } ( \mathbf { z } , \mathbf { y } _ { i } ) \big ) - \mathbf { y } _ { i } \| ^ { 2 } \approx \mathbb { E } _ { q ( \mathbf { z } _ { j } | \mathbf { x } _ { j } ) } \nabla _ { \theta , \omega } \| f _ { \omega } \big ( g _ { \theta } ( \mathbf { z } , \mathbf { y } _ { i } ) \big ) - \mathbf { y } _ { i } \| ^ { 2 } . } \end{array}$$
for any uniformly randomly sampled $j \neq i$ . By sampling $\mathbf { z } _ { j }$ from $q ( \mathbf { z } _ { j } | \mathbf { x } _ { j } )$ where $j \neq i$ , we make sure that all the label information decoder is receiving comes from the actual $\mathbf { y } _ { i }$ that is feed to the decoder and $\mathbf { z } _ { j }$ does not include any information about label. This can be evaluated easily by simply evaluating the penalty term of Eq. (10) twice per minibatch; once as in Eq. (10), and once to approximate $\mathcal { L } _ { d i s e n t } ( \theta , \omega )$ by permuting the properties in the minibatch to be assigned to incorrect molecules. We detail the training algorithm in Section 6.2 of the appendix.
# 4 EXPERIMENTS
We experiment with the QM9 dataset (Ramakrishnan et al., 2014), that contains $1 3 4 \mathbf { k }$ molecules with up to 9 heavy atoms, and the ZINC dataset (Sterling & Irwin, 2015) containing $2 5 0 \mathrm { k }$ druglike molecules. Our goal here is two-fold: we would like to understand (1) whether a supervised variational autoencoder is capable of learning suitable conditional distributions over molecules, and (2) to what extent this task is assisted by the additional regularization term corresponding to the soft constraint.
We represent molecules using the one-hot encoding of their SMILES production rules (Kusner et al., 2017) and add a semantic constraint (Dai et al., 2018) on the decoder network to avoid generating syntactically correct but semantically invalid molecules. We use 80 production rules to describe molecules and set the maximum SMILES sequence length to 100 for the QM9 dataset and 278 for the Zinc dataset. We experiment with the logP property of the molecules (Wildman & Crippen, 1999). We use the same encoder and decoder network structure as Dai et al. (2018) with the only difference that our decoder takes as input the concatenation of $\mathbf { y } , \mathbf { z }$ . We give the details of the architecture in the appendix section 6.2.
We evaluate the reconstruction accuracy and the quality of the molecules generated by our method, which we denote by CGD-VAE (conditional generation with disentangling) and compare against CVAE (Gomez-Bombarelli et al., 2016), GVAE (Kusner et al., 2017), and SD-VAE (Dai et al., 2018). ´ We explore its conditional generation performance in two settings: controlling only the property value and controlling both the property value and the molecule structure to what can be seen as property transfer. We took the results of CVAE, GVAE from the literature. For SD-VAE we used the authors code with the default values to generate results for QM9 since these were not available for QM9. We also implemented supervised VAE versions of SD-VAE which we denote Sup-VAE-X-GRU $\mathrm { ( X \in \{ 1 , 3 \} }$ , denotes GRU layers) and which can do conditional generation.
 Figure 3: Conditional generation given the desired $\mathrm { l o g P { = } { - } 0 . 5 7 5 9 }$ , row molecules have a logP within a $15 \%$ range of the desired one.
 Figure 4: Property transfer
Before proceeding with the experiments we will give some additional details on how we do conditional generation from $p _ { \theta } ( \mathbf { x } | \mathbf { y } _ { 0 } )$ given the target property $\mathbf { y } _ { 0 }$ . Instead of marginalizing over the prior marginal inference distribution mass of the dataset is in the late $p ( z )$ , we mirror the approach taken during training and integrate over an approximation to the $\begin{array} { r } { q _ { \phi } ( \mathbf { z } ) = \frac { 1 } { N } \sum _ { i = 1 } ^ { N } q _ { \phi } ( \mathbf { z } | \mathbf { x } _ { i } ) } \end{array}$ which better characterizes where the large and we do not wish to keep the $N$ entire dataset available at test time, we approximate $q _ { \phi } ( \mathbf { z } )$ with an isotropic Gaussian distribution $\hat { q } _ { \sigma } ( \mathbf { z } ) = \mathcal { N } ( \mathbf { z } | \mathbf { 0 } , \sigma ^ { 2 } \mathbf { I } )$ . We estimate $\sigma$ for each model by Monte Carlo samples from $q _ { \phi } ( \mathbf { z } )$ . For the supervised VAE without the soft constraint regularizer this yields 0.053 for QM9 and 0.118 for ZINC. For our model with the soft constraint we get 0.0354 for QM9 and 0.096 for ZINC. We do conditional generation of $\mathbf { x }$ given $\mathbf { y } _ { 0 }$ by sampling from $\begin{array} { r } { p _ { \theta } ( \mathbf { x } | \mathbf { y } _ { 0 } ) = \int \hat { q } _ { \sigma } ( \mathbf { z } ) p _ { \theta } ( \mathbf { x } | \mathbf { z } , \mathbf { y } _ { 0 } ) d \mathbf { z } } \end{array}$ .
We evaluate reconstruction performance in terms of the correctly reconstructed molecules on test sets of size 10k for QM9 and $5 \mathrm { k }$ for ZINC, for the latter we used the default test set. We evaluate the generated molecules’ quality by the percentage of valid, unique (i.e. percentage of unique molecules among the generated valid molecules) and novel (i.e. percentage of molecules never seen in the training set among the generated molecules) molecules. We estimate these quantities by sampling 10k (5K for ZINC) $\mathbf { z }$ from the ${ \hat { q } } _ { \sigma } ( \mathbf { z } )$ and coupling each one of them with a logP value, $\mathbf { y }$ , randomly selected from the test set, and we subsequently decode the $\mathbf { z } , \mathbf { y }$ concatenation. We can see that our model has a better reconstruction performance compared to the baselines while in some cases generating slightly less valid molecules table 1. In terms of the three quality measures achieves an excellent performance across all three metrics being always one of the two best performing methods for any metric.
To visualise how the conditional generation operates we randomly sample from the test set some molecule and obtain its property value $\mathbf { y } _ { 0 }$ . We then draw 50 random samples $\mathbf { z } _ { i }$ from $\hat { q } _ { \sigma } ( \mathbf { z } )$ and decode the $\left[ \mathbf { z } _ { i } , \mathbf { y } _ { 0 } \right]$ vectors. Among the generated valid molecules we compute the percentage of those that have a property value $\mathbf { y } _ { i }$ that is within a $15 \%$ range from the $\mathbf { y } _ { 0 }$ property value. In Figure 3 we present the molecules obtained for a test molecule that had a logP of $- 0 . 5 7 5 9$ . Out of the 50 generated molecules 46 were valid of which we give the five that were within a $15 \%$ range from the $\mathbf { y } _ { 0 }$ value in Figure 3. As we can see we get molecules that are structurally very different from the original one yet they have similar logP value.
To quantify the quality of the conditional generations we measure the correlation between the property value we obtain by the conditional generation and the property value on which we conditioned the generation. We randomly sample $1 0 0 0 { \textbf { y } }$ values from the test set and $1 0 0 0 \textbf { z }$ values from the approximate learned prior $\hat { q } _ { \sigma } ( \mathbf { z } )$ . We decode each pair, obtain $\hat { \mathbf { x } } \sim p _ { \theta } ( \mathbf { x } | \mathbf { y } , \mathbf { z } )$ , and then measure the correlation of the original y with the $\hat { \mathbf { y } }$ of generated $\hat { \bf x }$ . In Table 2, we give the correlation estimates for our method and the Sup-VAE baselines. As we can see our method has a considerably higher correlation score between the input and the obtained property than Sup-VAE. Conditional generation seems considerably harder for the ZINC dataset for all methods.
To visualise the style transfer behavior of our model we randomly sample two molecules $\mathbf { x } _ { A } , \mathbf { x } _ { B }$ from the test set. We then sample $\mathbf { z } _ { A }$ from the learned posterior $q _ { \phi } ( \mathbf { z } | \mathbf { x } _ { A } )$ . We subsequently decode $\left[ \mathbf { z } _ { A } , \mathbf { y } _ { B } \right]$ , $\mathbf { y } _ { B }$ is the property of $\mathbf { x } _ { B }$ , and get a new molecule $\hat { \mathbf { x } } _ { A B }$ . Ideally, the obtained molecule $\hat { \mathbf { x } } _ { A B }$ should have a property value (logP) close to the target $\mathbf { y } _ { B }$ and be similar to $\mathbf { x } _ { A }$ . In Figure 4 we give one such example. To put the results into context in Figure 8 in appendix, we give the results of a virtual screening method, where we select from the full dataset five molecules which are structurally similar to $\mathbf { x } _ { A }$ and have logP values close to $\mathbf { y } _ { B }$ . As we can see the molecule that our model generates is a new one.
 Figure 5: Style transfer. The $\mathbf { z }$ of the nine real molecules placed in the $\mathbf { X }$ -axis is combined with 11 y property values, sampled in [-4.9, 4.9], the resulting pair is decoded to a molecule.
To quantify the style transfer performance we proceed in exactly the same manner as we did to quantify the conditional generation performance. However, now instead of sampling $\mathbf { z }$ from the approximate learned prior, ${ \hat { q } } _ { \sigma } ( \mathbf { z } )$ , we first sample some $\mathbf { x }$ from the test set and then we sample $\mathbf { z }$ from the learned posterior $q ( \mathbf { z } | \mathbf { x } )$ . The results are in the second column of Table 2. As we can see the correlation values are now lower than the ones we obtained in the simple conditional generation case. This can be explained by the fact that now we are forcing a specific combination of structure, z comes from a real molecule, and property, which might simply be physically infeasible since the molecule space is discrete and not all combinations are possible. In addition, as it was the case for the conditional generation, style transfer is considerably more difficult for the ZINC dataset.
We further explore the style transfer and visualize how our model covers the combined space of molecule structure and properties. We sample nine molecules from the QM9 test set, and get their $\mathbf { z }$ encodings. For each such encoding we decode the vectors $[ \mathbf { z } , y ] , y \in [ - 4 . 9 , 4 . 9 ]$ , with the $y$ (logP) interval sampled at 11 points. We give in Figure 5 the resulting valid molecules, each column there corresponds to one of the nine original molecules, the ones surrounded by dotted rectangle, and their decodings with different logP values.For each original molecule we give the generated molecules ordered along the y axis according to the y property that they actually exhibit. The x-axis does not provide an ordering of the original molecules according to $\mathbf { Z }$ , in fact we have ordered the original molecules by their y property. As we can see not all $( \mathbf { z } , y )$ combinations produce a result. These holes can be explained either by the physical infeasibility of the combination and/or a limitation of the learned model.
We can use conditional generation to control in a fine manner the value of the desired property, to what can be seen as direct property optimization. We visualise the level of control we have on an experiment with a single molecule (with logP is -1.137), which we randomly sample from the test set. We obtain its $\mathbf { z }$ encoding and perform generations with increased logP taking values in 1000 point grid in $\left[ - 1 . 1 3 7 , 4 . 9 \right]$ . We then decode $\left[ \mathbf { z } , \mathbf { y } _ { i } \right]$ and compute the logP value of the generated molecules. Among the 1000 generated molecules only 19 are unique. We get an increase of logP of a very discrete nature, Figure 6. As already discussed not all combinations of structure and properties are possible. The generated molecules themselves are shown in the supplemental material.
<table><tr><td>Model</td><td></td><td>z~qo(z)</td><td>z~q(z|x)</td></tr><tr><td rowspan="4">QM9</td><td>Sup-VAE-1-GRU</td><td>0.5420</td><td>0.2526</td></tr><tr><td>CGD-VAE-1-GRU</td><td>0.7185</td><td>0.5005</td></tr><tr><td>Sup-VAE-3-GRU</td><td>0.6958</td><td>0.4204</td></tr><tr><td>CGD-VAE-3-GRU</td><td>0.7414</td><td>0.4715</td></tr><tr><td rowspan="4">ZINC</td><td>Sup-VAE-1-GRU</td><td>0.2301</td><td>0.0481</td></tr><tr><td>CGD-VAE-1-GRU</td><td>0.3877</td><td>0.0880</td></tr><tr><td>Sup-VAE-3-GRU</td><td>0.3514</td><td>0.1808</td></tr><tr><td>CGD-VAE-3-GRU</td><td>0.3966</td><td>0.1559</td></tr></table>
Table 2: Correlation between the desired input property and the obtained property . $\mathbf { z } \sim \hat { q } _ { \sigma } ( \mathbf { z } )$ corresponding to conditional generation), and x, $\mathbf { z } \sim q ( \mathbf { z } | \mathbf { x } )$ to property transfer case.
 Figure 6: Property optimization. Given a start molecule (red), we combine its $\mathbf { z }$ with $1 0 0 0 \log \mathrm { P }$ values and decode (blue)

 Figure 7: A comparison of simulated logP values and Tanimoto similarity to a target on the ZINC dataset. While the stacked LSTM model has high accuracy in terms of matching the desired property, it would require drawing many samples before finding any close matches to any particular desired prototype. The CGD-VAE-3-GRU model represents a middle ground between a standard VAE model which does not condition on the property, and the stacked LSTM model which does not learn a reusable representation.
# 4.1 CONDITIONAL LSTM BASELINE
Finally, we consider a variant of the stacked LSTM model of Segler et al. (2017), with no latent space, where the model is modified to take a target logP value as an additional input at each generation step. This model forms a very strong baseline for many distribution matching tasks (Liu et al., 2018; ?), though as best we are aware this has never been used directly for conditional generation given a target property. We use a modification of the implementation provided by (?) with three layers and default settings, and fit the model by maximum likelihood training on $\begin{array} { r } { p _ { \theta } ( \mathbf { x } | \mathbf { y } ) = \prod _ { t = 1 } ^ { T } p _ { \theta } ( x _ { t } | x _ { 1 : t - 1 } , \mathbf { y } ) } \end{array}$ .
Training on the ZINC dataset, we find the generated molecules from this model have a very high correlation 0.975 with the target logP value, greatly outperforming any of the latent variable models we consider. This suggests that such a model would be very useful for generating candidates globally, but as the model has no latent variable it is not amenable to style transfer. We observe this in Figure 7, which samples 100 candidate molecules from both the stacked LSTM model and for CGD-VAE-3- GRU, conditioning on the property of one randomly-chosen test set example, while computing the Tanimoto similarity (computed using Morgan fingerprints of radius 2) to a second randomly-chosen test set example, across 200 pairs. The VAE has higher Tanimoto similarities as it can condition on the latent variable of the target molecule, representing a trade-off against the better adherence to the target property value of the unconditioned LSTM.
# 5 CONCLUSION
We presented a single step approach for the conditional generation of molecules with desired properties. Our model allows also to condition generation on a prototype molecule with a desired high-level structure. This work thus directly inverts the traditional relationship between molecules and their properties. We found that training the deep generative models conditional on target properties, following a supervised VAE approach, does not appreciably harm the quality of the unconditional generative model as measured by validity, novelty, and uniqueness of samples. Furthermore, we see that the additional act of regularizing the output using an approximate property predictor helps improve both reconstruction accuracy and property correlations in most combinations of tasks and datasets, particularly for the smaller QM9 dataset and for smaller models with fewer RNN layers. We also note that although none of the deep latent variable models are competitive with an LSTM baseline when purely considering generation conditioned on a target property value, the low Tanimoto similarity between randomly sampled candidates and an arbitrary style transfer target makes clear that such a model is not suitable for targeted generation of candidates which are close in structure to a particular prototype.
In future work, we want to explore how to further improve the correlation between the desired input properties to the decoder, and the properties of the generated molecules. Moreover, we want also to condition on multiple properties; while this is in principle possible in our framework, we do not explore it empirically here. Modifying a single property while constraining the remaining to be close to the original can further aggravate the infeasibility problem, as not all combinations of molecular properties may even be feasible, perhaps requiring learning a dependency structure between multiple properties.
# REFERENCES
Rim Assouel, Mohamed Ahmed, Marwin H. Segler, Amir Saffari, and Yoshua Bengio. Defactor: Differentiable edge factorization-based probabilistic graph generation. CoRR, abs/1811.09766, 2018. URL http://arxiv.org/abs/1811.09766.
Yoshua Bengio, Aaron Courville, and Pascal Vincent. Representation learning: A review and new perspectives. IEEE transactions on pattern analysis and machine intelligence, 35(8):1798–1828, 2013a.
Yoshua Bengio, Nicholas Leonard, and Aaron Courville. Estimating or propagating gradients through ´ stochastic neurons for conditional computation. arXiv preprint arXiv:1308.3432, 2013b.
Xi Chen, Yan Duan, Rein Houthooft, John Schulman, Ilya Sutskever, and Pieter Abbeel. Infogan: Interpretable representation learning by information maximizing generative adversarial nets. In Advances in neural information processing systems, pp. 2172–2180, 2016.
Junyoung Chung, Caglar Gulcehre, KyungHyun Cho, and Yoshua Bengio. Empirical evaluation of gated recurrent neural networks on sequence modeling. arXiv preprint arXiv:1412.3555, 2014.
Hanjun Dai, Yingtao Tian, Bo Dai, Steven Skiena, and Le Song. Syntax-directed variational autoencoder for structured data. arXiv preprint arXiv:1802.08786, 2018.
Nicola De Cao and Thomas Kipf. MolGAN: An implicit generative model for small molecular graphs. May 2018.
Hanna Eckert and Jurgen Bajorath. Molecular similarity analysis in virtual screening: foundations, ¨ limitations and novel approaches. Drug discovery today, 12(5-6):225–233, 2007.
Rafael Gomez-Bombarelli, David K. Duvenaud, Jos ´ e Miguel Hern ´ andez-Lobato, Jorge Aguilera- ´ Iparraguirre, Timothy D. Hirzel, Ryan P. Adams, and Alan Aspuru-Guzik. Automatic chemical ´ design using a data-driven continuous representation of molecules. CoRR, abs/1610.02415, 2016. URL http://arxiv.org/abs/1610.02415.
Gabriel Lima Guimaraes, Benjamin Sanchez-Lengeling, Carlos Outeiral, Pedro Luis Cunha Farias, and Alan Aspuru-Guzik. Objective-Reinforced generative adversarial networks (ORGAN) for ´ sequence generation models. May 2017.
Irina Higgins, Loic Matthey, Arka Pal, Christopher Burgess, Xavier Glorot, Matthew Botvinick, Shakir Mohamed, and Alexander Lerchner. beta-vae: Learning basic visual concepts with a constrained variational framework. In International Conference on Learning Representations, 2017.
Zhiting Hu, Zichao Yang, Xiaodan Liang, Ruslan Salakhutdinov, and Eric P Xing. Toward controlled generation of text. In Proceedings of the 34th International Conference on Machine LearningVolume 70, pp. 1587–1596. JMLR. org, 2017.
Eric Jang, Shixiang Gu, and Ben Poole. Categorical reparameterization with gumbel-softmax. arXiv preprint arXiv:1611.01144, 2016.
Wengong Jin, Regina Barzilay, and Tommi Jaakkola. Junction tree variational autoencoder for molecular graph generation. arXiv preprint arXiv:1802.04364, 2018.
Diederik P Kingma, Shakir Mohamed, Danilo Jimenez Rezende, and Max Welling. Semi-supervised learning with deep generative models. In Advances in Neural Information Processing Systems, pp. 3581–3589, 2014.
Peter Kirkpatrick and Clare Ellis. Chemical space. Nature, 432(7019):823, 2004.
Matt J Kusner, Brooks Paige, and Jose Miguel Hern ´ andez-Lobato. Grammar variational autoencoder. ´ arXiv preprint arXiv:1703.01925, 2017.
Greg Landrum. Rdkit: Open-source cheminformatics. URL http://www.rdkit.org.
Qi Liu, Miltiadis Allamanis, Marc Brockschmidt, and Alexander Gaunt. Constrained graph variational autoencoders for molecule design. In Advances in Neural Information Processing Systems 31, pp. 7806–7815. 2018.
Tengfei Ma, Jie Chen, and Cao Xiao. Constrained generation of semantically valid graphs via regularizing variational autoencoders. In Advances in Neural Information Processing Systems 31, pp. 7113–7124. 2018.
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.
Marwin HS Segler, Thierry Kogej, Christian Tyrchan, and Mark P Waller. Generating focused molecule libraries for drug discovery with recurrent neural networks. ACS central science, 4(1): 120–131, 2017.
N. Siddharth, Brooks Paige, Jan-Willem Van de Meent, Alban Desmaison, Noah Goodman, Pushmeet Kohli, Frank Wood, and Philip Torr. Learning disentangled representations with semi-supervised deep generative models. In Advances in Neural Information Processing Systems, pp. 5925–5935, 2017.
Martin Simonovsky and Nikos Komodakis. Graphvae: Towards generation of small graphs using variational autoencoders. arXiv preprint arXiv:1802.03480, 2018.
Teague Sterling and John J Irwin. Zinc 15–ligand discovery for everyone. Journal of chemical information and modeling, 55(11):2324–2337, 2015.
Scott A Wildman and Gordon M Crippen. Prediction of physicochemical parameters by atomic contributions. Journal of chemical information and computer sciences, 39(5):868–873, 1999.
Jiaxuan You, Bowen Liu, Rex Ying, Vijay Pande, and Jure Leskovec. Graph convolutional policy network for goal-directed molecular graph generation. In Advances in Neural Information Processing Systems 31, pp. 6412–6422. 2018.
# 6 APPENDIX
# 6.1 THE REGULARISER AND ITS RELATION TO THE MUTUAL INFORMATION MAXIMIZATION
The soft constrain in the loss 3, in fact , is equivalent to a simple maximizing mutual information formulation between generated molecules $\hat { \bf x }$ and the target property $\mathbf { y }$ provided to the generator. Assume the true conditional distribution is $\tilde { p } ( \mathbf { y } | \mathbf { x } )$ :
$$\begin{array} { r l } & { \mathbf { I } ( \mathbf { y } ; \hat { \mathbf { x } } ) = H ( \mathbf { y } ) - H ( \mathbf { y } \vert \hat { \mathbf { x } } ) } \\ & { \qquad = H ( \mathbf { y } ) + \mathbb { E } _ { \hat { \mathbf { x } } \sim p _ { \theta } ( \mathbf { x } \vert \mathbf { y } ) } \mathbb { E } _ { \mathbf { y } ^ { \prime } \sim \tilde { p } ( \mathbf { y } \vert \hat { \mathbf { x } } ) } [ \log \tilde { p } ( \mathbf { y } ^ { \prime } \vert \hat { \mathbf { x } } ) ] } \end{array}$$
We do not know the true distribution $\tilde { p } ( \mathbf { y } | \hat { \mathbf { x } } )$ , however, the RDKit provides an estimation $p ( \mathbf { y } \vert \hat { \mathbf { x } } )$ of the distribution assuming a Gaussian distribution over error:
$$p ( \mathbf { y } \vert \hat { \mathbf { x } } ) = \mathcal { N } ( \mathbf { y } \vert f ( \hat { \mathbf { x } } ) , \lambda _ { 1 } ^ { - 1 } \mathbf { I } )$$
where $f$ is the molecule property estimator, i.e., RDKit. We have:
$$\begin{array} { l } { { \displaystyle { \bf I } ( { \bf y } ; \hat { \bf x } ) = H ( { \bf y } ) + \mathbb { E } _ { \hat { \bf x } \sim p _ { \theta } ( { \bf x } \mid { \bf y } ) } \mathbb { E } _ { { \bf y } ^ { \prime } \sim \tilde { p } ( { \bf y } \mid \hat { \bf x } ) } [ \log \frac { \tilde { p } ( { \bf y } ^ { \prime } \mid \hat { \bf x } ) } { p ( { \bf y } ^ { \prime } \mid \hat { \bf x } ) } p ( { \bf y } ^ { \prime } \mid \hat { \bf x } ) ] } \ ~ } \\ { { \displaystyle ~ = H ( { \bf y } ) + \mathbb { E } _ { \hat { \bf x } \sim p _ { \theta } ( { \bf x } \mid { \bf y } ) } [ D _ { k l } ( \tilde { p } ( { \bf y } ^ { \prime } \mid \hat { \bf x } ) \vert \vert p ( { \bf y } ^ { \prime } \vert \hat { \bf x } ) ) + \mathbb { E } _ { { \bf y } ^ { \prime } \sim \tilde { p } ( { \bf y } \mid \hat { \bf x } ) } \log p ( { \bf y } ^ { \prime } \mid \hat { \bf x } ) ] } \ ~ } \\ { { \displaystyle ~ \geq H ( { \bf y } ) + \mathbb { E } _ { \hat { \bf x } \sim p _ { \theta } ( { \bf x } \mid { \bf y } ) } [ \mathbb { E } _ { { \bf y } ^ { \prime } \sim \tilde { p } ( { \bf y } \mid \hat { \bf x } ) } \log p ( { \bf y } ^ { \prime } \mid \hat { \bf x } ) ] } } \end{array}$$
By following the Lemma 5.1 given in Chen et al. (2016), we have
$$\mathbf { I } ( \mathbf { y } ; \hat { \mathbf { x } } ) \geq H ( \mathbf { y } ) + \mathbb { E } _ { \mathbf { y } \sim p ( \mathbf { y } ) , \hat { \mathbf { x } } \sim p _ { \theta } ( \mathbf { x } | \mathbf { y } ) } [ \log p ( \mathbf { y } | \hat { \mathbf { x } } ) ]$$
As $H ( \mathbf { y } )$ is constant, minimizing $\mathbb { E } _ { \hat { \mathbf { x } } \sim p _ { \theta } ( \mathbf { x } | \mathbf { y } _ { i } ) } \| f ( \hat { \mathbf { x } } ) - \mathbf { y } _ { i } \| ^ { 2 }$ is equivalent to maximizing $\mathbf { I } ( \mathbf { y } ; \hat { \mathbf { x } } )$ under the assumption that $p ( \mathbf { y } \vert \hat { \mathbf { x } } )$ is close to $\tilde { p } ( \mathbf { y } | \hat { \mathbf { x } } )$
# 6.2 ARCHITECTURE AND TRAINING PROCEDURE DESCRIPTION
We use the same encoder and decoder network structure as Dai et al. (2018) with the only difference that our decoder takes as input the concatenation of $\mathbf { y } , \mathbf { z }$ . As GRU layers become computationally expensive when the sequences length increase, we also examined the model using less layer GRU. To be precise, the decoder in Dai et al. (2018) takes the from of a dense hidden layer with ReLU activation followed by three layers GRU Chung et al. (2014). We tried two different settings of decoder: in the first setting, we feed the concatenation of $\mathbf { y } , \mathbf { z }$ to dense layer then apply one layer GRU, in the second setting, to enhance the effect of $\mathbf { y }$ in the decoder, we feed y not only to the dense layer but also to each layer of GRU. Furthermore, we set the dimension of the latent representation to 56. For the oracle function estimator $f _ { w }$ , we use the same network architecture as the encoder (there is no parameter sharing) and we add one more fully connected layer followed by a Tanh transformation.
To speed up convergence, we initialize the $f _ { w }$ from a pre-training, where we train $f _ { w }$ on the welltrained (maximum 500 epochs with early stopping) supervised VAE’s decoder output to predict the molecules property value. We also initialize the parameters of the encoder/decoder networks with the partially trained supervised VAE model (after 40 epochs for QM9, 100 epochs for ZINC). We do not update $\omega$ and $\phi , \theta$ simultaneously, instead we do an alternate optimization. We update $\omega$ continuously for five epochs while holding $\phi , \theta$ and do the same for updating $\phi , \theta$ . We set the hyper-parameter value $\lambda _ { 1 }$ to 50 and $\lambda _ { 2 }$ to 1. The mini-batch size is set to 300 for QM9 and 100 for ZINC. We use ADAM optimizer with learning rate 0.0001 and pytorch lr-schedular on the validation loss. The general training algorithm is described in below algorithm block1. In our experiment, to train $f _ { \omega }$ , we skipped the second term in step 7, which means we only train $f _ { \omega }$ on the training data but not the newly generated molecules obtained by permuting the property. The reason for this is that, during the training, we found that it is easy for the model to learn to reconstruct but hard to conditionally generate the molecules with given properties while we have no guidance of what the molecules should look like. Further more, some combination of $\mathbf { z }$ and $\mathbf { y }$ are physically not feasible. In this case, when the conditional generation is not good enough yet during the training, we end up fitting $f _ { \omega }$ on the miss represented molecules representations and it makes the optimization harder.
# Algorithm 1 Training algorithm
1: Initialize $p _ { \theta } ( \mathbf { x } | \mathbf { z } , \mathbf { y } )$ , $q _ { \phi } ( { \bf z } | { \bf x } )$ , $f _ { w }$ 2: for i=1,2, . . . , N (maximum epoch number) do 3: for ${ \bf j } = 1 , 2 , \ldots , { \bf L }$ , sample a minibatch $D = ( { \bf X } , { \bf Y } ) = \{ { \bf x } _ { i } , { \bf y } _ { i } ) \} _ { i = 1 } ^ { M }$ of M samples do 4: randomly permute the property set $\mathbf { Y }$ to obtain $\mathbf { Y } ^ { \ast }$ and define a label permuted mini batch $D ^ { * } = ( \mathbf { X } , \mathbf { \bar { Y } } ^ { * } ) = \{ \mathbf { x } _ { i } , \mathbf { y } _ { i } ^ { * } \} _ { i = 1 } ^ { \bar { M } }$ 5: $\begin{array} { l } { { \displaystyle \theta ^ { j } = \theta ^ { j - 1 } - \gamma \big ( - \nabla _ { \theta } \mathcal { L } _ { E L B O } \big ( \theta , \phi , \omega \big ) + \frac { \lambda _ { 1 } } { 2 } \sum _ { \substack { ( \mathbf { x } _ { i } , \mathbf { y } _ { i } ) \in D ^ { * } } } \mathbb { E } _ { q ( \mathbf { z } | \mathbf { x } _ { i } ) } \nabla _ { \theta } \| f _ { \omega } \big ( g _ { \theta } \big ( \mathbf { z } , \mathbf { y } _ { i } \big ) \big ) - \mathbf { y } _ { i } \| ^ { 2 } \big ) } } \\ { { \displaystyle \phi ^ { j } = \phi ^ { j - 1 } - \gamma \big ( - \nabla _ { \phi } \mathcal { L } _ { E L B O } \big ( \theta , \phi , \omega \big ) \big ) } } \\ { { \displaystyle w ^ { j } = w ^ { j - 1 } - \gamma \big ( \frac { \lambda _ { 2 } } { 2 } \sum _ { \substack { ( \mathbf { x } _ { i } , \mathbf { y } _ { i } ) \in D } } \mathbb { E } _ { q ( \mathbf { z } | \mathbf { x } _ { i } ) } \nabla _ { \omega } \| f _ { \omega } \big ( g _ { \theta } ( \mathbf { z } , \mathbf { y } _ { i } ) \big ) - \mathbf { y } _ { i } \| ^ { 2 } + \frac { \lambda _ { 1 } } { 2 } \sum _ { \substack { ( \mathbf { x } _ { i } , \mathbf { y } _ { i } ) \in D ^ { * } } } \mathbb { E } _ { q ( \mathbf { z } | \mathbf { x } _ { i } ) } \nabla _ { \omega } \| f _ { \omega } \big ( g _ { \theta } ( \mathbf { z } , \mathbf { y } _ { i } ) \big ) - \mathbf { y } _ { i } \| ^ { 2 } \big ) } } \end{array}$ 6: 7:
# 6.3 USE A FIXED PRE-TRAINED PROPERTY PREDICTION FUNCTION
We also investigate the case where we train the property prediction function $f _ { \omega }$ on the well trained supervised VAE output and keep it fixed during the training of the main model. We give the performance in tables 3, 4. Using a fixed $f _ { \omega }$ , in terms of reconstruction and generation performance, delivers mixed results 3. However, in terms of conditional generation 4, it does perform better than the baselines but worse compared to the case where we also update $f _ { \omega }$ during the learning.
Table 3: Sup-VAE-1-GRU /Sup-VAE-3-GRU: supervised version of SD-VAE model where y is been feed to only the first layer/all layer decoder. CGD-VAE: our model, conditional generation with disentangling. The result for CVAE and GVAE are taken from the literature, ”-” refers that those measures are not reported. The rest of baseline result is obtained by rerunning (SD-VAE) and editing the original code (Sup-VAE).
<table><tr><td></td><td colspan="3">QM9</td><td colspan="5">ZINC</td></tr><tr><td>Model</td><td>Reconstruction %</td><td>Valid%</td><td>Unique %</td><td>Novel %</td><td>Reconstruction %</td><td>Valid%</td><td>Unique %</td><td>Novel %</td></tr><tr><td>CVAE</td><td>3.61</td><td>10.30</td><td>1</td><td>90.00</td><td>44.60</td><td>0.70</td><td>-</td><td>100</td></tr><tr><td>GVAE</td><td>96.00</td><td>60.20</td><td>=</td><td>80.90</td><td>53.70</td><td>7.20</td><td></td><td>100</td></tr><tr><td>SD-VAE</td><td>97.84</td><td>98.40</td><td>99.28</td><td>91.97</td><td>76.20</td><td>43.50</td><td>-</td><td>、</td></tr><tr><td>Sup-VAE-1-GRU</td><td>97.53</td><td>93.66</td><td>91.30</td><td>92.05</td><td>74.12</td><td>32.84</td><td>95.61</td><td>100</td></tr><tr><td>CGD-VAE-1-GRU</td><td>98.96</td><td>95.03</td><td>92.77</td><td>89.74</td><td>67.46</td><td>17.38</td><td>82.44</td><td>100</td></tr><tr><td>Sup-VAE-3-GRU</td><td>97.81</td><td>97.9</td><td>95.09</td><td>89.47</td><td>82.40</td><td>36.16</td><td>86.26</td><td>100</td></tr><tr><td>CGD-VAE-3-GRU</td><td>96.9</td><td>93.8</td><td>98.29</td><td>89.55</td><td>81.80</td><td>37.78</td><td>98.70</td><td>100</td></tr></table>
<table><tr><td></td><td>Model</td><td>z~qq(z)</td><td>z ~ q(z|x)</td></tr><tr><td rowspan="4">QM9</td><td>Sup-VAE-1-GRU</td><td>0.5420</td><td>0.2526</td></tr><tr><td>CGD-VAE-1-GRU</td><td>0.6331</td><td>0.3835</td></tr><tr><td>Sup-VAE-3-GRU</td><td>0.6958</td><td>0.4204</td></tr><tr><td>CGD-VAE-3-GRU</td><td>0.6665</td><td>0.4507</td></tr><tr><td rowspan="4">ZINC</td><td>Sup-VAE-1-GRU</td><td>0.2301</td><td>0.0481</td></tr><tr><td>CGD-VAE-1-GRU</td><td>0.2981</td><td>0.0866</td></tr><tr><td>Sup-VAE-3-GRU</td><td>0.3638</td><td>0.1818</td></tr><tr><td>CGD-VAE-3-GRU</td><td>0.3765</td><td>0.1310</td></tr></table>
Table 4: Correlation between the desired input property and the obtained property when z is sampled from the approximate learned prior, $\mathbf { z } \sim \hat { q } _ { \sigma } ( \mathbf { z } )$ , (conditional generation), and when $\mathbf { z }$ is sampled from the learned posterior given some x, $\mathbf { z } \sim q ( \mathbf { z } | \mathbf { x } )$ , (property transfer).
# 6.4 VIRTUAL SCREENING
The figure 8 displays the results of a virtual screening method, where we select from the full dataset five molecules which are structurally similar to $\mathbf { x } _ { A }$ in figure 4 in section 4 and have logP values close to $\mathbf { y } _ { B }$ . As we can see the molecule that our model generates is a new one.
 Figure 8: Molecules selected with virtual screening over the full dataset in a manner that they are structurally similar to the A molecule of figure 4 while they have a logP value which is close to the logP value of the B molecule also of figure 4
# 6.5 METRICS AS FUNCTION OF $\mathbf { y } - \mathbf { y } ^ { \prime }$
The validity and novelty were mainly used to assess purely the generative model performance. However, it is also interesting to see if the model capable of generating valid and novel molecules if we start from an existing molecules and drift away from the original label, i.e., if we get $\mathbf { z }$ from $q ( \mathbf { z } | \mathbf { x } )$ , and then compare different values from $p ( \mathbf { \bar { x } } | \mathbf { z } , \mathbf { y } ^ { \prime } )$ as $\mathbf { y } ^ { \prime }$ moves far from y. We randomly sample a molecule $\mathbf { x }$ whose LogP is y from the test set, then sample $1 0 \textbf { z }$ from $q ( \mathbf { z } | \mathbf { x } )$ . For each such $\mathbf { z }$ we couple it with a $\mathbf { y } ^ { \prime }$ that is different that $\mathbf { y }$ , and sample 10 molecules from $p ( \mathbf { x } | \mathbf { z } , \mathbf { y } ^ { \prime } )$ . Eventually, for each such $\mathbf { y } ^ { \prime }$ , starting from original molecule $\mathbf { x }$ , we generated 100 molecules, and we report the validity, uniqueness and novelty as a function of $\mathbf { y } - \mathbf { y } ^ { \prime }$ . The figure 9 displays result of repeating above process for 20 randomly sampled $\displaystyle ( \mathbf { x } , \mathbf { y } )$ along 100 grid points for $\mathbf { y } - \mathbf { y } ^ { \prime }$ . The result confirms that on a big data set, conditional generative models uniqueness, validity and novelty performance is not affected by the size of the modification done on the property. However, on a small dataset, uniqueness is not affected. As expected, novelty increases as the properties modification size increases and validity drops slightly as the property modification size increase.
 Figure 9: CGD-VAE-3-GRU model validity, novelty, uniqueness performance on property transfer task as a function of $\mathbf { y } - \mathbf { y } ^ { \prime }$ on QM9 dataset.
 Figure 10: CGD-VAE-3-GRU model validity, novelty, uniqueness performance on property transfer task as a function of $\mathbf { y } - \mathbf { y } ^ { \prime }$ on ZINC dataset.
With our model, during the generation, we observe that sampling from the approximated marginal posterior improves generation performance when compered to sampling from the prior. Here we investigate if this findings holds for other baseline models or not. We explored the behavior of baselines when the $\mathbf { z }$ is sampled from the approximate marginal posterior, we observe that for CVAE and GVAE the validity did not change (as the ${ \hat { q } } ( \mathbf { z } )$ and $p ( \mathbf { z } )$ are essentially identical); for the SD-VAE the validity increases (Table 5).
SDVAE Table 5: Baseline model performance on ZINC
<table><tr><td></td><td>Valid%</td><td>Unique %</td><td>Novel %</td></tr><tr><td>z ~qσ(z)</td><td>56.05</td><td>80.69</td><td>100</td></tr><tr><td>z ~p(z)</td><td>43.50</td><td>82.26</td><td>100</td></tr></table>
# 6.7 MOLECULE PROPERTY OPTIMIZATION
Figure 11 is the visualization of the generated molecules from property optimization task, given in figure 6 section 4. The molecules are generated by increasing the logP of a given molecule, i.e. we hold $\mathbf { z }$ fixed and increase the y value. Among the all generated molecules, 19 of them are unique.
 Figure 11: Molecules generated with an increasing logP123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246# FAST TASK ADAPTATION FOR FEW-SHOT LEARNING
Anonymous authors Paper under double-blind review
# ABSTRACT
Few-shot classification is a challenging task due to the scarcity of training examples for each class. The key lies in generalization of prior knowledge learned from large-scale base classes and fast adaptation of the classifier to novel classes. In this paper, we introduce a two-stage framework. In the first stage, we attempt to learn task-agnostic feature on base data with a novel Metric-Softmax loss. The Metric-Softmax loss is trained against the whole label set and learns more discriminative feature than episodic training. Besides, the Metric-Softmax classifier can be applied to base and novel classes in a consistent manner, which is critical for the generalizability of the learned feature. In the second stage, we design a task-adaptive transformation which adapts the classifier to each few-shot setting very fast within a few tuning epochs. Compared with existing fine-tuning scheme, the scarce examples of novel classes are exploited more effectively. Experiments show that our approach outperforms current state-of-the-arts by a large margin on the commonly used mini-ImageNet and CUB-200-2011 benchmarks.
# 1 INTRODUCTION
In recent years, deep learning models have achieved great success in many visual tasks such as image classification (Krizhevsky et al., 2012), object detection (Girshick, 2015) and semantic segmentation (Long et al., 2015). In general, training a deep network needs massively labeled instances which leads to expensive manual annotation cost. In contrast, humans can learn novel concepts from only one or a few examples. Analogously, few-shot learning aims to recognize unseen instances by accessing just a small number of labeled images in each class. Unfortunately, naive methods such as re-training or fine-tuning the model on novel data would severely suffer from overfitting and provide poor result (Finn et al., 2017). The major difficulty lies in the exceedingly limited data, which can hardly represent the class distribution.
In the task of few-shot classification, we are given three datasets, namely training set, support set and query set. The training set (also known as base dataset) normally contains large-scale labeled data for learning of prior knowledge. The support set and query set contain a small number of examples which are drawn from unseen classes disjoint with the training set. We are expected to classify the query images, leveraging the prior knowledge from the base training set and the limited cue from the support images. If the support set contains $k$ annotated images for each of $m$ unique classes, then this task is called $m$ -way $k$ -shot classification.
Previous works on few-shot learning can be roughly divided into two categories, namely metalearning based and metric learning based. The former typically learns a meta-learner model on base data and generalizes it to novel unseen data. Usually, a recurrent neural network (Santoro et al., 2016) or long short-term memory network (Hochreiter & Schmidhuber, 1997) is utilized to learn a memory network to store knowledge. The latter attempts to learn a feature embedding where samples of the same class are closer to each other than samples of different classes. To make training on base data and inference on novel data consistent, a so-called episodic training strategy is widely employed (Vinyals et al., 2016; Snell et al., 2017; Sung et al., 2018). There are two limitations in metric learning based approaches. One is that episodic training only considers local sample similarity in current data batch. As shown in Snell et al. (2017), the limited number of classes pertraining episode is harmful for discriminative feature learning, while simply increasing it leads to better performance. However, in a sampled episode, a large number of classes is infeasible due to limited GPU memory. The other limitation is that most existing methods only utilize the labeled support images in novel classes as templates for feature similarity comparison. We argue that the support images could be better exploited to improve the performance.
 Figure 1: Overview of the proposed FTA framework, which is composed of two stages.
In this work, we introduce a two-stage framework named Fast Task Adaption (FTA). As illustrated in Figure 1, the few-shot classification task is decomposed into two steps, i.e. task-agnostic feature learning on base data and adaptation of the classifier to each few-shot learning task. To learn more general and discriminative feature on base data, we propose a novel Metric-Softmax loss, which is an improvement of the Softmax loss. Specifically, we replace the score computing in softmax with a Gaussian kernel-based radial basis function. The Metric-Softmax loss is trained against the full base classes, overcoming the limitation of small number of classes in episodic training. Moreover, the Metric-Softmax classifier can be applied to base and novel classes in the same way. The consistency between training and inference is well preserved. After task-agnostic feature is learned, we design a novel task-adaptive transformation to adapt the classifier to current few-shot learning task. It is essentially an affine transformation applied to features of novel images. Notably, compared with fine-tuning re-initialized weights, it exhibits the desirable characteristics of fast convergence and superior performance. In this way, the aforementioned weaknesses of existing metric learning based methods are well addressed, leading to significant accuracy improvement. Experimental results on the mini-ImageNet and CUB-200-2011 datasets show that our approach consistently outperforms current state-of-the-art methods with respect to various backbone networks.
The main contributions of this paper can be summarized as follows.
• We propose the Metric-Softmax loss, which learns highly discriminative feature and ensures the consistency between training and inference as well. We design a novel task-adaptive transformation to adapt the classifier to novel classes efficiently and effectively. • We improve few-shot classification significantly and achieve state-of-the-art performance on two common few-shot learning benchmarks.
# 2 RELATED WORK
In this section, we briefly review the previous approaches relevant to ours and current state-of-the-art methods we compare with in experiments.
Meta-learning based methods aim to learn task-agnostic knowledge from a sequence of similar tasks which have enough training data and apply it to new tasks for fast adaption. Ravi & Larochelle (2017) utilize an LSTM-based network to control the parameter optimization process, which results in better generalization than SGD when training on a few labeled samples. Qiao et al. (2018) propose to adapt a pre-trained network to novel classes by directly predicting the parameters from the activations. MAML (Finn et al., 2017) learns sensitive and general initial parameters, which can fast adapt to a novel task with only one or a few steps of gradient-descent update. MTL (Sun et al., 2019) learns to adapt a deep neural network for few-shot learning tasks by learning scaling and shifting functions of weights for each task. Cai et al. (2018) use a contextual learner to predict the parameters of an embedding network for unlabeled data by using memory slots. Mishra et al. (2018) propose a meta-learner architecture that combines temporal convolutions and soft attention.
Metric learning based methods aim to learn a feature embedding that preserves the class neighborhood structure. Specifically, samples of the same class are closer than samples of different classes in the learned embedding space. Matching networks (Vinyals et al., 2016) combine attention and memory together by learning a network that maps a small labeled support set and an unlabeled example to its label. They also first introduce the episodic training strategy, where the training process mimics the test scenario based on support-query metric learning. Prototypical network (Snell et al., 2017) uses the mean feature of each class as its corresponding prototype representation to learn a similarity metric space. Relation network (Sung et al., 2018) learns a deep non-linear distance metric by considering the relation between query images and support images. Satorras & Estrach (2018) propose a graph neural network to learn the feature similarity between query and support set. Our approach belongs to this category. Compared with existing methods, our major improvements are the Metric-Softmax loss for generic feature learning and the task-adaptive transformation for fast task adaptation.
Other methods. Zhang et al. (2018) propose a GAN-based approach to help few-shot classifiers to learn sharper decision boundary. Si et al. (2019) propose a progressive cluster purification method for transductive few-shot learning. Li et al. (2019) propose a deep nearest neighbor neural network for few-shot learning. Chen et al. (2019) give a consistent comparative analysis of several representative few-shot classification algorithms and show that the depth of backbone network matters. Besides, they attempt to fine-tune a Softmax classifier on the support set. On the contrary, we first apply an affine transformation to features of the support images, and compute the class centroids of the transformed features as the classfier’s weights. Concretely, we learn the affine transforming matrix rather than directly fine-tune the randomly initialized weights. Optimizing the transformation is computationally more stable even when one example per-class is available.
# 3 METHOD
As shown in Figure 1, the proposed FTA framework is composed of two stages, namely task-agnostic feature learning stage and fast task adaptation stage. In the first stage, we train the network on the base data with the proposed Metric-Softmax loss. After that, we fix the parameters of the network backbone and use it as a feature extractor. In the second stage, we learn a task-adaptive classifier, which is also a Metric-Softmax classifier with its weights replaced with affine transformed features of the support images. The affine transformation $g$ is named Task-Adaptive Transformation (TAT), which is learned on the scarce support set. With proper initialization, training of $g$ converges very fast within a few epochs. After training finishes, $g$ is applied to both support and query images.
In this section, we first elaborately describe the proposed Metric-Softmax loss. Since it is an improvement of the Softmax loss, we first give a brief review of the Softmax loss and reveal the issue of discrepancy between training and inference. Then we explain how to address this issue with the Metric-Softmax loss. Finally, we introduce the task-adaptive transformation for fast task adaptation.
# 3.1 SOFTMAX CLASSIFIER
Feature learning with the Softmax loss has achieved great success in many feature ranking tasks like person re-identification (Zhang et al., 2017) and face verification (Wen et al., 2016). Given an image $\boldsymbol { X }$ of base classes, a backbone network $f$ is applied to project $\boldsymbol { X }$ into feature space $\pmb { h } = f ( \pmb { X } ) , \pmb { h } \in \mathbb { R } ^ { d }$ . Then, the logits $_ { z }$ are computed by feeding $^ { h }$ into an affine transformation:
$$\begin{array} { r } { \pmb { z } = \pmb { W } ^ { T } \pmb { h } + \pmb { b } , } \end{array}$$
where $W \in \mathbb { R } ^ { d \times c }$ and $\pmb { b } \in \mathbb { R } ^ { c }$ are the transforming weights. $c$ is the number of classes in base data. The Softmax classifier predicts the probability score that the image belongs to class $i$ by
$$s _ { i } = \mathrm { s o f t m a x } ( z ) _ { i } = \frac { \exp ( z _ { i } ) } { \sum _ { j } ^ { c } \exp ( z _ { j } ) }$$
The Softmax loss is an assembly of the Softmax classifier and cross-entropy loss. Suppose the one-hot category label of the image is ${ \pmb y } \in \{ 0 , 1 \} ^ { c }$ , the training cross-entropy loss is defined as
$$\mathcal { L } = - \sum _ { j } ^ { c } y _ { j } \log ( s _ { j } )$$
During inference, if a test image belongs to one of the training classes, its label can be predicted by
$$\hat { y } = \arg \operatorname* { m a x } _ { i } s _ { i }$$
In this case, the scores in both training and inference are computed by an affine transformation and softmax function applied to the feature vector $^ { h }$ . However, in the context of few-shot learning, the query image for testing belongs to a novel class unseen in training. A common way to classify the novel query image is to compare its similarities to the few labeled support images, which share the same label space with the query image. Concretely, for $m$ -way $k$ -shot classification, we can extract features of the support images, and compute the mean feature for each class by
$$\bar { \boldsymbol { h } } _ { i } = \frac { 1 } { k } \sum _ { j } ^ { k } f ( \boldsymbol { X } _ { j } ^ { i } )$$
Here, $X _ { j } ^ { i }$ denotes the $j$ -th image of class $i$ in the support set. The label of a query image $\boldsymbol { X }$ can be predicted by
$$\hat { y } = \mathop { \arg \operatorname* { m i n } } _ { i } | | f ( X ) - \bar { \pmb { h } } _ { i } | |$$
Rather than an inner-product between $^ { h }$ and column vectors of the weight matrix $( \boldsymbol { z } _ { i } = \boldsymbol { W } _ { : , i } ^ { T } \boldsymbol { h } + \boldsymbol { b } _ { i } )$ followed by softmax function in the previous case, the prediction is based on the euclidean distance between the query and support features. We argue that this discrepancy hurts the transferability of features pre-trained on base data to novel data.
# 3.2 METRIC-SOFTMAX CLASSIFIER
To eliminate this discrepancy, we improve the Softmax classifier by redefining the probability score calculating function. Specifically, we replace the $\exp ( z _ { i } )$ term in Equation 2 with a Gaussian kernel-based radial basis function, whose center is the column vector of a learnable weight matrix $W _ { : , i } , W \in \mathbb { R } ^ { d \times c }$ . Then the score can be computed by
$$s _ { i } = \frac { \exp ( - \alpha \vert \vert { h - W _ { : , i } } \vert \vert ) } { \sum _ { j } ^ { c } \exp ( - \alpha \vert \vert { h - W _ { : , j } } \vert \vert ) } ,$$
where $\alpha \in \mathbb { R } , \alpha > 0$ is a hyper-parameter for scaling and $^ { h }$ is an L2-normalized feature vector. In this way, it can be easily derived that arg max $s _ { i }$ is equal to $\arg \operatorname* { m i n } _ { i } \left| \left| \boldsymbol { h } - \boldsymbol { W } _ { : , i } \right| \right|$ . Here $W _ { : , i }$ can i be interpreted as the centroid of class $i$ in the learned embedding space. That means the training procedure is essentially optimizing the euclidean distance-based similarity between images to their corresponding class centroids. During training, the cross-entropy loss is adopted as in the Softmax loss.
During inference, we replace $W _ { : , i }$ with the mean feature (see Equation 5) of class $i$ in the support set. Then classification of a query image is conducted according to Equation 4. Like episodic training, the consistency between training and inference is well preserved. And we easily enjoy the benefit of more general and discriminative feature learned with the cross-entropy loss. It is worth noting that the number of classes during inference on novel data is independent from the base dataset, which makes it flexible enough to adapt to different few-shot classification tasks.
# 3.3 FAST TASK ADAPTATION
Although the feature learned on the large-scale base data is highly general and discriminative, it is unlikely to perfectly fit arbitrary novel classes. A proper adaptation to each few-shot task is beneficial. To leverage the valuable cue provided by the support images, a straightforward choice is to fine-tune a specific Softmax classifier as in Chen et al. (2019). However, even with the feature extractor being fixed, it is still difficult to train the classifier due to easy overfitting on small dataset. In contrast, we design a parameterized transformation function $g$ to adapt the general feature to current few-shot learning task,
$$\begin{array} { r } { h ^ { \prime } = g ( h ) } \end{array}$$
Concretely, $g$ is simply a zero-offset affine transformation: $g ( \pmb { h } ) = \pmb { M } ^ { T } \pmb { h } ,\pmb { M } \in \mathbb { R } ^ { d \times d }$ . For $m$ - way $k$ -shot classification, we reconstruct an $m$ -class Metric-Softmax classifier whose weight matrix $\bar { \pmb { W } } \in \mathbb { R } ^ { d \times m }$ is derived from the transformed features of the support images
$$\bar { W } _ { : , i } = \frac { 1 } { k } \sum _ { j } ^ { k } g ( \pmb { h } _ { ( i , j ) } )$$
Here $\pmb { h } _ { ( i , j ) }$ denotes the feature of $j$ -th image in class $i$ . It is worth mentioning that both the transformed feature vector $g ( h )$ and each column of the weight matrix $\bar { \pmb { W } }$ should be L2-normalized. And now, the computation of probability score is defined as
$$s _ { i } = \frac { \exp ( - \alpha \vert \vert g ( \pmb { h } ) - \bar { \pmb { W } } _ { : , i } \vert \vert ) } { \sum _ { j } ^ { c } \exp ( - \alpha \vert \vert g ( \pmb { h } ) - \bar { \pmb { W } } _ { : , j } \vert \vert ) }$$
The transformation $g$ is trained on all labeled images in the support set with the cross-entropy loss. To ease optimization, the transforming matrix $M$ is initialized with an identity matrix. After training of $g$ finishes, it is applied to both support and query images. And the final prediction of a query image $\boldsymbol { X }$ is computed by
$$\hat { y } = \underset { i } { \arg \operatorname* { m i n } } \left| \left| g ( f ( X ) ) - \bar { W } _ { : , i } \right| \right|$$
# 4 EXPERIMENTS
# 4.1 DATASETS
We conduct few-shot classification experiments on two common benchmarks, namely miniImageNet (Vinyals et al., 2016) and CUB-200-2011 (Wah et al., 2011).
mini-ImageNet is first proposed by Vinyals et al. (2016) for few-shot classification evaluation. It consists of 100 classes and 600 images per class, which is a subset sampled from the ImageNet dataset (Deng et al., 2009). In our experiments, we follow the dataset splits proposed in Ravi & Larochelle (2017), which takes 64, 16 and 20 classes for training, validation and testing respectively.
CUB-200-2011 is initially proposed for fine-grained classification of birds. It contains 200 categories and 11,788 images in total. We follow the evaluation protocol used in Hilliard et al. (2018), which randomly splits the dataset into 100, 50 and 50 classes for training, validation and testing.
# 4.2 IMPLEMENTATION DETAILS
To make a fair comparison with existing works, we evaluate our method for three commonly used backbone networks, namely Conv-4 (Vinyals et al., 2016), ResNet-10 (Chen et al., 2019) and ResNet-12 (Oreshkin et al., 2018). Besides difference in depth and architecture, Conv-4 and ResNet12 expect an input size of $8 4 \times 8 4$ , while ResNet-10 takes $2 2 4 \times 2 2 4$ images as input, following the setting in existing works. In our experiments, we mainly focus on the 5-way 1-shot and 5-way 5-shot classification settings which are the most commonly used in existing works. The test episode contains 5 classes and each class contains 1 (or 5) support image(s) and 15 query images. For all experiments, we report the mean accuracy over 1200 randomly sampled episodes and the $9 5 \%$ confidence interval.
Table 1: Few-shot classification results on the test set of the mini-ImageNet dataset. ∗Results reported by Chen et al. (2019).
<table><tr><td>Method</td><td>Backbone</td><td>5-way 1-shot</td><td> 5-way 5-shot</td></tr><tr><td rowspan="2">MatchingNet*(Vinyals et al., 2016) ProtoNet (Snell et al., 2017) MAML (Finn et al., 2017) RelationNet (Sung et al., 2018) PABN (Huang et al., 2019) Baseline++ (Chen et al., 2019)</td><td rowspan="2">Conv-4</td><td>48.14±0.78 49.42±0.78 48.70±1.84</td><td>63.48±0.66 68.20±0.66</td></tr><tr><td>50.44±0.82 51.87±0.45</td><td>63.11±0.92 65.32±0.70</td></tr><tr><td rowspan="2">DN4 (Li et al., 2019) FTA (Ours) MetaGAN (Zhang et al., 2018) SNAIL (Mishra et al., 2018)</td><td rowspan="2">AdaResNet (Munkhdalai et al.,2018) ResNet-12</td><td>48.24±0.75 51.24±0.74 52.13±0.53</td><td>66.43±0.63 71.02±0.64 80.35±0.41</td></tr><tr><td>52.71±0.64 55.71±0.99 56.88±0.62 58.5±0.3</td><td>68.63±0.67 68.88±0.92 71.94±0.57</td></tr></table>
Our implementation is based on PyTorch (Paszke et al., 2017). We apply the same data augmentation as Chen et al. (2019), including random cropping, horizontal flipping and color jittering in both feature learning and fast task adaptation stages. The Adam (Kingma & Ba, 2015) optimizer with $\epsilon = 1 0 ^ { - 3 }$ , $\beta _ { 1 } \stackrel { - } { = } 0 . 9$ and $\beta _ { 2 } = 0 . 9 9 9$ is used. In the feature learning stage, the backbone network is trained from scratch for 300 epochs in total with a batch size of 32. We decay the learning rate by a factor of 0.1 every 75 epochs. The scaling factor $\alpha$ used in Metric-Softmax is set to 15 for mini-ImageNet and 1 for CUB-200-2011. In the task adaptation stage, we use the same optimizer with different learning rate. We set the learning rate to 0.005 for the 1-shot setting and 0.05 for the 5-shot setting. $\alpha$ is set to 0.25 and 2 for the 1-shot and 5-shot settings respectively. We fine-tune the weights of the transformation $g$ for 20 epochs. Note that all the hyper-parameters are determined by the performance on the validation set of each dataset.
# 4.3 COMPARISONS WITH THE STATE-OF-THE-ARTS
Results on mini-ImageNet. Table 1 shows a comparison of our method to current state-of-the-arts on the mini-ImageNet dataset. Classification accuracies are reported for two backbone networks, i.e. Conv-4 and ResNet-12. For Conv-4 backbone, we achieve the best accuracy in both 5-way 1-shot and 5-way 5-shot settings. Our method boosts the performance for the 5-shot setting, surpassing the second best by $9 . 3 3 \%$ and $2 . 1 0 \%$ for the Conv-4 and ResNet-12 backbones respectively. A closer analysis on the larger improvement for the 5-shot setting than 1-shot setting is given in the discussion section.
Results on CUB-200-2011. On this dataset, we find that there is no work reporting the few-shot performance for the ResNet-12 backbone. For a fair comparison, we report the accuracies of the Conv-4 and ResNet-10 backbones. As shown in Table 2, similar to mini-ImageNet, our method outperforms the second best method by a large margin $( 8 7 . 9 2 \%$ vs. $8 1 . 9 0 \%$ for Conv-4 and $9 2 . 8 9 \%$ vs. $8 7 . 4 5 \%$ for ResNet-10) in the 5-way 5-shot setting. In the 1-shot setting, we achieve the best performance for ResNet-10 and comparable accuracy to PABN $6 5 . 1 1 \%$ vs. $6 6 . 7 1 \%$ for Conv-4. It is worth mentioning that in PABN, the max-pooling layers of the backbone network are replaced with bilinear pooling, which is specially optimized for fine-grained classification tasks. We expect further accuracy improvement by incorporating such techniques in our method.
Results under Domain Shift. To evaluate the generalizability of the task-agnostic feature learned with the proposed Metric-Softmax loss, we perform the cross domain experiments. In the cross domain scenario, we swap the training sets of the two datasets. Specifically, in the miniImageNet CUB-200-2011 setting, the training set is comprised of the 64 base classes from miniImageNet, while the validation and test data come from CUB-200-2011. Similarly, in the CUB$2 0 0 { - } 2 0 1 1 \{ 1 \to$ mini-ImageNet setting, we use the 100-class base data of CUB-200-2011 for general feature learning and evaluate its performance on the mini-ImageNet dataset. We report the results under the same setting as Devos & Grossglauser (2019) in Table 3. Compared with existing methods, our approach achieves the highest accuracy in all settings. Notably, we improve SubspaceNet by $2 2 . 6 7 \%$ in the mini-ImageNet CUB-200-2011 setting. The strong cross domain performance is mainly attributed to the task-adaptive transformation $g$ of our FTA. If it is disabled, the accuracy drops drastically from $8 5 . 3 8 \%$ to $6 7 . 2 2 \%$ . Another observation is that the performance degrades more in CUB-200-2011 mini-ImageNet than mini-ImageNet CUB-200-2011. This is because mini-ImageNet contains more abundant classes than CUB-200-2011 and the network can learn more general and discriminative feature.
Table 2: Few-shot classification results on the test set of the CUB-200-2011 dataset.
<table><tr><td>Method</td><td>Backbone</td><td>5-way 1-shot</td><td>5-way 5-shot</td></tr><tr><td>MatchingNet (Vinyals et al., 2016)</td><td rowspan="6">Conv-4</td><td>61.16±0.89</td><td>72.86±0.70</td></tr><tr><td>ProtoNet (Snell et al.,2017)</td><td>51.31±0.91</td><td>70.77±0.69</td></tr><tr><td>MAML (Finn et al., 2017)</td><td>55.92±0.95</td><td>72.09±0.76</td></tr><tr><td>RelationNet (Sung et al.,2018)</td><td>62.45±0.98</td><td>76.11±0.69</td></tr><tr><td>PABN (Huang et al., 2019)</td><td>66.71±0.43</td><td>76.90±0.21</td></tr><tr><td>Baseline++ (Chen et al., 2019) DN4 (Li et al., 2019)</td><td>60.53±0.83</td><td>79.34±0.61</td></tr><tr><td rowspan="3">FTA (Ours) Baseline++ (Chen et al., 2019)</td><td rowspan="3">ResNet-10</td><td>53.15±0.84 65.11±0.65</td><td>81.90±0.60 87.92±0.38</td></tr><tr><td></td><td></td></tr><tr><td>69.55±0.89 72.92±0.90</td><td>85.17±0.50</td></tr><tr><td colspan="2">SubspaceNet (Devos & Grossglauser,2019) FTA (Ours)</td><td>73.19±0.62</td><td>87.45±0.48 92.89±0.28</td></tr></table>
Table 3: Identical domain and cross domain results for 5-way 5-shot classification using the ResNet10 backbone. The dataset names (mini-ImageNet and CUB-200-2011) are abbreviated to mini and CUB respectively for brevity.
<table><tr><td rowspan="2">Method</td><td colspan="2">Identical Domain</td><td colspan="2">Cross Domain</td></tr><tr><td>mini-ImageNet</td><td>CUB-200-2011</td><td>mini → CUB</td><td>CUB →mini</td></tr><tr><td>MatchingNet</td><td>69.14±0.69</td><td>83.75±0.60</td><td>52.59±0.71</td><td>48.95±0.67</td></tr><tr><td>ProtoNet</td><td>73.77±0.64</td><td>85.70±0.52</td><td>59.22±0.74</td><td>53.58±0.73</td></tr><tr><td>RelationNet</td><td>69.97±0.68</td><td>82.67±0.61</td><td>54.36±0.71</td><td>45.27±0.66</td></tr><tr><td>SubspaceNet</td><td>74.03±0.68</td><td>87.45±0.48</td><td>62.71±0.71</td><td>56.66±0.68</td></tr><tr><td>FTA (Ours)</td><td>86.44±0.36</td><td>92.89±0.28</td><td>85.38±0.45</td><td>58.35±0.52</td></tr></table>
# 5 DISCUSSION
Ablation Study of FTA. As shown in Table 4, compared with the Softmax classifier, the proposed Metric-Softmax classifier improves the accuracy by $4 . 7 7 \%$ and $3 . 4 1 \%$ in the 5-way 1-shot and 5- way 5-shot settings respectively. This improvement is attributed to elimination of the discrepancy between training and inference brought by our Metric-Softmax classifier. By incorporating the taskadaptive transformation, the performance is further boosted, especially in the 5-shot setting.
TAT vs. Fine-tuning. To leverage the cue from the supported set, an alternative method is to fine-tune a re-initialized Metric-Softmax classifier similar to Chen et al. (2019). Figure 2 shows a comparison of the proposed task-adaptive transformation to the alternative fine-tuning scheme. In terms of convergence speed, TAT takes only 5 epochs to get an appreciable performance. However, direct fine-tuning takes over 40 epochs to converge for the 5-way 5-shot setting. For the 5-way 1- shot setting, it barely improves the accuracy. In terms of final performance, TAT is far more superior over direct fine-tuning.
Table 4: Ablation study of FTA on the mini-ImageNet dataset using the ResNet-12 backbone.
<table><tr><td>Method</td><td>Metric-Softmax</td><td>TAT</td><td> 5-way 1-shot</td><td> 5-way 5-shot</td></tr><tr><td>Softmax Classifier</td><td>×</td><td>×</td><td>48.62±0.56</td><td>69.99±0.57</td></tr><tr><td>Metric-Softmax Classifier</td><td></td><td>×</td><td>53.39±0.55</td><td>73.40±0.47</td></tr><tr><td>FTA</td><td>√</td><td>√</td><td>58.03±0.58</td><td>80.73±0.44</td></tr></table>
 Figure 2: Performance comparison of TAT to direct fine-tuning on the mini-ImageNet dataset using the ResNet-12 backbone. Accuracies on the test set at different training epochs are plotted.

 Figure 3: Schematic illustration of different feature transformations by TAT in the 5-way 1-shot (a) and 5-way 5-shot (b) settings. Circles of different colors represent the features of different classes. In (b) the black circles indicate the centroid of each class.
Why does FTA improve the 5-shot setting more than 1-shot setting? As shown in Section 4.3, our FTA outperforms existing methods more significantly in the 5-shot setting than 1-shot setting. It can be explained by the mechanism of the task-adaptive transformation. In the 1-shot setting, only one image is available in each class. Then Equation 9 degenerates to $\bar { \pmb { W } } _ { : , i } ~ = ~ g ( \pmb { h } _ { ( i , 1 ) } \big )$ . For an image with label $y , y \in \{ 1 , 2 , 3 , 4 , 5 \}$ , the numerator of Equation 10 becomes a constant: $\exp ( - \alpha | | g ( \pmb { h } _ { ( y , 1 ) } ) - g ( \pmb { h } _ { ( y , 1 ) } ) | | ) = 1$ . Now minimizing the cross-entropy means minimizing the denominator of Equation 10, which is equivalent to maximizing the total distance of this feature to others: $\begin{array} { r } { \sum _ { j } ^ { 5 } | | g ( \bar { \pmb h } _ { ( y , 1 ) } ) - g ( \pmb h _ { ( j , 1 ) } ) | | } \end{array}$ . As illustrated in Figure 3(a), task-adaptive transformation only enlarges the distance among different classes in the 1-shot setting. However, for the 5-shot setting (see Figure $3 ( \mathbf { b } ) )$ ), the transformation not only enlarges inter-class distance but also shrinks the intra-class distance, which helps to improve the classifier.
# 6 CONCLUSIONS
In this paper, we propose the Metric-Softmax loss which can adequately explore the feature similarities in the whole base dataset with the premise of keeping the classifier consistent between training and inference. In addition, we take full advantage of the few labeled novel data by introducing a parameterized transformation to adapt the learned general feature to each few-shot classification task. Our approach is particularly helpful for the 5-shot setting. We leave further improvement for the 1-shot setting as our future work.
# REFERENCES
Qi Cai, Yingwei Pan, Ting Yao, Chenggang Yan, and Tao Mei. Memory matching networks for one-shot image recognition. In 2018 IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 4080–4088, 2018.
Wei-Yu Chen, Yen-Cheng Liu, Zsolt Kira, Yu-Chiang Frank Wang, and Jia-Bin Huang. A closer look at few-shot classification. In ICLR 2019 : 7th International Conference on Learning Representations, 2019.
Jun Deng, Wenjie Dong, Richard Socher, Li-Jia Li, Kehui Li, and Li Fei-Fei. Imagenet: A largescale hierarchical image database. In 2009 IEEE Conference on Computer Vision and Pattern Recognition, pp. 248–255, 2009.
Arnout Devos and Matthias Grossglauser. Subspace networks for few-shot classification. arXiv preprint arXiv:1905.13613, 2019.
Chelsea Finn, Pieter Abbeel, and Sergey Levine. Model-agnostic meta-learning for fast adaptation of deep networks. In ICML’17 Proceedings of the 34th International Conference on Machine Learning - Volume 70, pp. 1126–1135, 2017.
Ross B. Girshick. Fast r-cnn. In 2015 IEEE International Conference on Computer Vision (ICCV), pp. 1440–1448, 2015.
Nathan Hilliard, Lawrence Phillips, Scott Howland, Artem Yankov, Courtney D. Corley, and ¨ Nathan O. Hodas. Few-shot learning with metric-agnostic conditional embeddings. arXiv preprint arXiv:1802.04376, 2018.
Sepp Hochreiter and Jurgen Schmidhuber. Long short-term memory. ¨ Neural Computation, 9(8): 1735–1780, 1997.
Huaxi Huang, Junjie Zhang, Jian Zhang, Qiang Wu, and Jingsong Xu. Compare more nuanced: Pairwise alignment bilinear network for few-shot fine-grained learning. In 2019 IEEE International Conference on Multimedia and Expo (ICME), pp. 91–96, 2019.
Diederik P. Kingma and Jimmy Lei Ba. Adam: A method for stochastic optimization. In ICLR 2015 : International Conference on Learning Representations 2015, 2015.
Alex Krizhevsky, Ilya Sutskever, and Geoffrey E. Hinton. Imagenet classification with deep convolutional neural networks. neural information processing systems, 141(5):1097–1105, 2012.
Kwonjoon Lee, Subhransu Maji, Avinash Ravichandran, and Stefano Soatto. Meta-learning with differentiable convex optimization. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pp. 10657–10665, 2019.
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. arXiv preprint arXiv:1903.12290, 2019.
Jonathan Long, Evan Shelhamer, and Trevor Darrell. Fully convolutional networks for semantic segmentation. In 2015 IEEE Conference on Computer Vision and Pattern Recognition (CVPR), pp. 3431–3440, 2015.
Nikhil Mishra, Mostafa Rohaninejad, Xi Chen, and Pieter Abbeel. A simple neural attentive metalearner. In ICLR 2018 : International Conference on Learning Representations 2018, 2018.
Tsendsuren Munkhdalai, Xingdi Yuan, Soroush Mehri, and Adam Trischler. Rapid adaptation with conditionally shifted neurons. In ICML 2018: Thirty-fifth International Conference on Machine Learning, pp. 3661–3670, 2018.
Boris N. Oreshkin, Pau Rodr´ıguez Lopez, and Alexandre Lacoste. Tadam: Task dependent adaptive ´ metric for improved few-shot learning. In NIPS 2018: The 32nd Annual Conference on Neural Information Processing Systems, pp. 721–731, 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 NIPS Autodiff Workshop, 2017.
Siyuan Qiao, Chenxi Liu, Wei Shen, and Alan L. Yuille. Few-shot image recognition by predicting parameters from activations. In 2018 IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 7229–7238, 2018.
Sachin Ravi and Hugo Larochelle. Optimization as a model for few-shot learning. In ICLR 2017 : International Conference on Learning Representations 2017, 2017.
Avinash Ravichandran, Rahul Bhotika, and Stefano Soatto. Few-shot learning with embedded class models and shot-free meta training. In The IEEE International Conference on Computer Vision (ICCV), October 2019.
Adam Santoro, Sergey Bartunov, Matthew Botvinick, Daan Wierstra, and Timothy P. Lillicrap. Meta-learning with memory-augmented neural networks. In ICML’16 Proceedings of the 33rd International Conference on International Conference on Machine Learning - Volume 48, pp. 1842–1850, 2016.
Victor Garcia Satorras and Joan Bruna Estrach. Few-shot learning with graph neural networks. In ICLR 2018 : International Conference on Learning Representations 2018, 2018.
Chenyang Si, Wentao Chen, Wei Wang, Liang Wang, and Tieniu Tan. Progressive cluster purification for transductive few-shot learning. arXiv preprint arXiv:1906.03847, 2019.
Jake Snell, Kevin Swersky, and Richard S. Zemel. Prototypical networks for few-shot learning. In Advances in Neural Information Processing Systems, pp. 4077–4087, 2017.
Qianru Sun, Yaoyao Liu, Tat-Seng Chua, and Bernt Schiele. Meta-transfer learning for few-shot learning. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pp. 403–412, 2019.
Flood Sung, Yongxin Yang, Li Zhang, Tao Xiang, Philip H.S. Torr, and Timothy M. Hospedales. Learning to compare: Relation network for few-shot learning. In 2018 IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 1199–1208, 2018.
Oriol Vinyals, Charles Blundell, Timothy P. Lillicrap, Koray Kavukcuoglu, and Daan Wierstra. Matching networks for one shot learning. In NIPS’16 Proceedings of the 30th International Conference on Neural Information Processing Systems, pp. 3637–3645, 2016.
Catherine Wah, Steve Branson, Peter Welinder, Pietro Perona, and Serge J. Belongie. The caltechucsd birds-200-2011 dataset. Advances in Water Resources, 2011.
Yandong Wen, Kaipeng Zhang, Zhifeng Li, and Yu Qiao. A discriminative feature learning approach for deep face recognition. In European Conference on Computer Vision, pp. 499–515, 2016.
Ruixiang Zhang, Tong Che, Zoubin Ghahramani, Yoshua Bengio, and Yangqiu Song. Metagan: An adversarial approach to few-shot learning. In NIPS 2018: The 32nd Annual Conference on Neural Information Processing Systems, pp. 2371–2380, 2018.
Xuan Zhang, Hao Luo, Xing Fan, Weilai Xiang, Yixiao Sun, Qiqi Xiao, Wei Jiang, Chi Zhang, and Jian Sun. Alignedreid: Surpassing human-level performance in person re-identification. arXiv preprint arXiv:1711.08184, 2017.123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634# SENSEI: SENSITIVE SET INVARIANCE FOR ENFORCING INDIVIDUAL FAIRNESS
# Yuekai Sun
Mikhail Yurochkin IBM Research MIT-IBM Watson AI Lab mikhail.yurochkin@ibm.com
Department of Statistics University of Michigan yuekai@umich.edu
# ABSTRACT
In this paper, we cast fair machine learning as invariant machine learning. We first formulate a version of individual fairness that enforces invariance on certain sensitive sets. We then design a transport-based regularizer that enforces this version of individual fairness and develop an algorithm to minimize the regularizer efficiently. Our theoretical results guarantee the proposed approach trains certifiably fair ML models. Finally, in the experimental studies we demonstrate improved fairness metrics in comparison to several recent fair training procedures on three ML tasks that are susceptible to algorithmic bias.
# 1 INTRODUCTION
As machine learning (ML) models replace humans in high-stakes decision-making and decisionsupport roles, concern regarding the consequences of algorithmic bias is growing. For example, ML models are routinely used in criminal justice and welfare to supplement humans, but they may have racial, class, or geographic biases (Metz & Satariano, 2020). In response, researchers proposed many formal definitions of algorithmic fairness as a first step towards combating algorithmic bias.
Broadly speaking, there are two kinds of definitions of algorithmic fairness: group fairness and individual fairness. In this paper, we focus on enforcing individual fairness. At a high-level, the idea of individual fairness is the requirement that a fair algorithm should treat similar individuals similarly. Individual fairness was dismissed as impractical because there is no consensus on which users are similar for many ML tasks. Fortunately, there is a flurry of recent work that addresses this issue (Ilvento, 2019; Wang et al., 2019; Yurochkin et al., 2020; Mukherjee et al., 2020). In this paper, we assume there is a similarity metric for the ML task at hand and consider the task of enforcing individual fairness. Our main contributions are:
1. we define distributional individual fairness, a variant of Dwork et al.’s original definition of individual fairness that is (i) more amenable to statistical analysis and (ii) easier to enforce by regularization; 2. we develop a stochastic approximation algorithm to enforce distributional individual fairness when training smooth ML models; 3. we show that the stochastic approximation algorithm converges and the trained ML model generalizes under standard conditions; 4. we demonstrate the efficacy of the approach on three ML tasks that are susceptible to algorithmic bias: income-level classification, occupation prediction, and toxic comment detection.
# 2 ENFORCING INDIVIDUAL FAIRNESS WITH SENSITIVE SET INVARIANCE (SENSEI)
# 2.1 A TRANSPORT-BASED DEFINITION OF INDIVIDUAL FAIRNESS
Let $\mathcal { X }$ and $\mathcal { V }$ be the space of inputs and outputs respectively for the supervised learning task at hand. For example, in classification tasks, $\mathcal { V }$ may be the probability simplex. An ML model is a function $h : \mathcal { X } \mathcal { Y }$ in a space of functions $\mathcal { H }$ (e.g. the set of all neural nets with a certain architecture).
Dwork et al. (2011) define individual fairness as $L$ -Lipschitz continuity of an ML model $h$ with respect to appropriate metrics on $\mathcal { X }$ and $\mathcal { V }$ :
$$d _ { \mathcal { V } } ( h ( x ) , h ( x ^ { \prime } ) ) \leq L d _ { \mathcal { X } } ( x , x ^ { \prime } )$$
for all $x , x ^ { \prime } \in { \mathcal { X } }$ . The choice of $d _ { \mathcal { Y } }$ is often determined by the form of the output. For example, if the ML model outputs a vector of the logits, then we may pick the Euclidean norm as $d _ { \mathcal { Y } }$ (Kannan et al., 2018; Garg et al., 2018). The metric $d _ { \mathcal { X } }$ is the crux of (2.1) because it encodes our intuition of which inputs are similar for the ML task at hand. For example, in natural language processing tasks, $d _ { \mathcal { X } }$ may be a metric on word/sentence embeddings that ignores variation in certain sensitive directions. In light of the importance of the similarity metric in (2.1) to enforcing individual fairness, there is also a line of work on learning the similarity metric from data (Ilvento, 2019; Wang et al., 2019; Mukherjee et al., 2020). In our experiments, we adapt the methods from Yurochkin et al. (2020) to learn similarity metrics.
Although intuitive, individual fairness is statistically and computationally intractable. Statistically, it is generally impossible to detect violations of individual fairness on zero measure subset of the sample space. Computationally, individual fairness is a Lipschitz restriction, and such restrictions are hard to enforce. In this paper, we address both issues by lifting (2.1) to the space of probability distributions on $\mathcal { X }$ to obtain an “average case” version of individual fairness. This version (i) is more amenable to statistical analysis, (ii) is easy to enforce by minimizing a data-dependent regularizer, and (iii) preserves the intuition behind Dwork et al. (2011)’s original definition of individual fairness.
Definition 2.1 (distributional individual fairness (DIF)). Let , $\delta > 0$ be tolerance parameters and $\Delta ( { \mathcal { X } } \times { \mathcal { X } } )$ be the set of probability measures on $\mathcal { X } \times \mathcal { X }$ . Define
$$R ( h ) \triangleq \left\{ \begin{array} { l l } { \operatorname* { s u p } _ { \Pi \in \Delta ( { \mathcal { X } } \times { \mathcal { X } } ) } } & { { \mathbf { E } } _ { \Pi } \big [ d _ { { \mathcal { Y } } } ( h ( X ) , h ( X ^ { \prime } ) ) \big ] } \\ { s u b j e c t t o } & { { \mathbf { E } } _ { \Pi } \big [ d _ { { \mathcal { X } } } ( X , X ^ { \prime } ) \big ] \leq \epsilon } \\ & { \Pi ( \cdot , { \mathcal { X } } ) = P _ { X } } \end{array} \right\} .$$
where $P _ { X }$ is the (marginal) distribution of the inputs in the ML task at hand. An ML model $h$ is $( \epsilon , \delta )$ -distributionally individually fair $( D I F )$ iff $R ( h ) \leq \delta$ .
We remark that DIF only depends on $h$ and $P _ { X }$ . It does not depend on the (conditional) distribution of the labels $P _ { Y \mid X }$ , so it does not depend on the performance of the ML model. In other words, it is possible for a model to perform poorly and be perfectly DIF (e.g. the constant model $h ( x ) = 0$ ).
The optimization problem in (2.2) formalizes correspondence studies in the empirical literature (Bertrand & Duflo, 2016). Here is a prominent example.
Example 2.2. Bertrand & Mullainathan studied racial bias in the US labor market. The investigators responded to help-wanted ads in Boston and Chicago newspapers with fictitious resumes. To manipulate the perception of race, they randomly assigned African-American or white sounding names to the resumes. The investigators concluded there is discrimination against African-Americans because the resumes assigned white names received $50 \%$ more callbacks for interviews than the resumes.
We view Bertrand & Mullainathan’s investigation as evaluating the objective in (2.3) at a special $T$ . Let $\mathcal { X }$ be the space of resumes, and $h : \mathcal { X } \{ 0 , 1 \}$ be the decision rule that decides whether a resume receives a callback. Bertrand & Mullainathan implicitly pick the $T$ that reassigns the name on a resume from an African-American sounding name to a white one (or vice versa) and measures discrimination with the difference between callback rates before and after reassignment:
$$\mathbf { E } _ { P } \left[ 1 \{ h ( X ) \neq h ( T ( X ) ) \} \right] = \mathbf { P } \{ h ( X ) \neq h ( T ( X ) ) \} .$$
We consider distributional individual fairness a variant of Dwork et al.’s original definition. It is not a fundamentally new definition of algorithmic fairness because it encodes the same intuition as Dwork et al.’s original definition. Most importantly, it remains an individual notion of algorithmic fairness because it compares individuals to similar (close in $d _ { \mathcal { X } }$ ) individuals.
# 2.2 DIF VERSUS INDIVIDUAL FAIRNESS
It is hard to directly compare Dwork et al.’s original definition of individual fairness and DIF directly. First, they are parameterized differently: the original definition (2.1) is parameterized by a Lipschitz constant $L$ , while DIF is parameterized by an $( \epsilon , \delta )$ pair. Intuitively, (2.1) enforces (approximate) invariance at all scales (at any $\epsilon > 0$ ), while DIF only enforces invariance at one scale (determined by the input tolerance parameter). Second, (2.1) enforces invariance uniformly on $\mathcal { X }$ , while (2.2) enforces invariance on average. Although DIF seems a weaker notion of algorithmic fairness than (2.1) (average fairness vs uniform fairness), DIF is actually more stringent in some ways because the constraints in (2.2) are looser. This is evident in the Mongé version of the optimization problem in (2.2):
$$\begin{array} { r l } { \operatorname* { s u p } _ { T : \mathcal { X } \to \mathcal { X } } } & { \mathbf { E } _ { P } \left[ d _ { \mathcal { Y } } ( h ( X ) , h ( T ( X ) ) ) \right] } \\ { \mathrm { s u b j e c t ~ t o ~ } } & { \mathbf { E } _ { P } \left[ d _ { \mathcal { X } } ( X , T ( X ) ) \right] \le \epsilon . } \end{array}$$
The map corresponding to (2.1)
$$\begin{array} { r } { T _ { \mathrm { I F } } ( x ) \triangleq \arg \operatorname* { m a x } _ { d _ { \mathcal { X } } ( x , x ^ { \prime } ) \leq \epsilon } d _ { \mathcal { Y } } ( h ( x ) , h ( x ^ { \prime } ) ) } \end{array}$$
maps each $x$ to its worse-case counterpart $x ^ { \prime }$ in (2.1). It is not hard to see that $T _ { \mathrm { I F } }$ is a feasible map for (2.3), but it may not be optimal. This is because (2.3) only restricts $T$ to transport points by at most $\epsilon$ on average; the optimal $T$ may transport some points by more than $\epsilon$ .
To make the two definitions more comparable, we consider an $\epsilon { - } \delta$ version of individual fairness. A model $h : \mathcal { X } \to \mathcal { Y }$ satisfies $( \epsilon , \delta )$ -individual fairness at $x \in \mathcal { X }$ if and only if
$$\begin{array} { r } { d _ { \mathcal { Y } } ( h ( x ) , h ( T _ { \mathrm { I F } } ( x ) ) ) = \operatorname* { s u p } _ { d _ { \mathcal { X } } ( x , x ^ { \prime } ) \leq \epsilon } d _ { \mathcal { Y } } ( h ( x ) , h ( x ^ { \prime } ) ) \leq \delta . } \end{array}$$
To arrive at (2.4), we start by observing that (2.1) is equivalent to
$$\begin{array} { r } { \operatorname* { s u p } _ { x \in \mathcal { X } } d _ { \mathcal { Y } } ( h ( x ) , h ( T _ { \mathrm { I F } } ( x ) ) ) \le L \epsilon \mathrm { f o r } \operatorname * { a n y } x \in \mathcal { X } \mathrm { ~ a n d ~ } \epsilon > } \end{array}$$
We fix $x$ and $\epsilon$ and re-parameterize the right side with $\delta$ to obtain (2.4). It is possible to show that if $h$ is $( \epsilon , \delta )$ -DIF, then there exists $\delta ^ { \prime }$ such that it satisfies $( \epsilon , \delta ^ { \prime } )$ -individual fairness for “most” $x$ ’s. We formally state this result in a proposition.
Proposition 2.3. If $h : \mathcal { X } \to \mathcal { Y }$ is $( \epsilon , \delta )$ -DIF, then
$$\begin{array} { r } { P _ { X } ( d _ { \mathcal { Y } } ( h ( X ) , h ( T _ { \mathrm { I F } } ( X ) ) ) \ge \tau ) \le \frac { \delta } { \tau } f o r a n y \tau > 0 . } \end{array}$$
# 2.3 ENFORCING DIF
There are two general approaches to enforcing invariance conditions such as (2.2). The first is distributionally robust optimization (DRO):
$$\begin{array} { r } { \operatorname* { m i n } _ { h \in \mathcal { H } } L _ { \mathrm { a d v } } ( h ) \triangleq \operatorname* { s u p } _ { P ^ { \prime } : W _ { d } ( P , P ^ { \prime } ) \leq \epsilon } { \bf E } _ { P ^ { \prime } } \big [ \ell ( Y ^ { \prime } , h ( X ^ { \prime } ) ) \big ] , } \end{array}$$
where $\ell$ is a loss function and $W _ { d } ( P , Q )$ is the Wasserstein distance between distributions on $\mathcal { X } \times \mathcal { V }$ induced by the transport cost function $c ( ( x , y ) , ( x ^ { \prime } y ^ { \prime } ) ) \triangleq d _ { \mathcal { X } } ( x , x ^ { \prime } ) + \infty \cdot 1 \{ y \neq y ^ { \prime } \}$ . This approach is very similar to adversarial training, and it was considered by Yurochkin et al. (2020) for enforcing (their modification of) individual fairness. In this paper, we consider a regularization approach to enforcing (2.2):
$$\begin{array} { r } { \operatorname* { m i n } _ { h \in \mathcal { H } } L ( h ) + \rho R ( h ) , \quad L ( h ) \triangleq \mathbf { E } \big [ \ell ( Y , h ( X ) ) \big ] , } \end{array}$$
where $\rho > 0$ is a regularization parameter and the regularizer $R$ is defined in (2.2). An obvious advantage of the regularization approach is it allows the user to fine-tune the trade-off between goodness-of-fit and fairness by adjusting $\rho$ (see Figure 1; in Figure 3 of Appendix D we show the lack of such flexibility in the method of Yurochkin et al. (2020)). As we shall see, although the two approaches share many theoretical properties, we show in Section 4 that the regularization approach has superior empirical performance. We defer a more in-depth comparison between the two approaches to subsection 2.4.
At first blush, the regularized risk minimization problem (2.6) is not amenable to stochastic optimization because $R$ is not an expected value of a function of the training examples. Fortunately, by appealing to duality, it is possible to obtain a dual formulation of $R$ that is suitable for stochastic optimization.
Theorem 2.4 (dual form of $R$ ). If $d y ( h ( x ) , h ( x ^ { \prime } ) ) - \lambda d _ { \mathcal { X } } ( x , x ^ { \prime } )$ is continuous (in $( x , x ^ { \prime } )$ ) for any $\lambda \geq 0$ , then
$$\begin{array} { r } { R ( h ) = \operatorname* { i n f } _ { \lambda \geq 0 } \{ \lambda \epsilon + { \bf E } _ { P x } \left[ r _ { \lambda } ( h , X ) \right] \} , r _ { \lambda } ( h , X ) \triangleq \operatorname* { s u p } _ { x ^ { \prime } \in \mathcal { X } } \{ d y ( h ( X ) , h ( x ^ { \prime } ) ) - \lambda d _ { \mathcal { X } } ( X , x ^ { \prime } ) \} . } \end{array}$$
 Figure 1: The decision surface of a one hidden layer neural network trained with SenSeI as the fair regularization parameter $\rho$ varies. In this ML task, points on a horizontal line (points with identical $y$ -values) are similar, but the training data is biased because $P _ { Y \mid X }$ is not constant on horizontal lines. We see that fair regularization (eventually) corrects the bias in the data.
We defer the proof of this result to Appendix A. In light of the dual form of the fair regularizer, the regularized risk minimization problem is equivalently
$$\begin{array} { r } { \operatorname* { m i n } _ { h \in \mathcal { H } } \operatorname* { i n f } _ { \lambda \ge 0 } { \bf E } _ { P } \big [ \ell ( Y , h ( X ) ) + \rho ( \lambda \epsilon + r _ { \lambda } ( h , X ) ) \big ] , } \end{array}$$
where $r _ { \lambda }$ is defined in Theorem 2.4, which has the form of minimizing an expected value of a function of the training examples. To optimize with respect to $h$ , we parameterize the function space $\mathcal { H }$ with a parameter $\mathbf { \bar { \theta } } \in \Theta \mathsf { \bar { \Lambda } } \subset \mathbf { R } ^ { d }$ and consider a stochastic approximation approach to finding the best parameter. Let $w \triangleq ( \theta , \lambda )$ and $Z \triangleq ( X , Y )$ . The stochastic optimization problem we wish to solve is
$\begin{array} { r } { \operatorname* { m i n } _ { w \in \Theta \times { \bf R } _ { + } } F ( w ) \triangleq { \bf E } _ { P } \big [ f ( w , Z ) \big ] , \quad f ( w , Z ) \triangleq \ell ( Y , h _ { \theta } ( X ) ) + \rho ( \lambda \epsilon + r _ { \lambda } ( h _ { \theta } , X ) ) . } \end{array}$ (2.8) It is not hard to see that (2.8) is a stochastic optimization problem. We summarize Sensitive Set Invariance (SenSeI) for stochastic optimization of (2.8) in Algorithm 1.
# Algorithm 1 SenSeI: Sensitive Set Invariance
<table><tr><td>inputs: starting point (0o,Xo), step sizes (nt)</td></tr><tr><td>repeat</td></tr><tr><td>(Xt1,Yt1),...,(Xtb,YtB)~P > sample mini-batch from P</td></tr><tr><td>xtb←argmax'∈x{dy(hθ(Xtb),h(x'))-Xtdx(Xtb,x')},b∈[B] generate worst-case examples</td></tr><tr><td></td></tr><tr><td>λt+1←max{0,Xt-ntp(∈-B∑b=1dx(Xtb,xtb)},</td></tr><tr><td>0t+1←t-nt(∑-{e(Yth(t)))+p{dy(h(Xt),(x)))) until converged</td></tr></table>
# 2.4 ADVERSARIAL TRAINING VS FAIR REGULARIZATION
Adversarial training is a popular approach to training invariant ML models. It was originally developed to defend ML models against adversarial examples (Goodfellow et al., 2014; Madry et al., 2017). There are many versions of adversarial training; the Wasserstein distributionally robust optimization (DRO) version by Sinha et al. (2017) is most closely related to (2.5). The direct goal of adversarial training is training ML models whose risk is small on adversarial examples, and the robust risk that adversarial training seeks to minimize (2.5) is exactly the risk on adversarial examples.
An indirect consequence of adversarial training is invariance to imperceptible changes to the inputs. Recall an adversarial example is a training example with the same label as a non-adversarial training example whose inputs differ imperceptibly from those of a training example. Thus (successful) adversarial training leads to ML models that ignore such imperceptible changes and are thus invariant in “imperceptible neighborhoods” of the training examples.
Unlike adversarial training, which leads to invariance as an indirect consequence of adversarial robustness, fair regularization enforces fairness by explicitly minimizing a fair regularizer. A key benefit of invariance regularization is it permits practitioners to fine-tune the trade-off between goodness-of-fit and invariance by adjusting the regularization parameter (see Figure 1).
# 2.5 RELATED WORK
There are three lines of work on enforcing individual fairness. There is a line of work that enforces group fairness with respect to many (possibly overlapping) groups to avoid disparate treatment of individuals (Hébert-Johnson et al., 2017; Kearns et al., 2017; Kim et al., 2018a;b). At a high-level, these methods repeatedly find groups in which group fairness is violated and updates the ML model to correct violations. Compared to these methods that approximate individual fairness with group fairness, we directly enforce individual fairness.
There is another line of work on enforcing individual fairness without knowledge of the similarity metric. Gillen et al. (2018); Rothblum & Yona (2018); Jung et al. (2019) reduce the problem of enforcing individual fairness to a supervised learning problem by minimizing the number of violations. Instead of a similarity metric, these algorithms rely on an oracle that detects violations of individual fairness. Garg et al. (2018) enforce individual fairness by penalizing the expected difference in predictions between counterfactual inputs. Instead of a similarity metric, this algorithm relies a way of generating counterfactual inputs. Our approach complements these methods by relying on a similarity metric instead of such oracles. This allows us to take advantage of recent work on learning fair metrics (Ilvento, 2019; Wang et al., 2019; Yurochkin et al., 2020; Mukherjee et al., 2020).
Most similar to our work is SenSR (Yurochkin et al., 2020) that also assumes access to a similarity metric. SenSR is based on adversarial training, i.e. it enforces a risk-based notion of individual fairness that only requires the risk of the ML model to be similar on similar inputs. In contrast, our method is based on fair regularization, i.e. it enforces a notion of individual fairness that requires the outputs of the ML model to be similar. The latter is stronger (it implies the former) and is much closer to Dwork et al.’s original definition. In addition, the risk-based notion of SenSR ties accuracy to fairness. Our approach separates these two (usually conflicting) goals and allows practitioners to more easily adjust the trade-off between accuracy and fairness as demonstrated in our experimental studies.
Finally, there is a line of work that proposes pre-processing techniques to learn a fair representation of the individuals and training an ML model that accepts the fair representation as input (Zemel et al., 2013; Bower et al., 2018; Madras et al., 2018; Lahoti et al., 2019). These works are complimentary to ours as we propose an in-processing algorithm.
# 3 THEORETICAL PROPERTIES OF SENSEI
In this section, we describe some theoretical properties of SenSeI. We defer all proofs to Appendix A. First, Algorithm 1 is an instance of a stochastic gradient method, and its convergence properties are well-studied. Even if $f ( w , Z )$ is non-convex in $w$ , the algorithm converges (globally) to a stationary point (see Appendix A for a rigorous statement). Second, the fair regularizer is data-dependent, and it is unclear whether minimizing its empirical counterpart (3.1) enforces distributional fairness. We show that the fair regularizer generalizes under standard conditions. Consequently,
1. it is possible for practitioners to certify that an ML model $h$ is DIF a posteriori by checking $\hat { R } ( h )$ (even if $h$ was trained by minimizing $\widehat { R } )$ ; 2. fair regularization enforces distributional individual fairness (as long as the hypothesis class includes DIF ML models);
Notation Let $\{ ( X _ { i } , Y _ { i } ) \} _ { i = 1 } ^ { n }$ be the training set and ${ \widehat { P } } _ { X }$ be the empirical distribution of the inputs. Define $\widehat { L } : \mathcal H \to \mathbf { R }$ as the empirical risk and $\widehat { R } : \mathcal { H } \to \mathbf { R }$ as the empirical counterpart of the fair regularizer $R$ (2.2):
$$\widehat { R } ( h ) \triangleq \left\{ \begin{array} { l l } { \operatorname* { m a x } _ { \Pi \in \Delta ( \mathcal { X } \times \mathcal { X } ) } } & { \mathbf { E } _ { \Pi } \big [ d y ( h ( X ) , h ( X ^ { \prime } ) ) \big ] } \\ { \mathrm { s u b j e c t ~ t o ~ } } & { \mathbf { E } _ { \Pi } \big [ d _ { \mathcal { X } } ( X , X ^ { \prime } ) \big ] \leq \epsilon } \\ & { \Pi ( \cdot , \mathcal { X } ) = \widehat { P } _ { X } , } \end{array} \right\} .$$
Define the loss class $\mathcal { L }$ and its counterpart for the fair regularizer as
$$\begin{array} { r l r } & { } & { \mathcal { L } \triangleq \{ \ell _ { h } : \mathcal { Z } \to { \bf R } \mid h \in \mathcal { H } \} , \quad \ell _ { h } ( z ) \triangleq \ell ( h ( x ) , y ) , } \\ & { } & { \mathcal { D } \triangleq \{ d _ { h } : \mathcal { X } \times \mathcal { X } \to { \bf R } _ { + } \mid h \in \mathcal { H } \} , \quad d _ { h } ( x , x ^ { \prime } ) \triangleq d _ { \mathcal { V } } ( h ( x ) , h ( x ^ { \prime } ) ) . } \end{array}$$
We measure the complexity of $\mathcal { D }$ and $\mathcal { L }$ with their entropy integrals with respect to to the uniform metric: $\begin{array} { r } { J ( \mathcal { D } / \mathcal { L } ) \triangleq \int _ { 0 } ^ { \infty } \log N ( \mathcal { D } / \mathcal { L } , \| \cdot \| _ { \infty } , \epsilon ) ^ { \frac { 1 } { 2 } } d \epsilon } \end{array}$ , where $N ( \mathcal { D } , \| \cdot \| _ { \infty } , \epsilon )$ is the $\epsilon$ -covering number of $\mathcal { D }$ in the uniform metric. The main benefit of using entropy integrals instead of Rademacher or Gaussian complexities to measure the complexity of $\mathcal { D }$ and $\mathcal { L }$ is it does not depend on the distribution of the training examples. This allows us to obtain generalization error bounds for counterfactual training sets that are similar to the (observed) training set. Finally, define the diameter of $\mathcal { X }$ in the $d _ { \mathcal { X } }$ metric, that of $\mathcal { V }$ in the $d _ { \mathcal { Y } }$ metric as $\begin{array} { r } { D _ { \mathcal { X } } \triangleq \operatorname* { s u p } _ { x , x ^ { \prime } \in \mathcal { X } } d _ { \mathcal { X } } ( x , x ^ { \prime } ) } \end{array}$ , $\begin{array} { r } { D _ { \mathcal { Y } } \triangleq \operatorname* { s u p } _ { y , y ^ { \prime } \in \mathcal { Y } } d _ { \mathcal { Y } } ( y , y ^ { \prime } ) } \end{array}$ . The first result shows that the fair regularizer $R ( h )$ generalizes. We assume $D _ { \mathcal { X } }$ , $D _ { c Y } < \infty$ . This is a boundedness condition on $\mathcal { X } \times \mathcal { V }$ , and it is a common simplifying assumption in statistical learning theory. We also assume $J ( \mathcal { D } ) < \infty$ . This is a standard assumption that appears in many uniform convergence results.
Theorem 3.1. As long as $D _ { \mathcal { X } } , D _ { \mathcal { Y } }$ , and $J ( { \mathcal { G } } )$ are all finite, with probability at least $1 - t$ :
$$\begin{array} { r } { \operatorname* { s u p } _ { h \in \mathcal { H } } | \widehat { R } ( h ) - R ( h ) | \leq \frac { 4 8 ( J ( \mathcal { D } ) + \frac { 1 } { \epsilon } D _ { \mathcal { X } } D _ { \mathcal { Y } } ) } { \sqrt { n } } + D _ { \mathcal { Y } } ( \frac { \log \frac { 2 } { t } } { 2 n } ) ^ { \frac { 1 } { 2 } } . } \end{array}$$
Theorem 3.1 implies it is possible to certify that an ML model $h$ satisfies distributional individual fairness (modulo error terms that vanish in the large-sample limit) by inspecting $\widehat { R } ( h )$ . This is important because a practitioner may inspect $\widehat { R } ( h )$ after training to verify whether the trained ML model $h$ is fair enough. Theorem 3.1 assures the user that $\widehat { R } ( h )$ is close to $R ( h )$ .
# 4 COMPUTATIONAL EXPERIMENTS
In this section we present empirical evidence that SenSeI trains individually fair ML models in practice and study the trade-off between accuracy and fairness parametrized by $\rho$ (defined in (2.6)).
Baselines We compare SenSeI to empirical risk minimization (Baseline) and two recent approaches for training individually fair ML models: Sensitive Subspace Robustness (SenSR) (Yurochkin et al., 2020) that uses DRO to achieve robustness to perturbations in a fair metric, and Counterfactual Logit Pairing (CLP) (Garg et al., 2018) that penalizes the differences in the output of an ML model on training examples and hand-crafted counterfactuals. We provide implementation details of SenSeI and the baselines in Appendix B.
# 4.1 TOXIC COMMENT DETECTION
We consider the task of training a classifier to identify toxic comments, i.e. rude or disrespectful messages in online conversations. Identifying and moderating toxic comments is crucial for facilitating inclusive online conversations. Data is available through the “Toxic Comment Classification Challenge” Kaggle competition. We utilize the subset of the dataset that is labeled with a range of identity contexts (e.g. “muslim”, “white”, “black”, “homosexual gay or lesbian”). Many of the toxic comments in the train data also relate to these identities leading to a classifier with poor test performance on the sets of comments with some of the identity contexts (group fairness violation) and prediction rule utilizing words such as “gay” to flag a comment as toxic (individual fairness violation). To obtain good features we use last layer representation of BERT (base, uncased) (Devlin et al., 2018) fine tuned on a separate subset of $5 0 0 \mathrm { k }$ randomly selected comments without identity labels. We then train a 2000 hidden units neural network with these BERT features.
Counterfactuals and fair metric. CLP (Garg et al., 2018) requires defining a set of counterfactual tokens. The training proceeds by taking an input comment and if it contains a counterfactual token replacing it with another random counterfactual token. For example, if “gay” and “straight” are among the counterfactual tokens, comment “Some people are gay” may be modified to “Some people are straight”. Then difference in logit outputs of the classifier on the original and modified comments is used as a regularizer. For toxicity classification Garg et al. (2018) adopted a set of 50 counterfactual tokens from (Dixon et al., 2018). Counterfactuals allow for a simple fair metric learning procedure via factor analysis: since any variation in representation of a data point and its counterfactuals is considered undesired, Yurochkin et al. (2020); Mukherjee et al. (2020) proposed to use a Mahalanobis metric with the major directions of variation among counterfactuals projected out. We utilize this approach here to obtain fair metric for training SenSR (Yurochkin et al., 2020) and SenSeI. See Appendix B.1 for additional details regarding the fair metric construction in the experiments.
Table 1: Summary of Toxicity classification experiment over 10 restarts
<table><tr><td></td><td>BA</td><td>CTF score</td><td>PC</td><td>BA STD</td><td>ACC STD</td></tr><tr><td>Baseline</td><td>0.807±0.002</td><td>0.072±0.002</td><td>0.621±0.014</td><td>0.044±0.003</td><td>0.081±0.004</td></tr><tr><td>SenSeI</td><td>0.791±0.005</td><td>0.029±0.005</td><td>0.773±0.043</td><td>0.035±0.003</td><td>0.052±0.003</td></tr><tr><td>SenSR</td><td>0.794±0.003</td><td>0.043±0.005</td><td>0.729±0.044</td><td>0.036±0.002</td><td>0.059±0.004</td></tr><tr><td>CLP</td><td>0.795±0.006</td><td>0.032±0.006</td><td>0.763±0.048</td><td>0.038±0.003</td><td>0.056±0.004</td></tr></table>
Table 2: Summary of Bios classification experiment over 10 restarts
<table><tr><td></td><td>BA</td><td>CTF score</td><td>PC</td><td>Gap RMS</td><td>Gap ABS</td></tr><tr><td>Baseline</td><td>0.842±0.002</td><td>0.028±0.001</td><td>0.942±0.001</td><td>0.120±0.004</td><td>0.080±0.003</td></tr><tr><td>SenSeI</td><td>0.843±0.003</td><td>0.003±0.000</td><td>0.977±0.001</td><td>0.086±0.005</td><td>0.054±0.003</td></tr><tr><td>SenSR</td><td>0.842±0.003</td><td>0.004±0.000</td><td>0.976±0.001</td><td>0.087±0.004</td><td>0.054±0.003</td></tr><tr><td>CLP</td><td>0.841±0.003</td><td>0.005±0.000</td><td>0.974±0.001</td><td>0.087±0.005</td><td>0.056±0.004</td></tr></table>
Comparison metrics. To evaluate individual fairness of the classifiers we use test data and 50 counterfactuals to check if the classifier toxicity decision varies across counterfactuals. For example, is prediction for “Some people are gay” same as for “Some people are straight”? An intuitive fair metric should be 0 on a pair of such comments and prediction of the classifier should not change based on the Dwork et al.’s individual fairness definition. We report Counterfactual Token Fairness (CTF) score (Garg et al., 2018) that quantifies variance across counterfactuals of the predicted probability that a comment is toxic, and Prediction Consistency (PC) equal to the portion of test comments where prediction is the same across all 50 counterfactual variations.
For goodness-of-fit we use balanced accuracy due to class imbalance. To quantify group fairness we follow accuracy parity notion (Zafar et al., 2017; Zhao et al., 2019). Here protected groups correspond to the identity context labels available in the data and accuracy parity quantifies whether a classifier is equally accurate on, e.g., comments labeled to have “white” context and those labeled with “black”. There are 9 protected groups and we report standard deviation of the accuracies and balanced accuracies across them. We present mathematical expressions for each of the metrics in Appendix C for completeness.
Results. We repeat our experiment 10 times with random 70-30 train-test splits, every time utilizing a random subset of 25 counterfactuals during training. Results are summarized in Table 1. SenSeI on average outperforms other fair training methods on all individual and group fairness metrics at the cost of slightly lower balanced accuracy. SenSR has the lowest prediction consistency score suggesting that our fair regularization is more effective in enforcing individual fairness than adversarial training. This observation aligns with the empirical study by Yang et al. (2019) comparing various invariance enforcing techniques for spatial robustness in image recognition.
SenSeI also outperforms CLP: our approach uses optimization to find worst case perturbations of the data according to a fair metric induced by counterfactuals, while CLP chooses a random perturbation among the counterfactuals. SenSeI is searching for a perturbation on every data point that potentially allows to generalize to unseen counterfactuals, while CLP can only perturb comments that explicitly contain a counterfactual known during training time. In Figure 2 we verify that both SenSeI and CLP allow to “trade” fairness and accuracy by varying the regularization strength $\rho$ (in the table we used $\rho = 5$ for both). We also notice the effect of worst case optimization opposed to random sampling: SenSeI has higher prediction consistency at the cost of balanced accuracy.
# 4.2 OCCUPATION PREDICTION
Online professional presence via dedicated services or personal websites is the common practice in many industries. ML systems can be trained using data from these sources to identify person’s occupation and used by recruiters to assist in finding suitable candidates for the job openings. Gender imbalances in occupations may trigger biases in such ML systems exacerbating societal inequality. De-Arteaga et al. (2019) proposed Bias in Bios dataset to study fairness in occupation prediction from a person’s bio. The dataset consists of $4 0 0 \mathrm { k }$ textual bio descriptions and the goal is to predict one of the 28 occupations. We again use BERT fine-tuned on the train data to obtain bio representations and then train a 2000 hidden neurons neural networks using each of the fair training methods.
 Figure 2: Balanced accuracy (BA) and prediction consistency (PC) trade-off.
Table 3: Adult experiment over 10 restarts. Prior methods are duplicated from Yurochkin et al. (2020)
<table><tr><td></td><td>BA,%</td><td>S-Con.</td><td>GR-Con.</td><td>GapG RMS</td><td>GapR RMS</td><td>GapG max</td><td>GapR max</td></tr><tr><td>SenSR</td><td>78.9</td><td>.934</td><td>.984</td><td>.068</td><td>.055</td><td>.087</td><td>.067</td></tr><tr><td>Baseline</td><td>82.9</td><td>.848</td><td>.865</td><td>.179</td><td>.089</td><td>.216</td><td>.105</td></tr><tr><td>Project</td><td>82.7</td><td>.868</td><td>1.00</td><td>.145</td><td>.064</td><td>.192</td><td>.086</td></tr><tr><td>Adv. debiasing</td><td>81.5</td><td>.807</td><td>.841</td><td>.082</td><td>.070</td><td>.110</td><td>.078</td></tr><tr><td>CoCL</td><td>79.0</td><td>1</td><td>1</td><td>.163</td><td>.080</td><td>.201</td><td>.109</td></tr><tr><td>SenSeI (p= 40)</td><td>76.8</td><td>.945</td><td>.963</td><td>.043</td><td>.054</td><td>.053</td><td>.064</td></tr></table>
Counterfactuals and fair metric. Counterfactuals definition for this problem is the gender analog of the Bertrand & Mullainathan (2004) investigation of the racial bias in the labor market. For each bio we create a counterfactual bio by replacing male pronouns with the corresponding female ones and vice a versa. For the fair metric we use same approach as in the Toxicity study.
Comparison metrics. We use the same individual fairness metrics. To compare group fairness we report root mean squared gap (Gap RMS) and mean absolute gap (Gap ABS) between male and female true positive rates for each of the occupations following prior studies of this dataset (Romanov et al., 2019; Prost et al., 2019). For performance we report balanced accuracy due to imbalance in occupation proportions in the data.
Results. We repeat the experiment 10 times with 70-30 train-test splits and summarize results in Table 2 (for SenSeI and CLP we set $\rho = 5$ ). Comparing to the Toxicity experiment, we note that individual fairness metrics are much better. In particular, attaining prediction consistency is easier because there is only one type of counterfactuals. Overall, fairness metrics are comparable across fair training methods with a slight SenSeI advantage. It is interesting to note mild accuracy improvement: learning a classifier invariant to gender can help to avoid spurious correlations between occupations and gender present in the data. We present fairness accuracy “trade-off” in Figure 2 — increasing regularization strength has clear upward trend in terms of the prediction consistency without decreasing accuracy. This experiments is an example where fairness can be improved without ”trading” performance.
We note two prior group fairness studies of the Bios dataset: Romanov et al. (2019) and Prost et al. (2019). Both reported worse classification results and fairness metrics. Better classification performance in our work is likely attributed to using BERT for obtaining bios feature vectors. For the group fairness, we note that relative to baseline improvement with SenSeI is more significant.
# 4.3 INCOME PREDICTION
The Adult dataset (Bache & Lichman, 2013) is a common benchmark in the group fairness literature. The task is to predict if a person earns more than $\$ 50\mathbf { k }$ per year using information about their education, gender, race, marital status, hours worked per week, etc. Yurochkin et al. (2020) studied individual fairness on Adult by considering prediction consistency with respect to demographic features: race and gender (GR-Con.) and marital status (S-Con., i.e. spouse consistency). To quantify group fairness they used RMS gaps and maximum gaps between true positive rates across genders $\bar { ( \mathrm { G a p } _ { G } ^ { \mathrm { R M S } } }$ and ${ \mathrm { G a p } } _ { G } ^ { \operatorname* { m a x } } ,$ ) and races ${ ( \mathrm { G a p } _ { R } ^ { \mathrm { R M S } } }$ and ${ \mathrm { G a p } } _ { R } ^ { \operatorname* { m a x } } .$ ). Due to class imbalance, performance is quantified with balanced accuracy (B-Acc). For the fair metric they used Mahalanobis distance with race, gender and a logistic regression vector predicting gender projected out. We note that CLP was proposed as a fair training method for text classification (Garg et al., 2018) and is not applicable on Adult because it is not clear how to define counterfactuals. We compare SenSeI to results reported in Yurochkin et al. (2020). In Table 3 we show that with sufficiently large regularization strength $\rho = 4 0$ SenSeI is able to further reduce all group fairness gaps and improve one of the individual fairness metrics, however trading off some accuracy.
# 5 SUMMARY AND DISCUSSION
In this paper, we studied a regularization approach to enforcing individual fairness. We defined distributional individual fairness, a variant of Dwork et al.’s original definition of individual fairness and a data-dependent regularizer that enforces this distributional fairness (see Definition 2.1). We also developed a stochastic approximation algorithm to solve regularized empirical risk minimization problems and showed that it trains ML models with distributional fairness guarantees. Finally, we showed that the algorithm mitigates algorithmic bias on three ML tasks that are susceptible to such biases: income-level classification, occupation prediction, and toxic comment detection.
# ACKNOWLEDGEMENTS
This paper is based upon work supported by the National Science Foundation (NSF) under grants no. 1830247 and 1916271. Any opinions, findings, and conclusions or recommendations expressed in this paper are those of the authors and do not necessarily reflect the views of the NSF.
# REFERENCES
K. Bache and M. Lichman. UCI machine learning repository. 2013.
Marianne Bertrand and Esther Duflo. Field Experiments on Discrimination. Technical Report w22014, National Bureau of Economic Research, Cambridge, MA, February 2016.
Marianne Bertrand and Sendhil Mullainathan. Are Emily and Greg More Employable Than Lakisha and Jamal? A Field Experiment on Labor Market Discrimination. American Economic Review, 94 (4):991–1013, September 2004. ISSN 0002-8282. doi: 10.1257/0002828042002561.
Jose Blanchet and Karthyek R. A. Murthy. Quantifying Distributional Model Risk via Optimal Transport. arXiv:1604.01446 [math, stat], April 2016.
Amanda Bower, Laura Niss, Yuekai Sun, and Alexander Vargo. Debiasing representations by removing unwanted variation due to protected attributes. arXiv:1807.00461 [cs], July 2018.
Maria De-Arteaga, Alexey Romanov, Hanna Wallach, Jennifer Chayes, Christian Borgs, Alexandra Chouldechova, Sahin Geyik, Krishnaram Kenthapadi, and Adam Tauman Kalai. Bias in Bios: A Case Study of Semantic Representation Bias in a High-Stakes Setting. Proceedings of the Conference on Fairness, Accountability, and Transparency - FAT\* ’19, pp. 120–128, 2019. doi: 10.1145/3287560.3287572.
Jacob Devlin, Ming-Wei Chang, Kenton Lee, and Kristina Toutanova. BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding. arXiv:1810.04805 [cs], October 2018.
Lucas Dixon, John Li, Jeffrey Sorensen, Nithum Thain, and Lucy Vasserman. Measuring and Mitigating Unintended Bias in Text Classification. In Proceedings of the 2018 AAAI/ACM Conference on AI, Ethics, and Society - AIES ’18, pp. 67–73, New Orleans, LA, USA, 2018. ACM Press. ISBN 978-1-4503-6012-8. doi: 10.1145/3278721.3278729.
Cynthia Dwork, Moritz Hardt, Toniann Pitassi, Omer Reingold, and Rich Zemel. Fairness Through Awareness. arXiv:1104.3913 [cs], April 2011.
Sahaj Garg, Vincent Perot, Nicole Limtiaco, Ankur Taly, Ed H. Chi, and Alex Beutel. Counterfactual Fairness in Text Classification through Robustness. arXiv:1809.10610 [cs, stat], September 2018.
Saeed Ghadimi and Guanghui Lan. Stochastic First- and Zeroth-order Methods for Nonconvex Stochastic Programming. arXiv:1309.5549 [cs, math, stat], September 2013.
Stephen Gillen, Christopher Jung, Michael Kearns, and Aaron Roth. Online Learning with an Unknown Fairness Metric. arXiv:1802.06936 [cs], February 2018.
Ian J. Goodfellow, Jonathon Shlens, and Christian Szegedy. Explaining and Harnessing Adversarial Examples. December 2014.
Úrsula Hébert-Johnson, Michael P. Kim, Omer Reingold, and Guy N. Rothblum. Calibration for the (Computationally-Identifiable) Masses. arXiv:1711.08513 [cs, stat], November 2017.
Christina Ilvento. Metric Learning for Individual Fairness. arXiv:1906.00250 [cs, stat], June 2019.
Christopher Jung, Michael Kearns, Seth Neel, Aaron Roth, Logan Stapleton, and Zhiwei Steven Wu. Eliciting and Enforcing Subjective Individual Fairness. arXiv:1905.10660 [cs, stat], May 2019.
Harini Kannan, Alexey Kurakin, and Ian Goodfellow. Adversarial Logit Pairing. arXiv:1803.06373 [cs, stat], March 2018.
Michael Kearns, Seth Neel, Aaron Roth, and Zhiwei Steven Wu. Preventing Fairness Gerrymandering: Auditing and Learning for Subgroup Fairness. arXiv:1711.05144 [cs], November 2017.
Michael P. Kim, Amirata Ghorbani, and James Zou. Multiaccuracy: Black-Box Post-Processing for Fairness in Classification. arXiv:1805.12317 [cs, stat], May 2018a.
Michael P. Kim, Omer Reingold, and Guy N. Rothblum. Fairness Through Computationally-Bounded Awareness. arXiv:1803.03239 [cs], March 2018b.
Preethi Lahoti, Krishna P. Gummadi, and Gerhard Weikum. iFair: Learning Individually Fair Data Representations for Algorithmic Decision Making. arXiv:1806.01059 [cs, stat], February 2019.
Jaeho Lee and Maxim Raginsky. Minimax Statistical Learning with Wasserstein Distances. arXiv:1705.07815 [cs], May 2017.
David Luenberger. OPTIMIZATION BY VECTOR SPACE METHODS. John Wiley & Sons, 1968.
David Madras, Elliot Creager, Toniann Pitassi, and Richard Zemel. Learning Adversarially Fair and Transferable Representations. arXiv:1802.06309 [cs, stat], February 2018.
Aleksander Madry, Aleksandar Makelov, Ludwig Schmidt, Dimitris Tsipras, and Adrian Vladu. Towards Deep Learning Models Resistant to Adversarial Attacks. arXiv:1706.06083 [cs, stat], June 2017.
Cade Metz and Adam Satariano. An Algorithm That Grants Freedom, or Takes It Away. The New York Times, February 2020. ISSN 0362-4331.
Debarghya Mukherjee, Mikhail Yurochkin, Moulinath Banerjee, and Yuekai Sun. Two simple ways to learn individual fairness metrics from data. In International Conference on Machine Learning, July 2020.
Flavien Prost, Nithum Thain, and Tolga Bolukbasi. Debiasing Embeddings for Reduced Gender Bias in Text Classification. arXiv:1908.02810 [cs, stat], August 2019.
R. Tyrrell Rockafellar and Roger J.-B. Wets. Variational Analysis. Number 317 in Grundlehren Der Mathematischen Wissenschaften. Springer, Berlin, corr. 2nd print edition, 2004. ISBN 978-3-540-62772-2.
Alexey Romanov, Maria De-Arteaga, Hanna Wallach, Jennifer Chayes, Christian Borgs, Alexandra Chouldechova, Sahin Geyik, Krishnaram Kenthapadi, Anna Rumshisky, and Adam Tauman Kalai. What’s in a Name? Reducing Bias in Bios without Access to Protected Attributes. arXiv:1904.05233 [cs, stat], April 2019.
Guy N. Rothblum and Gal Yona. Probably Approximately Metric-Fair Learning. arXiv:1803.03242 [cs], March 2018.
Aman Sinha, Hongseok Namkoong, and John Duchi. Certifying Some Distributional Robustness with Principled Adversarial Training. arXiv:1710.10571 [cs, stat], October 2017.
Hanchen Wang, Nina Grgic-Hlaca, Preethi Lahoti, Krishna P. Gummadi, and Adrian Weller. An Empirical Study on Learning Fairness Metrics for COMPAS Data with Human Supervision. arXiv:1910.10255 [cs], October 2019.
Fanny Yang, Zuowen Wang, and Christina Heinze-Deml. Invariance-inducing regularization using worst-case transformations suffices to boost accuracy and spatial robustness. arXiv:1906.11235 [cs, stat], June 2019.
Mikhail Yurochkin, Amanda Bower, and Yuekai Sun. Training individually fair ML models with sensitive subspace robustness. In International Conference on Learning Representations, Addis Ababa, Ethiopia, 2020.
Muhammad Bilal Zafar, Isabel Valera, Manuel Gomez Rodriguez, and Krishna P. Gummadi. Fairness Beyond Disparate Treatment & Disparate Impact: Learning Classification without Disparate Mistreatment. Proceedings of the 26th International Conference on World Wide Web - WWW ’17, pp. 1171–1180, 2017. doi: 10.1145/3038912.3052660.
Rich Zemel, Yu Wu, Kevin Swersky, Toni Pitassi, and Cynthia Dwork. Learning Fair Representations. In International Conference on Machine Learning, pp. 325–333, February 2013.
Han Zhao, Amanda Coston, Tameem Adel, and Geoffrey J. Gordon. Conditional Learning of Fair Representations. In International Conference on Learning Representations, September 2019.
# A THEORETICAL PROPERTIES
We collect the proofs of all the theoretical results in the paper here. We restate the results before proving them for the reader’s convenience. We assume that $( \mathcal { X } , d _ { \mathcal { X } } )$ and $( \mathcal { V } , d _ { \mathcal { V } } )$ are complete and separable metric spaces (Polish spaces).
# A.1 DIF AND INDIVIDUAL FAIRNESS
Proposition A.1 (Proposition 2.3). If $h : \mathcal { X } \to \mathcal { Y }$ is $( \epsilon , \delta )$ -DIF, then
$$\begin{array} { r } { P _ { X } ( \operatorname* { s u p } _ { d _ { \mathcal { X } } ( x , x ^ { \prime } ) \leq \epsilon } d y ( h ( x ) , h ( x ^ { \prime } ) ) \geq \tau ) \leq \frac { \delta } { \tau } . } \end{array}$$
Proof. Recall
$$\begin{array} { r } { T _ { \mathrm { I F } } \triangleq \arg \operatorname* { m a x } _ { d _ { \mathcal { X } } ( x , x ^ { \prime } ) \leq \epsilon } d _ { \mathcal { Y } } ( h ( x ) , h ( x ^ { \prime } ) ) . } \end{array}$$
is feasible for (the Mongé version of) (2.2). Thus $R ( h ) \leq \delta$ implies ${ \bf E } _ { P x } \left[ d y ( X , T _ { \mathrm { I F } } ( X ) ) \right] \leq \delta$ Markov’s inequality implies $\begin{array} { r } { P _ { X } ( d _ { \mathcal { V } } ( X , T _ { \mathrm { I F } } ( X ) ) \ge \tau ) \le \frac { \delta } { \tau } } \end{array}$ for any $\tau > 0$ . □
# A.2 CONVERGENCE PROPERTIES OF SENSEI
Algorithm 1 is an instance of a stochastic gradient method, and its convergence properties are wellstudied. Even if $f ( w , Z )$ is non-convex in $w$ , the algorithm converges (globally) to a stationary point. This a well-known result in stochastic approximation, and we state it here for completeness.
Theorem A.2 (Ghadimi & Lan (2013)). Let
$$\begin{array} { r } { \sigma ^ { 2 } \geq { \bf E } \big [ \| \frac { 1 } { B } \sum _ { b = 1 } ^ { B } \partial _ { w } f ( w , Z _ { b } ) - \partial F ( w ) \| _ { 2 } ^ { 2 } \big ] } \end{array}$$
e an upper bound of the variance of the stochastic gradient. As long as $F$ is $L$ -strongly smooth,
$$\begin{array} { r } { F ( w ^ { \prime } ) \leq F ( w ) + \langle \partial F ( w ) , w ^ { \prime } - w \rangle + \frac { L } { 2 } \| w - w ^ { \prime } \| _ { 2 } ^ { 2 } } \end{array}$$
for any $w , w ^ { \prime } \in \Theta \times \mathbf { R } _ { + }$ , then Algorithm $\cdot$ with constant step sizes $\begin{array} { r } { \eta _ { t } = \big ( \frac { 2 B \epsilon _ { 0 } } { L \sigma ^ { 2 } T } \big ) ^ { \frac { 1 } { 2 } } } \end{array}$ satisfies
$$\begin{array} { r } { \frac { 1 } { T } \sum _ { t = 1 } ^ { T } \mathbf { E } \big [ \| \partial F ( w _ { t } ) \| _ { 2 } ^ { 2 } \big ] \leq \sigma ( \frac { 8 L \epsilon _ { 0 } } { B T } ) , } \end{array}$$
where $\epsilon _ { \mathrm { 0 } }$ is any upper bound of the suboptimality of $w _ { 0 }$
In other words, Algorithm 1 finds an $\epsilon$ -stationary point of (2.8) in at most $O ( \textstyle { \frac { 1 } { \epsilon ^ { 2 } } } )$ iterations. If $F$ has more structure (e.g. convexity), then Algorithm 1 may converge faster.
# A.3 PROOF OF DUALITY RESULTS IN SECTION 2
Theorem A.3 (Theorem 2.4). If $d y ( h ( x ) , h ( x ^ { \prime } ) ) - \lambda d _ { \mathcal { X } } ( x , x ^ { \prime } )$ is continuous (in $( x , x ^ { \prime } ) )$ for any $\lambda \geq 0$ , then
$$\begin{array} { r l r } & { } & { R ( h ) = \operatorname* { i n f } _ { \lambda \ge 0 } \{ \lambda \epsilon + { \bf E } _ { P _ { X } } \left[ r _ { \lambda } ( h , X ) \right] \} , } \\ & { } & { r _ { \lambda } ( h , X ) \triangleq \operatorname* { s u p } _ { x ^ { \prime } \in \mathcal { X } } \{ d _ { \mathcal { V } } ( h ( X ) , h ( x ^ { \prime } ) ) - \lambda d _ { \mathcal { X } } ( X , x ^ { \prime } ) \} . } \end{array}$$
Proof. We abuse notation and denote the function $d y ( h ( x ) , h ( x ^ { \prime } ) )$ as $d _ { \mathcal { Y } } \circ h$ . We recognize the optimization problem in (2.2) as an (infinite dimensional) linear optimization problem:
$$R ( h ) \triangleq \left\{ \begin{array} { l l } { \operatorname* { s u p } _ { \Pi : \Delta ( \mathcal { X } \times \mathcal { X } ) } } & { \langle \Pi , d _ { \mathcal { Y } } \circ h \rangle = \mathbf { E } _ { \Pi } \big [ d _ { \mathcal { Y } } ( h ( X ) , h ( X ^ { \prime } ) ) \big ] } \\ { \mathrm { s u b j e c t ~ t o ~ } } & { \langle \Pi , d _ { \mathcal { X } } \rangle = \mathbf { E } _ { \Pi } \big [ d _ { \mathcal { X } } ( X , X ^ { \prime } ) \big ] \leq \epsilon } \\ & { \Pi ( \cdot , \mathcal { X } ) = P _ { \mathcal { X } } , } \end{array} \right.$$
It is not hard check Slater’s condition: $d \Pi ( x , x ^ { \prime } ) = { \bf 1 } \{ x = x ^ { \prime } \} d P ( x )$ is strictly feasible. Thus we have strong duality (see Theorem 8.7.1 in (Luenberger, 1968)):
$$\begin{array} { r l r } & { } & { R ( h ) = \operatorname* { s u p } _ { \Pi : \Pi ( \cdot , \mathcal { X } ) = P _ { X } } \operatorname* { i n f } _ { \lambda \geq 0 } \langle \Pi , d _ { \mathcal { Y } } \circ h \rangle + \lambda ( \epsilon - \langle \Pi , d _ { \mathcal { X } } \rangle ) } \\ & { } & { \quad = \operatorname* { s u p } _ { \Pi : \Pi ( \cdot , \mathcal { X } ) = P _ { X } } \operatorname* { i n f } _ { \lambda \geq 0 } \lambda \epsilon + \langle \Pi , d _ { \mathcal { Y } } \circ h - \lambda d _ { \mathcal { X } } \rangle \quad } \\ & { } & { \quad = \operatorname* { i n f } _ { \lambda \geq 0 } \{ \lambda \epsilon + \operatorname* { s u p } _ { \Pi : \Pi ( \cdot , \mathcal { X } ) = P _ { X } } \langle \Pi , d _ { \mathcal { Y } } \circ h - \lambda d _ { \mathcal { X } } \rangle \} , } \end{array}$$
It remains to show
$$\begin{array} { r } { \operatorname* { s u p } _ { \Pi : \Pi ( \cdot , x ) = P } \langle d _ { \mathcal { Y } } \circ h - \lambda d _ { \mathcal { X } } , \Pi \rangle = \mathbf { E } _ { P } \left[ \operatorname* { s u p } _ { x ^ { \prime } \in \mathcal { X } } \{ d _ { \mathcal { Y } } ( h ( X ) , h ( x ^ { \prime } ) ) - \lambda d _ { \mathcal { X } } ( X , x ^ { \prime } ) \} \right] . } \end{array}$$
$\leq$ direction The integrands in (A.1) satisfy
( $\begin{array} { r } { d _ { \mathcal { V } } \circ h - \lambda d _ { \mathcal { X } } ) ( x , x ^ { \prime } ) = d _ { \mathcal { V } } ( h ( x ) , h ( x ^ { \prime } ) ) - \lambda d _ { \mathcal { X } } ( x , x ^ { \prime } ) \leq \operatorname* { s u p } _ { x ^ { \prime } \in \mathcal { X } } \big \{ d _ { \mathcal { V } } ( h ( x ) , h ( x ^ { \prime } ) ) - \lambda d _ { \mathcal { X } } ( x , x ^ { \prime } ) \big \} , } \end{array}$ so the integrals satisfy the $\leq$ version of (A.1).
$\geq$ direction Let $\mathcal { Q }$ be the set of all Markov kernels from $\mathcal { X }$ to $\mathcal { X }$ . We have
$$\begin{array} { r l r } { { \operatorname* { s u p } _ { \Pi : \Pi ( \cdot , \mathcal { X } ) = P } \langle d y \circ h - \lambda d _ { \mathcal { X } } , \Pi \rangle = \operatorname* { s u p } _ { Q \in \mathcal { Q } } \int _ { \mathcal { X } \times \mathcal { X } } d y ( h ( x ) , h ( x ^ { \prime } ) ) - \lambda d _ { \mathcal { X } } ( x , x ^ { \prime } ) d Q ( x ^ { \prime } \mid x ) d P ( x ) } } \\ & { } & { \ge \operatorname* { s u p } _ { T : \mathcal { X } \to \mathcal { X } } \int _ { \mathcal { X } } d y ( h ( x ) , h ( T ( x ) ) ) - \lambda d _ { \mathcal { X } } ( x , T ( x ) ) d P ( x ) , } \end{array}$$
where we recalled $Q ( A \mid x ) = \mathbf { 1 } \{ T ( x ) \in A \}$ is a Markov kernel in the second step. (Technically, in the second step, we only sup over $T$ ’s that are decomposable (see Definition 14.59 in Rockafellar & Wets (2004)) with respect to $P$ , but we gloss over this detail here.) We appeal to the technology of integrands (Rockafellar & Wets, 2004) to interchange integration and maximization. We assumed $d _ { \mathscr { y } } \circ h - \lambda d _ { \mathscr { x } }$ is continuous, so it is a normal integrand (see Corollary 14.34 in Rockafellar & Wets (2004)). Thus it is OK to interchange integration and maximization (see Theorem 14.60 in Rockafellar & Wets (2004)):
$$\operatorname* { s u p } _ { T : \mathcal { X } \to \mathcal { X } } \int _ { \mathcal { X } } d y ( h ( x ) , h ( T ( x ) ) ) - \lambda d _ { \mathcal { X } } ( x , T ( x ) ) d P ( x ) = \int _ { \mathcal { X } } \operatorname* { s u p } _ { x ^ { \prime } \in \mathcal { X } } \left\{ d y ( h ( x ) , h ( x ^ { \prime } ) ) - \lambda d _ { \mathcal { X } } ( x , x ^ { \prime } ) \right\} d P ( x ) .$$
This shows the $\geq$ direction of (A.1).
We remark that it is not necessary to rely on the technology of normal integrands to interchange expectation and maximization in the proof of Theorem 2.4. For example, Blanchet & Murthy (2016) prove a similar strong duality result without resorting to normal integrands. We do so here to simplify the proof.
# A.4 PROOFS OF GENERALIZATION RESULTS IN SECTION 3
Theorem A.4 (Theorem 3.1). As long as $D _ { \mathcal { X } } , D _ { \mathcal { Y } } , J ( \mathcal { G } )$ are all finite,
$$\begin{array} { r } { \operatorname* { s u p } _ { f \in \mathcal { F } } | \mathbf { E } _ { \widehat { P } } \big [ f ( Z ) \big ] - \mathbf { E } _ { P } \big [ f ( Z ) \big ] | \leq \frac { 4 8 ( J ( \mathcal { D } ) + \frac { 1 } { \epsilon } D x D y ) } { \sqrt { n } } + D y ( \frac { \log \frac { 2 } { t } } { 2 n } ) ^ { \frac { 1 } { 2 } } } \end{array}$$
with probability at least $1 - t$ .
Proof. Let
$$\widehat { R } ( h ) \triangleq \left\{ \begin{array} { l l } { \operatorname* { m a x } _ { \Pi \in \Delta ( \mathcal { X } \times \mathcal { X } ) } } & { \mathbf { E } _ { \Pi } \big [ d y ( h ( X ) , h ( X ^ { \prime } ) ) \big ] } \\ { \mathrm { s u b j e c t ~ t o ~ } } & { \mathbf { E } _ { \Pi } \big [ d _ { \mathcal { X } } ( X , X ^ { \prime } ) \big ] \leq \epsilon } \\ & { \Pi ( \cdot , \mathcal { X } ) = \widehat { P } _ { X } , } \end{array} \right\} .$$
where ${ \widehat { P } } _ { X }$ is the empirical distribution of the inputs in the training set. By Theorem 2.4, we have
$$\begin{array} { r l } & { \widehat { R } ( h ) - R ( h ) = \operatorname* { i n f } _ { \lambda \geq 0 } \{ \lambda \epsilon + \mathbf { E } _ { \widehat { P } _ { X } } \left[ r _ { \lambda } ( h , X ) \right] \} - \operatorname* { i n f } _ { \lambda \geq 0 } \{ \lambda \epsilon + \mathbf { E } _ { P _ { X } } \left[ r _ { \lambda } ( h , X ) \right] \} } \\ & { \qquad = \operatorname* { i n f } _ { \lambda \geq 0 } \{ \lambda \epsilon + \mathbf { E } _ { \widehat { P } _ { X } } \left[ r _ { \lambda } ( h , X ) \right] \} - \lambda _ { * } \epsilon - \mathbf { E } _ { \widehat { P } _ { X } } \left[ r _ { \lambda _ { * } } ( h , X ) \right] } \\ & { \qquad \leq \mathbf { E } _ { \widehat { P } _ { X } } \left[ r _ { \lambda _ { * } } ( h , X ) \right] \} - \mathbf { E } _ { P _ { X } } \left[ r _ { \lambda _ { * } } ( h , X ) \right] , } \end{array}$$
where $\begin{array} { r } { \lambda _ { * } \in \arg \operatorname* { m i n } _ { \lambda \geq 0 } \lambda \epsilon + \mathbf { E } _ { P _ { X } } \left[ r _ { \lambda } ( h , X ) \right] } \end{array}$ . The infimum is attained because
$$\begin{array} { r } { \operatorname* { i n f } _ { \lambda \ge 0 } \{ \lambda \epsilon + \mathbf { E } _ { P _ { X } } \left[ r _ { \lambda } ( h , X ) \right] \} } \end{array}$$
is an strictly feasible (infinite-dimensional) linear optimization problem (see proof of Theorem 2.4). To bound $\lambda _ { * }$ , we observe that $r _ { \lambda } ( h , X ) \ge 0$ for any $h \in { \mathcal { H } } , \lambda \geq 0$ :
$$\begin{array} { r l } & { r _ { \lambda } ( h , X ) = \operatorname* { s u p } _ { x ^ { \prime } \in { \mathcal { X } } } \{ d _ { { \mathcal { V } } } ( h ( X ) , h ( x ^ { \prime } ) ) - \lambda d _ { { \mathcal { X } } } ( X , x ^ { \prime } ) \} } \\ & { \qquad \geq d _ { { \mathcal { V } } } ( h ( X ) , h ( X ) ) - \lambda d _ { { \mathcal { X } } } ( X , X ) . } \end{array}$$
This implies
$$R ( h ) = \lambda _ { * } \epsilon + \mathbb { E } _ { P _ { X } } \left[ r _ { \lambda _ { * } } ( h , X ) \right] \geq \lambda _ { * } \epsilon .$$
We rearrange to obtain a bound on $\lambda _ { * }$ :
$$\lambda _ { * } \leq \frac { 1 } { \epsilon } R ( h ) \leq \frac { 1 } { \epsilon } D _ { \mathscr { y } } \triangleq \bar { \lambda } .$$
This is admittedly a crude bound, but it is good enough here. Similarly,
$$R ( h ) - \widehat { R } ( h ) \leq { \bf E } _ { P _ { X } } \left[ r _ { \widehat { \lambda } _ { * } } ( h , X ) \right] \} - { \bf E } _ { \widehat { P } _ { X } } \left[ r _ { \widehat { \lambda } _ { * } } ( h , X ) \right] ,$$
where $\begin{array} { r } { \widehat { \lambda } _ { * } \in \arg \operatorname* { m i n } _ { \lambda \geq 0 } \lambda \epsilon + \mathbf { E } _ { \widehat { P } _ { X } } \left[ r _ { \lambda } ( h , X ) \right] } \end{array}$ , and $\widehat { \lambda } _ { * } \leq \bar { \lambda }$ . Combining (A.2) and (A.4), we obtain
$$\begin{array} { r } { | \widehat { R } ( h ) - R ( h ) | \leq \operatorname* { s u p } _ { f \in \mathcal { F } } \big | \mathbf { E } _ { \widehat { P } } \big [ f ( Z ) \big ] - \mathbf { E } _ { P } \big [ f ( Z ) \big ] \big | , } \end{array}$$
where $\mathcal { F } \triangleq \{ r _ { \lambda } ( h , \cdot ) \ | \ h \in \mathcal { H } , \lambda \in [ 0 , \bar { \lambda } ] \}$ . It is possible to bound $\begin{array} { r } { \operatorname* { s u p } _ { f \in \mathcal { F } } | \mathbf { E } _ { \widehat { P } } \big [ f ( Z ) \big ] - \mathbf { E } _ { P } \big [ f ( Z ) \big ] | } \end{array}$ bwith results from statistical learning theory. First, we observe that the functions in $\mathcal { F }$ are bounded:
$$0 \leq r _ { \lambda } ( h , X ) \leq \frac { 1 } { \epsilon } \operatorname* { s u p } _ { y , y ^ { \prime } \in \mathcal { V } } d _ { \mathcal { V } } ( y , y ^ { \prime } ) .$$
Thus $\begin{array} { r } { \operatorname* { s u p } _ { f \in \mathcal { F } } \left| \mathbf { E } _ { \widehat { P } } \big [ f ( Z ) \big ] - \mathbf { E } _ { P } \left[ f ( Z ) \right] \right| } \end{array}$ has bounded differences inequality, so it concentrates sharply baround its expectation. By the bounded-differences inequality and a standard symmetrization argument,
$$\begin{array} { r } { \operatorname* { s u p } _ { f \in \mathcal { F } } \big | \mathbf { E } _ { \widehat { P } } \big [ f ( Z ) \big ] - \mathbf { E } _ { P } \big [ f ( Z ) \big ] \big | \leq 2 \Re _ { n } ( \mathcal { F } ) + D _ { \mathcal { V } } ( \frac { \log \frac { 2 } { t } } { 2 n } ) ^ { \frac { 1 } { 2 } } } \end{array}$$
with probability at least $1 - t$ , where $\Re _ { n } ( \mathcal { F } )$ is the Rademacher complexity of $\mathcal { F }$
$$\begin{array} { r } { \mathfrak { R } _ { n } ( \mathcal { F } ) = \mathbf { E } \big [ \operatorname* { s u p } _ { f \in \mathcal { F } } \frac { 1 } { n } \sum _ { i = 1 } ^ { n } \sigma _ { i } f ( Z _ { i } ) \big ] . } \end{array}$$
It remains to study $\textstyle { \frac { 1 } { n } } \sum _ { i = 1 } ^ { n } \sigma _ { i } f ( Z _ { i } )$ n is sub-Gaussian with respect to to the metric . First, we show that the -indexed Rademacher process $X _ { f }$ ,
$$\begin{array} { r l } & { | \mathcal { F } \big ( ( h _ { 1 } , \lambda _ { 1 } ) , ( h _ { 2 } , \lambda _ { 2 } ) \big ) \triangleq \operatorname* { s u p } _ { x _ { 1 } , x _ { 2 } \in \mathcal { X } } \big | d y \big ( h _ { 1 } ( x _ { 1 } ) , h _ { 1 } ( x _ { 2 } ) \big ) - d y \big ( h _ { 2 } ( x _ { 1 } ) , h _ { 2 } ( x _ { 2 } ) \big ) \big | + D _ { \mathcal { X } } \big | \lambda _ { 1 } - \lambda _ { 1 } \big | : } \\ & { \mathrm { \Lambda } \mathrm { \Lambda } } \\ & { = \mathbf { E } \big [ \mathrm { e x p } ( t ( X _ { f _ { 1 } } - X _ { f _ { 2 } } ) \big ) \big ] } \\ & { \quad = \mathbf { E } \big [ \mathrm { e x p } \big ( \frac { t } { n } \sum _ { i = 1 } ^ { n } \sigma _ { i } ( r _ { \lambda _ { 1 } } ( h _ { 1 } , X _ { i } ) - r _ { \lambda _ { 2 } } ( h _ { 2 } , X _ { i } ) \big ) \big ) \big ] } \\ & { \quad = \mathbf { E } \big [ \mathrm { e x p } \big ( \frac { t } { n } \sigma ( r _ { \lambda _ { 1 } } ( h _ { 1 } , X _ { i } ) - r _ { \lambda _ { 2 } } ( h _ { 2 } , X _ { i } ) ) \big ) \big ) \big ] ^ { n } } \\ & { \quad = \mathbf { E } \big [ \mathrm { e x p } \Big ( \frac { t } { n } \sigma ( \operatorname* { s u p } _ { x _ { 1 } ^ { \prime } \in \mathcal { X } } \operatorname { i n f } _ { x _ { 2 } ^ { \prime } \in \mathcal { X } } d y \big ( h _ { 1 } ( X _ { i } ) , h _ { 1 } ( x _ { 1 } ^ { \prime } ) \big ) - \lambda _ { 1 } d _ { \mathcal { X } } ( x _ { 1 } , X ) - d _ { \mathcal { V } } ( h _ { 2 } ( X _ { i } ) , h _ { 2 } ( x _ { 2 } ^ { \prime } ) ) + \lambda _ { 2 } } \\ & \quad \leq \mathbf { E } \big [ \mathrm { e x p } \big ( \frac { t } { n } \sigma ( \operatorname* { s u p } _ { x _ { 1 } \in \mathcal { X } } d y \big ( h _ { 1 } ( X _ { i } ) , h _ { 1 } ( x _ { 1 } ^ { \prime } ) \big ) - d y \big ( h _ { 2 } ( X _ { i } ) , h _ { 2 } ( x \end{array}$$
Let $N ( \mathcal { F } , d _ { \mathcal { F } } , \epsilon )$ be the $\epsilon$ -covering number of $\mathcal { F }$ in the $d _ { \mathcal { F } }$ metric. We observe
$$\begin{array} { r } { N ( \mathcal { F } , d _ { \mathcal { F } } , \epsilon ) \leq N ( \mathcal { D } , \| \cdot \| _ { \infty } , \frac { \epsilon } { 2 } ) \cdot N ( [ 0 , \bar { \lambda } ] , | \cdot | , \frac { \epsilon } { 2 D _ { \mathcal { X } } } ) . } \end{array}$$
By Dudley’s entropy integral,
$$\begin{array} { l } { \displaystyle \mathfrak { R } _ { n } ( \mathcal { F } ) \leq \frac { 1 2 } { \sqrt { n } } \int _ { 0 } ^ { \infty } \log N ( \mathcal { F } , d _ { \mathcal { F } } , \epsilon ) ^ { \frac { 1 } { 2 } } d \epsilon } \\ { \displaystyle \quad \leq \frac { 1 2 } { \sqrt { n } } \int _ { 0 } ^ { \infty } \left( \log N ( \mathcal { D } , \| \cdot \| _ { \infty } , \frac { \epsilon } { 2 } ) + N \big ( [ 0 , \bar { \lambda } ] , | \cdot | , \frac { \epsilon } { 2 D x } \big ) \right) ^ { \frac { 1 } { 2 } } d \epsilon } \\ { \displaystyle \quad \leq \frac { 1 2 } { \sqrt { n } } \left( \int _ { 0 } ^ { \infty } \log N ( \mathcal { D } , \| \cdot \| _ { \infty } , \frac { \epsilon } { 2 } ) ^ { \frac { 1 } { 2 } } d \epsilon + \int _ { 0 } ^ { \infty } N \big ( [ 0 , \bar { \lambda } ] , | \cdot | , \frac { \epsilon } { 2 D x } \big ) ^ { \frac { 1 } { 2 } } d \epsilon \right) } \\ { \displaystyle \quad \leq \frac { 2 4 J ( \mathcal { D } ) } { \sqrt { n } } + \frac { 2 4 D _ { x } \bar { \lambda } } { \sqrt { n } } \int _ { 0 } ^ { \frac { 1 } { 2 } } \log ( \frac { 1 } { \epsilon } ) d \epsilon . } \end{array}$$
We check that $\begin{array} { r } { \int _ { 0 } ^ { \frac { 1 } { 2 } } \log ( \frac { 1 } { \epsilon } ) d \epsilon < 1 } \end{array}$ to arrive at Theorem 3.1.
The chief technical novelty of this proof is the bound on $\lambda _ { * }$ in terms of the diameter of the output space. This bound allows us to restrict the relevant function class in a way that allows us to appeal to standard techniques from empirical process theory to obtain uniform convergence results. In prior work (e.g. Lee & Raginsky (2017)), this bound relies on smoothness properties of the loss, but this precludes non-smooth $d _ { \mathcal { Y } }$ in our problem setting.
Corollary A.5. Assume there is $h _ { 0 } \in \mathcal { H }$ such that $L ( h _ { 0 } ) + \rho R ( h _ { 0 } ) < \delta _ { 0 }$ . As long as $D _ { \mathcal { X } } , D _ { \mathcal { Y } } , J ( \mathcal { L } )$ , and $J ( { \mathcal { G } } )$ are all finite, any global minimizer $\begin{array} { r } { \widehat { h } \in \arg \operatorname* { m i n } _ { h \in \mathcal { H } } \widehat { L } ( h ) + \rho \widehat { R } ( h ) } \end{array}$ satisfies
$$L ( \hat { h } ) + \rho R ( \hat { h } ) \leq \delta _ { 0 } + 2 \left( \frac { 2 4 J ( \mathcal { L } ) + 4 8 \rho ( J ( \mathcal { D } ) + \frac { 1 } { \epsilon } D x D y ) } { \sqrt { n } } + ( \bar { L } + \rho D y ) ( \frac { \log \frac { 2 } { t } } { 2 n } ) ^ { \frac { 1 } { 2 } } \right)$$
with probability at least $1 - 2 t$ .
Proof. Let $F ( h ) \triangleq L ( h ) + \rho R ( h )$ and $\widehat F$ be its empirical counterpart. The optimality of $\hat { h }$ implies
$$\begin{array} { r } { { \boldsymbol { \mathcal { F } } } ( \widehat { h } ) = F ( \widehat { h } ) - \widehat { F } ( \widehat { h } ) + \widehat { F } ( \widehat { h } ) - \widehat { F } ( h _ { 0 } ) + \widehat { F } ( h _ { 0 } ) - F ( h _ { 0 } ) + F ( h _ { 0 } ) \le \delta _ { 0 } + 2 \operatorname* { s u p } _ { h \in \mathcal { H } } \vert \widehat { F } ( h ) - F ( h ) \vert . } \end{array}$$
We have
$$\begin{array} { r } { \operatorname* { s u p } _ { h \in \mathcal { H } } | \widehat { F } ( h ) - F ( h ) | \leq \operatorname* { s u p } _ { h \in \mathcal { H } } | \widehat { L } ( h ) - L ( h ) | + \rho \operatorname* { s u p } _ { h \in \mathcal { H } } | \widehat { R } ( h ) - R ( h ) | . } \end{array}$$
We assumed $\ell$ is bounded, so $\begin{array} { r } { \operatorname* { s u p } _ { h \in \mathcal { H } } | \widehat { L } ( h ) - L ( h ) | } \end{array}$ has bounded differences inequality, so it concentrates sharply around its expectation. By the bounded-differences inequality and a standard symmetrization argument,
$$\operatorname* { s u p } _ { h \in \mathcal { H } } | \widehat { L } ( h ) - L ( h ) | \leq 2 \Re _ { n } ( \mathcal { L } ) + \bar { L } ( \frac { \log \frac { 2 } { t } } { 2 n } ) ^ { \frac { 1 } { 2 } }$$
with probability at least $1 - t$ , where $\Re _ { n } ( \mathcal { L } )$ is the Rademacher complexity of $\mathcal { L }$ . By Dudley’s entropy integral,
$$\Re _ { n } ( { \mathcal { L } } ) \leq { \frac { 1 2 } { \sqrt { n } } } \int _ { 0 } ^ { \infty } \log N ( { \mathcal { L } } , \| \cdot \| _ { \infty } , \epsilon ) ^ { \frac { 1 } { 2 } } d \epsilon ,$$
so the first term on the right side of (A.6) is at most
$$\operatorname* { s u p } _ { h \in \mathcal { H } } | \widehat { L } ( h ) - L ( h ) | \leq \frac { 2 4 J ( \mathcal { L } ) } { \sqrt { n } } + \bar { L } ( \frac { \log \frac { 2 } { t } } { 2 n } ) ^ { \frac { 1 } { 2 } }$$
with probability at least $1 - t$ . Theorem 3.1 implies the second term on the right side of (A.6) is at most
$$\operatorname* { s u p } _ { h \in \mathcal { H } } | \widehat { R } ( h ) - R ( h ) | \leq \frac { 4 8 ( J ( \mathcal { D } ) + \frac { 1 } { \epsilon } D _ { \mathcal { X } } D _ { \mathcal { Y } } ) } { \sqrt { n } } + D _ { \mathcal { Y } } ( \frac { \log \frac { 2 } { t } } { 2 n } ) ^ { \frac { 1 } { 2 } }$$
with probability at least $1 - t$ . We combine the bounds to arrive at the stated result.
# B SENSEI AND BASELINES IMPLEMENTATION DETAILS
In this section we describe implementation details of all methods and hyperparameter selection to facilitate reproducibility of the experimental results reported in the main text.
Improving balanced accuracy All three datasets we consider have noticeable class imbalances: over $80 \%$ comments in toxicity classification are non-toxic; several occupations in the Bias in Bios dataset are scarcely present (see Figure 1 in De-Arteaga et al. (2019) for details); about $7 5 \%$ of individuals in the Adult dataset make below $\$ 50\mathrm { k }$ a year. Because of this class imbalance we choose to report balanced accuracy to quantify classification performance of different methods. Balanced accuracy is simply an average of true positive rates of all classes. To improve balanced accuracy for all methods we use balanced mini-batches following Yurochkin et al. (2020), i.e. when sampling a mini-batch we enforce that every class is equally represented.
Fair regularizer distance metric Recall that fair regularizer in Definition 2.1 of the main text requires selecting a distance metric on the classifier outputs $d y ( h ( x ) , h ( x ^ { \prime } ) )$ . This distance is also required for the implementation of Counterfactual Logit Pairing (CLP) (Garg et al., 2018). In a $K$ -class problem, let $h ( x ) \in \mathbf { R } ^ { K }$ denote a vector of $K$ logits of a classifier for an observation $x$ then for both SenSeI and CLP we define $\begin{array} { r } { d _ { \mathcal { V } } ( h ( x ) , h ( x ^ { \prime } ) ) \stackrel { = } { = } \frac { 1 } { K } \| h ( x ) - h ( x ^ { \prime } ) \| _ { 2 } ^ { 2 } } \end{array}$ , i.e. mean squared difference between logits of $x$ and $x ^ { \prime }$ . This is one of the choices empirically studied by Yang et al. (2019) for image classification. We defer exploring alternative fairness regularizer distance metrics for future work.
Data processing and classifier architecture Data processing and classifier are shared across all methods in all experiments. In Toxicity experiment we utilized BERT (Devlin et al., 2018) finetuned on a random $33 \%$ subset of the data. We downloaded the fine-tuned model from one of the Kaggle kernels.1 In the Bios experiment for each train-test split we fine-tuned BERT-Base, Uncased2 for 3 epochs with mini-batch size 32, learning rate 2e−5 and 128 maximum sequence length. In both Toxicity and Bios experiments we obtained 768-dimensional sentence representations by average-pooling token embeddings of the corresponding fined-tuned BERTs. Then we trained a fully connected neural network with one hidden layer consisting of 2000 neurons with ReLU activations using BERT sentence representations as inputs.
For Adult experiment we followed data processing and classifier choice (i.e. 100 hidden units neural network) as described in Yurochkin et al. (2020).
Hyperparameters selection In Table 4 for each hyperparameter we summarize its meaning, abbreviation, name in the code provided with the submission3 and methods where it is used.
To select hyperparameters for each experiment we performed a grid search on an independent train-test split. Then we fixed selected hyperparameters and ran 10 experiment repetitions with random train test splits (these results are reported in the main text). Hyperparameter choices for all experiments are summarized in Tables 5, 6, 7. For the Adult experiment we duplicated results for all prior methods from Yurochkin et al. (2020).
Table 4: Hyperparameter names and notations
<table><tr><td></td><td>notation</td><td>name in code</td><td>relevant methods</td></tr><tr><td>Number of optimization steps</td><td>E</td><td>epoch</td><td>All</td></tr><tr><td>Mini-batch size</td><td>B</td><td>batch_size</td><td>All</td></tr><tr><td>Parameter learning rate n</td><td>n</td><td>lr</td><td>All</td></tr><tr><td>Subspace attack step size</td><td>S</td><td>adv_step</td><td>SenSeI, SenSR</td></tr><tr><td>Number of subspace attack steps</td><td>se</td><td>adv_epoch</td><td>SenSeI, SenSR</td></tr><tr><td>Full attack step size</td><td>f</td><td>l2_attack</td><td>SenSeI, SenSR</td></tr><tr><td>Number of full attack steps</td><td>fe</td><td>adv_epoch_full</td><td>SenSeI, SenSR</td></tr><tr><td>Attack budget E</td><td>E</td><td>ro</td><td>SenSeI, SenSR</td></tr><tr><td>Fair regularization strength p</td><td>p</td><td>fair_reg</td><td>SenSeI, CLP</td></tr></table>
Table 5: Hyperparameter choices in Toxicity experiment
<table><tr><td></td><td>E</td><td>B</td><td>m</td><td>S</td><td>se</td><td>S</td><td>fe</td><td>E</td><td>p</td></tr><tr><td>Baseline</td><td>100k</td><td>256</td><td>1e-5</td><td>一</td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>SenSR</td><td>100k</td><td>256</td><td>1e-5</td><td>0.1</td><td>10</td><td>0</td><td>0</td><td>0</td><td></td></tr><tr><td>SenSeI</td><td>100k</td><td>256</td><td>1e-5</td><td>0.1</td><td>10</td><td>0</td><td>0</td><td>0</td><td>5</td></tr><tr><td>CLP</td><td>100k</td><td>256</td><td>1e-5</td><td>一</td><td></td><td></td><td></td><td>一</td><td>5</td></tr></table>
Table 6: Hyperparameter choices in Bios experiment
<table><tr><td></td><td>E</td><td>B</td><td>n</td><td>S</td><td>se</td><td>S</td><td>fe</td><td>E</td><td>p</td></tr><tr><td>Baseline</td><td>100k</td><td>504</td><td>1e-6</td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>SenSR</td><td>100k</td><td>504</td><td>1e-5</td><td>0.1</td><td>50</td><td>0.01</td><td>10</td><td>0.1</td><td></td></tr><tr><td>SenSeI</td><td>100k</td><td>504</td><td>1e-5</td><td>0.1</td><td>50</td><td>0.01</td><td>10</td><td>0.1</td><td>5</td></tr><tr><td>CLP</td><td>100k</td><td>504</td><td>1e-5</td><td>一</td><td></td><td>一</td><td></td><td>一</td><td>5</td></tr></table>
Table 7: Hyperparameter choices in Adult experiment
<table><tr><td></td><td>E</td><td>B</td><td>n</td><td>S</td><td>se</td><td>f</td><td>fe</td><td>E</td><td>p</td></tr><tr><td>SenSeI</td><td>200k</td><td>1000</td><td>1e-5</td><td>5</td><td>50</td><td>0.001</td><td>50</td><td>0.01</td><td>40</td></tr></table>
# B.1 FAIR METRIC LEARNING DETAILS
Following Yurochkin et al. (2020); Mukherjee et al. (2020) we consider the fair metric of the form $d _ { \mathcal { X } } ( x , x ^ { \prime } ) \overset { } { = } ( x - x ^ { \prime } ) ^ { T } \Sigma ( x - x ^ { \prime } )$ . We utilize their sensitive subspace idea writing $\Sigma = I - P _ { r a n ( A ) }$ i.e. an orthogonal complement projector of the subspace spanned by the columns of $A \in \mathbb { R } ^ { d \times k }$ . Here $A$ encodes the $k$ directions of sensitive variations that should be ignored by the fair metric $d$ is the data dimension), such as differences in sentence embeddings due to gender pronouns in the Bios experiment or due to identity (counterfactual) tokens in the Toxicity experiment.
Synthetic experiment In the synthetic experiment in Figure 1 we consider a fair metric ignoring variation along the $x$ -axis coordinate, i.e. $\bar { A ^ { \mathbf { \alpha } } } = [ 1 \mathbf { \beta } 0 ] ^ { T }$ .
Toxicity experiment To compute $A$ we utilize FACE algorithm of Mukherjee et al. (2020) (see section 2.1 and Algorithm 1 in their paper). Here groups of comparable samples are the BERT embeddings of sentences from the train data and their modifications obtained using 25 counterfactuals known at the training time. For example, suppose we have a sentence “Some people are gay” in the train data and the list of known counterfactuals is “gay”, “straight” and “muslim”. Then we can obtain two comparable sentences: “Some people are straight” and “Some people are muslim”. BERT embeddings of the original and two created sentences constitute a group of comparable sentences. Embeddings of groups of comparable sentences are the inputs to Algorithm 1 of Mukherjee et al. (2020), which consists of a per-group centering step followed by a singular value decomposition. Taking the top $k = 2 5$ singular vectors gives us matrix of sensitive directions $A$ defining the fair metric.
Bios experiment We again utilize FACE algorithm of Mukherjee et al. (2020) to obtain the fair metric. Here the counterfactual modification is based on male and female gender pronouns. For example, sentence “He went to law school” is modified to “She went to law school”. As a result, each group of comparable samples consists of a pair of bios (original and modified). Let $\ b { X } \in \mathbb { R } ^ { n \times d }$ be the data matrix of BERT embeddings of the $n$ train bios, and let $X ^ { \prime } \in \mathbb { R } ^ { n \times d }$ be the corresponding modified bios. Here Algorithm 1 of Mukherjee et al. (2020) is equivalent to performing SVD on $X - X ^ { \prime }$ . We take the top $k = 2 5$ singular vectors to obtain sensitive directions $A$ and the corresponding fair metric.
Adult experiment In this experiment $A$ consists of three vectors: a vector of zeros with 1 in the gender coordinate; a vector of zeros with 1 in the race coordinate; and a vector of logistic regression coefficients trained to predict gender using the remaining features (and 0 in the gender coordinate). This sensitive subspace construction replicates the approach Yurochkin et al. (2020) utilized in their Adult experiment for obtaining the fair metric. Please see Appendix B.1 and Appendix $\mathrm { D }$ in their paper for additional details.
# C FAIRNESS EVALUATION METRICS DEFINITIONS
Individual fairness To compare individual fairness we used two metrics: prediction consistency and Counterfactual Token Fairness (CTF) score of Garg et al. (2018). The idea behind these metrics is to quantify changes in prediction when modifying original data in ways that intuitively should not change behavior of an individually fair classifier.
For Toxicity experiment an individually fair classifier should not change its prediction when a word “gay” in a comment is replaced with a word “straight”. For example, we expect toxicity predictions on “Some people are gay” and “Some people are straight” to be the same. Following prior work (Dixon et al., 2018; Garg et al., 2018) we considered a set of 50 tokens4 that should not affect the classifier when interchanged. For any comment that contains at least one of these 50 tokens we can create 49 versions of it via a simple word replacement and evaluate classifier prediction and probability of being toxic for each of the 50 variations (including the original). Prediction consistency is the proportion of comments (with at least one of the 50 tokens) where prediction is the same on all 50 variations. CTF score is the average (across all comments with at least one of the 50 tokens) standard deviation of the toxicity probability across 50 variations.
We use similar individual fairness metrics for the Bios experiment. We create a single variation of each bio by interchanging “he” and “she”; “his” and “her”; “him” and “hers”; “himself” and “herself”; “mr” and “ms” or “mrs”; original name with a random name from a different gender sampled among those present in the data. Prediction consistency is computed as before using 2 variations (including the original one) of each bio. Note that although there are fewer variations, there are significantly more classes in the Bios dataset. CTF score in the average (across all bios) squared Euclidean distance between the vectors of class probabilities for the 2 bio variations.
In the Adult experiment we compute same individual fairness metrics as in Yurochkin et al. (2020). S-Con. (spouse consistency) is the prediction consistency when creating data variations by altering marital status feature. GR-Con. (gender and race consistency) is the prediction consistency when creating data variations by altering race and gender features.
Group fairness In our experiments we observed that enforcing individual fairness also has positive effect on group fairness metrics.
In the Toxicity experiment we used accuracy parity (Zafar et al., 2017; Zhao et al., 2019) to quantify group fairness. There are multiple protected groups in the Toxicity dataset (e.g. “muslim”, “white”, “black”, “homosexual or lesbian”) that correspond to human annotated identity contexts (not necessarily mutually exclusive). To account for this when evaluating accuracy parity we computed accuracies for each of the protected groups and reported their standard deviation. Large standard deviation implies that classifier is significantly more accurate on some protected groups than on the others. Because of the class imbalance we also reported standard deviation of the corresponding balanced accuracies.
For the Bios experiment we used same group fairness metrics as in the prior works studying this dataset (Romanov et al., 2019; Prost et al., 2019). Here protected attribute is binary: male or female genders. Let $\mathrm { T P R } _ { 0 , k }$ and $\mathrm { T P R } _ { 1 , k }$ denote true positive rates for class $k$ for protected attributes 0 and 1. Then TPR gap for class $k$ is $\mathrm { G a p } _ { k } = | \mathrm { T P R } _ { 0 , k } - \mathrm { T P R } _ { 1 , k } |$ . The summary statistics we report are Gap $\begin{array} { r } { \mathrm { R M S } = \sqrt { \frac { 1 } { K } \sum _ { k } \mathrm { G a p } _ { k } ^ { 2 } } } \end{array}$ and $\begin{array} { r } { \mathrm { G a p \ A B S } = \frac { 1 } { K } \sum _ { k } \mathrm { G a p } _ { k } . } \end{array}$ .
For the Adult experiment we used same group fairness metrics as in Yurochkin et al. (2020), which correspond to Gap RMS described above and Gap $\mathbf { M A X } = \mathbf { m a x } _ { k } \mathbf { G a p } _ { k }$ , evaluated with respect to race and gender (both are binary protected attributes in the dataset).
# D ADDITIONAL FAIRNESS-ACCURACY TRADE-OFF RESULTS
Synthetic data experiment In Figure 1 we demonstrated how SenSeI allows to control fairnessaccuracy trade-off in simulations by plotting the decision boundary of the corresponding classifier for varying $\rho$ . In Figure 3 we show the lack of such flexibility in SenSR (Yurochkin et al., 2020): varying the radius of the DRO ball $\epsilon$ in their definition of individual fairness results in a horizontal decision boundary even for $\epsilon = 0$ . SenSR ties loss to fairness in its objective, and in this experiment loss can be increased significantly for anything but a horizontal decision boundary (fair metric allows free movement along the $\mathbf { X }$ -axis and a data-point can be perturbed in horizontal direction even for $\epsilon = 0$ ).
 Figure 3: The decision surface of a one hidden layer neural network trained with SenSR (Yurochkin et al., 2020) as the DRO radius $\epsilon$ varies. Problem setting is the same as in Figure 1. Even for $\epsilon = 0$ , SenSR prioritizes fairness over accuracy producing a horizontal decision surface. It is unable to achieve intermediate behaviors of SenSeI trading accuracy and fairness as in Figure 1 (a,b,c).
Toxicity and Bios experiments In Figure 2 we presented trade-offs between prediction consistency and balanced accuracy for SenSeI and CLP (Garg et al., 2018) for the Toxicity and Bios experiments. For completeness we also present corresponding CTF score and balanced accuracy trade-offs in Figure 4. As with the prediction consistency, we see that increasing fair regularization strength $\rho$ allows to train classifiers with better individual fairness properties. SenSeI outperforms CLP as it trains classifiers with lower CTF score across all values of $\rho$ .
 Figure 4: Balanced accuracy (BA) and CTF score trade-off on Toxicity and Bios experiments123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283# BLOCKWISE SELF-ATTENTION FOR LONG DOCUMENT UNDERSTANDING
Anonymous authors Paper under double-blind review
# ABSTRACT
We present BlockBERT, a lightweight and efficient BERT model that is designed to better modeling long-distance dependencies. Our model extends BERT by introducing sparse block structures into the attention matrix to reduce both memory consumption and training time, which also enables attention heads to capture either short- or long-range contextual information. We conduct experiments on several benchmark question answering datasets with various paragraph lengths. Results show that BlockBERT uses $1 8 . 7 \substack { - 3 6 . 1 \% }$ less memory and reduces the training time by $1 2 . 0 { - } 2 5 . 1 \%$ , while having comparable and sometimes better prediction accuracy, compared to an advanced BERT-based model, RoBERTa.
# 1 INTRODUCTION
Recent emergence of the pre-training and fine-tuning paradigm, exemplified by methods like ELMo (Peters et al., 2018), GPT-2 (Radford et al., 2019), BERT (Devlin et al., 2019), XLNet (Yang et al., 2019) and RoBERTa (Liu et al., 2019), has drastically reshaped the landscape of the natural language processing research. These methods first pre-train a deep model with language model objectives using a large corpus and then fine-tune the model using in-domain supervised data for target applications. Despite its conceptual simplicity, this paradigm has reestablished the new state-ofthe-art baselines across various tasks, such as question answering (Devlin et al., 2019), coreference resolution (Joshi et al., 2019b), relation extraction (Soares et al., 2019) and text retrieval (Lee et al., 2019; Nogueira & Cho, 2019), to name a few.
Building such models in practice, however, is an extremely resource-intensive process. For instance, the training of BERT-family models is notoriously expensive. Devlin et al. (2019) report that it takes four days for pre-training BERT-Base/BERT-Large on 4/16 Cloud TPUs, respectively. In order to reduce the pre-training time of RoBERTa to 1 day, Liu et al. (2019) use 1,024 V100 GPUs. One crucial factor that contributes to the long training time is the memory consumption of these deep models, as it directly affects the batch size. Although the fine-tuning stage is relatively inexpensive, the memory issue still restricts the scenarios in which BERT can be used. For instance, “it is currently not possible to re-produce most of the BERT-Large results on the paper using a GPU with 12GB-16GB of RAM, because the maximum batch size that can fit in memory is too small.1”
Although one may think that model size is the main contributor to the large memory consumption, our analysis (Section 2.1) shows that one of the main bottlenecks is actually dot-product selfattention, operated in multiple layers of Transformers (Vaswani et al., 2017), the building block of BERT. As the attention operation is quadratic to the sequence length, this fundamentally limits the maximum length of the input sequence, and thus restricts the model capacity in terms of capturing long-distance dependencies. As a result, downstream tasks have to either truncate their sequences to leading tokens (Nogueira & Cho, 2019) or split their sequences with a sliding window (Joshi et al., 2019a;b). Ad-hoc handling of long sequences is also required in the pre-training stage, such as updating the model using only short sequences in the early stage (Devlin et al., 2019).
Common strategies for reducing memory consumption, unfortunately, do not work. For instance, shrinking the model by lowering the number of layers $L$ , attention heads $A$ , or hidden units $H$ leads to significant performance degradation (Vaswani et al., 2017; Devlin et al., 2019) and does not address the long sequence issue. Alternatively, general low-memory training techniques, such as microbatching (Huang et al., 2018) and gradient checkpointing (Chen et al., 2016) essentially trade off training time for memory consumption, prolongs the already lengthy training process.
In this work, we explore a different strategy, sparsifying the attention layers, intending to design a lightweight and effective BERT that can model long sequences in a memory-efficient way. Our BlockBERT extends BERT by introducing sparse block substructures into the attention matrix to reduce both memory consumption and the number of floating point operations (FLOPs), which also enables attention heads to capture either short- or long-range contextual information. Compared to the previous method that also enforces sparsity (e.g., Child et al. (2019)), our approach is much simpler mathematically and very easy to implement. More importantly, the results of experiments conducted on several benchmark question answering datasets with various paragraph lengths show that BlockBERT performs comparably or even better than the original BERT-family models, while enjoying an $1 8 . 7 \substack { - 3 6 . 1 \% }$ reduction in memory usage and $1 2 . 0 { - } 2 5 . 1 \%$ reduction in training time.
The rest of the paper is organized as follows. Section 2 gives a brief introduction of the BERT model, along with an in-depth analysis of its memory usage during training time. We describe our proposed model in Section 3 and contrast it with existing methods that aim for creating a lighter model. Section 4 presents the experimental results and ablation studies, followed by a short survey of other related work in Section 5 and the conclusion in Section 6.
# 2 BACKGROUND: MEMORY BOTTLENECK IN TRAINING BERT
We briefly review BERT and introduce its memory profiling in this section. Following the paradigm of language model pre-training and down-stream task fine-tuning, BERT (Devlin et al., 2019) consists of multiple layers of bidirectional Transformers (Vaswani et al., 2017), where each Transformer encoder has a multi-head self-attention layer and a position-wise feed-forward layer. Using the same notation as in (Devlin et al., 2019), we denote the number of Transformer layers by $L$ , the number of hidden units by $H$ , the number of attention heads by $A$ , the sequence length by $N$ and the batch size by $B$ . We also assume the feed-forward hidden unit size to be $4 H$ .2
# 2.1 MEMORY PROFILING
Training BERT is a memory-intensive process. In order to identify the bottleneck, we follow the memory model proposed by Sohoni et al. (2019), where the memory usage throughout neural network training is categorized into three main types: (1) Model Memory is used to store model parameters; (2) Optimizer Memory is the additional memory used by the specific learning algorithm during the process; (3) Activation Memory consists of the outputs of each layer, which are cached for reuse in backpropagation to compute gradients.
Take BERT-Base training as an example. The model has 110M parameters, so the model memory uses $0 . 2 \mathrm { \ G B }$ if stored in half-precision floating-point format (FP16). For Adam (Kingma & Ba, 2014), the optimizer needs additional memory to store the gradients, first moments, and second moments of model parameters. If stored using the same precision, the optimizer memory should be three times of model memory.3 To calculate the exact size of activation memory is not trivial because it depends heavily on the implementation of the toolkit. Instead, we measure it empirically by training BERT-Base using Adam with a memory profiler (more details are provided in Appendix A.2).
We use 32 NVIDIA V100 GPUs for training. Each single GPU thus consumes a mini-batch of size $b ~ = ~ B / 3 2 ~ = ~ 8 .$ . Figure 1a shows the profiling result for a single GPU, where the model/optimizer/activation memory consumes $0 . 2 1 / 1 . 0 3 / 8 . 4 9$ GB, resp. We can see that activation memory accounts for the vast majority of the total GPU memory $( 8 7 . 6 \% )$ and is clearly the bottleneck. Notice that although our analysis is done on BERT-Base, it can be easily generalized to BERT-Large and other models such as RoBERTa (Liu et al., 2019) and XLNet (Yang et al., 2019).
 Figure 1: Memory Profiling for BERT
# 2.2 A REGRESSION ANALYSIS ON ACTIVATION MEMORY
For BERT, or more specifically, Transformer, the activation memory corresponds to intermediate results of different layers It grows linearly in all the model hyper-parameters, except the sequence length $N$ , due to the attention layers. To quantify more clearly the $O ( N )$ and $O ( N ^ { 2 } )$ components in the activation memory, we conduct a regression analysis as follows. Assume that the activation memory (in each GPU) is a polynomial $\bar { a _ { 2 } } b \bar { N } ^ { 2 } + a _ { 1 } \bar { b } \bar { N } + a _ { 0 }$ , where $b$ is the batch size in each GPU. If we fix the total number of tokens in a GPU, i.e., $b \times N$ , to be constant (in our case, 4096), we should have a linear function w.r.t. $N$ , i.e., $4 0 9 6 a _ { 2 } N + 4 0 9 6 a _ { 1 } + a _ { 0 }$ . We enumerate $N$ from $\{ 1 2 8 , 2 5 6 , 5 1 2 , 1 0 2 4 \}$ in our experiments, and plot the corresponding profiled activation memory in Figure 1b. Using ordinary least squares (OLS), with $b \times N = 4 0 9 6$ , the estimated linear function for activation memory is $0 . 0 0 7 1 5 \times N + 4 . 8 3$ , where the first term is responsible for the $O ( N ^ { 2 } )$ component. When $N = 5 1 2$ , we can see that for BERT-Base, the $O ( N ^ { 2 } )$ component accounts for 3.66 GB and $O ( N )$ accounts for 4.83 GB. When the sequence length $N$ increases to 1024, however, the $O ( N ^ { 2 } )$ component increases to 7.32 GB, while $O ( \bar { N } )$ is unchanged.
# 2.3 GENERAL TECHNIQUES FOR REDUCING MEMORY USAGE IN MODEL TRAINING
Observing that activation memory is the bottleneck, we discuss the effectiveness of common memory reduction techniques for BERT training below.
Low Precision (Micikevicius et al., 2017): Low precision is to use half-precision or mixed-precision for training neural networks. This technique has been widely used in Transformer training (Ott et al., 2019; Liu et al., 2019). In this work, we already assume to use mixed-precision training by default, as indicated in the aforementioned analysis.
Microbatching (Huang et al., 2018): Microbatching is to split a batch into small microbatches (which can be fit into memory), and then run forward and backward passes on them separately with gradients for each micro-batch accumulated. Because it runs forward/backward pass multiple times for a single batch, it trades off time for memory.
Gradient Checkpointing (Chen et al., 2016): Gradient checkpointing saves memory by only caching activations of a subset of layers. The un-cached activations will be recomputed during backpropagation from the latest checkpoint. This strategy trades off time for memory by repeating computations that require large memory and will obviously extend the model training time.
Knowledge Distillation (Hinton et al., 2015): Knowledge distillation aims to compress and transfer knowledge from a teacher model to a simpler student model. However, knowledge distillation relies on a teacher model (which is still expensive in training time) and usually suffers from a certain degree of performance degradation.
As common techniques are limited in reducing both the training time and memory usage, we investigate how to optimize the dot-product attention layers and introduce our approach next.
# 3 MODEL: BLOCKBERT
Following (Vaswani et al., 2017), the dot-product attention in Transformer is defined as:
$$\operatorname { A t t e n t i o n } ( Q , K , V ) = \operatorname { s o f t m a x } \biggl ( \frac { Q K ^ { \top } } { \sqrt { d } } \biggr ) V .$$
where $Q , K , V \in \mathbb { R } ^ { N \times d }$ with $N$ to be the sequence length and $d$ to be a hidden dimension. As we can see, the inner product between $Q$ and $\kappa$ consumes $\bar { O } ( N ^ { 2 } )$ memory. One simple way to reduce memory consumption of attention is to sparsify the attention matrix. Suppose we have a masking matrix $\mathbf { \bar { \chi } } M \in \{ 0 , \mathbf { \bar { 1 } } \} ^ { N \times N }$ . We define a masked version of attention as follows:
$$\mathrm { A t t e n t i o n } ( Q , K , V , M ) = \mathrm { s o f t m a x } \bigg ( \frac { Q K ^ { \top } } { \sqrt { d } } \odot M \bigg ) V ,$$
with operator $\odot$ defined by
$$( \pmb { A } \odot \pmb { M } ) _ { i j } = \left\{ \begin{array} { l l } { \pmb { A } _ { i j } } & { \mathrm { i f } \ M _ { i j } = 1 } \\ { - \infty } & { \mathrm { i f } \ M _ { i j } = 0 } \end{array} \right. .$$
In this work, we design $M$ to be a sparse block matrix, which not only reduces memory and the number of floating point operations (FLOPs) but also benefits from efficient dense matrix support from deep learning frameworks, such as PyTorch and Tensorflow. More formally, we split the length- $. N$ input sequence into $n$ partitions, with each partition of length $\textstyle { \frac { N } { n } }$ .4 The $N \times N$ attention matrix is then partitioned into $n \times n$ blocks, where each block matrix is of size $\textstyle { \frac { N } { n } } \times { \frac { N } { n } }$ Nn . A sparse block matrix $M$ can be defined by a permutation $\pi$ of $\{ 1 , 2 , \cdots , n \}$ :
$$M _ { i j } = \left\{ \begin{array} { l l } { 1 } & { \mathrm { i f } \pi \left( \lfloor \frac { ( i - 1 ) n } { N } + 1 \rfloor \right) = \lfloor \frac { ( j - 1 ) n } { N } + 1 \rfloor } \\ { 0 } & { \mathrm { o t h e r w i s e . } } \end{array} \right.$$
By writing $Q , K , V$ as be block matrices, such that $\begin{array} { r } { \pmb { Q } = \left[ \pmb { Q } _ { 1 } ^ { \top } \quad \cdot \cdot \mathrm { ~ ~ \lambda ~ } \pmb { Q } _ { n } ^ { \top } \right] ^ { \top } , \pmb { K } = \left[ \pmb { K } _ { 1 } ^ { \top } \quad \cdot \cdot \mathrm { ~ ~ \lambda ~ } \pmb { K } _ { n } ^ { \top } \right] ^ { \top } } \end{array}$ and $V _ { . } = \left[ \boldsymbol { v } _ { 1 } ^ { \top } \quad \cdot \cdot \quad \boldsymbol { v } _ { n } ^ { \top } \right] ^ { \top }$ and pluging them into Equation 1, we can formally define Blockwise Attention as follows:
$$\mathrm { B l o c k w i s e - A t t e n t i o n } ( Q , K , V , M ) = \left[ \begin{array} { c } { { \mathrm { s o f t m a x } \bigg ( \frac { Q _ { 1 } K _ { \pi ( 1 ) } ^ { \top } } { \sqrt { d } } \bigg ) V _ { \pi ( 1 ) } } } \\ { { \vdots } } \\ { { \mathrm { s o f t m a x } \bigg ( \frac { Q _ { n } K _ { \pi ( n ) } ^ { \top } } { \sqrt { d } } \bigg ) V _ { \pi ( n ) } } } \end{array} \right] .$$
sult, it only needs to compute and store . In other words, BlockBERT reduces the $Q _ { i } K _ { \pi ( i ) } ^ { \top } ~ ( i = 1 , \cdot \cdot \cdot n )$ , each of which has sizememory consumption and $\textstyle { \frac { N } { n } } \times { \frac { N } { n } }$ $O ( N ^ { 2 } )$ FLOPs by a factor of $n$ , since $\begin{array} { r } { \frac { N } { n } \times \frac { N } { n } \times n = \frac { N \times N } { n } } \end{array}$ .
# 3.1 BLOCKWISE MULTI-HEAD ATTENTION
Analogous to Multi-head Attention (Vaswani et al., 2017), we allow queries, keys, and values to be projected multiple times and perform blockwise attentions in parallel. Moreover, different blockwise attention heads can use different masking matrices. The outputs of multiple heads are then concatenated and aggregated with another linear projection. Let $A$ be the number of attention heads and $H$ the number of hidden units. Blockwise multi-head attention is formally defined by:
$$\begin{array} { r l } & { \mathrm { i o n } ( Q , K , V ) = \mathrm { C o n c a t } ( \mathrm { h e a d } _ { 1 } , \cdot \cdot \cdot \mathrm { h e a d } _ { \cal A } ) { \cal W } ^ { \cal O } } \\ & { \quad \mathrm { w h e r e ~ h e a d } _ { i } = \mathrm { B l o c k w i s e } { \mathrm { - A t t e n t i o n } ( Q W _ { i } ^ { \it Q } , K W _ { i } ^ { \it K } , V W _ { i } ^ { \it V } , { M } _ { i } ) } , } \end{array}$$
with $\begin{array} { r } { d = \frac { H } { A } , W _ { i } ^ { Q } , W _ { i } ^ { K } , W _ { i } ^ { V } \in \mathbb { R } ^ { H \times d } } \end{array}$ and the projection matrix $W ^ { O } \in \mathbb { R } ^ { H \times H }$ . Each masking matrix $M _ { i }$ is determined by permutation $\pi _ { i }$ according to Equation 2. In particular, we choose $\pi$ from permutations generated by shifting one position: $\sigma = ( 2 , 3 , \cdots , n , 1 )$ , i.e., we select $\pi \in$ $\{ \sigma , \sigma ^ { \dot { 2 } } , \cdots , \sigma ^ { n } \}$ . For example, with 12 attention heads $A = 1 2$ ) and 2 blocks $( n \ = \ 2$ ), one configuration can be assigning 10 heads to permutation $( 1 , 2 )$ and the other 2 heads to permutation $( 2 , 1 )$ . Figure 2 illustrates the blockwise multi-head attention with the block numbers $\bar { n } \in \{ 2 , 3 \}$ . Blockwise sparsity captures both local and long-distance dependencies in a memory-efficiency way, which is crucial for long-document understanding tasks. For instance, the identity permutation, i.e., $( 1 , 2 , \cdots , n )$ , enables each token to attend its nearby tokens in self-attention. Tokens within the same local group attend a long-distance group of tokens together in other permutations. Our proposed BlockBERT essentially replaces the multi-head attention layers in Transformer/BERT with blockwise multi-head attention.
 Figure 2: Architecture of Blockwise Multi-head Attention.
 Figure 3: Regression analysis on activation memory for BERT and BlockBERT.
Table 1: Estimated $O ( N ^ { 2 } )$ and $O ( N )$ activation memory for BERT and BlockBERT.
<table><tr><td>N</td><td>b</td><td>Model</td><td>Act.Mem. (GB) O(N) O(N2)</td></tr><tr><td rowspan="3">512</td><td rowspan="3">8</td><td>BERT</td><td>4.83 3.66</td></tr><tr><td>BlockBERT n=2</td><td>4.84 1.83</td></tr><tr><td>BlockBERT n=3</td><td>4.87 1.22</td></tr><tr><td rowspan="3">1024</td><td rowspan="3">4</td><td>BERT</td><td>4.83 7.32</td></tr><tr><td>BlockBERT n=2</td><td>4.84 3.66</td></tr><tr><td>BlockBERT n=3</td><td>4.87 2.44</td></tr></table>
# 3.2 ANALYSIS OF MEMORY USAGE REDUCTION
To validate our claim that BlockBERT with $n \times n$ blocks can reduce the $O ( N ^ { 2 } )$ memory use by a factor of $n$ , we perform the same memory profiling as described in sections 2.1 and 2.2. Again, We fix the number of tokens in each GPU $\left( b \times N = 4 0 9 6 \right)$ ) and choose $N$ from $\{ 1 2 8 , 2 5 6 , 5 1 2 , 1 0 2 4 , 2 0 4 8 \} .$ 5 As we can see from Figure 3 and Table 1, the empirical results align well with the theoretical values. When we set block size to be 2 and 3 for BlockBERT, their estimated $O ( N ^ { 2 } )$ activation memory decreases to 1/2 and $1 / 3$ of BERT’s $O ( N ^ { 2 } )$ activation memory, resp. As shown in Table 2, for the sequence length $N = 5 1 2$ , BlockBERT with $^ \textrm { \scriptsize 2 / 3 }$ blocks saves $1 8 . 7 \% / \ 2 3 . 8 \%$ overall memory, resp. The saving is more significant for longer sequences. When $N = 1 0 2 4$ , the overall memory reduction of BlockBERT with $^ { 2 / 3 }$ blocks is $2 7 . 3 \% / 3 6 . 1 \%$ , resp.
# 4 EXPERIMENTS
We evaluate the pre-training and fine-tuning performance of BlockBERT. In particular, when $n = 2$ , we denote 10:2 to be the configuration which distributes 10 heads to permutation $( 1 , 2 )$ and 2 to permutation $( 2 , 1 )$ ; when $n = 3$ , we denote 8:2:2 to be the configuration which assigns 8, 2, 2 heads
Table 2: Pre-training Performance Analysis.
<table><tr><td>N</td><td>Model</td><td>Training Time (day)</td><td>Memory (per GPU, GB)</td><td>Heads Config.</td><td>Valid. ppl</td></tr><tr><td rowspan="3">512</td><td>RoBERTa-1seq</td><td>6.62</td><td>9.73</td><td>1</td><td>3.58</td></tr><tr><td>BlockBERT n=2</td><td>5.83 (-12.0%)</td><td>7.91 (-18.7%)</td><td>10:2</td><td>3.56</td></tr><tr><td>BlockBERT n=3</td><td>5.80 (-12.5%)</td><td>7.32 (-23.8%)</td><td>8:2:2</td><td>3.71</td></tr><tr><td rowspan="3">1024</td><td>RoBERTa-1seq</td><td>9.66</td><td>13.39</td><td>-</td><td>3.60</td></tr><tr><td>BlockBERT n=2</td><td>7.51 (-22.3%)</td><td>9.73 (-27.3%)</td><td>9:3</td><td>3.57</td></tr><tr><td>BlockBERT n=3</td><td>7.23 (-25.1%)</td><td>8.55 (-36.1%)</td><td>8:2:2</td><td>3.63</td></tr></table>
to permutation $( 1 , 2 , 3 )$ , $( 2 , 3 , 1 )$ , and $( 3 , 1 , 2 )$ , resp. We compare BlockBERT with the following baselines:
Google BERT The pre-trained base model from Devlin et al. (2019).
RoBERTa-2seq and RoBERTa-1seq We compare with two versions of RoBERTa (Liu et al., 2019). RoBERTa-2seq is trained with both masked language model (MLM) task and next sentence prediction (NSP) task, while RoBERTa-1seq refers to the pre-training model with only MLM task.
SparseBERT We pre-train BERT models with its Transformer encoder replaced by a Sparse Transformer encoder (Child et al., 2019). We set its sparsity hyper-parameters stride $\ell = 1 2 8$ and expressivity $c = 3 2$ . The attention masks used for Sparse Transformer encoder are illustrated in Figure 5.
# 4.1 PRE-TRAINING
All the models follow the base setting, i.e., $L = 1 2 , H = 7 6 8 , A = 1 2$ and are trained on the same corpus — BooksCorpus and English Wikipedia with uncased word piece tokens. We fix the number of tokens per batch $B \times N = 1 3 1 , 0 7 2$ , i.e., if sequence length $N = 5 1 2$ then batch size $B = 2 5 6$ , if sequence length $N = 1 0 2 4$ then batch size $B = 1 2 8$ . The detailed pre-training configuration is listed in Table 6 in Appendix A.1. Moreover, the pre-training of SparseBERT and BlockBERT follows the RoBERTa-1seq setting, i.e., we drop the NSP (Next Sentence Prediction) task, and an input sequence is up to $N$ tokens until it reaches a document boundary. A summary of the pretraining performance comparison between BlockBERT and RoBERTa-1seq is shown in Table 2. Besides memory saving, we also achieve a significant speedup. For example, when $N = 1 0 2 4$ , BlockBERT $( n = 2$ ) reduces the training time from RoBERTa’s 9.7 days to 7.5 days.
# 4.2 FINE-TUNING TASKS
We evaluate BlockBERT on several question answering tasks, including SQuAD 1.1/2.0 (Rajpurkar et al., 2018) and five other tasks from the MrQA shared task6 — HotpotQA (Yang et al., 2018), NewsQA (Trischler et al., 2017), SearchQA (Dunn et al., 2017), TriviaQA (Joshi et al., 2017) and NaturalQA (Kwiatkowski et al., 2019). Since MrQA does not have an official test set, we follow Joshi et al. (2019a) who split the development set evenly to build a new development set and test set.
These QA datasets have different paragraph length distribution patterns and are thus ideal for testing the effectiveness of BlockBERT. For example, SQuAD, NaturalQA, and HotpotQA consist of mostly short paragraphs (shorter than 512), while paragraphs in SearchQA (average length 1,004) and TriviaQA (average length 934) have around 1,000 tokens. This means that for SearchQA and TriviaQA, a BERT model with sequence length $N = 5 1 2$ can only capture half of the context. The detailed paragraph length distributions can be found in Figure 6.
For all the pre-trained models, we adopt the same fine-tuning QA setup from Devlin et al. (2019). The tokenized paragraph $( p _ { 1 } , \cdots , p _ { s } )$ and question $( q _ { 1 } , \cdots , q _ { t } )$ are concatenated to be a sequence [CLS] $\mid q _ { 1 } \cdot \cdot \cdot q _ { t } [ \mathsf { S E P } ] p _ { 1 } \cdot \cdot \cdot p _ { s }$ [SEP]. The sequence is then fed into the pre-trained model with two extra linear layers for predicting the start and end positions of the answer spans. The detailed fine-tuning setting is listed in Appendix A.4. Table 3 and Table 4 report the experimental results.
Table 3: Dev set results on SQuAD 1.1/2.0. The result of XLNet(-Base) is from (Yang et al., 2019).
<table><tr><td></td><td></td><td colspan="2">SQuAD 1.1</td><td colspan="2">SQuAD 2.0</td></tr><tr><td>N</td><td>Model</td><td>EM</td><td>F1</td><td>EM</td><td>F1</td></tr><tr><td>=</td><td>Human Perf.</td><td>82.30</td><td>91.20</td><td>86.80</td><td>89.40</td></tr><tr><td></td><td>Google BERT</td><td>81.19</td><td>88.45</td><td>74.08</td><td>77.16</td></tr><tr><td></td><td>XLNet</td><td>-</td><td>-</td><td>78.46</td><td>81.33</td></tr><tr><td></td><td>RoBERTa-2seq</td><td>82.91</td><td>89.78</td><td>75.79</td><td>79.17</td></tr><tr><td>512</td><td>RoBERTa-1seq</td><td>84.43</td><td>91.48</td><td>79.22</td><td>82.27</td></tr><tr><td></td><td>SparseBERT</td><td>80.49</td><td>88.09</td><td>74.15</td><td>76.96</td></tr><tr><td></td><td>BlockBERT n=2,10:2</td><td>84.08</td><td>90.77</td><td>78.34</td><td>81.46</td></tr><tr><td></td><td>BlockBERT n=3,8:2:2</td><td>82.37</td><td>89.64</td><td>77.33</td><td>80.33</td></tr><tr><td></td><td>RoBERTa-1seq</td><td>84.58</td><td>91.14</td><td>79.34</td><td>82.26</td></tr><tr><td></td><td>SparseBERT</td><td>81.02</td><td>88.37</td><td>74.51</td><td>77.57</td></tr><tr><td>1024</td><td>BlockBERT n=2,9:3</td><td>83.65</td><td>90.74</td><td>78.55</td><td>81.45</td></tr><tr><td></td><td>BlockBERT n=3,8:2:2</td><td>82.74</td><td>90.05</td><td>76.79</td><td>79.84</td></tr></table>
BlockBERT $\scriptstyle ( \mathbf { n } = 2 )$ v.s. RoBERTa-1seq Comparing BlockBERT $( n = 2$ ) with RoBERTa-1seq on pre-trained model with $N = 5 1 2$ , we observe an absolute F1 difference from 0.04 (in NaturalQA) to 1.18 (in NewsQA), with average difference to be 0.55. For $N = 1 0 2 4$ , BlockBERT achieves more comparable or even better performance (in SearchQA, NewsQA, and HotpotQA) to RoBERTa-1seq. The average difference on F1 reduces to 0.27.
BlockBERT v.s. SparseBERT For $N = 5 1 2$ , it is interesting that BlockBERT with 3 blocks (density $3 3 . 3 3 \%$ ) performs better then SparseBERT (density $4 4 . 2 0 \%$ ) in both SQuAD and MrQA tasks. Similar patterns can be observed for $N = 1 0 2 4$ . These results show that off-diagonal masking matrices, e.g., the masking matrix defined by permutation $( 2 , 1 )$ , play crucial roles in BlockBERT.
Effect of Long Sequence Pre-training Our observations are twofold. (1) Long sequence pretraining benefits long sequence fine-tuning. In TriviaQA and SearchQA, of which paragraph lengths are around 1024, pre-training models with $N = 1 0 2 4$ achieve significantly better performance. (2) The heterogeneity of pre-training and fine-tuning sequence length may hurt performance. For example, in SQuAD, we do not see significant performance gain by using pre-trained models with $N = 1 0 2 4$ ; in HotpotQA and NewsQA, longer sequence pre-training even hurts performance.
Effect of #Blocks It is not surprising that BlockBERT with 2 blocks ${ \it n } = 2$ ) performs better than that with 3 blocks ${ \mathrm { ~ \ : ~ } } ( n = 3$ ), because it keeps more attention matrix entries. The biggest difference is in SQuAD 2.0 and NewsQA with $N = 1 0 2 4$ , where we observe an absolute loss of 1.6 F1 by increasing block number from 2 to 3.
In summary, not only BlockBERT saves training time and memory, but it also has competitive and sometimes better performance, especially for tasks with longer sequences. This demonstrates the effectiveness of our blockwise multi-head attention approach.
Table 4: MrQA test results (Tasks are sorted decreasingly by average paragraph length).
<table><tr><td></td><td></td><td colspan="2">SearchQA</td><td colspan="2">TriviaQA</td><td colspan="2">NewsQA</td><td colspan="2">NaturalQA</td><td colspan="2">HotpotQA</td></tr><tr><td>N</td><td>Model</td><td>EM</td><td>F1</td><td>EM</td><td>F1</td><td>EM</td><td>F1</td><td>EM</td><td>F1</td><td>EM</td><td>F1</td></tr><tr><td rowspan="6">512</td><td>Google BERT</td><td>74.94</td><td>80.37</td><td>70.18</td><td>75.35</td><td>51.27</td><td>66.25</td><td>66.13</td><td>78.29</td><td>60.50</td><td>77.08</td></tr><tr><td>RoBERTa-2seq</td><td>76.12</td><td>81.74</td><td>71.92</td><td>76.79</td><td>52.45</td><td>66.73</td><td>66.98</td><td>78.63</td><td>61.52</td><td>77.81</td></tr><tr><td>RoBERTa-1seq</td><td>77.09</td><td>82.62</td><td>73.65</td><td>78.22</td><td>56.13</td><td>70.64</td><td>67.14</td><td>79.07</td><td>62.77</td><td>79.28</td></tr><tr><td>SparseBERT</td><td>73.36</td><td>79.01</td><td>68.71</td><td>73.15</td><td>51.18</td><td>65.47</td><td>65.53</td><td>77.46</td><td>58.54</td><td>74.85</td></tr><tr><td>BlockBERT n=2,10:2</td><td>76.68</td><td>82.33</td><td>72.36</td><td>77.53</td><td>54.66</td><td>69.46</td><td>66.94</td><td>79.03</td><td>62.13</td><td>79.15</td></tr><tr><td>BlockBERT n=3,8:2:2</td><td>75.54</td><td>81.07</td><td>72.05</td><td>76.74</td><td>53.82</td><td>68.39</td><td>66.14</td><td>78.47</td><td>60.64</td><td>77.46</td></tr><tr><td rowspan="4">1024</td><td>RoBERTa-1seq</td><td>77.47</td><td>83.12</td><td>75.29</td><td>80.20</td><td>55.00</td><td>69.64</td><td>68.28</td><td>80.35</td><td>61.89</td><td>78.71</td></tr><tr><td>SparseBERT</td><td>74.83</td><td>80.54</td><td>70.56</td><td>75.34</td><td>51.67</td><td>67.16</td><td>65.07</td><td>77.31</td><td>59.65</td><td>76.02</td></tr><tr><td>BlockBERT n=2, 9:3</td><td>77.95</td><td>83.51</td><td>75.06</td><td>79.41</td><td>55.44</td><td>70.08</td><td>67.31</td><td>79.39</td><td>62.13</td><td>78.94</td></tr><tr><td>BlockBERT n=3,8:2:2</td><td>76.98</td><td>82.76</td><td>74.78</td><td>79.28</td><td>53.48</td><td>68.50</td><td>65.91</td><td>78.20</td><td>61.89</td><td>78.18</td></tr></table>
# 4.3 ABLATION STUDY
We fix the assignment of attention heads in above experiments. For example, BlockBERT with sequence length $N = 5 1 2$ and 2 blocks is trained with ten heads using permutation $( 1 , 2 )$ and the other two using permutation $( 2 , 1 )$ . However, we know that there are other ways to partition twelve attention heads, e.g., seven heads for permutation $( 1 , 2 )$ and the other five for permutation $( 2 , 1 )$ . It would be interesting to see how the assignment of heads affects model performance. In this section, we grid search attention head assignments and plot their best validation performance in $1 . 2 \mathbf { M }$ training steps. The results are shown in Figure 4.
Our observations are threefold: (1) Identity permutations, i.e., $( 1 , 2 )$ and $( 1 , 2 , 3 )$ , are important. As shown in Figure 4, all optimal solutions assign considerable attention heads to block diagonal matrices, since those matrices enable each token to attend to its nearby tokens; (2) Non-identity permutations follow the rule of “vital few and trivial many.” Although identity permutations are important, assigning all attention heads to them (corresponding to 12:0 and 12:0:0 in Figure 4) significantly hurts performance, since the model can not learn long-term dependencies with only identity permutation; (3) Pre-training performance and fine-tuning performance are correlated but not always consistent. When $n = 3$ , pre-training performance suggests 10:1:1 to be the best head assignment — ten heads for permutation $( 1 , 2 , 3 )$ , one head for $( 2 , 3 , 1 )$ and one head for $( 3 , 1 , 2 )$ , but we observe that the configuration of 8:2:2 achieves better performance in fine-tuning tasks.
 Figure 4: Ablation over blockwise attention heads assignment.
# 5 RELATED WORK
In this section, we review the related work of memory optimization for neural network training and recent efforts to simplify Transformer and BERT. In recent years, there is an increasing interest in training neural networks with low-memory (Sohoni et al., 2019). Mainstream techniques include low-precision training (Micikevicius et al., 2017), microbatching (Huang et al., 2018), gradient checkpointing (Chen et al., 2016). Another line of researches studies this problem from a theoretical perspective, including the recently proposed lottery ticket hypothesis (Frankle & Carbin, 2018). Since the invention of Transformer (Vaswani et al., 2017; Dai et al., 2019) and its successful application on language model pre-training (Devlin et al., 2019; Radford et al., 2019; Yang et al., 2019; Liu et al., 2019), there have been several studies attempted to simplify it from different perspectives. The first line of research focuses on attention matrix sparsification, such as Star Transformer (Guo et al., 2019), Sparse Transformer (Child et al., 2019), Adaptive Sparse Transformer (Correia et al., 2019; Sukhbaatar et al., 2019), Log-Sparse Transformer (Li et al., 2019), etc. However, due to limited support for sparse tensor from current deep learning platforms, most of studies have to represent a sparse matrix using a dense matrix with a binary mask or rely on customized CUDA kernels (Gray et al., 2017). The second line of research attempts to prune redundant heads in Transformer, such as Voita et al. (2019) and Michel et al. (2019). The third line of research focuses on knowledge distillation, including DistilBERT7 which distills BERT using a smaller BERT and Tang et al. (2019) which distills BERT with BiLSTM (Hochreiter & Schmidhuber, 1997).
# 6 CONCLUSION
In this work, we study lightweight BERT model with the goal of achieving both efficiency and effectiveness. We profile and analyze the memory bottlenecks of BERT, and focus on optimize dotproduct self-attention, which consumes quadratic memory with respect to the sequence length. To reduce both training time and memory consumption, we present BlockBERT, which sparsifies the attention matrices to be sparse block matrices. The proposed model achieves time and memory saving without significant loss of performance. In the future, we would like to explore more applications of BlockBERT on NLP tasks involving long sequences such as coreference resolution (Joshi et al., 2019b) and document-level machine translation (Miculicich et al., 2018), and also non-NLP tasks such as protein sequence modeling (Rives et al., 2019).
# REFERENCES
Tianqi Chen, Bing Xu, Chiyuan Zhang, and Carlos Guestrin. Training deep nets with sublinear memory cost. arXiv preprint arXiv:1604.06174, 2016. Rewon Child, Scott Gray, Alec Radford, and Ilya Sutskever. Generating long sequences with sparse transformers. arXiv preprint arXiv:1904.10509, 2019. Gonc¸alo M Correia, Vlad Niculae, and Andre FT Martins. Adaptively sparse transformers. ´ arXiv preprint arXiv:1909.00015, 2019. Zihang Dai, Zhilin Yang, Yiming Yang, William W Cohen, Jaime Carbonell, Quoc V Le, and Ruslan Salakhutdinov. Transformer-xl: Attentive language models beyond a fixed-length context. arXiv preprint arXiv:1901.02860, 2019. Jacob Devlin, Ming-Wei Chang, Kenton Lee, and Kristina Toutanova. Bert: Pre-training of deep bidirectional transformers for language understanding. In NAACL-HLT’ 2019, pp. 4171–4186, 2019. Matthew Dunn, Levent Sagun, Mike Higgins, V Ugur Guney, Volkan Cirik, and Kyunghyun Cho. Searchqa: A new q&a dataset augmented with context from a search engine. arXiv preprint arXiv:1704.05179, 2017. Jonathan Frankle and Michael Carbin. The lottery ticket hypothesis: Finding sparse, trainable neural networks. arXiv preprint arXiv:1803.03635, 2018. Scott Gray, Alec Radford, and Diederik P Kingma. Gpu kernels for block-sparse weights. arXiv preprint arXiv:1711.09224, 2017. Qipeng Guo, Xipeng Qiu, Pengfei Liu, Yunfan Shao, Xiangyang Xue, and Zheng Zhang. Startransformer. In NAACL-HLT’ 2019, pp. 1315–1325, 2019. Geoffrey Hinton, Oriol Vinyals, and Jeff Dean. Distilling the knowledge in a neural network. arXiv preprint arXiv:1503.02531, 2015. Sepp Hochreiter and Jurgen Schmidhuber. Long short-term memory. ¨ Neural computation, 9(8): 1735–1780, 1997. 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. arXiv preprint arXiv:1811.06965, 2018. Mandar Joshi, Eunsol Choi, Daniel Weld, and Luke Zettlemoyer. Triviaqa: A large scale distantly supervised challenge dataset for reading comprehension. In ACL’ 17, pp. 1601–1611, 2017. Mandar Joshi, Danqi Chen, Yinhan Liu, Daniel S Weld, Luke Zettlemoyer, and Omer Levy. Spanbert: Improving pre-training by representing and predicting spans. arXiv preprint arXiv:1907.10529, 2019a. Mandar Joshi, Omer Levy, Daniel S Weld, and Luke Zettlemoyer. Bert for coreference resolution:
Baselines and analysis. arXiv preprint arXiv:1908.09091, 2019b.
Diederik P Kingma and Jimmy Ba. Adam: A method for stochastic optimization. arXiv preprint arXiv:1412.6980, 2014.
Tom Kwiatkowski, Jennimaria Palomaki, Olivia Redfield, Michael Collins, Ankur Parikh, Chris Alberti, Danielle Epstein, Illia Polosukhin, Jacob Devlin, Kenton Lee, et al. Natural questions: a benchmark for question answering research. Transactions of the Association for Computational Linguistics, 7:453–466, 2019.
Kenton Lee, Ming-Wei Chang, and Kristina Toutanova. Latent retrieval for weakly supervised open domain question answering. arXiv preprint arXiv:1906.00300, 2019.
Shiyang Li, Xiaoyong Jin, Yao Xuan, Xiyou Zhou, Wenhu Chen, Yu-Xiang Wang, and Xifeng Yan. Enhancing the locality and breaking the memory bottleneck of transformer on time series forecasting. arXiv preprint arXiv:1907.00235, 2019.
Yinhan Liu, Myle Ott, Naman Goyal, Jingfei Du, Mandar Joshi, Danqi Chen, Omer Levy, Mike Lewis, Luke Zettlemoyer, and Veselin Stoyanov. Roberta: A robustly optimized bert pretraining approach. arXiv preprint arXiv:1907.11692, 2019.
Paul Michel, Omer Levy, and Graham Neubig. Are sixteen heads really better than one? arXiv preprint arXiv:1905.10650, 2019.
Paulius Micikevicius, Sharan Narang, Jonah Alben, Gregory Diamos, Erich Elsen, David Garcia, Boris Ginsburg, Michael Houston, Oleksii Kuchaiev, Ganesh Venkatesh, et al. Mixed precision training. arXiv preprint arXiv:1710.03740, 2017.
Lesly Miculicich, Dhananjay Ram, Nikolaos Pappas, and James Henderson. Document-level neural machine translation with hierarchical attention networks. In EMNLP’ 18, pp. 2947–2954, 2018.
Rodrigo Nogueira and Kyunghyun Cho. Passage re-ranking with bert. arXiv preprint arXiv:1901.04085, 2019.
Myle Ott, Sergey Edunov, Alexei Baevski, Angela Fan, Sam Gross, Nathan Ng, David Grangier, and Michael Auli. fairseq: A fast, extensible toolkit for sequence modeling. arXiv preprint arXiv:1904.01038, 2019.
Matthew Peters, Mark Neumann, Mohit Iyyer, Matt Gardner, Christopher Clark, Kenton Lee, and Luke Zettlemoyer. Deep contextualized word representations. In Proceedings of the 2018 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, Volume 1 (Long Papers), pp. 2227–2237, 2018.
Alec Radford, Jeff Wu, Rewon Child, David Luan, Dario Amodei, and Ilya Sutskever. Language models are unsupervised multitask learners. 2019.
Pranav Rajpurkar, Robin Jia, and Percy Liang. Know what you don’t know: Unanswerable questions for squad. arXiv preprint arXiv:1806.03822, 2018.
Alexander Rives, Siddharth Goyal, Joshua Meier, Demi Guo, Myle Ott, C Lawrence Zitnick, Jerry Ma, and Rob Fergus. Biological structure and function emerge from scaling unsupervised learning to 250 million protein sequences. bioRxiv, pp. 622803, 2019.
Livio Baldini Soares, Nicholas FitzGerald, Jeffrey Ling, and Tom Kwiatkowski. Matching the blanks: Distributional similarity for relation learning. arXiv preprint arXiv:1906.03158, 2019.
Nimit Sharad Sohoni, Christopher Richard Aberger, Megan Leszczynski, Jian Zhang, and Christopher Re. Low-memory neural network training: A technical report. ´ arXiv preprint arXiv:1904.10631, 2019.
Sainbayar Sukhbaatar, Edouard Grave, Piotr Bojanowski, and Armand Joulin. Adaptive attention span in transformers. arXiv preprint arXiv:1905.07799, 2019.
Raphael Tang, Yao Lu, Linqing Liu, Lili Mou, Olga Vechtomova, and Jimmy Lin. Distilling taskspecific knowledge from bert into simple neural networks. arXiv preprint arXiv:1903.12136, 2019.
Adam Trischler, Tong Wang, Xingdi Yuan, Justin Harris, Alessandro Sordoni, Philip Bachman, and Kaheer Suleman. Newsqa: A machine comprehension dataset. In Proceedings of the 2nd Workshop on Representation Learning for NLP, pp. 191–200, 2017.
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.
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.
Zhilin Yang, Peng Qi, Saizheng Zhang, Yoshua Bengio, William W. Cohen, Ruslan Salakhutdinov, and Christopher D. Manning. HotpotQA: A dataset for diverse, explainable multi-hop question answering. In EMNLP’ 18, 2018.
Zhilin Yang, Zihang Dai, Yiming Yang, Jaime Carbonell, Ruslan Salakhutdinov, and Quoc V Le. Xlnet: Generalized autoregressive pretraining for language understanding. arXiv preprint arXiv:1906.08237, 2019.
# A APPENDIX
# A.1 NOTATIONS AND PRE-TRAINING HYPER-PARAMETERS
The notations and pre-training hyper-parameters are listed in Table 5 and Table 6.
Table 5: BERT notations.
<table><tr><td></td><td>Description</td><td>Base</td><td>Large</td></tr><tr><td>B</td><td>Batch size</td><td>256</td><td>256</td></tr><tr><td>A</td><td># Self-attention heads</td><td>12</td><td>16</td></tr><tr><td>L</td><td>#Layers</td><td>12</td><td>24</td></tr><tr><td>H</td><td># Hidden units</td><td>768</td><td>1024</td></tr><tr><td>4H</td><td>#Feed-forward hidden units</td><td>3072</td><td>4096</td></tr><tr><td>N</td><td>Sequence length</td><td>512</td><td>512</td></tr></table>
Table 6: Pre-training hyperparameters.
<table><tr><td>Hyper-parameter</td><td>Value</td></tr><tr><td>Vocabulary Size</td><td>30,522</td></tr><tr><td>Dropout</td><td>0.1</td></tr><tr><td>Attention dropout</td><td>0.1</td></tr><tr><td>Warmup steps</td><td>10K</td></tr><tr><td>Weight decay</td><td>0.01</td></tr><tr><td>Max steps</td><td>2.4M</td></tr><tr><td>Initial learning rate</td><td>0.00025</td></tr><tr><td>Learning rate decay</td><td>Linear</td></tr><tr><td>Adam ∈</td><td>1e-8</td></tr><tr><td>Adam β1</td><td>0.9</td></tr><tr><td>Adam β2</td><td>0.999</td></tr><tr><td>Gradient Clipping</td><td>1.0</td></tr></table>
# A.2 PROFILER IMPLEMENTATION
Among the three types of training memory, model memory and optimizer memory is relatively easy to profile (can be computed by enumerate each tenor and summing up tensor.numel() $\star$ tensor.element size()). To calculate activation memory, Sohoni et al. (2019) traverse PyTorch’s autograd graph and sum up necessary storage space. They find that the summation of model memory, optimizer memory and activation memory matches PyTorch memory profiling tool torch.cuda.max memory allocated. Based on their observation, we use
torch.cuda.max memory allocated − model memory − optimizer memory as an estimate to activation memory. When profiling BERT, we first pre-train it for 1000 steps, and then compute its model and optimizer memory. Finally, we esitmate its activation memory according to Equation 4.
# A.3 SPARSEBERT
The sparse masking matrices we use for Sparse Transformer (Child et al., 2019) are shown in Figure 5. We adopt the implementation from Fairseq8.
 Figure 5: The sparse masking matrices we use in Sparse Transformer (fixed mode) encoder. White color indicates attention values to be masked. (a) $\bar { N } = 5 1 2 , \ell = 1 2 8 , c = 3 2$ , density $4 4 . 2 0 \%$ ; (b) $N = 1 0 2 4 , \ell = 1 2 8$ , $c = 3 2$ , density $3 4 . 9 7 \%$ .
# A.4 FINE-TUNING SETTINGS
Our fine-tuning is implemented based on code base from HuggingFace9 and SpanBERT (Joshi et al., 2019a). We use max sequence length $\it { \Omega } = \it { N }$ , i.e., we allow fine-tuning task to input sequences as long as the pre-training model. If the input sequence is too long to fit the max sequence lengt $\neg = N$ constraints, we use a sliding window of stride 128 to split it. We grid search learning rate from {5e-6, 1e-5, 2e-5, 3e-5, 5e-5} and batch size from $\{ 1 6 , 3 2 \}$ . The fine-tuning is performed for 4 epoches.
 Figure 6: Paragraph length (after tokenization) distribution. The distribution of SQuAD 2.0 is very similar to SQuAD 1.1, so we only plot SQuAD 1.1 here.
# A.5 TEST EFFICIENCY
We benchmark test efficiency of RoBERTa and our proposed BlockBERT. The benchmark code follows huggingface10. All experiments are run 30 times on a 32GB V100 GPU with half precision (FP16). We report the average running time at Table 7. As we can see, BlockBERT does achieve speedup and memory reduction during test time. Take $8 \times 1 0 2 4$ , i.e., batch size $B = 8$ sequence length $N = 1 0 2 4$ , as an example, we can see that BlockBERT with 2 blocks saves $2 7 . 8 \%$ of test time, and BlockBERT with 3 blocks saves more $( 3 0 . 4 \% )$ . As for memory, we can observe that RoBERTa can not handle an input of $1 6 \times 1 0 2 4$ , while it is possible for BlockBERT to work on it.
<table><tr><td>B×N</td><td>8×1024</td><td>16×1024</td><td>24×1024</td><td>32×1024</td></tr><tr><td>RoBERTa</td><td>0.1371</td><td>OOM</td><td>0OM</td><td>OOM</td></tr><tr><td>BlockBERT n=2</td><td>0.0990</td><td>0.1869</td><td>0OM</td><td>0OM</td></tr><tr><td>BlockBERT n=3</td><td>0.0954</td><td>0.1790</td><td>0.2634</td><td>OOM</td></tr></table>
Table 7: Test time statistics (sec) for different input size (Batch size $\times$ Sequence length). OOM indicates out-of-memory.123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437# FIXUP INITIALIZATION: RESIDUAL LEARNING WITHOUT NORMALIZATION
Hongyi Zhang∗ MIT hongyiz@mit.edu
Yann N. Dauphin† Google Brain yann@dauphin.io
Tengyu Ma‡ Stanford University tengyuma@stanford.edu
# ABSTRACT
Normalization layers are a staple in state-of-the-art deep neural network architectures. They are widely believed to stabilize training, enable higher learning rate, accelerate convergence and improve generalization, though the reason for their effectiveness is still an active research topic. In this work, we challenge the commonly-held beliefs by showing that none of the perceived benefits is unique to normalization. Specifically, we propose fixed-update initialization (Fixup), an initialization motivated by solving the exploding and vanishing gradient problem at the beginning of training via properly rescaling a standard initialization. We find training residual networks with Fixup to be as stable as training with normalization — even for networks with 10,000 layers. Furthermore, with proper regularization, Fixup enables residual networks without normalization to achieve state-of-the-art performance in image classification and machine translation.
# 1 INTRODUCTION
Artificial intelligence applications have witnessed major advances in recent years. At the core of this revolution is the development of novel neural network models and their training techniques. For example, since the landmark work of He et al. (2016), most of the state-of-the-art image recognition systems are built upon a deep stack of network blocks consisting of convolutional layers and additive skip connections, with some normalization mechanism (e.g., batch normalization (Ioffe & Szegedy, 2015)) to facilitate training and generalization. Besides image classification, various normalization techniques (Ulyanov et al., 2016; Ba et al., 2016; Salimans & Kingma, 2016; Wu & He, 2018) have been found essential to achieving good performance on other tasks, such as machine translation (Vaswani et al., 2017) and generative modeling (Zhu et al., 2017). They are widely believed to have multiple benefits for training very deep neural networks, including stabilizing learning, enabling higher learning rate, accelerating convergence, and improving generalization.
Despite the enormous empirical success of training deep networks with normalization, and recent progress on understanding the working of batch normalization (Santurkar et al., 2018), there is currently no general consensus on why these normalization techniques help training residual neural networks. Intrigued by this topic, in this work we study
(i) without normalization, can a deep residual network be trained reliably? (And if so,) (ii) without normalization, can a deep residual network be trained with the same learning rate, converge at the same speed, and generalize equally well (or even better)?
Perhaps surprisingly, we find the answers to both questions are Yes. In particular, we show:
• Why normalization helps training. We derive a lower bound for the gradient norm of a residual network at initialization, which explains why with standard initializations, normalization techniques are essential for training deep residual networks at maximal learning rate. (Section 2)
• Training without normalization. We propose Fixup, a method that rescales the standard initialization of residual branches by adjusting for the network architecture. Fixup enables training very deep residual networks stably at maximal learning rate without normalization. (Section 3)
• Image classification. We apply Fixup to replace batch normalization on image classification benchmarks CIFAR-10 (with Wide-ResNet) and ImageNet (with ResNet), and find Fixup with proper regularization matches the well-tuned baseline trained with normalization. (Section 4.2)
• Machine translation. We apply Fixup to replace layer normalization on machine translation benchmarks IWSLT and WMT using the Transformer model, and find it outperforms the baseline and achieves new state-of-the-art results on the same architecture. (Section 4.3)
 Figure 1: Left: ResNet basic block. Batch normalization (Ioffe & Szegedy, 2015) layers are marked in red. Middle: A simple network block that trains stably when stacked together. Right: Fixup further improves by adding bias parameters. (See Section 3 for details.)
In the remaining of this paper, we first analyze the exploding gradient problem of residual networks at initialization in Section 2. To solve this problem, we develop Fixup in Section 3. In Section 4 we quantify the properties of Fixup and compare it against state-of-the-art normalization methods on real world benchmarks. A comparison with related work is presented in Section 5.
# 2 PROBLEM: RESNET WITH STANDARD INITIALIZATIONS LEAD TO EXPLODING GRADIENTS
Standard initialization methods (Glorot & Bengio, 2010; He et al., 2015; Xiao et al., 2018) attempt to set the initial parameters of the network such that the activations neither vanish nor explode. Unfortunately, it has been observed that without normalization techniques such as BatchNorm they do not account properly for the effect of residual connections and this causes exploding gradients. Balduzzi et al. (2017) characterizes this problem for ReLU networks, and we will generalize this to residual networks with positively homogenous activation functions. A plain (i.e. without normalization layers) ResNet with residual blocks $\{ F _ { 1 } , \ldots , F _ { L } \}$ and input $\mathbf { x } _ { \mathrm { 0 } }$ computes the activations as
$$\mathbf { x } _ { l } = \mathbf { x } _ { 0 } + \sum _ { i = 0 } ^ { l - 1 } F _ { i } ( \mathbf { x } _ { i } ) .$$
ResNet output variance grows exponentially with depth. Here we only consider the initialization, view the input $\mathbf { x } _ { \mathrm { 0 } }$ as fixed, and consider the randomness of the weight initialization. We analyze the variance of each layer $\mathbf { x } _ { l }$ , denoted by $\mathrm { V a r } [ { \bf x } _ { l } ]$ (which is technically defined as the sum of the variance of all the coordinates of $\mathbf { x } _ { l }$ .) For simplicity we assume the blocks are initialized to be zero mean, i.e., $\mathbb { E } [ F _ { l } ( \mathbf { x } _ { l } ) \mid \mathbf { x } _ { l } ] = 0$ . By $\mathbf { x } _ { l + 1 } = \mathbf { x } _ { l } + F _ { l } ( \mathbf { x } _ { l } )$ , and the law of total variance, we have $\mathrm { V a r } [ \mathbf { x } _ { l + 1 } ] = \mathbb { E } [ \mathrm { V a r } [ F ( \mathbf { x } _ { l } ) | \mathbf { x } _ { l } ] ] + \mathrm { V a r } ( \mathbf { x } _ { l } )$ . Resnet structure prevents $\mathbf { x } _ { l }$ from vanishing by forcing the variance to grow with depth, i.e. $\mathrm { V a r } [ \mathbf { x } _ { l } ] < \mathrm { V a r } [ \mathbf { x } _ { l + 1 } ]$ if $\mathbb { E } [ \mathrm { V a r } [ F ( \mathbf { x } _ { l } ) | \mathbf { x } _ { l } ] ] > 0$ . Yet, combined with initialization methods such as He et al. (2015), the output variance of each residual branch $\mathrm { V a r } [ F _ { l } ( \mathbf { x } _ { l } ) | \mathbf { x } _ { l } ]$ will be about the same as its input variance $\mathrm { V a r } [ \mathbf { x } _ { l } ]$ , and thus $\mathrm { V a r } [ \mathbf { x } _ { l + 1 } ] \approx 2 \mathrm { V a r } [ \mathbf { x } _ { l } ]$ . This causes the output variance to explode exponentially with depth without normalization (Hanin & Rolnick, 2018) for positively homogeneous blocks (see Definition 1). This is detrimental to learning because it can in turn cause gradient explosion.
As we will show, at initialization, the gradient norm of certain activations and weight tensors is lower bounded by the cross-entropy loss up to some constant. Intuitively, this implies that blowup in the logits will cause gradient explosion. Our result applies to convolutional and linear weights in a neural network with ReLU nonlinearity (e.g., feed-forward network, CNN), possibly with skip connections (e.g., ResNet, DenseNet), but without any normalization.
Our analysis utilizes properties of positively homogeneous functions, which we now introduce.
Definition 1 (positively homogeneous function of first degree). A function $f : \mathbb { R } ^ { m } \mathbb { R } ^ { n }$ is called positively homogeneous (of first degree) (p.h.) if for any input $\mathbf { x } \in \mathbb { R } ^ { m }$ and $\alpha > 0$ , $f ( \alpha \mathbf { x } ) = \alpha f ( \mathbf { x } )$ .
Definition 2 (positively homogeneous set of first degree). Let $\theta = \{ \theta _ { i } \} _ { i \in S }$ be the set of parameters of $f ( \mathbf { x } )$ and $\bar { \theta _ { p h } } = \{ \bar { \theta } _ { i } \} _ { i \in S _ { p h } \subset S }$ . We call $\theta _ { p h }$ a positively homogeneous set (of first degree) (p.h. set) if for any $\alpha > 0$ , $f ( { \bf { x } } ; \theta \dot { \bf { \delta } } \theta _ { p h } , \alpha \theta _ { p h } ) = \alpha f ( { \bf { x } } ; \theta \dot { \bf { \delta } } \theta _ { p h } , \theta _ { p h } )$ , where $\alpha \theta _ { p h }$ denotes $\{ \alpha \theta _ { i } \} _ { i \in S _ { p h } }$ .
Intuitively, a p.h. set is a set of parameters $\theta _ { p h }$ in function $f$ such that for any fixed input $\mathbf { x }$ and fixed parameters $\theta \setminus \theta _ { p h } , \bar { f } ( \theta _ { p h } ) \triangleq f ( \mathbf { x } ; \theta \setminus \theta _ { p h } , \theta _ { p h } )$ is a p.h. function.
Examples of p.h. functions are ubiquitous in neural networks, including various kinds of linear operations without bias (fully-connected (FC) and convolution layers, pooling, addition, concatenation and dropout etc.) as well as ReLU nonlinearity. Moreover, we have the following claim:
Proposition 1. A function that is the composition of p.h. functions is itself p.h.
We study classification problems with $c$ classes and the cross-entropy loss. We use $f$ to denote a neural network function except for the softmax layer. Cross-entropy loss is defined as $\ell ( \mathbf { z } , \mathbf { y } ) \triangleq$ $- \mathbf { y } ^ { T } ( \mathbf { z } - \mathsf { l o g s u m e x p } ( \mathbf { z } ) )$ where $\mathbf { y }$ is the one-hot label vector, $\mathbf { z } \triangleq f ( \mathbf { x } ) \in \mathbb { R } ^ { c }$ is the logits where $z _ { i }$ denotes its $i$ -th element, and $\begin{array} { r } { \mathsf { l o g s u m e x p } ( \mathbf { z } ) \triangleq \log \left( \sum _ { i \in [ c ] } \exp ( z _ { i } ) \right) } \end{array}$ . Consider a minibatch of training examples $\mathcal { D } _ { M } = \{ ( \mathbf { x } ^ { ( m ) } , \mathbf { y } ^ { ( m ) } ) \} _ { m = 1 } ^ { M }$ and the average cross-entropy loss $\ell _ { \mathrm { a v g } } ( { \mathcal D } _ { M } ) \triangleq$ $\begin{array} { r } { \frac { 1 } { M } \sum _ { m = 1 } ^ { M } \ell ( f ( \mathbf { x } ^ { ( m ) } ) , \mathbf { y } ^ { ( m ) } ) } \end{array}$ , where we use $( m )$ to index quantities referring to the $m$ -th example. $\| \cdot \|$ denotes any valid norm. We only make the following assumptions about the network $f$ :
1. $f$ is a sequential composition of network blocks $\{ f _ { i } \} _ { i = 1 } ^ { L }$ , i.e. $f ( \mathbf { x } _ { 0 } ) = f _ { L } ( f _ { L - 1 } ( . . . f _ { 1 } ( \mathbf { x } _ { 0 } ) ) )$ , each of which is composed of p.h. functions. 2. Weight elements in the FC layer are i.i.d. sampled from a zero-mean symmetric distribution.
These assumptions hold at initialization if we remove all the normalization layers in a residual network with ReLU nonlinearity, assuming all the biases are initialized at 0.
Our results are summarized in the following two theorems, whose proofs are listed in the appendix: Theorem 1. Denote the input to the $i$ -th block by $\mathbf { x } _ { i - 1 }$ . With Assumption $^ { l }$ , we have
$$\left\| \frac { \partial \ell } { \partial \mathbf { x } _ { i - 1 } } \right\| \geq \frac { \ell ( \mathbf { z } , \mathbf { y } ) - H ( \mathbf { p } ) } { \left\| \mathbf { x } _ { i - 1 } \right\| } ,$$
where $\mathbf { p }$ is the softmax probabilities and $H$ denotes the Shannon entropy.
Since $H ( \mathbf { p } )$ is upper bounded by $\log ( c )$ and $\| \mathbf { x } _ { i - 1 } \|$ is small in the lower blocks, blowup in the loss will cause large gradient norm with respect to the lower block input. Our second theorem proves a lower bound on the gradient norm of a p.h. set in a network.
Theorem 2. With Assumption $^ { l }$ , we have
$$\left\| \frac { \partial \ell _ { \mathrm { a v g } } } { \partial \theta _ { p h } } \right\| \geq \frac { 1 } { M \| \theta _ { p h } \| } \sum _ { m = 1 } ^ { M } \ell ( \mathbf { z } ^ { ( m ) } , \mathbf { y } ^ { ( m ) } ) - H ( \mathbf { p } ^ { ( m ) } ) \triangleq G ( \theta _ { p h } ) .$$
Furthermore, with Assumptions $I$ and 2, we have
$$\mathbb { E } G ( \theta _ { p h } ) \geq \frac { \mathbb { E } [ \operatorname* { m a x } _ { i \in [ c ] } z _ { i } ] - \log ( c ) } { \| \theta _ { p h } \| } .$$
It remains to identify such p.h. sets in a neural network. In Figure 2 we provide three examples of p.h. sets in a ResNet without normalization. Theorem 2 suggests that these layers would suffer from the exploding gradient problem, if the logits $\mathbf { z }$ blow up at initialization, which unfortunately would occur in a ResNet without normalization if initialized in a traditional way. This motivates us to introduce a new initialization in the next section.
 Figure 2: Examples of p.h. sets in a ResNet without normalization: (1) the first convolution layer before max pooling; (2) the fully connected layer before softmax; (3) the union of a spatial downsampling layer in the backbone and a convolution layer in its corresponding residual branch.
# 3 FIXUP: UPDATE A RESIDUAL NETWORK $\Theta ( \eta )$ PER SGD STEP
Our analysis in the previous section points out the failure mode of standard initializations for training deep residual network: the gradient norm of certain layers is in expectation lower bounded by a quantity that increases indefinitely with the network depth. However, escaping this failure mode does not necessarily lead us to successful training — after all, it is the whole network as a function that we care about, rather than a layer or a network block. In this section, we propose a top-down design of a new initialization that ensures proper update scale to the network function, by simply rescaling a standard initialization. To start, we denote the learning rate by $\eta$ and set our goal:
$f ( \mathbf { x } ; \theta )$ is updated by $\Theta ( \eta )$ per SGD step after initialization as $\eta 0$ . That is, $\| \Delta f ( \mathbf { x } ) \| = \Theta ( \eta )$ where $\begin{array} { r } { \Delta f ( \mathbf x ) \triangleq f ( \mathbf x ; \theta - \eta \frac { \partial } { \partial \theta } \ell ( f ( \mathbf x ) , \mathbf y ) ) - f ( \mathbf x ; \theta ) . } \end{array}$
Put another way, our goal is to design an initialization such that SGD updates to the network function are in the right scale and independent of the depth.
We define the Shortcut as the shortest path from input to output in a residual network. The Shortcut is typically a shallow network with a few trainable layers.1 We assume the Shortcut is initialized using a standard method, and focus on the initialization of the residual branches.
Residual branches update the network in sync. To start, we first make an important observation that the SGD update to each residual branch changes the network output in highly correlated directions. This implies that if a residual network has $L$ residual branches, then an SGD step to each residual branch should change the network output by $\Theta ( \eta / L )$ on average to achieve an overall $\Theta ( \eta )$ update. We defer the formal statement and its proof until Appendix B.1.
Study of a scalar branch. Next we study how to initialize a residual branch with $m$ layers so that its SGD update changes the network output by $\Theta ( \eta / L )$ . We assume $m$ is a small positive integer (e.g., 2 or 3). As we are only concerned about the scale of the update, it is sufficiently instructive to study the scalar case, i.e., $\begin{array} { r } { F ( x ) = ( \prod _ { i = 1 } ^ { m } a _ { i } ) x } \end{array}$ where $a _ { 1 } , \dots , a _ { m } , x \in \mathbb { R } ^ { + }$ . For example, the standard initialization methods typically initialize each layer so that the output (after nonlinear activation) preserves the input variance, which can be modeled as setting $\forall i \in [ m ] , a _ { i } = 1$ . In turn, setting $a _ { i }$ to a positive number other than 1 corresponds to rescaling the i-th layer by $a _ { i }$ .
Through deriving the constraints for $F ( x )$ to make $\Theta ( \eta / L )$ updates, we will also discover how to rescale the weight layers of a standard initialization as desired. In particular, we show the SGD update to $F ( x )$ is $\Theta ( \eta / L )$ if and only $i f$ the initialization satisfies the following constraint:
$$\left( \prod _ { i \in [ m ] \setminus \{ j \} } a _ { i } \right) x = \Theta \left( { \frac { 1 } { \sqrt { L } } } \right) , \quad { \mathrm { w h e r e } } \quad j \in \arg \operatorname* { m i n } a _ { k }$$
We defer the derivation until Appendix B.2.
Equation (5) suggests new methods to initialize a residual branch through rescaling the standard initialization of i-th layer in a residual branch by its corresponding scalar $a _ { i }$ . For example, we could set $\forall i \in [ m ] , a _ { i } = L ^ { - { \frac { 1 } { 2 m - 2 } } }$ . Alternatively, we could start the residual branch as a zero function by setting $a _ { m } = 0$ and $\forall i \in [ m - 1 ] , a _ { i } = L ^ { - { \frac { 1 } { 2 m - 2 } } }$ . In the second option, the residual branch does not need to “unlearn” its potentially bad random initial state, which can be beneficial for learning. Therefore, we use the latter option in our experiments, unless otherwise specified.
The effects of biases and multipliers. With proper rescaling of the weights in all the residual branches, a residual network is supposed to be updated by $\Theta ( \eta )$ per SGD step — our goal is achieved. However, in order to match the training performance of a corresponding network with normalization, there are two more things to consider: biases and multipliers.
Using biases in the linear and convolution layers is a common practice. In normalization methods, bias and scale parameters are typically used to restore the representation power after normalization.2 Intuitively, because the preferred input/output mean of a weight layer may be different from the preferred output/input mean of an activation layer, it also helps to insert bias terms in a residual network without normalization. Empirically, we find that inserting just one scalar bias before each weight layer and nonlinear activation layer significantly improves the training performance.
Multipliers scale the output of a residual branch, similar to the scale parameters in batch normalization. They have an interesting effect on the learning dynamics of weight layers in the same branch. Specifically, as the stochastic gradient of a layer is typically almost orthogonal to its weight, learning rate decay tends to cause the weight norm equilibrium to shrink when combined with L2 weight decay (van Laarhoven, 2017). In a branch with multipliers, this in turn causes the growth of the multipliers, increasing the effective learning rate of other layers. In particular, we observe that inserting just one scalar multiplier per residual branch mimics the weight norm dynamics of a network with normalization, and spares us the search of a new learning rate schedule.
Put together, we propose the following method to train residual networks without normalization:
Fixup initialization (or: How to train a deep residual network without normalization)
1. Initialize the classification layer and the last layer of each residual branch to 0. 2. Initialize every other layer using a standard method (e.g., He et al. (2015)), and scale only the weight layers inside residual branches by $L ^ { - } { \frac { 1 } { 2 m - 2 } }$ . 3. Add a scalar multiplier (initialized at 1) in every branch and a scalar bias (initialized at 0) before each convolution, linear, and element-wise activation layer.
It is important to note that Rule 2 of Fixup is the essential part as predicted by Equation (5). Indeed, we observe that using Rule 2 alone is sufficient and necessary for training extremely deep residual networks. On the other hand, Rule 1 and Rule 3 make further improvements for training so as to match the performance of a residual network with normalization layers, as we explain in the above text.3 We find ablation experiments confirm our claims (see Appendix C.1).
Our initialization and network design is consistent with recent theoretical work Hardt & Ma (2016); Li et al. (2018), which, in much more simplified settings such as linearized residual nets and quadratic neural nets, propose that small initialization tend to stabilize optimization and help generalizaiton. However, our approach suggests that more delicate control of the scale of the initialization is beneficial.4
# 4 EXPERIMENTS
# 4.1 TRAINING AT INCREASING DEPTH
One of the key advatanges of BatchNorm is that it leads to fast training even for very deep models (Ioffe & Szegedy, 2015). Here we will determine if we can match this desirable property by relying only on proper initialization. We propose to evaluate how each method affects training very deep nets by measuring the test accuracy after the first epoch as we increase depth. In particular, we use the wide residual network (WRN) architecture with width 1 and the default weight decay $5 \mathrm { e } { - 4 }$ (Zagoruyko & Komodakis, 2016). We specifically use the default learning rate of 0.1 because the ability to use high learning rates is considered to be important to the success of BatchNorm. We compare Fixup against three baseline methods — (1) rescale the output of each residual block by $\scriptstyle { \frac { 1 } { \sqrt { 2 } } }$ (Balduzzi et al., 2017), (2) post-process an orthogonal initialization such that the output variance of each residual block is close to 1 (Layer-sequential unit-variance orthogonal initialization, or LSUV) (Mishkin & Matas, 2015), (3) batch normalization (Ioffe & Szegedy, 2015). We use the default batch size of 128 up to 1000 layers, with a batch size of 64 for 10,000 layers. We limit our budget of epochs to 1 due to the computational strain of evaluating models with up to 10,000 layers.
 Figure 3: Depth of residual networks versus test accuracy at the first epoch for various methods on CIFAR-10 with the default BatchNorm learning rate. We observe that Fixup is able to train very deep networks with the same learning rate as batch normalization. (Higher is better.)
Figure 3 shows the test accuracy at the first epoch as depth increases. Observe that Fixup matches the performance of BatchNorm at the first epoch, even with 10,000 layers. LSUV and $\\\bar { \sqrt { { ^ 1 \mathord { \left/ { \vphantom { ^ { 1 2 } } } \right. \kern - delimiterspace } 2 } } }$ -scaling are not able to train with the same learning rate as BatchNorm past 100 layers.
# 4.2 IMAGE CLASSIFICATION
In this section, we evaluate the ability of Fixup to replace batch normalization in image classification applications. On the CIFAR-10 dataset, we first test on ResNet-110 (He et al., 2016) with default hyper-parameters; results are shown in Table 1. Fixup obtains $7 \%$ relative improvement in test error compared with standard initialization; however, we note a substantial difference in the difficulty of training. While network with Fixup is trained with the same learning rate and converge as fast as network with batch normalization, we fail to train a Xavier initialized ResNet-110 with $0 . 1 \mathbf { x }$ maximal learning rate.5 The test error gap in Table 1 is likely due to the regularization effect of BatchNorm rather than difficulty in optimization; when we train Fixup networks with better regularization, the test error gap disappears and we obtain state-of-the-art results on CIFAR-10 and SVHN without normalization layers (see Appendix C.2).
Table 1: Results on CIFAR-10 with ResNet-110 (mean/median of 5 runs; lower is better).
<table><tr><td>Dataset</td><td>ResNet-110</td><td>Normalization</td><td>Large n</td><td>Test Error (%)</td></tr><tr><td rowspan="3">CIFAR-10</td><td>w/ BatchNorm (He et al., 2016)</td><td>√</td><td>√</td><td>6.61</td></tr><tr><td>w/ Xavier Init (Shang et al., 2017)</td><td>X</td><td>×</td><td>7.78</td></tr><tr><td>w/ Fixup-init</td><td>X</td><td></td><td>7.24</td></tr></table>
On the ImageNet dataset, we benchmark Fixup with the ResNet-50 and ResNet-101 architectures (He et al., 2016), trained for 100 epochs and 200 epochs respectively. Similar to our finding on the CIFAR-10 dataset, we observe that (1) training with Fixup is fast and stable with the default hyperparameters, (2) Fixup alone significantly improves the test error of standard initialization, and (3) there is a large test error gap between Fixup and BatchNorm. Further inspection reveals that Fixup initialized models obtain significantly lower training error compared with BatchNorm models (see Appendix C.3), i.e., Fixup suffers from overfitting. We therefore apply stronger regularization to the Fixup models using Mixup (Zhang et al., 2017). We find it is beneficial to reduce the learning rate of the scalar multiplier and bias by 10x when additional large regularization is used. Best Mixup coefficients are found through cross-validation: they are 0.2, 0.1 and 0.7 for BatchNorm, GroupNorm (Wu & He, 2018) and Fixup respectively. We present the results in Table 2, noting that with better regularization, the performance of Fixup is on par with GroupNorm.
Table 2: ImageNet test results using the ResNet architecture. (Lower is better.)
<table><tr><td>Model</td><td>Method</td><td>Normalization</td><td>Test Error (%)</td></tr><tr><td rowspan="5">ResNet-50</td><td>BatchNorm (Goyal et al., 2017)</td><td rowspan="4">√</td><td>23.6</td></tr><tr><td>BatchNorm + Mixup (Zhang et al.,2017)</td><td>23.3</td></tr><tr><td>GroupNorm + Mixup</td><td>23.9</td></tr><tr><td>Xavier Init (Shang et al.,2017)</td><td>31.5</td></tr><tr><td>Fixup-init</td><td rowspan="3">X</td><td>27.6</td></tr><tr><td>Fixup-init + Mixup</td><td>24.0</td></tr><tr><td>BatchNorm (Zhang et al., 2017)</td><td>22.0</td></tr><tr><td rowspan="3">ResNet-101</td><td>BatchNorm + Mixup (Zhang et al., 2017)</td><td rowspan="3">√</td><td>20.8</td></tr><tr><td>GroupNorm + Mixup</td><td>21.4</td></tr><tr><td>Fixup-init + Mixup X</td><td>21.4</td></tr></table>
# 4.3 MACHINE TRANSLATION
To demonstrate the generality of Fixup, we also apply it to replace layer normalization (Ba et al., 2016) in Transformer (Vaswani et al., 2017), a state-of-the-art neural network for machine translation. Specifically, we use the fairseq library (Gehring et al., 2017) and follow the Fixup template in Section 3 to modify the baseline model. We evaluate on two standard machine translation datasets, IWSLT German-English (de-en) and WMT English-German (en-de) following the setup of Ott et al. (2018). For the IWSLT de-en dataset, we cross-validate the dropout probability from $\{ 0 . 3 , 0 . 4 , 0 . 5 , 0 . 6 \}$ and find 0.5 to be optimal for both Fixup and the LayerNorm baseline. For the WMT’16 en-de dataset, we use dropout probability 0.4. All models are trained for $2 0 0 \mathrm { k }$ updates.
It was reported (Chen et al., 2018) that “Layer normalization is most critical to stabilize the training process... removing layer normalization results in unstable training runs”. However we find training with Fixup to be very stable and as fast as the baseline model. Results are shown in Table 3. Surprisingly, we find the models do not suffer from overfitting when LayerNorm is replaced by Fixup, thanks to the strong regularization effect of dropout. Instead, Fixup matches or supersedes the state-of-the-art results using Transformer model on both datasets.
Table 3: Comparing Fixup vs. LayerNorm for machine translation tasks. (Higher is better.)
<table><tr><td>Dataset</td><td>Model</td><td>Normalization</td><td>BLEU</td></tr><tr><td rowspan="2">IWSLT DE-EN</td><td>(Deng et al., 2018) LayerNorm</td><td>√</td><td>33.1 34.2</td></tr><tr><td>Fixup-init</td><td>X</td><td>34.5</td></tr><tr><td rowspan="3">WMT EN-DE</td><td>(Vaswani et al., 2017)</td><td></td><td>28.4</td></tr><tr><td>LayerNorm (Ott et al., 2018)</td><td>√</td><td>29.3</td></tr><tr><td>Fixup-init</td><td>×</td><td>29.3</td></tr></table>
# 5 RELATED WORK
Normalization methods. Normalization methods have enabled training very deep residual networks, and are currently an essential building block of the most successful deep learning architectures. All normalization methods for training neural networks explicitly normalize (i.e. standardize) some component (activations or weights) through dividing activations or weights by some real number computed from its statistics and/or subtracting some real number activation statistics (typically the mean) from the activations.6 In contrast, Fixup does not compute statistics (mean, variance or norm) at initialization or during any phase of training, hence is not a normalization method.
Theoretical analysis of deep networks. Training very deep neural networks is an important theoretical problem. Early works study the propagation of variance in the forward and backward pass for different activation functions (Glorot & Bengio, 2010; He et al., 2015).
Recently, the study of dynamical isometry (Saxe et al., 2013) provides a more detailed characterization of the forward and backward signal propogation at initialization (Pennington et al., 2017; Hanin, 2018), enabling training 10,000-layer CNNs from scratch (Xiao et al., 2018). For residual networks, activation scale (Hanin & Rolnick, 2018), gradient variance (Balduzzi et al., 2017) and dynamical isometry property (Yang & Schoenholz, 2017) have been studied. Our analysis in Section 2 leads to the similar conclusion as previous work that the standard initialization for residual networks is problematic. However, our use of positive homogeneity for lower bounding the gradient norm of a neural network is novel, and applies to a broad class of neural network architectures (e.g., ResNet, DenseNet) and initialization methods (e.g., Xavier, LSUV) with simple assumptions and proof.
Hardt & Ma (2016) analyze the optimization landscape (loss surface) of linearized residual nets in the neighborhood around the zero initialization where all the critical points are proved to be global minima. Yang & Schoenholz (2017) study the effect of the initialization of residual nets to the test performance and pointed out Xavier or He initialization scheme is not optimal. In this paper, we give a concrete recipe for the initialization scheme with which we can train deep residual networks without batch normalization successfully.
Understanding batch normalization. Despite its popularity in practice, batch normalization has not been well understood. Ioffe & Szegedy (2015) attributed its success to “reducing internal covariate shift”, whereas Santurkar et al. (2018) argued that its effect may be “smoothing loss surface”. Our analysis in Section 2 corroborates the latter idea of Santurkar et al. (2018) by showing that standard initialization leads to very steep loss surface at initialization. Moreover, we empirically showed in Section 3 that steep loss surface may be alleviated for residual networks by using smaller initialization than the standard ones such as Xavier or He’s initialization in residual branches. van Laarhoven (2017); Hoffer et al. (2018) studied the effect of (batch) normalization and weight decay on the effective learning rate. Their results inspire us to include a multiplier in each residual branch.
ResNet initialization in practice. Gehring et al. (2017); Balduzzi et al. (2017) proposed to address the initialization problem of residual nets by using the recurrence $\mathbf { x } _ { l } = \sqrt { 1 / _ { 2 } } ( \mathbf { x } _ { l - 1 } + F _ { l } ( \mathbf { x } _ { l - 1 } ) )$ . Mishkin & Matas (2015) proposed a data-dependent initialization to mimic the effect of batch normalization in the first forward pass. While both methods limit the scale of activation and gradient, they would fail to train stably at the maximal learning rate for very deep residual networks, since they fail to consider the accumulation of highly correlated updates contributed by different residual branches to the network function (Appendix B.1). Srivastava et al. (2015); Hardt & Ma (2016); Goyal et al. (2017); Kingma & Dhariwal (2018) found that initializing the residual branches at (or close to) zero helped optimization. Our results support their observation in general, but Equation (5) suggests additional subtleties when choosing a good initialization scheme.
# 6 CONCLUSION
In this work, we study how to train a deep residual network reliably without normalization. Our theory in Section 2 suggests that the exploding gradient problem at initialization in a positively homogeneous network such as ResNet is directly linked to the blowup of logits. In Section 3 we develop Fixup initialization to ensure the whole network as well as each residual branch gets updates of proper scale, based on a top-down analysis. Extensive experiments on real world datasets demonstrate that Fixup matches normalization techniques in training deep residual networks, and achieves state-of-the-art test performance with proper regularization.
Our work opens up new possibilities for both theory and applications. Can we analyze the training dynamics of Fixup, which may potentially be simpler than analyzing models with batch normalization is? Could we apply or extend the initialization scheme to other applications of deep learning? It would also be very interesting to understand the regularization benefits of various normalization methods, and to develop better regularizers to further improve the test performance of Fixup.
# ACKNOWLEDGMENTS
The authors would like to thank Yuxin Wu, Kaiming He, Aleksander Madry and the anonymous reviewers for their helpful feedback.
# REFERENCES
Jimmy Lei Ba, Jamie Ryan Kiros, and Geoffrey E Hinton. Layer normalization. arXiv preprint arXiv:1607.06450, 2016.
David Balduzzi, Marcus Frean, Lennox Leary, JP Lewis, Kurt Wan-Duo Ma, and Brian McWilliams. The shattered gradients problem: If resnets are the answer, then what is the question? arXiv preprint arXiv:1702.08591, 2017.
Mia Xu Chen, Orhan Firat, Ankur Bapna, Melvin Johnson, Wolfgang Macherey, George Foster, Llion Jones, Niki Parmar, Mike Schuster, Zhifeng Chen, et al. The best of both worlds: Combining recent advances in neural machine translation. arXiv preprint arXiv:1804.09849, 2018.
Yuntian Deng, Yoon Kim, Justin Chiu, Demi Guo, and Alexander M Rush. Latent alignment and variational attention. Thirty-second Conference on Neural Information Processing Systems (NIPS), 2018.
Terrance DeVries and Graham W Taylor. Improved regularization of convolutional neural networks with cutout. arXiv preprint arXiv:1708.04552, 2017.
Jonas Gehring, Michael Auli, David Grangier, Denis Yarats, and Yann N Dauphin. Convolutional Sequence to Sequence Learning. In Proc. of ICML, 2017.
Xavier Glorot and Yoshua Bengio. Understanding the difficulty of training deep feedforward neural networks. In Proceedings of the thirteenth international conference on artificial intelligence and statistics, pp. 249–256, 2010.
Priya Goyal, Piotr Dollar, Ross Girshick, Pieter Noordhuis, Lukasz Wesolowski, Aapo Kyrola, An-´ drew Tulloch, Yangqing Jia, and Kaiming He. Accurate, large minibatch sgd: training imagenet in 1 hour. arXiv preprint arXiv:1706.02677, 2017.
Benjamin Graham. Fractional max-pooling. arXiv preprint arXiv:1412.6071, 2014.
Boris Hanin. Which neural net architectures give rise to exploding and vanishing gradients? arXiv preprint arXiv:1801.03744, 2018.
Boris Hanin and David Rolnick. How to start training: The effect of initialization and architecture. arXiv preprint arXiv:1803.01719, 2018.
Moritz Hardt and Tengyu Ma. Identity matters in deep learning. arXiv preprint arXiv:1611.04231, 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.
David J Heeger. Normalization of cell responses in cat striate cortex. Visual neuroscience, 9(2): 181–197, 1992.
Elad Hoffer, Ron Banner, Itay Golan, and Daniel Soudry. Norm matters: efficient and accurate normalization schemes in deep networks. arXiv preprint arXiv:1803.01814, 2018.
Sergey Ioffe and Christian Szegedy. Batch normalization: Accelerating deep network training by reducing internal covariate shift. arXiv preprint arXiv:1502.03167, 2015.
Diederik P Kingma and Prafulla Dhariwal. Glow: Generative flow with invertible 1x1 convolutions. arXiv preprint arXiv:1807.03039, 2018.
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.
Chen-Yu Lee, Patrick W Gallagher, and Zhuowen Tu. Generalizing pooling functions in convolutional neural networks: Mixed, gated, and tree. In Artificial Intelligence and Statistics, pp. 464–472, 2016.
Yuanzhi Li, Tengyu Ma, and Hongyang Zhang. Algorithmic regularization in over-parameterized matrix recovery. Conference on Learning Theory (COLT), 2018.
Siwei Lyu and Eero P Simoncelli. Nonlinear image representation using divisive normalization. In Computer Vision and Pattern Recognition, 2008. CVPR 2008. IEEE Conference on, pp. 1–8. IEEE, 2008.
Dmytro Mishkin and Jiri Matas. All you need is a good init. arXiv preprint arXiv:1511.06422, 2015.
Myle Ott, Sergey Edunov, David Grangier, and Michael Auli. Scaling neural machine translation. arXiv preprint arXiv:1806.00187, 2018.
Jeffrey Pennington, Samuel Schoenholz, and Surya Ganguli. Resurrecting the sigmoid in deep learning through dynamical isometry: theory and practice. In Advances in neural information processing systems, pp. 4785–4795, 2017.
Nicolas Pinto, David D Cox, and James J DiCarlo. Why is real-world visual object recognition hard? PLoS computational biology, 4(1):e27, 2008.
Tim Salimans and Diederik P Kingma. Weight normalization: A simple reparameterization to accelerate training of deep neural networks. In Advances in Neural Information Processing Systems, pp. 901–909, 2016.
Shibani Santurkar, Dimitris Tsipras, Andrew Ilyas, and Aleksander Madry. How does batch normalization help optimization?(no, it is not about internal covariate shift). arXiv preprint arXiv:1805.11604, 2018.
Andrew M Saxe, James L McClelland, and Surya Ganguli. Exact solutions to the nonlinear dynamics of learning in deep linear neural networks. arXiv preprint arXiv:1312.6120, 2013.
Wenling Shang, Justin Chiu, and Kihyuk Sohn. Exploring normalization in deep residual networks with concatenated rectified linear units. In AAAI, pp. 1509–1516, 2017. Rupesh Kumar Srivastava, Klaus Greff, and Jurgen Schmidhuber. Highway networks. ¨ arXiv preprint arXiv:1505.00387, 2015. Dmitry Ulyanov, Andrea Vedaldi, and Victor S. Lempitsky. Instance normalization: The missing ingredient for fast stylization. CoRR, abs/1607.08022, 2016. Twan van Laarhoven. L2 regularization versus batch and weight normalization. arXiv preprint arXiv:1706.05350, 2017. 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. Yuxin Wu and Kaiming He. Group normalization. In The European Conference on Computer Vision (ECCV), September 2018. Lechao Xiao, Yasaman Bahri, Jascha Sohl-Dickstein, Samuel S Schoenholz, and Jeffrey Pennington. Dynamical isometry and a mean field theory of cnns: How to train 10,000-layer vanilla convolutional neural networks. arXiv preprint arXiv:1806.05393, 2018. Yoshihiro Yamada, Masakazu Iwamura, and Koichi Kise. Shakedrop regularization. arXiv preprint arXiv:1802.02375, 2018. Ge Yang and Samuel Schoenholz. Mean field residual networks: On the edge of chaos. In Advances in neural information processing systems, pp. 7103–7114, 2017. Sergey Zagoruyko and Nikos Komodakis. Wide residual networks. arXiv preprint arXiv:1605.07146, 2016. Hongyi Zhang, Moustapha Cisse, Yann N Dauphin, and David Lopez-Paz. mixup: Beyond empirical risk minimization. arXiv preprint arXiv:1710.09412, 2017. Jun-Yan Zhu, Taesung Park, Phillip Isola, and Alexei A Efros. Unpaired image-to-image translation using cycle-consistent adversarial networks. In Computer Vision (ICCV), 2017 IEEE International Conference on, 2017.
# A PROOFS FOR SECTION 2
# A.1 GRADIENT NORM LOWER BOUND FOR THE INPUT TO A NETWORK BLOCK
Proof of Theorem $^ { l }$ . We use $f _ { i \to j }$ to denote the composition $f _ { j } \circ f _ { j - 1 } \circ \cdots \circ f _ { i }$ , so that $\mathbf { z } =$ $f _ { i \to L } ( \mathbf { x } _ { i - 1 } )$ for all $i \in [ L ]$ . Note that $\mathbf { z }$ is p.h. with respect to the input of each network block, i.e. $f _ { i \to L } ( ( 1 + \epsilon ) \mathbf { x } _ { i - 1 } ) = ( 1 + \epsilon ) f _ { i \to L } ( \mathbf { x } _ { i - 1 } )$ for $\epsilon > - 1$ . This allows us to compute the gradient of the cross-entropy loss with respect to the scaling factor $\epsilon$ at $\epsilon = 0$ as
$$\left. { \frac { \partial } { \partial \epsilon } } \ell ( f _ { i \to L } ( ( 1 + \epsilon ) { \bf x } _ { i - 1 } ) , { \bf y } ) \right| _ { \epsilon = 0 } = { \frac { \partial \ell } { \partial { \bf z } } } { \frac { \partial f _ { i \to L } } { \partial \epsilon } } = - { \bf y } ^ { T } { \bf z } + { \bf p } ^ { T } { \bf z } = \ell ( { \bf z } , { \bf y } ) - H ( { \bf p } )$$
Since the gradient $L _ { 2 }$ norm $\| \partial \ell / \partial { \bf x } _ { i - 1 } \|$ must be greater than the directional derivative $\begin{array} { r } { \frac { \partial } { \partial t } \ell ( f _ { i L } ( \mathbf x _ { i - 1 } + t \frac { \mathbf x _ { i - 1 } } { \parallel \mathbf x _ { i - 1 } \parallel } ) , \mathbf y ) } \end{array}$ k, defining $\epsilon = { t } / { | | { \bf x } _ { i - 1 } | | }$ we have
$$\| \frac { \partial \ell } { \partial \mathbf { x } _ { i - 1 } } \| \geq \frac { \partial } { \partial \epsilon } \ell ( f _ { i L } ( \mathbf { x } _ { i - 1 } + \epsilon \mathbf { x } _ { i - 1 } ) , \mathbf { y } ) \frac { \partial \epsilon } { \partial t } = \frac { \ell ( \mathbf { z } , \mathbf { y } ) - H ( \mathbf { p } ) } { \| \mathbf { x } _ { i - 1 } \| } .$$
Proof of Theorem 2. The proof idea is similar. Recall that if $\theta _ { p h }$ is a p.h. set, then $\bar { f } ^ { ( m ) } ( \theta _ { p h } )$ , $f ( \mathbf { x } ^ { ( m ) } ; \theta \setminus \theta _ { p h } , \theta _ { p h } )$ is a p.h. function. We therefore have
$$\frac { \partial } { \partial \epsilon } \ell _ { \mathrm { a v g } } ( \mathcal { D } _ { M } ; ( 1 + \epsilon ) \theta _ { p h } ) \bigg | _ { \epsilon = 0 } = \frac { 1 } { M } \sum _ { m = 1 } ^ { M } \frac { \partial \ell } { \partial \mathbf { z } ^ { ( m ) } } \frac { \partial \bar { f } ^ { ( m ) } } { \partial \epsilon } = \frac { 1 } { M } \sum _ { m = 1 } ^ { M } \ell ( \mathbf { z } ^ { ( m ) } , \mathbf { y } ^ { ( m ) } ) - H ( \mathbf { p } ^ { ( m ) } )$$
hence we again invoke the directional derivative argument to show
$$\left\| \frac { \partial \ell _ { \mathrm { a v g } } } { \partial \theta _ { p h } } \right\| \geq \frac { 1 } { M \| \theta _ { p h } \| } \sum _ { m = 1 } ^ { M } \ell ( \mathbf { z } ^ { ( m ) } , \mathbf { y } ^ { ( m ) } ) - H ( \mathbf { p } ^ { ( m ) } ) \triangleq G ( \theta _ { p h } ) .$$
In order to estimate the scale of this lower bound, recall the FC layer weights are i.i.d. sampled from a symmetric, mean-zero distribution, therefore $\mathbf { z }$ has a symmetric probability density function with mean 0. We hence have
$$\begin{array} { r } { \mathbb { E } \ell ( \mathbf { z } , \mathbf { y } ) = \mathbb { E } [ - \mathbf { y } ^ { T } ( \mathbf { z } - \mathrm { { \mathrm { 1 o g ~ s u m e x p } } } ( \mathbf { z } ) ) ] \geq \mathbb { E } [ \mathbf { y } ^ { T } ( \operatorname* { m a x } _ { i \in [ c ] } z _ { i } - \mathbf { z } ) ] = \mathbb { E } [ \operatorname* { m a x } _ { i \in [ c ] } z _ { i } ] } \end{array}$$
where the inequality uses the fact that $\mathrm { l o g s u m e } \mathbf { x } \mathbf { p } ( \mathbf { z } ) \geq \mathrm { m a x } _ { i \in [ c ] } z _ { i } ,$ ; the last equality is due to $\mathbf { y }$ and $\mathbf { z }$ being independent at initialization and $\mathbb { E } \mathbf { z } = \mathbf { 0 }$ . Using the trivial bound $\mathbb { E } H ( \mathbf { p } ) \leq \log ( c )$ , we get
$$\mathbb { E } G ( \theta _ { p h } ) \geq \frac { \mathbb { E } [ \operatorname* { m a x } _ { i \in [ c ] } z _ { i } ] - \log ( c ) } { \| \theta _ { p h } \| }$$
which shows that the gradient norm of a p.h. set is of the order $\Omega ( \mathbb { E } [ \operatorname* { m a x } _ { i \in [ c ] } z _ { i } ] )$ at initialization.
# B PROOFS FOR SECTION 3
# B.1 RESIDUAL BRANCHES UPDATE THE NETWORK IN SYNC
A common theme in previous analysis of residual networks is the scale of activation and gradient (Balduzzi et al., 2017; Yang & Schoenholz, 2017; Hanin & Rolnick, 2018). However, it is more important to consider the scale of actual change to the network function made by a (stochastic) gradient descent step. If the updates to different layers cancel out each other, the network would be stable as a whole despite drastic changes in different layers; if, on the other hand, the updates to different layers align with each other, the whole network may incur a drastic change in one step, even if each layer only changes a tiny amount. We now provide analysis showing that the latter scenario more accurately describes what happens in reality at initialization.
For our result in this section, we make the following assumptions:
• $f$ is a sequential composition of network blocks $\{ f _ { i } \} _ { i = 1 } ^ { L }$ , i.e. $f ( \mathbf { x } _ { 0 } ) = f _ { L } ( f _ { L - 1 } ( . . . f _ { 1 } ( \mathbf { x } _ { 0 } ) ) )$ , consisting of fully-connected weight layers, ReLU activation functions and residual branches. • $f _ { L }$ is a fully-connected layer with weights i.i.d. sampled from a zero-mean distribution. • There is no bias parameter in $f$ .
For $l < L$ , let ${ \bf x } _ { l - 1 }$ be the input to $f _ { l }$ and $F _ { l } ( \mathbf { x } _ { l - 1 } )$ be a branch in $f _ { l }$ with $m _ { l }$ layers. Without loss of generality, we study the following specific form of network architecture:
$$\begin{array} { r l } & { F _ { l } ( \mathbf { x } _ { l - 1 } ) \ = \ \overbrace { ( \mathrm { R e L U o } W _ { l } ^ { ( m _ { l } ) } \circ \cdot \cdot \cdot \circ \mathrm { R e L U } \circ W _ { l } ^ { ( 1 ) } ) } ^ { m _ { l } \mathrm { \normalfont \ R e L U } } ) ( \mathbf { x } _ { l - 1 } ) , } \\ & { f _ { l } ( \mathbf { x } _ { l - 1 } ) \ = \ \mathbf { x } _ { l - 1 } + F _ { l } ( \mathbf { x } _ { l - 1 } ) . } \end{array}$$
For the last block we denote $m _ { L } = 1$ and $f _ { L } ( \mathbf { x } _ { L - 1 } ) = F _ { L } ( \mathbf { x } _ { L - 1 } ) = W _ { L } ^ { ( 1 ) } \mathbf { x } _ { L - 1 } .$
Furthermore, we always choose 0 as the gradient of ReLU when its input is 0. As such, with input $\mathbf { x }$ , the output and gradient of $\scriptstyle \mathrm { R e L U } ( \mathbf { x } )$ can be simply written as $D _ { \mathbb { 1 } [ { \mathbf x } > 0 ] } { \mathbf x }$ , where $D _ { \mathbb { 1 } [ { \bf x } > 0 ] }$ is a diagonal matrix with diagonal entries corresponding to $\mathbb { 1 } [ \mathbf { x } > 0 ]$ . Denote the preactivation of the $i$ -th layer
(i.e. the input to the $i$ -th ReLU) in the $l$ -th block by $\mathbf { x } _ { l } ^ { ( i ) }$ . We define the following terms to simplify our presentation:
$$\begin{array} { r l } & { F _ { l } ^ { ( i - ) } \triangleq D _ { \mathbb { 1 } [ { \mathbf x } _ { l } ^ { ( i - 1 ) } > 0 ] } W _ { l } ^ { ( i - 1 ) } \cdot \cdot \cdot D _ { \mathbb { 1 } [ { \mathbf x } _ { l } ^ { ( 1 ) } > 0 ] } W _ { l } ^ { ( 1 ) } \mathbf x _ { l - 1 } , \quad l < L , i \in [ m _ { l } ] } \\ & { F _ { l } ^ { ( i + ) } \triangleq D _ { \mathbb { 1 } [ { \mathbf x } _ { l } ^ { ( m _ { l } ) } > 0 ] } W _ { l } ^ { ( m _ { l } ) } \cdot \cdot \cdot D _ { \mathbb { 1 } [ { \mathbf x } _ { l } ^ { ( i ) } > 0 ] } , \quad l < L , i \in [ m _ { l } ] } \\ & { F _ { L } ^ { ( 1 - ) } \triangleq \mathbf x _ { L - 1 } } \\ & { F _ { L } ^ { ( 1 + ) } \triangleq I } \end{array}$$
We have the following result on the gradient update to $f$ :
Theorem 3. With the above assumptions, suppose we update the network parameters by $\Delta \theta =$ $\begin{array} { r } { - \eta \frac { \partial } { \partial \theta } \ell ( f ( \mathbf { x } _ { 0 } ; \theta ) , \mathbf { y } ) } \end{array}$ , then the update to network output $\Delta f ( \mathbf { x } _ { 0 } ) \triangleq f ( \mathbf { x } _ { 0 } ; \theta + \Delta \theta ) - f ( \mathbf { x } _ { 0 } ; \theta )$ is
$$\Delta f ( \mathbf { x } _ { 0 } ) = - \eta \sum _ { l = 1 } ^ { L } \left[ \sum _ { i = 1 } ^ { m _ { l } } \overbrace { \left\| F _ { l } ^ { ( i - ) } \right\| ^ { 2 } \left( \frac { \partial f } { \partial \mathbf { x } _ { l } } \right) ^ { T } F _ { l } ^ { ( i + ) } \left( F _ { l } ^ { ( i + ) } \right) ^ { T } \left( \frac { \partial f } { \partial \mathbf { x } _ { l } } \right) } ^ { \triangleq \mathcal { I } _ { l } ^ { i } } \right] \frac { \partial \ell } { \partial \mathbf { z } } + O ( \eta ^ { 2 } ) ,$$
where $\mathbf { z } \triangleq f ( \mathbf { x } _ { 0 } ) \in \mathbb { R } ^ { c }$ is the logits.
Let us discuss the implecation of this result before delving into the proof. As each $J _ { l } ^ { i }$ is a $c \times c$ real symmetric positive semi-definite matrix, the trace norm of each $J _ { l } ^ { i }$ equals its trace. Similarly, the trace norm of $\begin{array} { r } { J \triangleq \sum _ { l } \sum _ { i } J _ { l } ^ { i } } \end{array}$ equals the trace of the sum of all $J _ { l } ^ { i }$ as well, which scales linearly with the number of residual branches $L$ . Since the output $\mathbf { z }$ has no (or little) correlation with the target $\mathbf { y }$ at the start of training, $\textstyle { \frac { \partial \ell } { \partial \mathbf { z } } }$ is a vector of some random direction. It then follows that the expected update scale is proportional to the trace norm of $J$ , which is proportional to $L$ as well as the average trace of $J _ { l } ^ { i }$ . Simply put, to allow the whole network be updated by $\Theta ( \eta )$ per step independent of depth, we need to ensure each residual branch contributes only a $\Theta ( \eta / L )$ update on average.
Proof. The first insight to prove our result is to note that conditioning on a specific input $\mathbf { x } _ { \mathrm { 0 } }$ , we can replace each ReLU activation layer by a diagonal matrix and does not change the forward and backward pass. (In fact, this is valid even after we apply a gradient descent update, as long as the learning rate $\eta > 0$ is sufficiently small so that all positive preactivation remains positive. This observation will be essential for our later analysis.) We thus have the gradient w.r.t. the $i$ -th weight layer in the $l$ -th block is
$$\frac { \partial \ell } { \partial \mathrm { V e c } ( W _ { l } ^ { ( i ) } ) } = \frac { \partial \mathbf { x } _ { l } } { \partial \mathrm { V e c } ( W _ { l } ^ { ( i ) } ) } \cdot \frac { \partial f } { \partial \mathbf { x } _ { l } } \cdot \frac { \partial \ell } { \partial \mathbf { z } } = \left( F _ { l } ^ { ( i - ) } \otimes I _ { l } ^ { ( i ) } \right) \left( F _ { l } ^ { ( i + ) } \right) ^ { T } \frac { \partial f } { \partial \mathbf { x } _ { l } } \cdot \frac { \partial \ell } { \partial \mathbf { z } } .$$
where $\otimes$ denotes the Kronecker product. The second insight is to note that with our assumptions, a network block and its gradient w.r.t. its input have the following relation:
$$f _ { l } ( \mathbf { x } _ { l - 1 } ) = \frac { \partial f _ { l } } { \partial \mathbf { x } _ { l - 1 } } \cdot \mathbf { x } _ { l - 1 } .$$
We then plug in Equation (13) to the gradient update $\begin{array} { r } { \Delta \theta = - \eta \frac { \partial } { \partial \theta } \ell ( f ( \mathbf { x } _ { 0 } ; \theta ) , \mathbf { y } ) } \end{array}$ , and recalculate the forward pass $f ( \mathbf { x } _ { 0 } ; \theta + \Delta \theta )$ . The theorem follows by applying Equation (14) and a first-order Taylor series expansion in a small neighborhood of $\eta = 0$ where $f ( \mathbf { x } _ { 0 } ; \theta + \Delta \theta )$ is smooth w.r.t. $\eta$ . □
# B.2 WHAT SCALAR BRANCH HAS $\Theta ( \eta / L )$ UPDATES?
For this section, we focus on the proper initialization of a scalar branch $\begin{array} { r } { F ( x ) = ( \prod _ { i = 1 } ^ { m } a _ { i } ) x } \end{array}$ . We have the following result:
Theorem 4. Assuming $\forall i , a _ { i } \geq 0 , x = \Theta ( 1 )$ and $\frac { \partial \ell } { \partial F ( x ) } = \Theta ( 1 )$ , then $\begin{array} { r } { \Delta F ( x ) \triangleq F ( x ; \theta - \eta \frac { \partial \ell } { \partial \theta } ) - } \end{array}$ $F ( x ; \theta )$ is $\Theta ( \eta / L )$ if and only if
$$\left( \prod _ { k \in [ m ] \setminus \{ j \} } a _ { k } \right) x = \Theta \left( { \frac { 1 } { \sqrt { L } } } \right) , \quad w h e r e \quad j \in \arg \operatorname* { m i n } a _ { k }$$
Proof. We start by calculating the gradient of each parameter:
$${ \frac { \partial \ell } { \partial a _ { i } } } = { \frac { \partial \ell } { \partial F } } \left( \prod _ { k \in [ m ] \backslash \{ i \} } a _ { k } \right) x$$
and a first-order approximation of $\Delta F ( x )$ :
$$\Delta F ( x ) = - \eta \frac { \partial \ell } { \partial F ( x ) } \left( F ( x ) \right) ^ { 2 } \sum _ { i = 1 } ^ { m } \frac { 1 } { a _ { i } ^ { 2 } }$$
where we conveniently abuse some notations by defining
$$F ( x ) { \frac { 1 } { a _ { i } } } \triangleq \left( \prod _ { k \in [ m ] \backslash \{ i \} } a _ { k } \right) x , \quad { \mathrm { i f ~ } } a _ { i } = 0 .$$
$\textstyle \sum _ { i = 1 } ^ { m } { \frac { 1 } { a _ { i } ^ { 2 } } }$ as $M$ and $\operatorname* { m i n } _ { k } a _ { k }$ as $A$ , we have
$$( F ( x ) ) ^ { 2 } \cdot { \frac { 1 } { A ^ { 2 } } } \leq ( F ( x ) ) ^ { 2 } M \leq ( F ( x ) ) ^ { 2 } \cdot { \frac { m } { A ^ { 2 } } }$$
and therefore by rearranging Equation (17) and letting $\Delta F ( x ) = \Theta ( \eta / L )$ we get
$$( F ( x ) ) ^ { 2 } \cdot { \frac { 1 } { A ^ { 2 } } } = \Theta \left( { \frac { \Delta F ( x ) } { \eta _ { \overline { { { \partial F ( x ) } } } } } } \right) = \Theta \left( { \frac { 1 } { L } } \right)$$
i.e. $F ( x ) / A = \Theta ( 1 / \sqrt { L } )$ . Hence the “only if” part is proved. For the “if” part, we apply Equation (19) to Equation (17) and observe that by Equation (15)
$$\Delta F ( x ) = \Theta \left( \eta ( F ( x ) ) ^ { 2 } \cdot \frac { 1 } { A ^ { 2 } } \right) = \Theta \left( \frac { \eta } { L } \right)$$
The result of this theorem provides useful guidance on how to rescale the standard initialization to achieve the desired update scale for the network function.
# C ADDITIONAL EXPERIMENTS
# C.1 ABLATION STUDIES OF FIXUP
In this section we present the training curves of different architecture designs and initialization schemes. Specifically, we compare the training accuracy of batch normalization, Fixup, as well as a few ablated options: (1) removing the bias parameters in the network; (2) use $0 . 1 \mathbf { x }$ the suggested initialization scale and no bias parameters; (3) use $1 0 \mathrm { x }$ the suggested initialization scale and no bias parameters; and (4) remove all the residual branches. The results are shown in Figure 4. We see that initializing the residual branch layers at a smaller scale (or all zero) slows down learning, whereas training fails when initializing them at a larger scale; we also see the clear benefit of adding bias parameters in the network.
# C.2 CIFAR AND SVHN WITH BETTER REGULARIZATION
We perform additional experiments to validate our hypothesis that the gap in test error between Fixup and batch normalization is primarily due to overfitting. To combat overfitting, we use Mixup (Zhang et al., 2017) and Cutout (DeVries & Taylor, 2017) with default hyperparameters as additional regularization. On the CIFAR-10 dataset, we perform experiments with WideResNet-40-10 and on SVHN we use WideResNet-16-12 (Zagoruyko & Komodakis, 2016), all with the default hyperparameters. We observe in Table 4 that models trained with Fixup and strong regularization are competitive with state-of-the-art methods on CIFAR-10 and SVHN, as well as our baseline with batch normalization.
 Figure 4: Minibatch training accuracy of ResNet-110 on CIFAR-10 dataset with different configurations in the first 3 epochs. We use minibatch size of 128 and smooth the curves using 10-step moving average.
Table 4: Additional results on CIFAR-10, SVHN datasets.
<table><tr><td>Dataset</td><td>Model</td><td>Normalization</td><td>Test Error (%)</td></tr><tr><td rowspan="4">CIFAR-10</td><td>(Zagoruyko & Komodakis, 2016) (Yamada et al., 2018)</td><td rowspan="4">Yes</td><td>3.8 2.3</td></tr><tr><td>BatchNorm + Mixup + Cutout</td><td>2.5</td></tr><tr><td></td><td></td></tr><tr><td>(Graham,2014) Fixup-init + Mixup + Cutout</td><td>3.5 2.3</td></tr><tr><td rowspan="4">SVHN</td><td>(Zagoruyko & Komodakis, 2016)</td><td rowspan="4">Yes</td><td>1.5</td></tr><tr><td>(DeVries& Taylor, 2017)</td><td>1.3</td></tr><tr><td>BatchNorm + Mixup + Cutout</td><td>1.4</td></tr><tr><td>(Lee et al., 2016)</td><td>1.7</td></tr></table>
 Figure 5 shows that without additional regularization Fixup fits the training set very well, but overfits significantly. We see in Figure 6 that Fixup is competitive with networks trained with normalization when the Mixup regularizer is used.
 Figure 5: Training and test errors on ImageNet using ResNet-50 without additional regularization. We observe that Fixup is able to better fit the training data and that leads to overfitting - more regularization is needed. Results of BatchNorm and GroupNorm reproduced from (Wu & He, 2018). Figure 6: Test error of ResNet-50 on ImageNet with Mixup (Zhang et al., 2017). Fixup closely matches the final results yielded by the use of GroupNorm, without any normalization.
D ADDITIONAL REFERENCES: A BRIEF HISTORY OF NORMALIZATION METHODS
The first use of normalization in neural networks appears in the modeling of biological visual system and dates back at least to Heeger (1992) in neuroscience and to Pinto et al. (2008); Lyu & Simoncelli (2008) in computer vision, where each neuron output is divided by the sum (or norm) of all of the outputs, a module called divisive normalization. Recent popular normalization methods, such as local response normalization (Krizhevsky et al., 2012), batch normalization (Ioffe & Szegedy, 2015) and layer normalization (Ba et al., 2016) mostly follow this tradition of dividing the neuron activations by their certain summary statistics, often also with the activation mean subtracted. An exception is weight normalization (Salimans & Kingma, 2016), which instead divides the weight parameters by their statistics, specifically the weight norm; weight normalization also adopts the idea of activation normalization for weight initialization. The recently proposed actnorm (Kingma & Dhariwal, 2018) removes the normalization of weight parameters, but still use activation normalization to initialize the affine transformation layers.123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385# DIVERSE BEAM SEARCH: DECODING DIVERSE SOLUTIONS FROM NEURAL SEQUENCE MODELS
Ashwin K Vijayakumar1, Michael Cogswell1, Ramprasaath R. Selvaraju1, Qing Sun1 Stefan Lee1, David Crandall2 & Dhruv Batra1
{ashwinkv,cogswell,ram21,sunqing,steflee}@vt.edu djcran@indiana.edu, dbatra@vt.edu
1 Department of Electrical and Computer Engineering, Virginia Tech, Blacksburg, VA, USA
2 School of Informatics and Computing Indiana University, Bloomington, IN, USA
# ABSTRACT
Neural sequence models are widely used to model time-series data. Equally ubiquitous is the usage of beam search (BS) as an approximate inference algorithm to decode output sequences from these models. BS explores the search space in a greedy left-right fashion retaining only the top $B$ candidates. This tends to result in sequences that differ only slightly from each other. Producing lists of nearly identical sequences is not only computationally wasteful but also typically fails to capture the inherent ambiguity of complex AI tasks. To overcome this problem, we propose Diverse Beam Search (DBS), an alternative to BS that decodes a list of diverse outputs by optimizing a diversity-augmented objective. We observe that our method not only improved diversity but also finds better top 1 solutions by controlling for the exploration and exploitation of the search space. Moreover, these gains are achieved with minimal computational or memory overhead compared to beam search. To demonstrate the broad applicability of our method, we present results on image captioning, machine translation, conversation and visual question generation using both standard quantitative metrics and qualitative human studies. We find that our method consistently outperforms BS and previously proposed techniques for diverse decoding from neural sequence models.
# 1 INTRODUCTION
In the last few years, Recurrent Neural Networks (RNNs), Long Short-Term Memory networks (LSTMs) or more generally, neural sequence models have become the standard choice for modeling time-series data for a wide range of applications including speech recognition (Graves et al., 2013), machine translation (Bahdanau et al., 2014), conversation modeling (Vinyals & Le, 2015), image and video captioning (Vinyals et al., 2015; Venugopalan et al., 2015), and visual question answering (Antol et al., 2015). RNN based sequence generation architectures model the conditional probability, $\operatorname* { P r } ( \mathbf { y } | \mathbf { x } )$ of an output sequence $\mathbf { y } = ( y _ { 1 } , \dots , y _ { T } )$ given an input $\mathbf { x }$ (possibly also a sequence); where the output tokens $y _ { t }$ are from a finite vocabulary, $\nu$ .
Inference in RNNs. Maximum a Posteriori (MAP) inference for RNNs is the task of finding the most likely output sequence given the input. Since the number of possible sequences grows as $| \mathcal { V } | ^ { T }$ , exact inference is NP-hard – so, approximate inference algorithms like beam search (BS) are commonly employed. BS is a heuristic graph-search algorithm that maintains the $B$ top-scoring partial sequences expanded in a greedy left-to-right fashion. Fig. 1 shows a sample BS search tree.
Lack of Diversity in BS. Despite the widespread usage of BS, it has long been understood that solutions decoded by BS are generic and lacking in diversity (Finkel et al., 2006; Gimpel et al.,
 Single engine train rolling down the tracks. A locomotive drives along the tracks amongst trees and bushes. An engine is coming down the train track. A steam locomotive is blowing steam. An old fashion train with steam coming out of its pipe. A black and red train moving down a train track. Figure 1: Comparing image captioning outputs decoded by BS (top) and our method, Diverse Beam Search (middle) – we notice that BS captions are near-duplicates with similar shared paths in the search tree and minor variations in the end. In contrast, DBS captions are significantly diverse and similar to the variability in human-generated ground truth captions (bottom).
2013; Li et al., 2015; Li & Jurafsky, 2016). Comparing the human (bottom) and BS (top) generated captions shown in Fig. 1 demonstrates this deficiency. While this behavior of BS is disadvantageous for many reasons, we highlight the three most crucial ones here:
i) The production of near-identical beams make BS a computationally wasteful algorithm, with essentially the same computation being repeated for no significant gain in performance. ii) Due to loss-evaluation mismatch (i.e. improvements in posterior-probabilities not necessarily corresponding to improvements in task-specific metrics), it is common practice to deliberately throttle BS to become a poorer optimization algorithm by using reduced beam widths (Vinyals et al., 2015; Karpathy & Fei-Fei, 2015; Ferraro et al., 2016). This treatment of an optimization algorithm as a hyperparameter is not only intellectually dissatisfying but also has a significant practical side-effect – it leads to the decoding of largely bland, generic, and “safe” outputs, e.g. always saying “I don’t know” in conversation models (Kannan et al., 2016). iii) Most importantly, lack of diversity in the decoded solutions is fundamentally crippling in AI problems with significant ambiguity – e.g. there are multiple ways of describing an image or responding in a conversation that are “correct” and it is important to capture this ambiguity by finding several diverse plausible hypotheses.
Overview and Contributions. To address these shortcomings, we propose Diverse Beam Search $( D B S ) - \mathbf { a }$ general framework to decode a set of diverse sequences that can be used as an alternative to BS. At a high level, DBS decodes diverse lists by dividing the given beam budget into groups and enforcing diversity between groups of beams. Drawing from recent work in the probabilistic graphical models literature on Diverse M-Best (DivMBest) MAP inference (Batra et al., 2012; Prasad et al., 2014; Kirillov et al., 2015), we optimize an objective that consists of two terms – the sequence likelihood under the model and a dissimilarity term that encourages beams across groups to differ. This diversity-augmented model score is optimized in a doubly greedy manner – greedily optimizing along both time (like BS) and groups (like DivMBest).
Our primary technical contribution is Diverse Beam Search, a doubly greedy approximate inference algorithm to decode diverse sequences from neural sequence models. We report results on image captioning, machine translation, conversations and visual question generation to demonstrate the broad applicability of DBS. Results show that DBS produces consistent improvements on both task-specific oracle and other diversity-related metrics while maintaining run-time and memory requirements similar to BS. We also evaluate human preferences between image captions generated by BS or DBS. Further experiments show that DBS is robust over a wide range of its parameter values and is capable of encoding various notions of diversity through different forms of the diversty term.
Overall, our algorithm is simple to implement and consistently outperforms BS in a wide range of domains without sacrificing efficiency. Our implementation is publicly available at https: //github.com/ashwinkalyan/dbs. Additionally, we provide an interactive demonstration of DBS for image captioning at http://dbs.cloudcv.org.
# 2 PRELIMINARIES: DECODING RNNS WITH BEAM SEARCH
We begin with a refresher on BS, before describing our generalization, Diverse Beam Search. For notational convenience, let $[ n ]$ denote the set of natural numbers from 1 to $n$ and let $\mathbf { v } _ { [ n ] } =$ $[ v _ { 1 } , \ldots , v _ { n } ] ^ { \intercal }$ index the first $n$ elements of a vector $\mathbf { v } \in \mathbb { R } ^ { m }$ .
The Decoding Problem. RNNs are trained to estimate the likelihood of sequences of tokens from a finite dictionary $\nu$ given an input $\mathbf { x }$ . The RNN updates its internal state and estimates the conditional probability distribution over the next output given the input and all previous output tokens. We denote the logarithm of this conditional probability distribution over all tokens at time $t$ as $\theta ( y _ { t } ) =$ $\log \operatorname* { P r } ( y _ { t } | y _ { t - 1 } , \dots , y _ { 1 } , \mathbf { x } )$ . To avoid notational clutter, we index $\theta ( \cdot )$ with a single variable $y _ { t }$ , but it should be clear that it depends on all previous outputs, $\mathbf { y } _ { [ t - 1 ] }$ . We write the log probability of a partial solution (i.e. the sum of log probabilities of all tokens decoded so far) as $\Theta ( \mathbf { y } _ { [ t ] } ) =$ $\textstyle \sum _ { \tau \in [ t ] } \theta ( y _ { \tau } )$ . The decoding problem is then the task of finding a sequence y that maximizes $\Theta ( \mathbf { y } )$ .
As each output is conditioned on all the previous outputs, decoding the optimal length- $\mathcal { T }$ sequence in this setting can be viewed as MAP inference on a $T$ -order Markov chain with nodes corresponding to output tokens at each time step. Not only does the size of the largest factor in such a graph grow as $| \nu | ^ { \star }$ , but computing these factors also requires repetitively evaluating the sequence model. Thus, approximate algorithms are employed and the most prevalent method is beam search (BS).
Beam search is a heuristic search algorithm which stores the top $B$ highest scoring partial candidates at each time step; where $B$ is known as the beam width. Let us denote the set of $B$ solutions held by BS at the start of time $t$ as $Y _ { [ t - 1 ] } = \{ \mathbf { y } _ { 1 , [ t - 1 ] } , \dotsc , \mathbf { y } _ { B , [ t - 1 ] } \}$ . At each time step, BS considers all possible single token extensions of these beams given by the set $\mathscr { V } _ { t } = Y _ { [ t - 1 ] } \times \mathscr { V }$ and retains the $B$ highest scoring extensions. More formally, at each step the beams are updated as
$$Y _ { [ t ] } = \operatorname * { a r g m a x } _ { \substack { \mathbf { y } _ { 1 , [ t ] } , \ldots , \mathbf { y } _ { B , [ t ] } \in \mathcal { V } _ { t } } } \sum _ { b \in [ B ] } \Theta ( \mathbf { y } _ { b , [ t ] } ) \ \ldots t . \ \mathbf { y } _ { i , [ t ] } \neq \mathbf { y } _ { j , [ t ] } \ \forall i \neq j .$$
The above objective can be trivially maximized by sorting all $B \times | \mathcal { V } |$ members of $\mathcal { V } _ { t }$ by their log probabilities and selecting the top $B$ . This process is repeated until time $T$ and the most likely sequence is selected by ranking the $B$ complete beams according to their log probabilities.
While this method allows for multiple sequences to be explored in parallel, most completions tend to stem from a single highly valued beam – resulting in outputs that are often only minor perturbations of a single sequence (and typically only towards the end of the sequences).
# 3 DIVERSE BEAM SEARCH: FORMULATION AND ALGORITHM
To overcome this, we augment the objective in Eq. 1 with a dissimilarity term $\Delta ( Y _ { [ t ] } )$ that measures the diversity between candidate sequences, assigning a penalty $\Delta ( Y _ { [ t ] } ) [ c ]$ to each possible sequence completion $c \in \mathcal V$ . Jointly optimizing this augmented objective for all $B$ candidates at each time step is intractable as the number of possible solutions grows with $| \gamma | ^ { B }$ (easily $1 0 ^ { 6 0 }$ for typical language modeling settings). To avoid this, we opt for a greedy procedure that divides the beam budget $B$ into $G$ groups and promotes diversity between these groups. The approximation is doubly greedy – across both time and groups – so $\Delta ( Y _ { [ t ] } )$ is constant with respect to other groups and we can sequentially optimize each group using regular BS. We now explain the specifics of our approach.
Diverse Beam Search. As joint optimization is intractable, we form $G$ smaller groups of beams and optimize them sequentially. Consider a partition of the set of beams $Y _ { [ t ] }$ into $G$ smaller sets $Y _ { [ t ] } ^ { g } , g { \in } [ G ]$ of $B ^ { \prime } = B / G$ beams each (we pick $G$ to divide $B$ ). In the example shown in Fig. 2, $B = 6$ beams are divided into $G = 3$ differently colored groups containing $B ^ { \prime } = 2$ beams each.
Considering diversity only between groups, reduces the search space at each time step; however, inference remains intractable. To enforce diversity efficiently, we consider a greedy strategy that steps each group forward in time sequentially while considering the others fixed. Each group can then evaluate the diversity term with respect to the fixed extensions of previous groups, returning the search space to $B ^ { \prime } \times | \mathcal { V } |$ . In the snapshot shown in Fig. 2, the third group is being stepped forward at time step $t = 4$ and the previous groups have already been completed. With this staggered beamfront, the diversity term of the third group can be computed using these completions. Here we use hamming diversity, which adds diversity penalty -1 for each appearance of a possible extension word at the same time step in a previous group – ‘birds’, ‘the’, and ‘an’ in the example – and 0 to all other possible completions. We discuss other forms for the diversity function in Section 5.1.
 Figure 2: Diverse beam search operates left-to-right through time and top to bottom through groups. Diversity between groups is combined with joint log probabilities, allowing continuations to be found efficiently. The resulting outputs are more diverse than for standard approaches.
As we optimize each group with the previous groups fixed, extending group $g$ at time $t$ amounts to a standard BS using dissimilarity augmented log probabilities and can be written as:
$$\begin{array} { r l } { Y _ { [ t ] } ^ { g } } & { = \underset { \mathbf { y } _ { 1 , [ t ] } ^ { g } \dots \mathbf { y } _ { B ^ { \prime } , [ t ] } ^ { g } \in \mathcal { Y } _ { t } ^ { g } } { \mathrm { a r g m a x } } \quad \quad \displaystyle \sum _ { b \in [ B ^ { \prime } ] } \Theta \left( \mathbf { y } _ { b , [ t ] } ^ { g } \right) + \lambda \Delta \left( \underset { h = 1 } { \bigcup ^ { g - 1 } } Y _ { [ t ] } ^ { h } \right) [ y _ { b , t } ^ { g } ] , } \\ & { \quad \quad s . t . \lambda \geq 0 , \mathbf { y } _ { i , [ t ] } ^ { g } \neq \mathbf { y } _ { j , [ t ] } ^ { g } \forall i \neq j } \end{array}$$
where $\lambda$ is scalar controlling the strength of the diversity term. The full procedure to obtain diverse sequences using our method, Diverse Beam Search (DBS), is presented in Algorithm 1. It consists of two main steps for each group at each time step –
1) augmenting the log probabilities of each possible extension with the diversity term computed from previously advanced groups (Algorithm 1, Line 5) and, 2) running one step of a smaller BS with $B ^ { \prime }$ beams using the augmented log probabilities to extend the current group (Algorithm 1, Line 6).
Note that the first group $( g = 1 )$ ) is not ‘conditioned’ on other groups during optimization, so our method is guaranteed to perform at least as well as a beam search of size $B ^ { \prime }$ .
# Algorithm 1: Diverse Beam Search
1 Perform a diverse beam search with $G$ groups using a beam width of $B$ 2 for $t = 1$ , . . . $T$ do // perform one step of beam search for first group without diversity 3 $\begin{array} { r } { Y _ { [ t ] } ^ { 1 } \operatorname { a r g m a x } _ { ( \mathbf { y } _ { 1 , [ t ] } ^ { 1 } , \dots , \mathbf { y } _ { B ^ { \prime } , [ t ] } ^ { 1 } ) } \sum _ { b \in [ B ^ { \prime } ] } \Theta ( \mathbf { y } _ { b , [ t ] } ^ { 1 } ) } \end{array}$ 4 for $g = 2$ , . . . $G$ do 5 $\begin{array} { r } { \Theta ( \mathbf { y } _ { b , [ t ] } ^ { g } ) \Theta ( \mathbf { y } _ { b , [ t ] } ^ { g } ) + \lambda \Delta ( \bigcup _ { h = 1 } ^ { g - 1 } Y _ { [ t ] } ^ { h } ) [ y _ { b , t } ^ { g } ] \quad \ b \in [ B ^ { \prime } ] , \mathbf { y } _ { b , [ t ] } ^ { g } \in \mathcal { Y } _ { t } ^ { g } : } \end{array}$ and $\lambda > 0$ 6 $Y _ { [ t ] } ^ { g } \overset { \cdot } { } \operatorname { a r g m a x } _ { ( \mathbf { y } _ { 1 , [ t ] } ^ { g } , \ldots , \mathbf { y } _ { B ^ { \prime } , [ t ] } ^ { g } ) } \sum _ { b \in [ B ^ { \prime } ] } \Theta ( \mathbf { y } _ { b , [ t ] } ^ { g } )$ r thes.t. $\mathbf { y } _ { i , [ t ] } \neq \mathbf { y } _ { j , [ t ] } \forall i \neq j$
7 Return set of B solutions, $\begin{array} { r } { Y _ { [ T ] } = \bigcup _ { g = 1 } ^ { G } Y _ { [ T ] } ^ { g } } \end{array}$
# 4 RELATED WORK
Diverse M-Best Lists. The task of generating diverse structured outputs from probabilistic models has been studied extensively (Park & Ramanan, 2011; Batra et al., 2012; Kirillov et al., 2015; Prasad et al., 2014). Batra et al. (2012) formalized this task for Markov Random Fields as the DivMBest problem and presented a greedy approach which solves for outputs iteratively, conditioning on previous solutions to induce diversity. Kirillov et al. (2015) show how these solutions can be found jointly (non-greedily) for certain kinds of energy functions. The techniques developed by Kirillov are not directly applicable to decoding from RNNs, which do not satisfy the assumptions made.
Most related to our proposed approach is the work of Gimpel et al. (2013), who applied DivMBest to machine translation using beam search as a black-box inference algorithm. Specifically, in this approach, DivMBest knows nothing about the inner-workings of BS and simply makes $B$ sequential calls to BS to generate $B$ diverse solutions. This approach is extremely wasteful because BS is called $B$ times, run from scratch every time, and even though each call to BS produces $B$ solutions, only one solution is kept by DivMBest. In contrast, DBS avoids these shortcomings by integrating diversity within BS such that no beams are discarded. By running multiple beam searches in parallel and at staggered time offsets, we obtain large time savings making our method comparable to $a$ single run of classical BS. One potential disadvantage of our method w.r.t. Gimpel et al. (2013) is that sentence-level diversity metrics cannot be incorporated in DBS since no group is complete when diversity is encouraged. However, as observed empirically by us and Li et al. (2015), initial words tend to disproportionally impact the diversity of the resultant sequences – suggesting that later words may not be important for diverse inference.
Diverse Decoding for RNNs. Efforts have been made by Li et al. (2015) and Li & Jurafsky (2016) to produce diverse decodings from recurrent models for conversation modeling and machine translation. Both of these works propose new heuristics for creating diverse M-Best lists and employ mutual information to re-rank lists of sequences. The latter achieves a goal separate from ours, which is simply to re-rank diverse lists.
Li & Jurafsky (2016) proposes a BS diversification heuristic that discourages beams from sharing common roots, implicitly resulting in diverse lists. Introducing diversity through a modified objective (as in DBS) rather than via a procedural heuristic provides easier generalization to incorporate different notions of diversity and control the exploration-exploitation trade-off as detailed in Section 5.1. Furthermore, we find that DBS outperforms the method of Li & Jurafsky (2016).
Li et al. (2015) introduced a novel decoding objective that maximizes mutual information between inputs and predicted outputs to penalize generic sequences. This operates on a principle orthogonal and complementary to DBS and Li & Jurafsky (2016). It works by penalizing utterances that are generally more frequent (diversity independent of input) rather than penalizing utterances that are similar to other utterances produced for the same input (diversity conditioned on input). Furthermore, the input-independent approach requires training a new language model for the target language while DBS just requires a diversity function $\Delta$ . Combination of these complementary techniques is left as interesting future work.
In other recent work, Wu et al. (2016) modify the beam search objective by introducing lengthnormalization to favor longer sequences and a coverage penalty that favors sequences that account for the complete input sequence. While the coverage term does not generalize to all neural sequence models, the length-normalization term can be implemented by modifying the joint-log-probability of each sequence. Although the goal of this method is not to produce diverse lists and hence not directly comparable, it is a complementary technique that can be used in conjunction with our diverse decoding method.
# 5 EXPERIMENTS
In this section, we evaluate our approach on image captioning, machine translation, conversation and visual question generation tasks to demonstrate both its effectiveness against baselines and its general applicability to any inference currently supported by beam search. We also analyze the effects of DBS parameters, explore human preferences for diversity, and discuss diversity’s importance in explaining complex images. We first explain the baselines and evaluations used in this paper.
Baselines & Metrics. Apart from classical beam search, we compare DBS with the diverse decoding method proposed in Li & Jurafsky (2016). We also compare against two other complementary decoding techniques proposed in Li et al. (2015) and Wu et al. (2016). Note that these two techniques are not directly comparable with DBS since the goal is not to produce diverse lists. We now provide a brief description of the comparisons mentioned:
- Li & Jurafsky (2016): modify BS by introducing an intra-sibling rank. For each partial solution, the set of $| \nu |$ beam extensions are sorted and assigned intra-sibling ranks $k \in \ [ | \nu | ]$ in order of decreasing log probabilities, $\theta _ { t } ( y _ { t } )$ . The log probability of an extension is then reduced in proportion to its rank, and continuations are re-sorted under these modified log probabilities to select the top $B$ ‘diverse’ beam extensions.
- Li et al. (2015): train an additional unconditioned target sequence model $U ( \mathbf { y } )$ and perform BS decoding on an augmented objective $P ( \mathbf { y } | x ) - \lambda U ( \mathbf { y } )$ , penalizing input-independent decodings.
- $\mathrm { { W u } }$ et al. (2016) modify the beam-search objective by introducing length-normalization that favors longer sequences. The joint log-probability of completed sequences is divided by a factor, $( 5 + | \mathbf { y } | ) ^ { \alpha } / ( 5 + 1 ) ^ { \alpha }$ , where $\alpha \in [ 0 , 1 ]$ .
We compare to our own implementations of these methods as none are publicly available. Both Li & Jurafsky (2016) and Li et al. (2015) develop and use re-rankers to pick a single solution from the generated lists. Since we are interested in evaluating the quality of the generated lists and in isolating the gains due to diverse decoding, we do not implement any re-rankers, simply sorting by log-probability.
We evaluate the performance of the generated lists using the following two metrics:
- Oracle Accuracy: Oracle or top $k$ accuracy w.r.t. some task-specific metric, such as BLEU (Papineni et al., 2002) or SPICE (Anderson et al., 2016), is the maximum value of the metric achieved over a list of $k$ potential solutions. Oracle accuracy is an upper bound on the performance of any re-ranking strategy and thus measures the maximum potential of a set of outputs. - Diversity Statistics: We count the number of distinct n-grams present in the list of generated outputs. Similar to Li et al. (2015), we divide these counts by the total number of words generated to bias against long sentences.
Simultaneous improvements in both metrics indicate that output sequences have increased diversity without sacrificing fluency and correctness with respect to target tasks.
5.1 SENSITIVITY ANALYSIS AND EFFECT OF DIVERSITY FUNCTIONS
Here we discuss the impact of the number of groups, strength of diversity , and various forms of diversity for language models. Note that the parameters of DBS (and other baselines) were tuned on a held-out validation set for each experiment. The supplement provides further discussion and experimental details.
Number of Groups $\mathbf { \Pi } ( \mathbf { G } )$ . Setting $G { = } B$ allows for the maximum exploration of the search space, while setting $G { = } 1$ reduces DBS to BS, resulting in increased exploitation of the search-space around the 1-best decoding. Empirically, we find that maximum exploration correlates with improved oracle accuracy and hence use $G { = } B$ to report results unless mentioned otherwise. See the supplement for a comparison and more details.
Diversity Strength $( \lambda )$ . The diversity strength $\lambda$ specifies the trade-off between the model score and diversity terms. As expected, we find that a higher value of $\lambda$ produces a more diverse list; however, very large values of $\lambda$ can overpower model score and result in grammatically incorrect outputs. We set $\lambda$ via grid search over a range of values to maximize oracle accuracies achieved on the validation set. We find a wide range of $\lambda$ values (0.2 to 0.8) work well for most tasks and datasets.
Choice of Diversity Function $( \Delta )$ . In Section 3, we defined $\Delta ( \cdot )$ as a function over a set of partial solutions that outputs a vector of dissimilarity scores for all possible beam completions. Assuming that each of the previous groups influences the completion of the current group independently, we can simplify $\Delta ( \bar { \bigcup } _ { h = 1 } ^ { g - 1 } Y _ { [ t ] } ^ { h } )$ as the sum of each group’s contributions as $\bar { \sum _ { h = 1 } ^ { g - 1 } \Delta ( Y _ { [ t ] } ^ { h } ) }$ . In Section 3, we illustrated a simple hamming diversity of this form that penalizes selection of tokens proportionally to the number of time it was used in previous groups. However, this factorized diversity term can take various forms in our model – with hamming diversity being the simplest. For language models, we study the effect of using cumulative (i.e. considering all past time steps), n-gram and neural embedding based diversity functions. Each of these forms encode differing notions of diversity and result in DBS outperforming BS. We find simple hamming distance to be effective and report results based on this diversity measure unless otherwise specified. More details about these forms of the diversity term are provided in the supplementary.
# 5.2 IMAGE CAPTIONING
Dataset and Models. We evaluate on two datasets – COCO (Lin et al., 2014) and PASCAL-50S (Vedantam et al., 2015). We use the public splits as in Karpathy & Fei-Fei (2015) for COCO. PASCAL-50S is used only for testing (with 200 held out images used to tune hyperparameters). We train a captioning model (Vinyals et al., 2015) using the neuraltalk21 code repository.
Results. Table 1 shows Oracle (top $k$ ) SPICE for different values of $k$ . DBS consistently outperforms BS and Li & Jurafsky (2016) on both datasets. We observe that gains on PASCAL-50S are more pronounced $7 . 1 4 \%$ and $4 . 6 5 \%$ SPICE $\textcircled{ a} 2 0$ improvements over BS and Li & Jurafsky (2016)) than COCO. This suggests diverse predictions are especially advantageous when there is a mismatch between training and testing sets, implying DBS may be better suited for real-world applications.
Table 1 also shows the number of distinct n-grams produced by different techniques. Our method produces significantly more distinct n-grams (almost $300 \%$ increase in the number of 4-grams produced) as compared to BS. We also note that our method tends to produce slightly longer captions compared on average. Moreover, on the PASCAL-50S test split we observe that DBS finds more likely top-1 solutions on average – DBS obtains an average maximum log probability of -6.53 opposed to -6.91 found by BS of the same beam width. This empirical evidence suggests that using DBS as a replacement to BS may lead to lower inference approximation error.
Table 1: Oracle accuracy and distinct n-grams on COCO and PASCAL-50S datasets for image captioning at $B = 2 0$ . While we report SPICE, we observe similar trends in other metrics (reported in supplement).
<table><tr><td rowspan="2">Dataset</td><td rowspan="2">Method</td><td colspan="4">Oracle Accuracy (SPICE)</td><td colspan="4">Diversity Statistics</td></tr><tr><td>@1</td><td>@5</td><td>@10</td><td>@20</td><td>distinct-1</td><td>distinct-2</td><td>distinct-3</td><td>distinct-4</td></tr><tr><td rowspan="5">PASCAL-50S</td><td>Beam Search</td><td>4.933</td><td>7.046</td><td>7.949</td><td>8.747</td><td>0.12</td><td>0.57</td><td>1.35</td><td>2.50</td></tr><tr><td>Li & Jurafsky (2016)</td><td>5.083</td><td>7.248</td><td>8.096</td><td>8.917</td><td>0.15</td><td>0.97</td><td>2.43</td><td>5.31</td></tr><tr><td>DBS</td><td>5.357</td><td>7.357</td><td>8.269</td><td>9.293</td><td>0.18</td><td>1.26</td><td>3.67</td><td>7.33</td></tr><tr><td>Wu et al. (2016)</td><td>5.301</td><td>7.322</td><td>8.236</td><td>8.832</td><td>0.16</td><td>1.10</td><td>3.16</td><td>6.45</td></tr><tr><td>Li et al. (2015)</td><td>5.129</td><td>7.175</td><td>8.168</td><td>8.560</td><td>0.13</td><td>1.15</td><td>3.58</td><td>8.42</td></tr><tr><td rowspan="5">COCO</td><td>Beam Search</td><td>16.278</td><td>22.962</td><td>25.145</td><td>27.343</td><td>0.40</td><td>1.51</td><td>3.25</td><td>5.67</td></tr><tr><td>Li & Jurafsky (2016)</td><td>16.351</td><td>22.715</td><td>25.234</td><td>27.591</td><td>0.54</td><td>2.40</td><td>5.69</td><td>8.94</td></tr><tr><td>DBS</td><td>16.783</td><td>23.081</td><td>26.088</td><td>28.096</td><td>0.56</td><td>2.96</td><td>7.38</td><td>13.44</td></tr><tr><td>Wu et al. (2016)</td><td>16.642</td><td>22.643</td><td>25.437</td><td>27.783</td><td>0.54</td><td>2.42</td><td>6.01</td><td>7.08</td></tr><tr><td>Li et al. (2015)</td><td>16.749</td><td>23.271</td><td>26.104</td><td>27.946</td><td>0.42</td><td>1.37</td><td>3.46</td><td>6.10</td></tr></table>
Human Studies. To evaluate human preference between captions generated by DBS and BS, we perform a human study via Amazon Mechanical Turk using all 1000 images of PASCAL-50S. For each image, both DBS and standard BS captions are shown to 5 different users. They are then asked – “Which of the two robots understands the image better?” In this forced-choice test, DBS captions were preferred over BS $60 \%$ of the time by human annotators.
Is diversity always needed? While these results show that diverse outputs are important for systems that interact with users, is diversity always beneficial? While images with many objects (e.g., a park or a living room) can be described in multiple ways, the same is not true when there are few objects (e.g., a close up of a cat or a selfie). This notion is studied by Ionescu et al. (2016), which defines a “difficulty score”: the human response time for solving a visual search task. On the PASCAL50S dataset, we observe a positive correlation $\zeta \rho = 0 . 7 3 )$ between difficulty scores and humans preferring DBS to BS. Moreover, while DBS is generally preferred by humans for ‘difficult’ images, both are about equally preferred on ‘easier’ images. Details are provided in the supplement.
# 5.3 MACHINE TRANSLATION
We use the WMT’14 dataset containing $4 . 5 { \mathrm { M } }$ sentences to train our machine translation models. We train stacking LSTM models as detailed in Luong et al. (2015), consisting of 4 layers and 1024- dimensional hidden states. While decoding sentences, we employ the same strategy to replace UNK tokens. We train our models using the publicly available seq2seq-attn2 code repository. We report results on news-test-2013 and news-test-2014 and use the news-test-2012 to tune the parameters of DBS. We use sentence level BLEU scores to compute oracle metrics and report distinct $\mathbf { n }$ -grams similar to image captioning. Results are shown in Table 2 and we again find that DBS consistently outperforms all baselines.
Table 2: Quantitative results on English-German translation on the newstest-2013 and newstest-2014 datasets combined (at $B = 2 0$ ).
<table><tr><td rowspan="2">Method</td><td colspan="4">Oracle Accuracy (BLEU-4)</td><td colspan="4">Diversity Statistics</td></tr><tr><td>@1</td><td>@5</td><td>@10</td><td>@20</td><td>distinct-1</td><td>distinct-2</td><td>distinct-3</td><td>distinct-4</td></tr><tr><td>Beam Search</td><td>20.5</td><td>22.4</td><td>23.8</td><td>24.2</td><td>0.04</td><td>0.75</td><td>2.10</td><td>3.23</td></tr><tr><td>Li & Jurafsky (2016)</td><td>20.7</td><td>22.6</td><td>24.0</td><td>24.3</td><td>0.04</td><td>0.81</td><td>2.92</td><td>4.61</td></tr><tr><td>DBS</td><td>20.8</td><td>22.9</td><td>24.4</td><td>24.8</td><td>0.06</td><td>0.95</td><td>3.67</td><td>5.54</td></tr><tr><td>Wu et al. (2016)</td><td>20.6</td><td>22.6</td><td>24.3</td><td>24.6</td><td>0.05</td><td>0.88</td><td>2.83</td><td>4.50</td></tr><tr><td>Li et al. (2015)</td><td>20.7</td><td>23.1</td><td>24.4</td><td>24.6</td><td>0.04</td><td>0.86</td><td>2.76</td><td>4.31</td></tr></table>
# 5.4 DIALOG GENERATION
Dialog generation is a task that is inherently diverse as there are multiple valid ways to respond to a statement. We train a seq2seq model consisting of LSTMs as in Vinyals & Le (2015) on the Cornell Movie Dialogs Corpus (Danescu-Niculescu-Mizil & Lee, 2011) using the neuralconvo3 repository. The training dataset consists of 222,182 conversational exchanges between movie characters. Since automatic evaluation of dialog generation responses is an open research problem with existing metrics being poorly correlated with human judgement (Liu et al., 2016), we show qualitative results to demonstrate the effectiveness of DBS. Table 3 compares BS and DBS at $\scriptstyle \mathrm { B } = 3$ .
Table 3: Qualitative examples of dialog generation comparing best-first search, BS and DBS
<table><tr><td>Prompt</td><td>Beam Search</td><td>Diverse Beam Search</td></tr><tr><td rowspan="2">Why do you want to be the president?</td><td>I don't know. I don't know...</td><td>I don't know.</td></tr><tr><td>I don't know,but Iam the best</td><td>Because you know! Because,I have another life.</td></tr><tr><td rowspan="2">It's such a beautiful day!</td><td>I know!</td><td>I know.</td></tr><tr><td>It's true.</td><td>Well...</td></tr><tr><td rowspan="2">What's your name?</td><td>Yeah. Jacob.</td><td>That's not true,honey.</td></tr><tr><td>Berger, my man. Berger, Thomas.</td><td>Jacob. Berger,darling</td></tr></table>
# 5.5 VISUAL QUESTION GENERATION
We also report results on Visual Question Generation (VQG) (Mostafazadeh et al., 2016), where a model is trained to produce questions about an image. Generating visually focused questions is interesting because it requires reasoning about multiple problems that are central to vision – e.g., object attributes, relationships between objects, and natural language. Furthermore, many questions could make sense for one image, so it is important that lists of generated questions be diverse.
We use the VQA dataset (Antol et al., 2015) to train a model similar to image captioning architectures. Instead of captions, the training set now consists of 3 questions per image. Similar to previous results, using beam search to sample outputs results in similarly worded questions (see Fig. 3) and DBS brings out new details captured by the model. Counting the number of types of questions generated (as defined by Antol et al. (2015)) allows us to measure this diversity. We observe that the number of question types generated per image increases from 2.3 for BS to 3.7 for DBS (at $B = 6$ ).
# 6 CONCLUSION
Beam search is widely a used approximate inference algorithm for decoding sequences from neural sequence models; however, it suffers from a lack of diversity. Producing multiple highly similar and generic outputs is not only wasteful in terms of computation but also detrimental for tasks with

Figure 3: Qualitative results on Visual Question Generation. DBS generates questions that are non-generic and belong to different question types.
inherent ambiguity like many involving language. In this work, we modify Beam Search with a diversity-augmented sequence decoding objective to produce Diverse Beam Search. We develop a ‘doubly greedy’ approximate algorithm to minimize this objective and produce diverse sequence decodings. Our method consistently outperforms beam search and other baselines across all our experiments without extra computation or task-specific overhead. DBS is task-agnostic and can be applied to any case where BS is used, which we demonstrate in multiple domains. Our implementation available at https://github.com/ashwinkalyan/dbs.
# REFERENCES
Peter Anderson, Basura Fernando, Mark Johnson, and Stephen Gould. Spice: Semantic propositional image caption evaluation. In Proceedings of European Conference on Computer Vision (ECCV), 2016. 6 Stanislaw Antol, Aishwarya Agrawal, Jiasen Lu, Margaret Mitchell, Dhruv Batra, C Lawrence Zitnick, and Devi Parikh. VQA: Visual question answering. In Proceedings of IEEE Conference on Computer Vision and Pattern Recognition (CVPR), pp. 2425–2433, 2015. 1, 8 Dzmitry Bahdanau, Kyunghyun Cho, and Yoshua Bengio. Neural machine translation by jointly learning to align and translate. Proceedings of the International Conference on Learning Representations (ICLR), 2014. 1 Dhruv Batra, Payman Yadollahpour, Abner Guzman-Rivera, and Gregory Shakhnarovich. Diverse M-Best Solutions in Markov Random Fields. In Proceedings of European Conference on Computer Vision (ECCV), 2012. 2, 4 Cristian Danescu-Niculescu-Mizil and Lillian Lee. Chameleons in imagined conversations: A new approach to understanding coordination of linguistic style in dialogs. In Proceedings of the Workshop on Cognitive Modeling and Computational Linguistics, ACL 2011, 2011. 8 Francis Ferraro, Ishan Mostafazadeh, Nasrinand Misra, Aishwarya Agrawal, Jacob Devlin, Ross Girshick, Xiadong He, Pushmeet Kohli, Dhruv Batra, and C Lawrence Zitnick. Visual storytelling. Proceedings of the Conference of the North American Chapter of the Association for Computational Linguistics – Human Language Technologies (NAACL HLT), 2016. 2 Jenny Rose Finkel, Christopher D Manning, and Andrew Y Ng. Solving the problem of cascading errors: Approximate bayesian inference for linguistic annotation pipelines. In Proceedings of the Conference on Empirical Methods in Natural Language Processing (EMNLP), pp. 618–626, 2006. 1 K. Gimpel, D. Batra, C. Dyer, and G. Shakhnarovich. A systematic exploration of diversity in machine translation. In Proceedings of the Conference on Empirical Methods in Natural Language Processing (EMNLP), 2013. 1, 5, 12 Alex Graves, Abdel-rahman Mohamed, and Geoffrey E. Hinton. Speech recognition with deep recurrent neural networks. abs/1303.5778, 2013. 1
Radu Tudor Ionescu, Bogdan Alexe, Marius Leordeanu, Marius Popescu, Dim Papadopoulos, and Vittorio Ferrari. How hard can it be? Estimating the difficulty of visual search in an image. In Proceedings of IEEE Conference on Computer Vision and Pattern Recognition (CVPR), 2016. 7
Anjuli Kannan, Karol Kurach, Sujith Ravi, Tobias Kaufmann, Andrew Tomkins, Balint Miklos, Greg Corrado, László Lukács, Marina Ganea, Peter Young, et al. Smart reply: Automated reeponse suggestion for email. In Proceedings of the ACM SIGKDD Conference on Knowledge Discovery and Data Mining (KDD), 2016. 2
Andrej Karpathy and Li Fei-Fei. Deep visual-semantic alignments for generating image descriptions. In Proceedings of IEEE Conference on Computer Vision and Pattern Recognition (CVPR), 2015. 2, 7
Alexander Kirillov, Bogdan Savchynskyy, Dmitrij Schlesinger, Dmitry Vetrov, and Carsten Rother. Inferring m-best diverse labelings in a single one. In Proceedings of IEEE Conference on Computer Vision and Pattern Recognition (CVPR), 2015. 2, 4
Jiwei Li and Dan Jurafsky. Mutual information and diverse decoding improve neural machine translation. arXiv preprint arXiv:1601.00372, 2016. 2, 5, 6, 7, 8, 13, 14
Jiwei Li, Michel Galley, Chris Brockett, Jianfeng Gao, and Bill Dolan. A diversity-promoting objective function for neural conversation models. Proceedings of the Conference of the North American Chapter of the Association for Computational Linguistics – Human Language Technologies (NAACL HLT), 2015. 2, 5, 6, 7, 8, 13, 14
Tsung-Yi Lin, Michael Maire, Serge Belongie, James Hays, Pietro Perona, Deva Ramanan, Piotr Dollar, and C. Lawrence Zitnick. Microsoft COCO: Common objects in context, 2014. 7
Chia-Wei Liu, Ryan Lowe, Iulian Vlad Serban, Michael Noseworthy, Laurent Charlin, and Joelle Pineau. How NOT to evaluate your dialogue system: An empirical study of unsupervised evaluation metrics for dialogue response generation. 2016. URL http://arxiv.org/abs/1603. 08023. 8
Minh-Thang Luong, Hieu Pham, and Christopher D Manning. Effective approaches to attentionbased neural machine translation. arXiv preprint arXiv:1508.04025, 2015. 7
Tomas Mikolov, Ilya Sutskever, Kai Chen, Greg S. Corrado, and Jeff Dean. Distributed representations of words and phrases and their compositionality. In Advances in Neural Information Processing Systems (NIPS), 2013. 12
Nasrin Mostafazadeh, Ishan Misra, Jacob Devlin, Margaret Mitchell, Xiaodong He, and Lucy Vanderwende. Generating natural questions about an image. Proceedings of the Annual Meeting on Association for Computational Linguistics (ACL), 2016. 8
Kishore Papineni, Salim Roukos, Todd Ward, and Wei-Jing Zhu. Bleu: a method for automatic evaluation of machine translation. In Proceedings of the Annual Meeting on Association for Computational Linguistics (ACL), 2002. 6
Dennis Park and Deva Ramanan. N-best maximal decoders for part models. In Proceedings of IEEE International Conference on Computer Vision (ICCV), 2011. 4
Adarsh Prasad, Stefanie Jegelka, and Dhruv Batra. Submodular meets structured: Finding diverse subsets in exponentially-large structured item sets. In Advances in Neural Information Processing Systems (NIPS), 2014. 2, 4
Ramakrishna Vedantam, C Lawrence Zitnick, and Devi Parikh. Cider: Consensus-based image description evaluation. In Proceedings of IEEE Conference on Computer Vision and Pattern Recognition (CVPR), 2015. 7
Subhashini Venugopalan, Marcus Rohrbach, Jeffrey Donahue, Raymond Mooney, Trevor Darrell, and Kate Saenko. Sequence to sequence-video to text. In Proceedings of IEEE Conference on Computer Vision and Pattern Recognition (CVPR), pp. 4534–4542, 2015. 1
Oriol Vinyals and Quoc Le. A neural conversational model. arXiv preprint arXiv:1506.05869, 2015. 1, 8
Oriol Vinyals, Alexander Toshev, Samy Bengio, and Dumitru Erhan. Show and tell: A neural image caption generator. In Proceedings of IEEE Conference on Computer Vision and Pattern Recognition (CVPR), 2015. 1, 2, 7
Yonghui Wu, Mike Schuster, Zhifeng Chen, Quoc V Le, Mohammad Norouzi, Wolfgang Macherey, Maxim Krikun, Yuan Cao, Qin Gao, Klaus Macherey, et al. Google’s neural machine translation system: Bridging the gap between human and machine translation. arXiv preprint arXiv:1609.08144, 2016. 5, 6, 7, 8, 13, 14
# APPENDIX
SENSIVITY STUDIES
Number of Groups. Fig. 4 presents snapshots of the transition from BS to DBS at $B = 6$ and $G = \{ 1 , 3 , 6 \}$ . As beam width moves from 1 to $G$ , the exploration of the method increases resulting in more diverse lists.

Figure 4: Effect of increasing the number of groups $G$ . The beams that belong to the same group are colored similarly. Recall that diversity is only enforced across groups such that $G = 1$ corresponds to classical BS.
Diversity Strength. As noted in Section 5.1, our method is robust to a wide range of values of the diversity strength $( \lambda )$ . Fig. 5a shows a grid search of $\lambda$ for image-captioning on the PASCAL-50S dataset.
Choice of Diversity Function. The diversity function can take various forms ranging from simple hamming diversity to neural embedding based diversity. We discuss some forms for language modelling below:
- Hamming Diversity. This form penalizes the selection of tokens used in previous groups proportional to the number of times it was selected before. - Cumulative Diversity. Once two sequences have diverged sufficiently, it seems unnecessary and perhaps harmful to restrict that they cannot use the same words at the same time. To encode this ‘backing-off’ of the diversity penalty we introduce cumulative diversity which keeps a count of identical words used at every time step, indicative of overall dissimilarity. Specifically, $\begin{array} { r } { \Delta ( Y _ { [ t ] } ^ { h } ) [ y _ { [ t ] } ^ { g } ] = \exp \{ - \big ( \sum _ { \tau \in t } \sum _ { b \in B ^ { \prime } } I \big [ y _ { b , \tau } ^ { h } \neq y _ { b , \tau } ^ { g } ] \big ) / \Gamma \} } \end{array}$ where $\Gamma$ is a temperature parameter controlling the strength of the cumulative diversity term and $I [ \cdot ]$ is the indicator function. - $n$ -gram Diversity. The current group is penalized for producing the same n-grams as previous groups, regardless of alignment in time – similar to Gimpel et al. (2013). This is proportional to the number of times each $\mathbf { n }$ -gram in a candidate occurred in previous groups. Unlike hamming diversity, n-grams capture higher order structures in the sequences. - Neural-embedding Diversity. While all the previous diversity functions discussed above perform exact matches, neural embeddings such as word2vec (Mikolov et al., 2013) can penalize semantically similar words like synonyms. This is incorporated in each of the previous diversity functions by replacing the hamming similarity with a soft version obtained by computing the cosine similarity between word2vec representations. When using with n-gram diversity, the representation of the n-gram is obtained by summing the vectors of the constituent words.
Each of these various forms encode different notions of diversity. Hamming diversity ensures different words are used at different times, but can be circumvented by small changes in sequence alignment. While n-gram diversity captures higher order statistics, it ignores sentence alignment. Neural-embedding based encodings can be seen as a semantic blurring of either the hamming or n-gram metrics, with word2vec representation similarity propagating diversity penalties not only to exact matches but also to close synonyms. Fig. 5b shows the oracle performace of various forms of the diversity function described in Section 5.1. We find that using any of the above functions help outperform BS in the tasks we examine; hamming diversity achieves the best oracle performance despite its simplicity.
# IMAGE CAPTIONING EVALUATION
While we report oracle SPICE values in the paper, our method consistently outperforms baselines and classical BS on other standard metrics such as CIDEr (Table 4), METEOR (Table 5) and ROUGE (Table 6). We provide these additional results in this section.
 Figure 5: Fig. 5a shows the results of a grid search of the diversity strength $( \lambda )$ parameter of DBS on the validation split of PASCAL 50S dataset. We observe that it is robust for a wide range of values. Fig. 5b compares the performance of multiple forms for the diversity function $( \Delta )$ . While naïve diversity performs the best, other forms are comparable while being better than BS.
Table 4: CIDEr Oracle accuracy on COCO and PASCAL-50S datasets for image captioning at $B = 2 0$ .
<table><tr><td>Dataset</td><td>Method</td><td colspan="4">Oracle Accuracy (CIDEr)</td></tr><tr><td></td><td></td><td>@1</td><td>@5</td><td>@10</td><td>@20</td></tr><tr><td rowspan="5">PASCAL-50S</td><td>Beam Search</td><td>53.79</td><td>83.94</td><td>96.70</td><td>107.63</td></tr><tr><td>Li & Jurafsky (2016)</td><td>54.61</td><td>85.21</td><td>99.80</td><td>110.64</td></tr><tr><td>DBS</td><td>57.82</td><td>89.38</td><td>103.75</td><td>113.43</td></tr><tr><td>Wu et al. (2016)</td><td>47.77</td><td>72.12</td><td>84.64</td><td>105.66</td></tr><tr><td>Li et al. (2015)</td><td>49.80</td><td>81.35</td><td>96.87</td><td>107.37</td></tr><tr><td rowspan="5">COCO</td><td>Beam Search</td><td>87.27</td><td>121.74</td><td>133.46</td><td>140.98</td></tr><tr><td>Li & Jurafsky (2016)</td><td>91.42</td><td>111.33</td><td>116.94</td><td>119.14</td></tr><tr><td>DBS</td><td>86.88</td><td>123.38</td><td>135.68</td><td>142.88</td></tr><tr><td>Wu et al. (2016)</td><td>87.54</td><td>122.06</td><td>133.21</td><td>139.43</td></tr><tr><td>Li et al. (2015)</td><td>88.18</td><td>124.20</td><td>138.65</td><td>150.06</td></tr></table>
Table 5: METEOR Oracle accuracy on COCO and PASCAL-50S datasets for image captioning at $B = 2 0$
<table><tr><td>Dataset</td><td>Method</td><td colspan="4">Oracle Accuracy (METEOR)</td></tr><tr><td></td><td></td><td>@1</td><td>@5</td><td>@10</td><td>@20</td></tr><tr><td rowspan="4">PASCAL-50S</td><td>Beam Search</td><td>12.24</td><td>16.74</td><td>19.14</td><td>21.22</td></tr><tr><td>Li & Jurafsky (2016)</td><td>13.52</td><td>17.65</td><td>19.91</td><td>21.76</td></tr><tr><td>DBS</td><td>13.71</td><td>18.45</td><td>20.67</td><td>22.83</td></tr><tr><td>Wu et al. (2016)</td><td>13.34</td><td>17.20</td><td>18.98</td><td>21.13</td></tr><tr><td rowspan="5">COCO</td><td>Li et al. (2015)</td><td>13.04</td><td>17.92</td><td>19.73</td><td>22.32</td></tr><tr><td>Beam Search</td><td>24.81</td><td>28.56</td><td>30.59</td><td>31.87</td></tr><tr><td>Li & Jurafsky (2016)</td><td>24.88</td><td>29.10</td><td>31.44</td><td>33.56</td></tr><tr><td>DBS</td><td>25.04</td><td>29.67</td><td>33.25</td><td>35.42</td></tr><tr><td>Wu et al. (2016)</td><td>24.82</td><td>28.92</td><td>31.53</td><td>34.14</td></tr><tr><td></td><td>Li et al. (2015)</td><td>24.93</td><td>30.11</td><td>32.34</td><td>34.88</td></tr></table>
Modified SPICE evaluation. To measure both the quality and the diversity of the generated captions, we compute SPICE-score by comparing the graph union of all the generated hypotheses with the ground truth scene graph. This measure rewards all the relevant relations decoded as against oracle accuracy that compares to relevant relations present only in the top-scoring caption. We observe that DBS outperforms both baselines under this measure with a score of 18.345 as against a score of 16.988 (beam search) and 17.452 (Li & Jurafsky, 2016).
Table 6: ROUGE Oracle accuracy on COCO and PASCAL-50S datasets for image captioning at $B = 2 0$
<table><tr><td>Dataset</td><td>Method</td><td colspan="4">Oracle Accuracy (ROUGE-L)</td></tr><tr><td></td><td></td><td>@1</td><td>@5</td><td>@10</td><td>@20</td></tr><tr><td rowspan="4">PASCAL-50S</td><td>Beam Search</td><td>45.23</td><td>56.12</td><td>59.61</td><td>62.04</td></tr><tr><td>Li & Jurafsky (2016)</td><td>46.21</td><td>56.17</td><td>60.15</td><td>62.95</td></tr><tr><td>DBS</td><td>46.24</td><td>56.90</td><td>60.35</td><td>63.02</td></tr><tr><td>Wu et al. (2016)</td><td>43.73</td><td>52.29</td><td>56.49</td><td>61.65</td></tr><tr><td rowspan="5">COCO</td><td>Li et al. (2015)</td><td>44.12</td><td>54.67</td><td>57.34</td><td>60.11</td></tr><tr><td>Beam Search</td><td>52.46</td><td>58.43</td><td>62.56</td><td>65.14</td></tr><tr><td>Li & Jurafsky (2016)</td><td>52.87</td><td>59.89 60.89</td><td>63.45</td><td>65.42</td></tr><tr><td>DBS</td><td>53.04</td><td></td><td>64.24</td><td>67.72</td></tr><tr><td>Wu et al. (2016) Li et al. (2015)</td><td>52.13 53.10</td><td>58.26 59.32</td><td>62.89 63.04</td><td>65.77 66.19</td></tr></table>
# HUMAN STUDIES
For image-captioning, we conduct a human preference study between BS and DBS captions as explained in Section 5. A screen shot of the interface used to collect human preferences for captions generated using DBS and BS is presented in Fig. 6. The lists were shuffled to guard the task from being gamed by a turker.
Table 7: Frequency table for image difficulty and human preference for DBS captions on PASCAL50S dataset
<table><tr><td>difficulty score bin range</td><td>#images</td><td>% images DBS was preffered</td></tr><tr><td>≤μ-σ</td><td>481</td><td>50.51%</td></tr><tr><td>[μ-σ,μ+σ]</td><td>409</td><td>69.92%</td></tr><tr><td>≥μ+σ</td><td>110</td><td>83.63%</td></tr></table>
As mentioned in Section 5, we observe that difficulty score of an image and human preference for DBS captions are positively correlated. The dataset contains more images that are less difficulty and so, we analyze the correlation by dividing the data into three bins. For each bin, we report the $\%$ of images for which DBS captions were preferred after a majority vote (i.e. at least 3/5 turkers voted in favor of DBS) in Table 7. At low difficulty scores consisting mostly of iconic images – one might expect that BS would be preferred more often than chance. However, mismatch between the statistics of the training and testing data results in a better performance of DBS. Some examples for this case are provided in Fig. 7. More general qualitative examples are provided in Fig. 8.
# DISCUSSION
Are longer sentences better? Many recent works propose a scoring or a ranking objective that depends on the sequence length. These favor longer sequences, reasoning that they tend to have more details and resulting in improved accuracies. We measure the correlation between length of a sequence and its accuracy (here, SPICE) and observe insignificant correlation between SPICE and sequence length. On the PASCAL-50S dataset, we find that BS and DBS have are negatively correlated ${ \mathrm { \Delta } } \rho = - 0 . 0 0 3$ and $\rho = - 0 . 0 1 5$ respectively), while (Li & Jurafsky, 2016) is correlated positively $\zeta = 0 . 0 0 2 )$ . Length is not correlated with performance in this case.
Efficient utilization of beam budget. In this experiment, we emperically show that DBS makes efficient use of the beam budget in exploring the search space for better solutions. Fig. 9 shows the variation of oracle SPICE $( \ @ \mathbf { B } )$ with the beam size. At really high beam widths, all decoding techniques achieve similar oracle accuracies. However, diverse decoding techniques like DBS achieve the same oracle at much lower beam widths. Hence, DBS not only produces sequence lists that are significantly different but also efficiently utilizes the beam budget to decode better solutions.
# Instructions
# Which of the two robots understands the image better?
Two robots are shown an image.They both make 5 guesses each for describing the image with a single sentence.
Which robot do you think is more intellgent or uman-like displaying a better understanding of the image?
 Note: Select the radio button above the set of captions that you pick. Figure 6: Screen-shot of the interface used to perform human studies

# Beam Search
A man riding a motorcycle on a dirt road A man riding a motorcycle on a beach A man riding a motorcycle on the side of a road A man riding a bike on a dirt road A man riding a motorcycle on the side of the road A man riding a motorcycle on the side of a beach
# Diverse Beam Search
A man riding a motorcycle on a beach A man riding abike on a dirt road A man riding a bike on a dirt road A man on a motorcycle is flying a kite A person on a skateboard riding on the side of a road A person on a bicycle with a helmet on on the ground
Difficulty Score : 2.8308
 Difficulty Score :2.9287
# Beam Search
A black bear standing in a grassy field A black bear standing in a field of grass A black bear is standing in the grass A black bear is standing in a field A black bear standing in the grass next to a tree A black bear standing in the grass near a fence
# Diverse Beam Search
# A black dog is standing in the grass A black dog is standing in the grass
A black bear walking through a grassy field A black bear walking ina field of grass A black and white dog is standing in the grass A black bear standing in the grass near a fence
Difficulty Score :2.8999
# Beam Search
A close up of a bowl of broccoli A close up of a plate of broccoli A close up of a broccoli plant on a table Aclose up of a bowl of broccoli on a table A close up of a broccoli plant in a garden A close up of a plate of broccoli and cauliflower
 Figure 7: For images with low difficulty score, BS captions are preferred to DBS – as show in the first figure. However, we observe that DBS captions perform better when there is a mismatch between the statistics of the testing and training sets. Interesting captions are colored in blue for readability.
# Diverse Beam Search
Aclose up of a bowl of broccoli Aclose up of a plate of broccoli and broccoli A green plant with a green plant in it A green plant with a bunch of green leaves A white plate topped with broccoli and a plant A small green plant with a green plant in it
 Difficulty Score : 5.4382
# Beam Search
A group of people sitting at a table with laptops A group of people sitting at a table A couple of people that are sitting at a table A group of people sitting around a table with laptops A group of people sitting at a table in front of laptops A group of people sitting at a table with a laptop
# Diverse Beam Search
A group of people sitting at a table with laptops A group of people sitting at a table with laptops A group of people sitting around a table with laptops A group of people are sitting at a table Two people sitting at a table with laptops Three people are siting at a table with laptops
 Difficulty Score : 4.1815
# Beam Search
A woman sitting in front of a laptop computer A woman sitting at a table with a laptop A woman sitting at a table with a laptop computer A woman is working on a laptop computer A woman siting at a desk with a laptop computer A woman is sitting at a table with a laptop
# Diverse Beam Search
A woman sitting at a table with a laptop computer A woman is working on a laptop computer A woman is sitting at a table with a laptop A man sitting at a desk with a laptop computer A woman in a kitchen with a laptop computer A man is sitting at a table with a laptop and a computer
 Difficulty Score : 3.8146
# Beam Search
A wooden table topped with plates of food A table with plates of food on it A wooden table topped with plates and bowls of food A table that hasa bunch of plates on it A wooden table topped with plates of food and glasses A wooden table topped with plates of food and cups
# Diverse Beam Search
A table with a plate of food and a glass of wine A table with a plate of food and a glass A table with plates of food and a glass of wine A dining table with a plate of food and a glass of wine A table with a bowl of food and a bowl of soup on it A dining room table with a plate of food and a glass of wine on it
Figure 8: For images with a high difficulty score, captions produced by DBS are preferred to BS. Interesting captions are colored in blue for readability.
 Figure 9: As the number of beams increases, all decoding methods tend to achieve about the same oracle accuracy. However, diverse decoding techniques like DBS utilize the beam budget efficiently achieving higher oracle accuracies at much lower beam budgets.123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408# GRADIENT SURGERY FOR MULTI-TASK LEARNING
Anonymous authors Paper under double-blind review
# ABSTRACT
While deep learning and deep reinforcement learning systems have demonstrated impressive results in domains such as image classification, game playing, and robotic control, data efficiency remains a major challenge, particularly as these algorithms learn individual tasks from scratch. Multi-task learning has emerged as a promising approach for sharing structure across multiple tasks to enable more efficient learning. However, the multi-task setting presents a number of optimization challenges, making it difficult to realize large efficiency gains compared to learning tasks independently. The reasons why multi-task learning is so challenging compared to single task learning are not fully understood. Motivated by the insight that gradient interference causes optimization challenges, we develop a simple and general approach for avoiding interference between gradients from different tasks, by altering the gradients through a technique we refer to as “gradient surgery”. We propose a form of gradient surgery that projects the gradient of a task onto the normal plane of the gradient of any other task that has a conflicting gradient. On a series of challenging multi-task supervised and multi-task reinforcement learning problems, we find that this approach leads to substantial gains in efficiency and performance. Further, it can be effectively combined with previously-proposed multi-task architectures for enhanced performance in a model-agnostic way.
# 1 INTRODUCTION
While deep learning and deep reinforcement learning (RL) have shown considerable promise in enabling systems to perform complex tasks, the data requirements of current methods make it difficult to learn a breadth of capabilities particularly when all tasks are learned individually from scratch. A natural approach to such multi-task learning problems is to train a single network on all tasks jointly, with the aim of discovering shared structure across the tasks in a way that achieves greater efficiency and performance than solving the tasks individually. However, learning multiple tasks all at once results in a difficult optimization problem, sometimes leading to worse overall performance and data efficiency compared to learning tasks individually (Parisotto et al., 2015; Rusu et al., 2016a). These optimization challenges are so prevalent that multiple multi-task RL algorithms have considered using independent training as a subroutine of the algorithm before distilling the independent models into a multi-tasking model (Levine et al., 2016; Parisotto et al., 2015; Rusu et al., 2016a; Ghosh et al., 2017; Teh et al., 2017), producing a multi-task model but losing out on the efficiency gains over independent training. If we could tackle the optimization challenges of multi-task learning effectively, we may be able to actually realize the hypothesized benefits of multi-task learning without the cost in final performance.
While there has been a significant amount of research in multi-task learning (Caruana, 1997; Ruder, 2017), the optimization challenges are not well understood. Prior work has described varying learning speeds of different tasks (Chen et al., 2017) and plateaus in the optimization landscape (Schaul et al., 2019) as potential causes, while a range of other works have focused on the model architecture (Misra et al., 2016b; Liu et al., 2018). In this work, we instead hypothesize that the central optimization issue in multi-task learning arises from gradients from different tasks conflicting with one another. In particular, we define two gradients to be conflicting if they point away from one another (i.e., have a negative cosine similarity). As a concrete example, consider the 2D optimization landscapes of two task objectives shown in Figure 1. The optimization landscape of each task consists of a deep valley, as has been characterized of neural network optimization landscapes in the past (Goodfellow et al., 2014). When considering the combined optimization landscape for multiple tasks, SGD produces gradients that struggle to efficiently find the optimum. This occurs due to a gradient thrashing phenomenon, where the gradient of one task destabilizes optimization in the valley. We can observe this in Figure 1(d) when the optimization reaches the deep valley of task 1, but is prevented from traversing the valley to an optimum. In Section 6.2, we find experimentally that this thrashing phenomenon also occurs in a neural network multi-task learning problem.
 Figure 1: Visualization of PCGrad’s effect on a 2D multi-task optimization problem. (a) A multi-task objective landscape. (b) & (c) Contour plots of the individual task objectives that comprise the multi-task objective. (d) Trajectory of gradient updates on the multi-task objective using the Adam optimizer. The gradient vectors of the two tasks at the end of the trajectory are indicated by blue and red arrows, where the relative lengths are on a log scale.(e) Trajectory of gradient updates on the multi-task objective using Adam with PCGrad. For (d) and (e), the optimization trajectory goes from black to yellow.
The core contribution of this work is a method for mitigating gradient interference by altering the gradients directly, i.e. by performing “gradient surgery”. If two gradients are conflicting, we alter the gradients by projecting each onto the normal plane of the other, preventing the interfering components of the gradient from being applied to the network. We refer to this particular form of gradient surgery as projecting conflicting gradients (PCGrad). PCGrad is model-agnostic, requiring only a single modification to the application of gradients. Hence, it is easy to apply to a range of problem settings, including multi-task supervised learning and multi-task reinforcement learning, and can also be readily combined with other multi-task learning approaches, such as those that modify the architecture. We evaluate PCGrad on multi-task CIFAR classification, multi-objective scene understanding, a challenging multi-task RL domain, and goal-conditioned RL. Across the board, we find PCGrad leads to significant improvements in terms of data efficiency, optimization speed, and final performance compared to prior approaches. Further, on multi-task supervised learning tasks, PCGrad can be successfully combined with prior state-of-the-art methods for multi-task learning for even greater performance.
# 2 PRELIMINARIES
The goal of multi-task learning is to find parameters $\theta$ of a model $f _ { \theta }$ that achieve high average performance across all the training tasks drawn from a distribution of tasks $p ( \tau )$ . More formally, we aim to solve the problem: $\operatorname* { m i n } _ { \theta } \mathbb { E } _ { \mathcal { T } _ { i } \sim p ( \mathcal { T } ) } \left[ \mathcal { L } _ { i } ( f _ { \theta } ) \right]$ , where $\mathcal { L } _ { i }$ is a loss function for the $i$ -th task $\mathcal { T } _ { i }$ that we want to minimize. To obtain a model that solves a specific task from the task distribution $p ( \mathcal { T } )$ , we define a task-conditioned model $f _ { \boldsymbol { \theta } } ( \boldsymbol { y } | \boldsymbol { x } , z _ { i } )$ , with input $x$ , output $y$ , and encoding $z _ { i }$ for task $\mathcal { T } _ { i }$ , which could be provided as a one-hot vector or in any other form.
# 3 MULTI-TASK LEARNING VIA GRADIENT SURGERY
While the multi-task problem can in principle be solved by simply applying a standard single-task algorithm with a suitable task identifier provided to the model or a simple multi-head or multi-output model, a number of prior works (Parisotto et al., 2015; Rusu et al., 2016a; Sener & Koltun, 2018) have found this learning problem to be difficult, especially in the reinforcement learning setting. We hypothesize that one of the main challenges of multi-task learning can be characterized by conflicting and thrashing gradients, and find that this can significantly impede learning progress, especially when combined with iterative data collection. We identify possible causes for this problem and propose a simple and general approach to mitigate it.
# 3.1 THRASHING GRADIENTS IN MULTI-TASK OPTIMIZATION LANDSCAPES
We hypothesize that a key optimization issue in multi-task learning arises when gradients from multiple tasks are in conflict with one another, i.e. when gradients point away from one another. More specifically, we hypothesize that such conflict may lead to gradient thrashing. Concretely, gradient thrashing refers to the phenomenon where a large gradient for one task changes the parameter vectors in a way that substantially decreases performance on another task. Since worse performance typically leads to larger gradients, this results in alternating gradient directions, where, at the next iteration, the second task will have large gradients that dominate and reduce performance on the former task. This issue can be particularly pronounced for neural network optimization, since neural network loss landscapes are known to resemble long narrow valleys (Goodfellow et al., 2014), where the gradient perpendicular to the direction of the valley will be small.
 Figure 2: Visual depiction of conflicting gradients and PCGrad. In (a), we see that tasks A and B have conflicting gradient directions, which can lead to destructive interference and unstable learning. In (b), we illustrate the PCGrad algorithm in cases where gradients are conflicting. PCGrad projects the gradient of task A onto the normal vector of task B’s gradient. In (c), we show that tasks with non-conflicting gradients are not altered under PCGrad, thereby keeping tasks with constructive interference.
We aim to study this hypothesis through two toy examples. First, consider the two-dimensional optimization landscape illustrated in Fig. 1a, where the landscape for each task objective corresponds to a deep and curved valley (Fig. 1b and 1c). The optima of this multi-task objective correspond to where the two valleys meet. More details on the optimization landscape are in Appendix B. We observe that the gradient thrashing hypothesis is consistent with what we observe when running Adam (Kingma & Ba, 2014) on this landscape in Fig. 1d, where we observe that Adam does not traverse one valley towards the other, preventing it from reaching an optimum.
We also aim to detect if a similar phenomenon occurs in multi-task learning with a neural network with thousands of parameters on a toy regression problem. To measure the extent of gradient thrashing, we plot the cosine similarity between the gradients of two tasks throughout the beginning of learning in Fig. 4 (left). We indeed observe a significant level of gradient thrashing at every iteration, where the cosine similarity varies between $- 0 . 7 5$ and 0.75 at a very high frequency.
Motivated by these observations, we develop an algorithm that aims to alleviate the optimization challenges caused by gradient thrashing by preventing such gradient conflict between tasks.
# 3.2 PCGRAD: PROJECTING CONFLICTING GRADIENTS
We aim to prevent gradient thrashing by directly altering the gradients themselves, i.e. through “gradient surgery.” To be maximally effective and maximally applicable, we must perform surgery in a way that still allows for positive interactions between the task gradients and does not introduce any assumptions on the form of the model.
We start by first detecting whether two gradients are in conflict, by measuring whether they point away from one another. More concretely, we characterize two tasks as conflicting for the current parameter setting if they yield a negative cosine similarity between their respective gradients. The goal of PCGrad is to modify the gradients for each task so as to minimize negative conflict with other task gradients, which will in turn mitigate gradient thrashing.
To deconflict gradients during optimization, PCGrad adopts a simple procedure: if the gradients between two tasks are in conflict, i.e. their cosine similarity is negative, we project the gradient from one task onto the normal plane of the gradient of the other task. This amounts to removing the conflicting component of the gradient for the task, thereby reducing the amount of destructive gradient interference between tasks. A pictorial description of this idea is shown in Fig. 2. Suppose the gradient for task $\mathcal { T } _ { i }$ is $\mathbf { g } _ { i }$ , and the gradient for task $\tau _ { j }$ is $\mathbf { g } _ { j }$ . PCGrad proceeds as follows: (1) First, it determines whether $\mathbf { g } _ { i }$ conflicts with ${ \bf { g } } _ { j }$ by computing the cosine similarity between vectors $\mathbf { g } _ { i }$ and $\mathbf { g } _ { j }$ , where negative values indicate conflicting gradients. (2) If the cosine similarity is negative, we replace $\mathbf { g } _ { i }$ by its projection onto the normal plane of $\mathbf { g } _ { j }$ : $\begin{array} { r } { \mathbf { g } _ { i } = \mathbf { g } _ { i } - \frac { \mathbf { g } _ { i } \cdot \mathbf { g } _ { j } } { \| \mathbf { g } _ { j } \| ^ { 2 } } \mathbf { g } _ { j } } \end{array}$ gi·gjkgjk2 gj . If the gradients are not in conflict, i.e. cosine similarity is non-negative, the original gradient $\mathbf { g } _ { i }$ remains unaltered. (3) PCGrad repeats this process across all of the other tasks sampled in random order from the current
# Algorithm 1 PCGrad Update Rule
Require: Current model parameters $\theta$ 1: Sample mini-batch of tasks $B = \{ \mathcal { T } _ { k } \} \sim p ( \mathcal { T } )$ 2: for $\bar { \mathcal { T } } _ { i } \sim \mathcal { B }$ in sequence do 3: Compute gradient ${ \bf g } _ { i }$ of $\mathcal { T } _ { i }$ as $\mathbf { g } _ { i } = \nabla _ { \theta } \mathcal { L } _ { i } ( f _ { \theta } )$ 4: for ${ \tau _ { j } } \stackrel { \mathrm { u n i f o r m l y } } { \sim } { B }$ in random order do 5: Compute gradient $\mathbf { g } _ { j }$ of task $\mathcal { T } _ { j }$ as $\mathbf { g } _ { j } = \nabla _ { \theta } \mathcal { L } _ { j } ( f _ { \theta } )$ 6: Compute cosine similarity between $\mathbf { g } _ { i }$ as $\mathbf { g } _ { j }$ as $\begin{array} { r } { \cos ( \phi _ { i j } ) = \frac { \mathbf { g } _ { i } \cdot \mathbf { g } _ { j } } { \| \mathbf { g } _ { i } \| \| \mathbf { g } _ { j } \| } } \end{array}$ . 7: 8: if $\begin{array} { r l } & { \cos ( \phi _ { i j } ) < 0 \mathrm { t h e n } } \\ & { \mathrm { S e t } \mathbf { g } _ { i } = \mathbf { g } _ { i } - \frac { \mathbf { g } _ { i } \cdot \mathbf { g } _ { j } } { \| \mathbf { g } _ { j } \| ^ { 2 } } \mathbf { g } _ { j } } \end{array}$ // Subtract the projection of ${ \bf g } _ { i }$ onto $\mathbf { g } _ { j }$ 9: end if 10: end for 11: Store $\mathbf { g } _ { i } ^ { \mathrm { p r o j } } = \mathbf { g } _ { i }$ 12: end for 13: return update $\begin{array} { r } { \Delta \theta = \sum _ { i } \mathbf { g } _ { i } ^ { \mathrm { p r o j } } } \end{array}$
batch $\mathcal { T } _ { j } \ \forall \ j \ \neq i$ , resulting in the gradient ${ \bf g } _ { i } ^ { \mathrm { p r o j } }$ that is applied for task $\mathcal { T } _ { i }$ . We perform the same procedure for all tasks in the batch to obtain their respective gradients. The full update procedure is described in Algorithm 1 and a discussion on using a random task order is included in Appendix D.
This procedure, while simple to implement, ensures that the gradients that we apply for each task per batch interfere minimally with the other tasks in the batch, mitigating the thrashing gradient problem, producing a variant on standard first-order gradient descent in the multi-objective setting. In practice, the PCGrad gradient surgery method can be combined with any gradient-based optimizer, including commonly used methods such as SGD with momentum and Adam (Kingma & Ba, 2014), by simply passing the computed update to the respective optimizer instead of the original gradient. Our experimental results verify the hypothesis that this procedure reduces the problem of thrashing gradients, and find that, as a result, learning progress is substantially improved.
Finally, we analyze the convergence of this procedure in Theorem 1 in the two-task setting, to ensure that the procedure is sensible under the standard assumptions in optimization.
Theorem 1. Consider two task loss functions $\mathcal { L } _ { 1 } : \mathbb { R } ^ { n } \mathbb { R }$ and $\mathcal { L } _ { 2 } : \mathbb { R } ^ { n } \mathbb { R }$ which are convex and differentiable. For all $\theta \in \mathbb { R } ^ { n }$ , let $\begin{array} { r } { \mathcal { L } ( \boldsymbol { \theta } ) = \mathcal { L } _ { 1 } ( \boldsymbol { \theta } ) + \mathcal { L } _ { 2 } ( \boldsymbol { \theta } ) , } \end{array}$ , i.e. $\mathcal { L }$ is a multi-task objective. Let $\phi$ be the angle between $\nabla { \mathcal { L } } _ { 1 } ( \theta )$ and $\nabla { \mathcal { L } } _ { 2 } ( \theta )$ . Suppose $\mathcal { L }$ is differentiable and that its gradient is Lipschitz continuous with constant $L > 0$ , i.e. we have $| | \nabla \mathcal { L } ( \bar { \theta _ { 1 } } ) - \nabla \mathcal { L } ( \theta _ { 2 } ) | | _ { 2 } \leq L | | \theta _ { 1 } - \theta _ { 2 } | | _ { 2 } f o r$ any $\theta _ { 1 } , \theta _ { 2 }$ . Then, the PCGrad update rule with step size $\begin{array} { r } { t \le \frac { 1 } { L } } \end{array}$ will converge to either $( l )$ a location in the optimization landscape where $\cos ( \phi ) = - 1$ or (2) the optimal value $\mathcal { L } ( \theta ^ { \ast } )$ .
Proof. See Appendix A.
Theorem 1 states that application of the PCGrad update in the two-task setting with a convex and Lipschitz multi-task loss function $\mathcal { L }$ leads to convergence to either the minimizer of $\mathcal { L }$ or a potentially sub-optimal objective value. A sub-optimal solution occurs when the cosine similarity between the gradients of the two tasks is $- 1$ , i.e. the gradients directly conflict, leading to zero gradient after applying PCGrad. However, in practice, since we are using SGD, which is a noisy estimate of the true batch gradients, the cosine similarity between the gradients of two tasks in a minibatch is unlikely to be $- 1$ , thus avoiding this scenario.
# 4 THE PRACTICAL OPERATIONS OF PCGRAD
We apply PCGrad to both supervised learning and reinforcement learning problem settings with multiple tasks or goals. In this section, we discuss the practical instantiations of PCGrad in those settings. Further implementation details are included in Section 6.
# 4.1 MULTI-TASK SUPERVISED LEARNING
In multi-task supervised learning, each task $\mathcal { T } _ { i } \sim p ( \mathcal { T } )$ has a corresponding training dataset $\mathcal { D } _ { i }$ consisting of $N _ { i }$ labeled training examples, i.e. $\mathcal { D } _ { i } = \{ ( x , y ) _ { n } \} _ { n = 1 } ^ { N _ { i } }$ . The objective for each task in this supervised setting is then defined as $\mathcal { L } _ { i } ( f _ { \theta } ) = \mathbb { E } _ { ( x , y ) \sim \mathcal { D } _ { i } } \left[ - \log f _ { \theta } ( y \vert x , z _ { i } ) \right]$ , where $z _ { i }$ is a one-hot encoding of task $\mathcal { T } _ { i }$ .
At each training step, we randomly sample a batch of data points $\boldsymbol { B }$ from the whole dataset $\textstyle \bigcup _ { i } { \mathcal { D } } _ { i }$ and then group the sampled data with the same task encoding into small batches denoted as $B _ { i }$ for each $\mathcal { T } _ { i }$ represented in $\boldsymbol { B }$ . We denote the set of tasks appearing in $\boldsymbol { B }$ as $B _ { T }$ . After sampling, we precompute the gradient of each task in $B _ { T }$ as
$$\begin{array} { r } { \nabla _ { \theta } \mathcal { L } _ { i } ( f _ { \theta } ) = \mathbb { E } _ { ( { x } , { y } ) \sim \mathcal { B } _ { i } } \left[ - \nabla _ { \theta } \log f _ { \theta } ( { y } | { x } , { z } _ { i } ) \right] . } \end{array}$$
Given the set of precomputed gradients $\nabla _ { \theta } \mathcal { L } _ { i } ( f _ { \theta } )$ , we also precompute the cosine similarity between all pairs of the gradients in the set. Using the pre-computed gradients and their similarities, we can obtain the PCGrad update by following Algorithm 1, without re-computing task gradients nor backpropagating into the network.
Since the PCGrad procedure is only modifying the gradients of shared parameters in the optimization step, it is model-agnostic and can be readily applied to any architecture designed for supervised multi-task learning. In Section 6, we combine PCGrad with two state-of-the-art architectures for multi-task learning, which leads to noticeable improvement over their original performance.
# 4.2 MULTI-TASK AND GOAL-CONDITIONED REINFORCEMENT LEARNING
For multi-task reinforcement learning, PCGrad can be readily applied to policy gradient methods by directly updating the computed policy gradient of each task, following Algorithm 1, analogous to the supervised learning setting. For actor-critic algorithms, it is also straightforward to apply PCGrad: we simply replace the task gradients for both the actor and the critic by their gradients computed via PCGrad. Hence, PCGrad can be readily incorporated into a variety of model-free RL algorithms. When applying PCGrad to goal-conditioned RL, we represent $p ( \mathcal T )$ as a distribution of goals and let $z _ { i }$ be the encoding of a goal. Similar to the multi-task supervised learning setting discussed above, PCGrad may be combined with various architectures designed for multi-task and goal-conditioned RL (Fernando et al., 2017; Devin et al., 2016), where PCGrad operates on the gradients of shared parameters, leaving task-specific parameters untouched.
In our experiments, we apply PCGrad to the soft actor-critic (SAC) algorithm (Haarnoja et al., 2018), a recently proposed off-policy actor-critic algorithm that has shown significant gains in sample efficiency and asymptotic performance across many different domains. In SAC, we employ a $\mathrm { Q } \mathrm { - }$ learning style gradient to compute the gradient of the Q-function network, $Q _ { \phi } ( s , a , z _ { i } )$ , often known as the critic, and a reparameterization-style gradient to compute the gradient of the policy network $\pi _ { \boldsymbol { \theta } } ( a | s , z _ { i } )$ , often known as the actor. For sampling, we instantiate a set of replay buffers $\{ \mathcal { D } _ { i } \} _ { \mathcal { T } _ { i } \sim p ( \mathcal { T } ) }$ . Training and data collection are alternated throughout training. During a data collection step, we run the policy $\pi _ { \theta }$ on all the tasks $\mathcal { T } _ { i } \sim p ( \mathcal { T } )$ to collect an equal number of paths for each task and store the paths of each task $\mathcal { T } _ { i }$ into the corresponding replay buffer $\mathcal { D } _ { i }$ . At each training step, we sample an equal amount of data from each replay buffer $\mathcal { D } _ { i }$ to form a stratified batch. For each task $\mathcal { T } _ { i } \sim p ( \mathcal { T } )$ , the parameters of the critic $\theta$ are optimized to minimize the soft Bellman residual:
$$\begin{array} { r l } & { J _ { Q } ^ { ( i ) } ( \phi ) = \mathbb { E } _ { ( s _ { t } , a _ { t } , z _ { i } ) \sim \mathcal { D } _ { i } } \left[ Q _ { \phi } ( s _ { t } , a _ { t } , z _ { i } ) - ( r ( s _ { t } , a _ { t } , z _ { i } ) + \gamma V _ { \bar { \phi } } ( s _ { t + 1 } , z _ { i } ) ) \right] , } \\ & { V _ { \bar { \phi } } ( s _ { t + 1 } , z _ { i } ) = \mathbb { E } _ { a _ { t + 1 } \sim \pi _ { \theta } } \left[ Q _ { \bar { \phi } } ( s _ { t + 1 } , a _ { t + 1 } , z _ { i } ) - \alpha \log \pi _ { \theta } ( a _ { t + 1 } | s _ { t + 1 } , z _ { i } ) \right] , } \end{array}$$
where $\gamma$ is the discount factor, $\bar { \phi }$ are the delayed parameters, and $\alpha$ is a learnable temperature that automatically adjusts the weight of the entropy term. For each task $\mathcal { T } _ { i } \sim p ( \mathcal { T } )$ , the parameters of the policy $\pi _ { \theta }$ are trained to minimize the following objective
$$J _ { \pi } ^ { ( i ) } ( \theta ) = \mathbb { E } _ { s _ { t } \sim \mathcal { D } _ { i } } \left[ \mathbb { E } _ { a _ { t } \sim \pi _ { \theta } ( a _ { t } \mid s _ { t } , z _ { i } ) ) } \left[ \alpha \log \pi _ { \theta } ( a _ { t } \mid s _ { t } , z _ { i } ) - Q _ { \phi } ( { s _ { t } , a _ { t } , z _ { i } } ) \right] \right] .$$
We compute $\nabla _ { \phi } J _ { Q } ^ { ( i ) } ( \phi )$ and $\nabla _ { \theta } J _ { \pi } ^ { ( i ) } ( \theta )$ for all $\begin{array} { r } { \mathcal { T } _ { i } \sim p ( \mathcal { T } ) } \end{array}$ and apply PCGrad to both following Algorithm 1.
In the context of SAC specifically, we further study how the temperature $\alpha$ should be adjusted. If we use a single learnable temperature for adjusting entropy of the multi-task policy $\pi _ { \boldsymbol { \theta } } ( a | s , z _ { i } )$ , SAC may stop exploring once all easier tasks are solved, leading to poor performance on tasks that are harder or require more exploration. To address this issue, we propose to learn the temperature on a per-task basis, i.e. using a parametrized model to represent $\alpha _ { \psi } ( z _ { i } )$ (which we abbreviate as PA for per-task alpha). This allows the method to control the entropy of $\dot { \pi } _ { \boldsymbol { \theta } } ( a | s , z _ { i } )$ per-task. We optimize the parameters of $\alpha _ { \psi } ( z _ { i } )$ using the same constrained optimization framework as in Haarnoja et al. (2018).
# 5 RELATED WORK
Algorithms for multi-task learning typically consider how to train a single model that can solve a variety of different tasks (Caruana, 1997; Bakker & Heskes, 2003; Ruder, 2017). The multi-task formulation has been applied to many different settings, including supervised learning (Zhang et al., 2014; Long & Wang, 2015; Yang & Hospedales, 2016; Sener & Koltun, 2018; Zamir et al., 2018) and reinforcement-learning (Espeholt et al., 2018; Wilson et al., 2007), as well as many different domains, such as vision (Bilen & Vedaldi, 2016; Misra et al., 2016a; Kokkinos, 2017; Liu et al., 2018; Zamir et al., 2018), language (Collobert & Weston, 2008; Dong et al., 2015; McCann et al., 2018; Radford et al., 2019) and robotics (Riedmiller et al., 2018; Wulfmeier et al., 2019; Hausman et al., 2018). While multi-task learning has the promise of accelerating acquisition of large task repertoires, in practice it presents a challenging optimization problem, which has been tackled in several ways in prior work.
A number of architectural solutions have been proposed to the multi-task learning problem based on multiple modules or paths (Fernando et al., 2017; Devin et al., 2016; Misra et al., 2016b; Rusu et al., 2016b; Rosenbaum et al., 2018; Vandenhende et al., 2019; Rosenbaum et al., 2018), or using attention-based architectures (Liu et al., 2018; Maninis et al., 2019). Our work is agnostic to the model architecture and can be combined with prior architectural approaches in a complementary fashion. A different set of multi-task learning approaches aim to decompose the problem into multiple local problems, often corresponding to each task, that are significantly easier to learn, akin to divide and conquer algorithms (Levine et al., 2016; Rusu et al., 2016a; Parisotto et al., 2015; Teh et al., 2017; Ghosh et al., 2017; Czarnecki et al., 2019). Eventually, the local models are combined into a single, multi-task policy using different distillation techniques (outlined in (Hinton et al., 2015; Czarnecki et al., 2019)). In contrast to these methods, we propose a simple and cogent scheme for multi-task learning that allows us to learn the tasks simultaneously using a single, shared model without the need for network distillation.
Similarly to our work, a number of prior approaches have observed the difficulty of optimization in the multi-task learning setting (Hessel et al., 2019; Chen et al., 2018; Kendall et al., 2018b; Schaul et al., 2019). Our work, in contrast to many of these optimization schemes, suggests that the challenge in multi-task learning may be attributed to the problem of gradient thrashing, which we address directly by introducing a simple and practical algorithm that de-conflicts gradients from different tasks. Prior work (Sener & Koltun, 2018) alternatively proposes a gradient-based multi-objective optimization problem for multi-task learning to address the problem of optimizing possibly conflicting objectives. As noted in Alg 2 in (Sener & Koltun, 2018), it learns a constant scaling factor for per-task gradient to avoid conflicting, while our method corrects both the scaling factor and the direction of per-task gradient, which can more effectively deconflict gradients. Prior work has also used the cosine similarity between gradients to define when an auxiliary task might be useful for single-task learning (Du et al., 2018). We similarly use cosine similarity between gradients to determine if the gradients between a pair of tasks are in conflict. Unlike Du et al. (2018), we use this measure of gradient conflict as a part of gradient surgery in the context of multi-task learning applications.
A number of works in continual learning have studied how to make gradient updates that do not adversely affect other tasks by projecting the gradients into a space that do not conflict with previous tasks (Lopez-Paz & Ranzato, 2017; Chaudhry et al., 2018). Those methods focus on the continual learning setting, and either need to solve for the gradient projections using quadratic programming (Lopez-Paz & Ranzato, 2017), or only projecting the gradient onto the normal plane of the average of the gradients of past tasks (Chaudhry et al., 2018). In contrast, our work focuses on multi-task learning, does not require solving any QP, and iteratively projects the gradients of each task onto the normal plane of the gradients of each of the other tasks instead of averaging. Finally, our method is distinct from and solves a different problem than the projected gradient method (Calamai & More, 1987), which is an approach for constrained optimization that projects gradients onto the ´ constraint manifold.
 Figure 3: We show visualization of 50 tasks used in MT50 from Meta-World (Yu et al., 2019), which we use for our multi-task RL experiments. MT10 is a subset of the total 50 tasks, which includes reach, push, pick & place, open drawer, close drawer, open door, press button top, open window, close window, and insert peg inside.
# 6 EXPERIMENTS
The goal of our experiments is to study the following questions: (1) Are conflicting gradients a major factor in making optimization for multi-task learning challenging? (2) Does PCGrad make the optimization problems easier for various multi-task learning problems including supervised, reinforcement, and goal-conditioned reinforcement learning settings across different task families? (3) Can PCGrad be combined with other multi-task learning approaches to further improve performance?
# 6.1 EXPERIMENTAL SETUP
To evaluate our method experimentally, we consider both a multi-task supervised learning and a multi-task reinforcement learning problem setup. For supervised learning, we first consider the MultiMNIST dataset (Sener & Koltun, 2018), which contains two tasks: classifying the digit on the top left and on the bottom right in an overlaid image. Beyond digit classification, we also use the CIFAR-100 dataset (Krizhevsky et al., 2009) where each of the 20 label superclasses are treated as distinct tasks, following Rosenbaum et al. (2018). We also conduct experiments on the NYUv2 dataset (Silberman et al., 2012), which consists of RGB-D indoor scene images. Following Liu et al. (2018), we evaluate our method on 3 tasks: 13-class semantic segmentation, depth estimation, and surface normal prediction. In the case of multi-task reinforcement learning, we evaluate our algorithm on the recently proposed Meta-World benchmark (Yu et al., 2019). This benchmark includes a variety of simulated robotic manipulation tasks contained in a shared, table-top environment with a simulated Sawyer arm (visualized as the ”Push” environment in Fig. 3). In particular, we use the multi-task benchmarks MT10 and MT50, which consists of the 10 tasks and 50 tasks respectively depicted in Fig. 3 that require diverse strategies to solve them, which makes them difficult to optimize jointly with a single policy. Note that MT10 is a subset of MT50. To evaluate goal-conditioned RL scenarios, we consider goal-conditioned robotic pushing with a Sawyer robot. This domain is representative of challenges in learning goal-conditioned policies over a wide distribution of goals. For details on the experimental set-up and model architectures see Appendix E.
# 6.2 ANALYSIS OF CONFLICTING GRADIENTS
To answer question (1), we consider a simple regression problem, where each task is regressing the input to the output of a sine function. The amplitude and the phase of each task are varied. We construct 10 tasks with the amplitude uniformly sampled from the range [0, 5] and the phase uniformly sampled from the range $[ 0 , \pi ]$ . The input is also uniformly sampled from the range $[ 0 , 5 ]$ and is concatenated with the one-hot task encoding. For training, we use a 3-layer fully-connected neural network with 100 hidden units.
 Figure 4: An analysis of the gradients during the first 1000 updates of training, on a toy 10-task sinusoid regression problem. Left: The cosine similarity between the gradients of 2 of the 10 tasks (selected arbitrarily, and fixed throughout this plot). We observe a substantial amount of thrashing with standard Adam training, while Adam with PCGrad reduces the thrashing and leads to more closely aligned updates. Right: Adam with PCGrad improves performance compared to standard Adam.
We compare the performance of the network trained with Adam and the network trained with Adam with PCGrad-modified gradients while plotting the cosine similarity between a pair of tasks during training as shown in Figure 4. The plot on the left in Figure 4 demonstrates that the cosine similarity of Adam gradients between a pair of tasks has high variance, which leads to the gradient thrashing problem, while the cosine similarity of the gradient projected by PCGrad yields positive values diminishing the conflicting-gradients problem. As shown in the plot on the right in Figure 4, Adam with PCGrad leads to faster learning over Adam, which implies that gradient thrashing is indeed a problem in multi-task optimization and reducing it can result in considerable performance boost.
# 6.3 MULTI-TASK AND MULTI-OBJECTIVE SUPERVISED LEARNING WITH PCGRAD
To answer question (3), we perform experiments on three standard multi-task supervised learning datasets: MultiMNIST, multi-task CIFAR-100 and NYUv2. We include the results on MultiMNIST in Appendix C.
For CIFAR-100, we follow (Rosenbaum et al., 2018) to treat 20 coarse labels in the dataset as distinct tasks and create a dataset with 20 tasks and 2500 training instances as well as 500 test instances per task. We combine PCGrad with a powerful multi-task learning architecture, routing networks (Rosenbaum et al., 2018; 2019), by simply projecting gradients of the shared parameters in routing networks. As shown in Table 1, applying PCGrad to a single network achieves $71 \%$ classification accuracy, which outperforms most of the prior methods such as independent training and cross-stitch (Misra et al., 2016b). Though routing networks achieve better performance than PCGrad on its own, PCGrad is complementary to routing networks and combining PCGrad with routing networks leads to a $2 . 8 \%$ absolute improvement in test accuracy averaged over 3 runs.
We also combine PCGrad with another state-of-art multi-task learning algorithm, MTAN (Liu et al., 2018), and evaluate the performance on a more challenging indoor scene dataset, NYUv2, which contains 3 tasks as described in Section 6.1. We compare MTAN with PCGrad to a list of methods mentioned in Section 6.1, where each method is trained with three different weighting schemes as in (Liu et al., 2018), equal weighting, weight uncertainty (Kendall et al., 2018a), and DWA (Liu et al., 2018). We only run MTAN with PCGrad with weight uncertainty as we find weight uncertainty as the most effective scheme for training MTAN. The results comparing Cross-Stitch, MTAN and MTAN $^ +$ PCGrad are presented in Table 2 while the full comparison can be found in Table 4 in the Appendix E.3. MTAN with PCGrad is able to achieve the best scores in 8 out of the 9 categories where there are 3 categories per task.
Our multi-task supervised learning results demonstrate that PCGrad can be seamlessly combined with state-of-art multi-task learning architectures and further improve their results on established supervised multi-task learning benchmarks.
# 6.4 MULTI-TASK REINFORCEMENT LEARNING
To answer question (2), we test all methods on 10 and 50 manipulation tasks respectively shown in Figure 3. At each data collection step, we collect 600 samples for each task, and at each training step,
<table><tr><td></td><td>% accuracy</td></tr><tr><td>task specific-1-fc (Rosenbaum et al., 2018)</td><td>42</td></tr><tr><td>task specific-all-fc (Rosenbaum et al., 2018)</td><td>49</td></tr><tr><td>cross stitch-all-fc (Misra et al.,2016b) routing-all-fc + WPL (Rosenbaum et al.,2019)</td><td>53</td></tr><tr><td>independent</td><td>74.7</td></tr><tr><td>PCGrad (ours)</td><td>67.7</td></tr><tr><td></td><td>71</td></tr><tr><td>routing-all-fc + WPL + PCGrad (ours)</td><td>[77.5</td></tr></table>
Table 1: CIFAR-100 multi-task results. We apply PCGrad to the routing networks and achieve a significant improvement in classfication accuracy.
<table><tr><td rowspan="2">#P.</td><td rowspan="2">Architecture</td><td rowspan="2">Weighting</td><td colspan="2">Segmentation</td><td colspan="2">Depth</td><td colspan="5">Surface Normal</td></tr><tr><td>(Higher Better) mIoU</td><td>Pix Acc</td><td>(Lower Better) Abs Err</td><td>Rel Err</td><td>Angle Distance (Lower Better) Mean1</td><td>Median</td><td>11.25</td><td>Within t° (Higher Better) 22.5</td><td>30</td></tr><tr><td rowspan="4">~3</td><td rowspan="2">Cros-Stitch+</td><td>Equal Weights</td><td>14.71</td><td>50.23</td><td>0.6481</td><td>0.2871</td><td>33.56</td><td>28.58</td><td>20.08</td><td>40.54</td><td>51.97</td></tr><tr><td>Uncert.Weights*</td><td>15.69</td><td>52.60</td><td>0.6277</td><td>0.2702</td><td>32.69</td><td>27.26</td><td>21.63</td><td>42.84</td><td>54.45</td></tr><tr><td rowspan="2"></td><td>DWA†,T=2</td><td>16.11</td><td>53.19</td><td>0.5922</td><td>0.2611</td><td>32.34</td><td>26.91</td><td>21.81</td><td>43.14</td><td>54.92</td></tr><tr><td>Equal Weights</td><td>17.72</td><td>55.32</td><td>0.5906</td><td>0.2577</td><td>31.44</td><td>25.37</td><td>23.17</td><td>45.65</td><td>57.48</td></tr><tr><td rowspan="2">1.77</td><td rowspan="2">MTANt</td><td>Uncert.Weights*</td><td>17.67</td><td>55.61</td><td>0.5927</td><td>0.2592</td><td>31.25</td><td>25.57</td><td>22.99</td><td>45.83</td><td>57.67</td></tr><tr><td>DWA+,T=2</td><td>17.15</td><td>54.97</td><td>0.5956</td><td>0.2569</td><td>31.60</td><td>25.46</td><td>22.48</td><td>44.86</td><td>57.24</td></tr><tr><td></td><td></td><td>1.77MTAN++ PCGrad (ours)Uncert.Weights*</td><td>20.17</td><td>56.65</td><td>0.5904</td><td>0.2467</td><td>30.01</td><td>24.83</td><td>22.28</td><td>46.12</td><td>58.77</td></tr></table>
Table 2: We present the results on three tasks on the NYUv2 dataset: 13-class semantic segmentation, depth estimation, and surface normal prediction results. #P shows the total number of network parameters. We highlight the best performing combination of multi-task architecture and weighting in bold. The top validation scores for each task are annotated with boxes. The symbols indicate prior methods: ∗: (Kendall et al., 2018a), †: (Liu et al., 2018), ‡: (Misra et al., 2016b). Performance of other methods as reported in (Liu et al., 2018).
 Figure 5: Learning curve on MT10, MT50 and goal-conditioned pushing. PCGrad outperforms the other methods in the three settings in terms of both success rates / average distance to the goal and data efficiency.
we sample 128 datapoints per task from corresponding replay buffers. The results are shown in the two plots on the left in Figure 5. We measure success according to the metrics used in the Meta-World benchmark where the reported the success rates are averaged across tasks. For all methods, we apply PA as discussed in Section 4 to learn a separate alpha term per task as the task encoding in MT10 and MT50 is just a one-hot encoding. PCGrad combined with SAC learns all tasks with the best data efficiency and successfully solves all of the 10 tasks in MT10 and about $70 \%$ of the 50 tasks in MT50. Training a single SAC policy and a multi-head policy turns out to be unable to acquire half of the skills in both MT10 and MT50, suggesting that eliminating gradient interference across tasks can significantly boost performance of multi-task RL. Training independent SAC agents is able to eventually solve all tasks in MT10 and $70 \%$ of the tasks in MT50, but requires about 2 millions and 15 millions more samples than PCGrad with SAC in MT10 and MT50 respectively, implying that applying PCGrad can result in leveraging shared structure among tasks that expedites multi-task learning.
As noted by $\mathrm { Y u }$ et al. (2019), these tasks involve fairly distinct behavior motions, which makes learning all of them with a single policy challenging as demonstrated by poor baseline performance. The ability to learn these tasks together opens the door for a number of interesting extensions to meta-learning, goal conditioned RL and generalization to novel task families. We present the results of PCGrad on goal-conditioned RL in the following subsection.
We also provide an ablation study on the importance of correcting the gradient direction and scaling the gradient magnitudes in PCGrad. We construct two variants of PCGrad: (1) only applying the gradient direction corrected with PCGrad while keeping the gradient magnitude unchanged and (2) only applying the gradient magnitude computed by PCGrad while keeping the gradient direction unchanged. As shown in the plot on the left in Figure 6, both variants perform worse than PCGrad and the variant where we only vary the gradient magnitudes is much worse than PCGrad. We also compare PCGrad to a prior method GradNorm (Chen et al., 2018), which scales the magnitude of gradients of all the tasks. As shown in the plot on the right in Figure 6, PCGrad significantly outperforms GradNorm. We also notice that the variant of PCGrad where only the gradient magnitudes change gets comparable results to GradNorm, which suggests that its important to modify both the gradient directions and magnitudes to eliminate interference and achieve good multi-task learning results.
 Figure 6: Ablation study on only using the magnitude and the direction of the gradients modified by PCGrad (left) and comparison between PCGrad and GradNorm (Chen et al., 2018) (right). PCGrad outperforms both ablations and GradNorm with a large margin, indicating the importance of modifying both the gradient directions and magnitudes in multi-task learning.
# 6.5 GOAL-CONDITIONED REINFORCEMENT LEARNING
For our goal-conditioned RL evaluation, we use the robot-pushing environment described in Sec. 6.1 where the goals are represented as the concatenations of the initial positions of the puck to be pushed and the its goal location, both of which are uniformly sampled (details in Appendix E.2). We also apply PA as discussed in Section 4 to predict the temperature for entropy term given the goal. We summarize the results in the plot on the right in Figure 5. PCGrad with SAC and PA achieves the best performance in terms of average distance to the goal position, while PCGrad with SAC improves over the baseline and a vanilla SAC agent is struggling to successfully accomplish the task. This suggests that PCGrad is able to ease the RL optimization problem also when the task distribution is continuous.
# 7 CONCLUSION
In this work, we identified one of the major challenges in multi-task optimization: conflicting gradients across tasks. We proposed a simple algorithm (PCGrad) to mitigate the challenge of conflicting gradients via “gradient surgery”. PCGrad provides a simple way to project gradients to be orthogonal in a multi-task setting, which substantially improves optimization performance, since the task gradients are prevented from negating each other. We provide some simple didactic examples and analysis of how this procedure works in simple settings, and subsequently show significant improvement in optimization for a variety of multi-task supervised learning and reinforcement learning problems. We show that, once some of the optimization challenges of multi-task learning are alleviated by PCGrad, we can obtain the hypothesized benefits in efficiency and asymptotic performance that are believed to be possible in multi-task settings.
While we studied multi-task supervised learning and multi-task reinforcement learning in this work, we suspect the problem of conflicting gradients to be prevalent in a range of other settings and applications, such as meta-learning, continual learning, multi-goal imitation learning (Codevilla et al., 2018), and multi-task problems in natural language processing applications (McCann et al., 2018). Due to its simplicity and model-agnostic nature, we expect that applying PCGrad in these domains to be a promising avenue for future investigation. Further, the general idea of gradient surgery may be an important ingredient for alleviating a broader class of optimization challenges in deep learning, such as the challenges in the stability challenges in two-player games (Roth et al., 2017) and multi-agent optimizations (Nedic & Ozdaglar, 2009). We believe this work to be a step towards simple yet general techniques for addressing some of these challenges.
# REFERENCES
Vijay Badrinarayanan, Alex Kendall, and Roberto Cipolla. Segnet: A deep convolutional encoderdecoder architecture for image segmentation. IEEE transactions on pattern analysis and machine intelligence, 39(12):2481–2495, 2017.
Bart Bakker and Tom Heskes. Task clustering and gating for bayesian multitask learning. J. Mach. Learn. Res., 2003.
Hakan Bilen and Andrea Vedaldi. Integrated perception with recurrent multi-task neural networks. In Advances in neural information processing systems, pp. 235–243, 2016.
Stephen Boyd and Lieven Vandenberghe. Convex optimization. Cambridge university press, 2004.
Paul H Calamai and Jorge J More. Projected gradient methods for linearly constrained problems. ´ Mathematical programming, 39(1):93–116, 1987.
Rich Caruana. Multitask learning. Machine Learning, 1997.
Arslan Chaudhry, Marc’Aurelio Ranzato, Marcus Rohrbach, and Mohamed Elhoseiny. Efficient lifelong learning with a-gem. arXiv preprint arXiv:1812.00420, 2018.
Zhao Chen, Vijay Badrinarayanan, Chen-Yu Lee, and Andrew Rabinovich. Gradnorm: Gradient normalization for adaptive loss balancing in deep multitask networks. arXiv preprint arXiv:1711.02257, 2017.
Zhao Chen, Vijay Badrinarayanan, Chen-Yu Lee, and Andrew Rabinovich. Gradnorm: Gradient normalization for adaptive loss balancing in deep multitask networks. In Proceedings of the International Conference on Machine Learning, 2018.
Felipe Codevilla, Matthias Miiller, Antonio Lopez, Vladlen Koltun, and Alexey Dosovitskiy. End-to- ´ end driving via conditional imitation learning. In 2018 IEEE International Conference on Robotics and Automation (ICRA), pp. 1–9. IEEE, 2018.
Ronan Collobert and Jason Weston. A unified architecture for natural language processing: Deep neural networks with multitask learning. In Proceedings of the 25th international conference on Machine learning, pp. 160–167. ACM, 2008.
Wojciech M. Czarnecki, Razvan Pascanu, Simon Osindero, Siddhant M. Jayakumar, Grzegorz Swirszcz, and Max Jaderberg. Distilling policy distillation. In The 22nd International Conference on Artificial Intelligence and Statistics, AISTATS, 2019.
Coline Devin, Abhishek Gupta, Trevor Darrell, Pieter Abbeel, and Sergey Levine. Learning modular neural network policies for multi-task and multi-robot transfer. CoRR, abs/1609.07088, 2016.
Daxiang Dong, Hua Wu, Wei He, Dianhai Yu, and Haifeng Wang. Multi-task learning for multiple language translation. In Proceedings of the 53rd Annual Meeting of the Association for Computational Linguistics and the 7th International Joint Conference on Natural Language Processing (Volume 1: Long Papers), pp. 1723–1732, 2015.
Yunshu Du, Wojciech M. Czarnecki, Siddhant M. Jayakumar, Razvan Pascanu, and Balaji Lakshminarayanan. Adapting auxiliary losses using gradient similarity. CoRR, abs/1812.02224, 2018.
Lasse Espeholt, Hubert Soyer, Remi Munos, Karen Simonyan, Volodymyr Mnih, Tom Ward, Yotam ´ Doron, Vlad Firoiu, Tim Harley, Iain Dunning, Shane Legg, and Koray Kavukcuoglu. IMPALA: scalable distributed deep-rl with importance weighted actor-learner architectures. In Proceedings of the 35th International Conference on Machine Learning, 2018.
Chrisantha Fernando, Dylan Banarse, Charles Blundell, Yori Zwols, David Ha, Andrei A. Rusu, Alexander Pritzel, and Daan Wierstra. Pathnet: Evolution channels gradient descent in super neural networks. CoRR, abs/1701.08734, 2017. URL http://arxiv.org/abs/1701.08734.
Dibya Ghosh, Avi Singh, Aravind Rajeswaran, Vikash Kumar, and Sergey Levine. Divide-andconquer reinforcement learning. CoRR, abs/1711.09874, 2017.
Ian J Goodfellow, Oriol Vinyals, and Andrew M Saxe. Qualitatively characterizing neural network optimization problems. arXiv preprint arXiv:1412.6544, 2014.
Tuomas Haarnoja, Aurick Zhou, Pieter Abbeel, and Sergey Levine. Soft actor-critic: Off-policy maximum entropy deep reinforcement learning with a stochastic actor. International Conference on Machine Learning, 2018.
Karol Hausman, Jost Tobias Springenberg, Ziyu Wang, Nicolas Heess, and Martin Riedmiller. Learning an embedding space for transferable robot skills. 2018.
Matteo Hessel, Hubert Soyer, Lasse Espeholt, Wojciech Czarnecki, Simon Schmitt, and Hado van Hasselt. Multi-task deep reinforcement learning with popart. In Proceedings of the AAAI Conference on Artificial Intelligence, volume 33, pp. 3796–3803, 2019.
Geoffrey Hinton, Oriol Vinyals, and Jeff Dean. Distilling the knowledge in a neural network. arXiv preprint arXiv:1503.02531, 2015.
Alex Kendall, Yarin Gal, and Roberto Cipolla. Multi-task learning using uncertainty to weigh losses for scene geometry and semantics. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pp. 7482–7491, 2018a.
Alex Kendall, Yarin Gal, and Roberto Cipolla. Multi-task learning using uncertainty to weigh losses for scene geometry and semantics. In CVPR, 2018b.
Diederik P Kingma and Jimmy Ba. Adam: A method for stochastic optimization. arXiv preprint arXiv:1412.6980, 2014.
Iasonas Kokkinos. Ubernet: Training a universal convolutional neural network for low-, mid-, and high-level vision using diverse datasets and limited memory. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pp. 6129–6138, 2017.
Alex Krizhevsky, Geoffrey Hinton, et al. Learning multiple layers of features from tiny images. Technical report, Citeseer, 2009.
Sergey Levine, Chelsea Finn, Trevor Darrell, and Pieter Abbeel. End-to-end training of deep visuomotor policies. The Journal of Machine Learning Research, 17(1):1334–1373, 2016.
Shikun Liu, Edward Johns, and Andrew J. Davison. End-to-end multi-task learning with attention. CoRR, abs/1803.10704, 2018.
Mingsheng Long and Jianmin Wang. Learning multiple tasks with deep relationship networks. arXiv preprint arXiv:1506.02117, 2, 2015.
David Lopez-Paz and Marc’Aurelio Ranzato. Gradient episodic memory for continual learning. In Advances in Neural Information Processing Systems, pp. 6467–6476, 2017.
Kevis-Kokitsi Maninis, Ilija Radosavovic, and Iasonas Kokkinos. Attentive single-tasking of multiple tasks. CoRR, abs/1904.08918, 2019.
Bryan McCann, Nitish Shirish Keskar, Caiming Xiong, and Richard Socher. The natural language decathlon: Multitask learning as question answering. arXiv preprint arXiv:1806.08730, 2018.
Ishan Misra, Abhinav Shrivastava, Abhinav Gupta, and Martial Hebert. Cross-stitch networks for multi-task learning. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pp. 3994–4003, 2016a.
Ishan Misra, Abhinav Shrivastava, Abhinav Gupta, and Martial Hebert. Cross-stitch networks for multi-task learning. In Conference on Computer Vision and Pattern Recognition, CVPR, 2016b.
Angelia Nedic and Asuman Ozdaglar. Distributed subgradient methods for multi-agent optimization. IEEE Transactions on Automatic Control, 54(1):48, 2009.
Emilio Parisotto, Jimmy Lei Ba, and Ruslan Salakhutdinov. Actor-mimic: Deep multitask and transfer reinforcement learning. arXiv preprint arXiv:1511.06342, 2015.
Alec Radford, Jeffrey Wu, Rewon Child, David Luan, Dario Amodei, and Ilya Sutskever. Language models are unsupervised multitask learners. OpenAI Blog, 1(8), 2019.
Martin Riedmiller, Roland Hafner, Thomas Lampe, Michael Neunert, Jonas Degrave, Tom Van de Wiele, Volodymyr Mnih, Nicolas Heess, and Jost Tobias Springenberg. Learning by playingsolving sparse reward tasks from scratch. arXiv preprint arXiv:1802.10567, 2018.
Clemens Rosenbaum, Tim Klinger, and Matthew Riemer. Routing networks: Adaptive selection of non-linear functions for multi-task learning. International Conference on Learning Representations (ICLR), 2018.
Clemens Rosenbaum, Ignacio Cases, Matthew Riemer, and Tim Klinger. Routing networks and the challenges of modular and compositional computation. arXiv preprint arXiv:1904.12774, 2019.
Kevin Roth, Aurelien Lucchi, Sebastian Nowozin, and Thomas Hofmann. Stabilizing training of generative adversarial networks through regularization. In Advances in neural information processing systems, pp. 2018–2028, 2017.
Sebastian Ruder. An overview of multi-task learning in deep neural networks. arXiv preprint arXiv:1706.05098, 2017.
Andrei A. Rusu, Sergio Gomez Colmenarejo, C¸ aglar Gul¨ c¸ehre, Guillaume Desjardins, James Kirkpatrick, Razvan Pascanu, Volodymyr Mnih, Koray Kavukcuoglu, and Raia Hadsell. Policy distillation. In 4th International Conference on Learning Representations, ICLR, 2016a.
Andrei A Rusu, Neil C Rabinowitz, Guillaume Desjardins, Hubert Soyer, James Kirkpatrick, Koray Kavukcuoglu, Razvan Pascanu, and Raia Hadsell. Progressive neural networks. arXiv preprint arXiv:1606.04671, 2016b.
Tom Schaul, Diana Borsa, Joseph Modayil, and Razvan Pascanu. Ray interference: a source of plateaus in deep reinforcement learning. arXiv preprint arXiv:1904.11455, 2019.
Ozan Sener and Vladlen Koltun. Multi-task learning as multi-objective optimization. In Advances in Neural Information Processing Systems, 2018.
Nathan Silberman, Derek Hoiem, Pushmeet Kohli, and Rob Fergus. Indoor segmentation and support inference from rgbd images. In European Conference on Computer Vision, pp. 746–760. Springer, 2012.
Yee Teh, Victor Bapst, Wojciech M Czarnecki, John Quan, James Kirkpatrick, Raia Hadsell, Nicolas Heess, and Razvan Pascanu. Distral: Robust multitask reinforcement learning. In Advances in Neural Information Processing Systems, pp. 4496–4506, 2017.
Simon Vandenhende, Bert De Brabandere, and Luc Van Gool. Branched multi-task networks: Deciding what layers to share. CoRR, abs/1904.02920, 2019.
Aaron Wilson, Alan Fern, Soumya Ray, and Prasad Tadepalli. Multi-task reinforcement learning: a hierarchical bayesian approach. In Proceedings of the 24th international conference on Machine learning, pp. 1015–1022. ACM, 2007.
Markus Wulfmeier, Abbas Abdolmaleki, Roland Hafner, Jost Tobias Springenberg, Michael Neunert, Tim Hertweck, Thomas Lampe, Noah Siegel, Nicolas Heess, and Martin Riedmiller. Regularized hierarchical policies for compositional transfer in robotics. arXiv preprint arXiv:1906.11228, 2019.
Yongxin Yang and Timothy M Hospedales. Trace norm regularised deep multi-task learning. arXiv preprint arXiv:1606.04038, 2016.
Tianhe Yu, Deirdre Quillen, Zhanpeng He, Ryan Julian, Karol Hausman, Chelsea Finn, and Sergey Levine. Meta-world: A benchmark and evaluation for multi-task and meta-reinforcement learning. arXiv preprint arXiv:1910.10897, 2019.
Amir R Zamir, Alexander Sax, William Shen, Leonidas J Guibas, Jitendra Malik, and Silvio Savarese. Taskonomy: Disentangling task transfer learning. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pp. 3712–3722, 2018.
Zhanpeng Zhang, Ping Luo, Chen Change Loy, and Xiaoou Tang. Facial landmark detection by deep multi-task learning. In European conference on computer vision, pp. 94–108. Springer, 2014.
# A PROOF OF THEOREM 1
Proof. We will use the shorthand $| | \cdot | |$ to denote the $L _ { 2 }$ -norm and $\nabla { \mathcal { L } } = \nabla _ { \theta } { \mathcal { L } }$ , where $\theta$ is the parameter vector. Let $\mathbf { g _ { 1 } } = \nabla \mathcal { L } _ { 1 }$ , $\mathbf { g _ { 2 } } = \nabla \mathcal { L } _ { 2 }$ , and $\phi$ be the angle between $\bf { g _ { 1 } }$ and $\mathbf { g _ { 2 } }$ .
At each PCGrad update, we have two cases: $c o s ( \phi ) \geq 0$ or $\cos ( \phi < 0 )$ .
If $\cos ( \phi ) \geq 0$ , then we apply the standard gradient descent update using $\begin{array} { r } { t \leq \frac { 1 } { L } } \end{array}$ , which leads to a strict decrease in the objective function value ${ \mathcal { L } } ( \phi )$ unless $\nabla \mathcal { L } ( \phi ) = 0$ , which occurs only when $\theta = \theta ^ { * }$ (Boyd & Vandenberghe, 2004).
In the case that $\cos ( \phi ) < 0$ , we proceed as follows:
Our assumption that $\nabla \mathcal { L }$ is Lipschitz continuous with constant $L$ implies that $\nabla ^ { 2 } { \mathcal { L } } ( \theta ) - L I$ is a negative semidefinite matrix. Using this fact, we can perform a quadratic expansion of $\mathcal { L }$ around $\mathcal { L } ( \boldsymbol { \theta } )$ and obtain the following inequality:
$$\begin{array} { l } { \displaystyle \mathcal { L } ( { \boldsymbol { \theta } } ^ { + } ) \leq \mathcal { L } ( { \boldsymbol { \theta } } ) + \nabla \mathcal { L } ( { \boldsymbol { \theta } } ) ^ { T } ( { \boldsymbol { \theta } } ^ { + } - { \boldsymbol { \theta } } ) + \frac { 1 } { 2 } \nabla ^ { 2 } \mathcal { L } ( { \boldsymbol { \theta } } ) \vert \vert { \boldsymbol { \theta } } ^ { + } - { \boldsymbol { \theta } } \vert \vert ^ { 2 } } \\ { \leq \mathcal { L } ( { \boldsymbol { \theta } } ) + \nabla \mathcal { L } ( { \boldsymbol { \theta } } ) ^ { T } ( { \boldsymbol { \theta } } ^ { + } - { \boldsymbol { \theta } } ) + \frac { 1 } { 2 } L \vert \vert { \boldsymbol { \theta } } ^ { + } - { \boldsymbol { \theta } } \vert \vert ^ { 2 } } \end{array}$$
Now, we can plug in the PCGrad update by letting θ+ = θ − t(∇L(θ) − g1·g2||g1||2 g1 − | g1·g2|g2||2 g2). We then get:
$$\begin{array} { r l } & { \mathcal { L } ( \boldsymbol { \theta } ^ { + } ) \leq \mathcal { L } ( \boldsymbol { \theta } ) + t ( \nabla \mathcal { L } ( \boldsymbol { \theta } ) ) ^ { T } ( - \nabla \mathcal { L } ( \boldsymbol { \theta } ) + \frac { \mathbf { g _ { 1 } } \cdot \mathbf { g _ { 2 } } } { | | \mathbf { g _ { 1 } } | | ^ { 2 } } \mathbf { g _ { 1 } } + \frac { \mathbf { g _ { 1 } } \cdot \mathbf { g _ { 2 } } } { | | \mathbf { g _ { 2 } } | | ^ { 2 } } \mathbf { g _ { 2 } } ) } \\ & { \qquad + \frac { 1 } { 2 } L t ^ { 2 } | | \nabla \mathcal { L } ( \boldsymbol { \theta } ) - \frac { \mathbf { g _ { 1 } } \cdot \mathbf { g _ { 2 } } } { | | \mathbf { g _ { 1 } } | | ^ { 2 } } \mathbf { g _ { 1 } } - \frac { \mathbf { g _ { 1 } } \cdot \mathbf { g _ { 2 } } } { | | \mathbf { g _ { 2 } } | | ^ { 2 } } \mathbf { g _ { 2 } } | | ^ { 2 } } \end{array}$$
$$\begin{array} { l } { = \displaystyle \mathcal { L } ( \boldsymbol { \theta } ) + t ( - | | \mathbf { g _ { 1 } } | | ^ { 2 } - | | \mathbf { g _ { 2 } } | | ^ { 2 } + 2 \mathbf { g _ { 1 } } \cdot \mathbf { g _ { 2 } } + \frac { ( \mathbf { g _ { 1 } } \cdot \mathbf { g _ { 2 } } ) ^ { 2 } } { | | \mathbf { g _ { 1 } } | | ^ { 2 } } + \frac { ( \mathbf { g _ { 1 } } \cdot \mathbf { g _ { 2 } } ) ^ { 2 } } { | | \mathbf { g _ { 2 } } | | ^ { 2 } } ) } \\ { + \displaystyle \frac { 1 } { 2 } L t ^ { 2 } | | \mathbf { g _ { 1 } } + \mathbf { g _ { 2 } } - \frac { \mathbf { g _ { 1 } } \cdot \mathbf { g _ { 2 } } } { | | \mathbf { g _ { 1 } } | | ^ { 2 } } \mathbf { g _ { 1 } } - \frac { \mathbf { g _ { 1 } } \cdot \mathbf { g _ { 2 } } } { | | \mathbf { g _ { 2 } } | | ^ { 2 } } \mathbf { g _ { 2 } } | | ^ { 2 } } \end{array}$$
(Expanding further and re-arranging terms)
$${ \begin{array} { l } { = { \mathcal { L } } ( \theta ) - ( t - { \frac { 1 } { 2 } } L t ^ { 2 } ) ( | | \mathbf { g _ { 1 } } | | ^ { 2 } + | | \mathbf { g _ { 2 } } | | ^ { 2 } - { \frac { \left( \mathbf { g _ { 1 } } \cdot \mathbf { g _ { 2 } } \right) } { | | \mathbf { g _ { 1 } } | | ^ { 2 } } } - { \frac { \left( \mathbf { g _ { 1 } } \cdot \mathbf { g _ { 2 } } \right) } { | | \mathbf { g _ { 2 } } | | ^ { 2 } } } ) } \\ { = { \mathcal { L } } t ^ { 2 } ( \mathbf { g _ { 1 } } \cdot \mathbf { g _ { 2 } } - { \frac { \left( \mathbf { g _ { 1 } } \cdot \mathbf { g _ { 2 } } \right) ^ { 2 } } { | | \mathbf { g _ { 1 } } | | ^ { 2 } | | \mathbf { g _ { 2 } } | | ^ { 2 } } } \mathbf { g _ { 1 } } \cdot \mathbf { g _ { 2 } } ) } \end{array} }$$
(Using the identity $\cos ( \phi ) = { \frac { \mathbf { g _ { 1 } } \cdot \mathbf { g _ { 2 } } } { | | \mathbf { g _ { 1 } } | | | | \mathbf { g _ { 2 } } | | } } )$
$$\begin{array} { l } { { \displaystyle = \mathcal { L } ( \theta ) - ( t - \frac { 1 } { 2 } L t ^ { 2 } ) [ ( 1 - \cos ^ { 2 } ( \phi ) ) | | { \bf g _ { 1 } } | ] ^ { 2 } + ( 1 - \cos ^ { 2 } ( \phi ) ) | | { \bf g _ { 2 } } | | ^ { 2 } } \} } \\ { { \displaystyle - \left. L t ^ { 2 } ( 1 - \cos ^ { 2 } ( \phi ) ) | | { \bf g _ { 1 } } | | | { \bf g _ { 2 } } | | \cos ( \phi ) \right. } } \end{array}$$
(Note that $\cos ( \phi ) < 0$ so the final term is non-negative)
Using $\begin{array} { r } { t \le \frac { 1 } { L } } \end{array}$ , we know that $\begin{array} { r } { - ( 1 - \frac 1 2 L t ) = \frac 1 2 L t - 1 \le \frac 1 2 L ( 1 / L ) - 1 = \frac { - 1 } { 2 } } \end{array}$ and $L t ^ { 2 } \leq t$
Plugging this into the last expression above, we can conclude the following:
$$\begin{array} { l } { \displaystyle \mathcal { L } ( \boldsymbol { \theta } ^ { + } ) \leq \mathcal { L } ( \boldsymbol { \theta } ) - \frac { 1 } { 2 } t [ ( 1 - \cos ^ { 2 } ( \boldsymbol { \phi } ) ) | | \mathbf { g } _ { 1 } | ] ^ { 2 } + ( 1 - \cos ^ { 2 } ( \boldsymbol { \phi } ) ) | | \mathbf { g } _ { 2 } | ] ^ { 2 } ] } \\ { \displaystyle - t ( 1 - \cos ^ { 2 } ( \boldsymbol { \phi } ) ) | | \mathbf { g } _ { 1 } | | | | \mathbf { g } _ { 2 } | | \cos ( \boldsymbol { \phi } ) } \\ { \displaystyle = \mathcal { L } ( \boldsymbol { \theta } ) - \frac { 1 } { 2 } t ( 1 - \cos ^ { 2 } ( \boldsymbol { \phi } ) ) | | | \mathbf { g } _ { 1 } | | ^ { 2 } + 2 | | \mathbf { g } _ { 1 } | | | | \mathbf { g } _ { 2 } | | \cos ( \boldsymbol { \phi } ) + | | \mathbf { g } _ { 2 } | | ^ { 2 } ] } \\ { \displaystyle = \mathcal { L } ( \boldsymbol { \theta } ) - \frac { 1 } { 2 } t ( 1 - \cos ^ { 2 } ( \boldsymbol { \phi } ) ) [ | | \mathbf { g } _ { 1 } | | ^ { 2 } + 2 \mathbf { g } _ { 1 } \cdot \mathbf { g } _ { 2 } + | | \mathbf { g } _ { 2 } | | ^ { 2 } ] } \\ { \displaystyle = \mathcal { L } ( \boldsymbol { \theta } ) - \frac { 1 } { 2 } t ( 1 - \cos ^ { 2 } ( \boldsymbol { \phi } ) ) | | \mathbf { g } _ { 1 } + \mathbf { g } _ { 2 } | | ^ { 2 } } \\ { \displaystyle = \mathcal { L } ( \boldsymbol { \theta } ) - \frac { 1 } { 2 } t ( 1 - \cos ^ { 2 } ( \boldsymbol { \phi } ) ) | | \nabla \mathcal { L } ( \boldsymbol { \theta } ) | | ^ { 2 } } \end{array}$$
If $\cos ( \phi ) > - 1$ , then $\begin{array} { r l } { { \frac { 1 } { 2 } t ( 1 - \cos ^ { 2 } ( \phi ) ) \| \nabla \mathcal { L } ( \theta ) \| ^ { 2 } } } \end{array}$ will always be positive unless $\nabla { \mathcal { L } } ( \theta ) = 0$ . This inequality implies that the objective function value strictly decreases with each iteration where $\cos ( \phi ) > - 1$ .
Hence repeatedly applying PCGrad process can either reach the optimal value ${ \mathcal { L } } ( \theta ) = { \mathcal { L } } ( \theta ^ { * } )$ or $\cos ( \phi ) = - 1$ , in which case $\begin{array} { r } { \frac { 1 } { 2 } t ( 1 - \bar { \cos ^ { 2 } ( \phi ) } ) \| \nabla \mathcal { L } ( \theta ) \| ^ { 2 } = 0 , } \end{array}$ . Note that this result only holds when we choose $t$ to be small enough, i.e. $\begin{array} { r } { t \le \frac { 1 } { L } } \end{array}$ .
# B 2D OPTIMIZATION LANDSCAPE DETAILS
To produce the 2D optimization visualizations in Figure 1, we used a parameter vector $\theta = \left[ \theta _ { 1 } , \theta _ { 2 } \right] \in$ $\mathbb { R } ^ { 2 }$ and the following task loss functions:
$$\begin{array} { r l } & { \mathcal { L } _ { 1 } ( \theta ) = 2 0 \log ( \operatorname* { m a x } ( | . 5 \theta _ { 1 } + \operatorname { t a n h } ( \theta _ { 2 } ) | , 0 . 0 0 0 0 0 5 ) ) } \\ & { \mathcal { L } _ { 2 } ( \theta ) = 2 5 \log ( \operatorname* { m a x } ( | . 5 \theta _ { 1 } - \operatorname { t a n h } ( \theta _ { 2 } ) + 2 | , 0 . 0 0 0 0 0 5 ) ) } \end{array}$$
The multi-task objective is $\mathcal { L } ( \theta ) = \mathcal { L } _ { 1 } ( \theta ) + \mathcal { L } _ { 2 } ( \theta )$ . We initialized $\theta = [ 0 . 5 , - 3 ]$ and performed 500,000 gradient updates to minimize $\mathcal { L }$ using the Adam optimizer with learning rate 0.001. We compared using Adam for each update to using Adam in conjunction with the PCGrad method presented in Section 3.2.
# C EXPERIMENTAL RESULTS ON MULTIMNIST
Following the same set-up in Sener & Koltun (2018), for each image, we sample a different one uniformly at random. Then we put one of the image on the top left and the other one on the bottom right. The two tasks in the multi-task learning problem are to classify the digits on the top left (task-L) and bottom right (task-R) respectively. We construct such $6 0 \mathrm { K }$ examples. We combine PCGrad with the same backbone architecture used in (Sener & Koltun, 2018) and compare its performance to Sener & Koltun (2018) by running the open-sourced code provided in (Sener & Koltun, 2018). As shown in Table 3, our method results $0 . 1 3 \%$ and $0 . 5 5 \%$ improvement over Sener & Koltun (2018) in left and right digit accuracy respectively.
<table><tr><td></td><td>left digit</td><td>right digit</td></tr><tr><td>Sener & Koltun (2018)</td><td>96.45</td><td>94.95</td></tr><tr><td>PCGrad (ours)</td><td>96.58</td><td>95.50</td></tr></table>
Table 3: MultiMNIST results. PCGrad achieves improvements over Sener & Koltun (2018) in both left and right digit classfication accuracy.
# D ABLATION STUDY ON THE TASK ORDER
As stated on line 4 in Algorithm 1, we sample the tasks from the batch and randomly shuffle the order of the tasks before performing the update steps in PCGrad. With random shuffling, we make
PCGrad symmetric w.r.t. the task order in expectation. In Figure 7, we observe that PCGrad with a random task order achieves better performance between PCGrad with a fixed task order in the setting of MT50 where the number of tasks is large and the conflicting gradient phenomenon is much more likely to happen.
 Figure 7: Ablation study on using a fixed task order during PCGrad. PCGrad with a random task order does significantly better PCGrad with a fixed task order in MT50 benchmark.
# E EXPERIMENT DETAILS
E.1 DETAILED EXPERIMENT SET-UP
For our CIFAR-100 multi-task experiment, we adopt the architecture used in Rosenbaum et al. (2019), which is a convolutional neural network that consists of 3 convolutional layers with $1 6 0 3 \times 3$ filters each layer and 2 fully connected layers with 320 hidden units. As for experiments on the NYUv2 dataset, we follow Liu et al. (2018) to use SegNet (Badrinarayanan et al., 2017) as the backbone architecture.
Our reinforcement learning experiments all use the SAC (Haarnoja et al., 2018) algorithm as the base algorithm, where the actor and the critic are represented as 6-layer fully-connected feedforward neural networks for all methods. The numbers of hidden units of each layer of the neural networks are 160, 300 and 200 for MT10, MT50 and goal-conditioned RL respectively.
We use five algorithms as baselines in the CIFAR-100 multi-task experiment: task specific-1-fc (Rosenbaum et al., 2018): a convolutional neural network shared across tasks except that each task has a separate last fully-connected layer, task specific-1-fc (Rosenbaum et al., 2018) : all the convolutional layers shared across tasks with separate fully-connected layers for each task, cross stitch-all-fc (Misra et al., 2016b): one convolutional neural network per task along with cross-stitch units to share features across tasks, routing-all-fc ${ \bf \Pi } _ { \bf { \Pi } } + { \bf W } { \bf P } { \bf L }$ (Rosenbaum et al., 2019): a network that employs a trainable router trained with multi-agent RL algorithm (WPL) to select trainable functions for each task, independent: training separate neural networks for each task.
For comparisons on the NYUv2 dataset, we consider 5 baselines: Single Task, One Task: the vanilla SegNet used for single-task training, Single Task, STAN (Liu et al., 2018): the single-task version of MTAN as mentioned below, Multi-Task, Split, Wide / Deep (Liu et al., 2018): the standard SegNet shared for all three tasks except that each task has a separate last layer for final task-specific prediction with two variants Wide and Deep specified in Liu et al. (2018), Multi-Task Dense: a shared network followed by separate task-specific networks, Multi-Task Cross-Stitch (Misra et al., 2016b): similar to the baseline used in CIFAR-100 experiment but with SegNet as the backbone, MTAN (Liu et al., 2018): a shared network with a soft-attention module for each task.
On the multi-task and goal-conditioned RL domain, we apply PCGrad to the vanilla SAC algorithm with task encoding as part of the input to the actor and the critic as described in Section 4 and compare our method to the vanilla SAC without PCGrad and training actors and critics for each task individually (Independent).
# E.2 GOAL-CONDITIONED EXPERIMENT DETAILS
We use the pushing environment from the Meta-World benchmark (Yu et al., 2019) as shown in Figure 3. In this environment, the table spans from $[ - 0 . 4 , 0 . 2 ]$ to [0.4, 1.0] in the 2D space. To construct the goals, we sample the intial positions of the puck from the range $[ - 0 . 2 , 0 . 6 ]$ to [0.2, 0.7] on the table and the goal positions from the range $[ - 0 . 2 , 0 . 8 5 ]$ to $[ 0 . 2 , 0 . 9 5 ]$ on the table. The goal is represented as a concatenation of the initial puck position and the goal position. Since in the goal-conditioned setting, the task distribution is continuous, we sample a minibatch of 9 goals and 128 samples per goal at each training iteration and also sample 600 samples per goal in the minibatch at each data collection step.
# E.3 FULL NYUV2 RESULTS
We provide the full comparison on the NYUv2 dataset in Table 4.
<table><tr><td rowspan="2">Type</td><td rowspan="2">#P.</td><td rowspan="2">Architecture Weighting</td><td colspan="2">Segmentation</td><td colspan="2">Depth</td><td colspan="5">Surface Normal</td></tr><tr><td colspan="2">mIoU Pix Acc Abs Err Rel Err</td><td colspan="2">(Higher Better) (Lower Better)</td><td colspan="2">Angle Distance (Lower Better) Mean Median</td><td colspan="2">Within t (Higher Better) 11.2522.5</td></tr><tr><td rowspan="2">Single Task</td><td>3 One Task</td><td></td><td></td><td>15.10 51.54</td><td></td><td>0.7508 0.3266</td><td>531.76</td><td>25.51</td><td></td><td>22.12 45.33</td><td>30 57.13</td></tr><tr><td>4.56 STANt</td><td>n.a. n.a.</td><td>15.73</td><td>52.89</td><td>0.6935</td><td>0.2891</td><td>32.09</td><td>26.32</td><td>21.49</td><td>44.38</td><td>56.51</td></tr><tr><td rowspan="9">Multi Task</td><td rowspan="3">1.75 Split, Wide</td><td>Equal Weights</td><td>15.89</td><td>51.19</td><td>0.6494</td><td>0.2804</td><td>33.69</td><td>28.91</td><td>18.54</td><td>39.91</td><td>52.02</td></tr><tr><td>Uncert.Weights*</td><td>15.86</td><td>51.12</td><td>0.6040</td><td>0.2570</td><td>32.33</td><td>26.62</td><td>21.68</td><td>43.59</td><td>55.36</td></tr><tr><td>DWA+,T=2</td><td>16.92</td><td>53.72</td><td>0.6125</td><td>0.2546</td><td>32.34</td><td>27.10</td><td>20.69</td><td>42.73</td><td>54.74</td></tr><tr><td rowspan="3">2Split, Deep</td><td>Equal Weights</td><td>13.03</td><td>41.47</td><td>0.7836</td><td>0.3326</td><td>38.28</td><td>36.55</td><td>9.50</td><td>27.11</td><td>39.63</td></tr><tr><td>Uncert.Weights*</td><td>14.53</td><td>43.69</td><td>0.7705</td><td>0.3340</td><td>35.14</td><td>32.13</td><td>14.69</td><td>34.52</td><td>46.94</td></tr><tr><td>DWA+,T= 2</td><td>13.63</td><td>44.41</td><td>0.7581</td><td>0.3227</td><td>36.41</td><td>34.12</td><td>12.82</td><td>31.12</td><td>43.48</td></tr><tr><td rowspan="3">4.95 Dense</td><td>Equal Weights</td><td>16.06</td><td>52.73</td><td>0.6488</td><td>0.2871</td><td>33.58</td><td>28.01</td><td>20.07</td><td>41.50</td><td>53.35</td></tr><tr><td>Uncert.Weights*</td><td>16.48</td><td>54.40</td><td>0.6282</td><td>0.2761</td><td>31.68</td><td>25.68</td><td>21.73</td><td>44.58</td><td>56.65</td></tr><tr><td>DWAt,T = 2</td><td>16.15</td><td>54.35</td><td>0.6059</td><td>0.2593</td><td>32.44</td><td>27.40</td><td>20.53</td><td>42.76</td><td>54.27</td></tr><tr><td rowspan="3">≈3 Cross-Stitcht</td><td>Equal Weights</td><td>14.71 15.69</td><td>50.23</td><td>0.6481</td><td>0.2871</td><td>33.56</td><td>28.58</td><td></td><td>20.08 40.54</td><td></td><td>51.97</td></tr><tr><td></td><td>Uncert. Weights*</td><td>52.60</td><td>0.6277</td><td>0.2702</td><td>32.69</td><td></td><td>27.26</td><td>21.63 21.81</td><td>42.84</td><td>54.45 54.92</td></tr><tr><td>DWA+,T= 2</td><td>16.11</td><td>53.19</td><td>0.5922</td><td>0.2611</td><td>32.34</td><td>26.91</td><td></td><td>43.14</td><td></td></tr><tr><td rowspan="3">1.77 MTANt</td><td></td><td>Equal Weights 17.72</td><td>55.32</td><td>0.5906</td><td>0.2577</td><td></td><td>31.44</td><td>25.37</td><td>23.17</td><td>45.65</td><td>57.48</td></tr><tr><td>Uncert.Weights*</td><td>17.67</td><td>55.61</td><td>0.5927</td><td>0.2592</td><td>31.25</td><td></td><td>25.57</td><td>22.99</td><td>45.83</td><td>57.67</td></tr><tr><td>DWAt,T=2</td><td>17.15</td><td>54.97</td><td>0.5956</td><td>0.2569</td><td>31.60</td><td>25.46</td><td></td><td>22.48 44.86</td><td></td><td>57.24</td></tr></table>
Table 4: We present the full results on three tasks on the NYUv2 dataset: 13-class semantic segmentation, depth estimation, and surface normal prediction results. #P shows the total number of network parameters. We highlight the best performing combination of multi-task architecture and weighting in bold. The top validation scores for each task are annotated with boxes. The symbols indicate prior methods: ∗: (Kendall et al., 2018a), †: (Liu et al., 2018), $^ \ddag$ : (Misra et al., 2016b). Performance of other methods taken from (Liu et al., 2018).md/train/2VXyy9mIyU3/2VXyy9mIyU3.mdAdded
md/train/3g5KdPD8LIL/3g5KdPD8LIL.mdAdded+504
md/train/9uFiX_HRsIL/9uFiX_HRsIL.mdAdded+221
md/train/Aw96fN64soV/Aw96fN64soV.mdAdded+334
md/train/B1hYRMbCW/B1hYRMbCW.mdAdded+671
md/train/BJj6qGbRW/BJj6qGbRW.mdAdded+346
md/train/BJlgt2EYwr/BJlgt2EYwr.mdAdded+266
md/train/BkgnhTEtDS/BkgnhTEtDS.mdAdded+381
md/train/BkgzniCqY7/BkgzniCqY7.mdAdded+580
md/train/BkxthxHYvr/BkxthxHYvr.mdAdded+368
md/train/ByxhOyHYwH/ByxhOyHYwH.mdAdded+246
md/train/DktZb97_Fx/DktZb97_Fx.mdAdded+634
md/train/H1gpET4YDB/H1gpET4YDB.mdAdded+283
md/train/H1gsz30cKX/H1gsz30cKX.mdAdded+437
md/train/HJV1zP5xg/HJV1zP5xg.mdAdded+385
md/train/HJewiCVFPB/HJewiCVFPB.mdAdded+408
md/train/HJlSmC4FPS/HJlSmC4FPS.mdAdded
md/train/HJrDIpiee/HJrDIpiee.mdAdded
md/train/HkCjNI5ex/HkCjNI5ex.mdAdded
md/train/HkgeGeBYDB/HkgeGeBYDB.mdAdded
md/train/Hkxr1nCcFm/Hkxr1nCcFm.mdAdded
md/train/Hy6GHpkCW/Hy6GHpkCW.mdAdded
md/train/HyzMyhCcK7/HyzMyhCcK7.mdAdded
md/train/IXexLXymbZ9/IXexLXymbZ9.mdAdded
md/train/LwEQnp6CYev/LwEQnp6CYev.mdAdded
md/train/MXmmuhJYPdU/MXmmuhJYPdU.mdAdded
md/train/MuSYkd1hxRP/MuSYkd1hxRP.mdAdded
md/train/N1i6BJzouX4/N1i6BJzouX4.mdAdded
md/train/OGg9XnKxFAH/OGg9XnKxFAH.mdAdded
md/train/QjINdYOfq0b/QjINdYOfq0b.mdAdded
md/train/S1GkToR5tm/S1GkToR5tm.mdAdded
md/train/SJCscQcge/SJCscQcge.mdAdded
md/train/SJICXeWAb/SJICXeWAb.mdAdded
md/train/SK7A5pdrgov/SK7A5pdrgov.mdAdded
md/train/SkeuexBtDr/SkeuexBtDr.mdAdded
md/train/SkxbDsR9Ym/SkxbDsR9Ym.mdAdded
md/train/TmkN9JmDJx1/TmkN9JmDJx1.mdAdded
md/train/US-TP-xnXI/US-TP-xnXI.mdAdded
md/train/a-xFK8Ymz5J/a-xFK8Ymz5J.mdAdded
md/train/e12NDM7wkEY/e12NDM7wkEY.mdAdded
md/train/ebS5NUfoMKL/ebS5NUfoMKL.mdAdded
md/train/hu2aMLzOxC/hu2aMLzOxC.mdAdded
md/train/jh-rTtvkGeM/jh-rTtvkGeM.mdAdded
md/train/rh0vIXw6i33/rh0vIXw6i33.mdAdded
md/train/rkeZIJBYvr/rkeZIJBYvr.mdAdded
md/train/rkgPnhNFPB/rkgPnhNFPB.mdAdded
md/train/rylBK34FDS/rylBK34FDS.mdAdded
md/train/rylejExC-/rylejExC-.mdAdded
md/train/sy4Kg_ZQmS7/sy4Kg_ZQmS7.mdAdded
md/train/zx_uX-BO7CH/zx_uX-BO7CH.mdAdded